繁体   English   中英

BarChart不适合图表区域

[英]BarChart does not fit on chart area

通过使用下面的代码,X轴最大值仅为85000并且部分隐藏了120k值,是否有任何选项来修复此轴渲染行为?

var s1 = ["84486", "74987", "120249"];
var ticks = ['Length', 'Width', 'Height'];

$.jqplot('revi_chart', [s1], {
    seriesDefaults: {
        renderer: $.jqplot.BarRenderer,
        pointLabels: { show: true, location: 'w'},
        rendererOptions: { barDirection: 'horizontal'},
    },
    axes: {
        xaxis: { tickOptions: { showLabel: true, showGridline: false}},
        yaxis: { renderer: $.jqplot.CategoryAxisRenderer, ticks: ticks,
        tickOptions: { showGridline: false }}
    },
    highlighter: { show: false}
});

这是小提琴: http//jsfiddle.net/frelis/x7Lyj5t6/12/

您可以在XAxis上设置最大值:

axes: {
        xaxis: { tickOptions: { showLabel: true, showGridline: false},
     max:200000},
        yaxis: { renderer: $.jqplot.CategoryAxisRenderer, ticks: ticks,
            tickOptions: { showGridline: false }}
    },

http://jsfiddle.net/Tintin37/dox289ea/

您可以获得数组的最大值并设置最大轴值如下:

var maxVal = Math.max.apply(null, s1);

xaxis: { tickOptions: { showLabel: true, showGridline: false},
         max: maxVal +10000},

http://jsfiddle.net/Tintin37/7ntw19Lp/

祝你有美好的一天 !

使s1成为一个数字数组。 它期望X轴上的数字。 更改代码:

var s1 = ["84486", "74987", "120249"];

var s1 = [84486, 74987, 120249];

请参阅以下工作版: http//jsfiddle.net/x7Lyj5t6/13/

这样X轴将始终自动设置最大值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM