简体   繁体   English

BarChart不适合图表区域

[英]BarChart does not fit on chart area

By using the code below, the X axis maximum value is only 85000 and that hides the partly the 120k value, Is there any option to fix this axis rendering behavior? 通过使用下面的代码,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}
});

Here is the Fiddle: http://jsfiddle.net/frelis/x7Lyj5t6/12/ 这是小提琴: http//jsfiddle.net/frelis/x7Lyj5t6/12/

You can set the max value on the XAxis like that : 您可以在XAxis上设置最大值:

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

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

You can get the max value of your array and set the max axis value like this too : 您可以获得数组的最大值并设置最大轴值如下:

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

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

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

Have a good day ! 祝你有美好的一天 !

Make s1 an array of numbers. 使s1成为一个数字数组。 It expects numbers on the X axis. 它期望X轴上的数字。 Change the code from: 更改代码:

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

to

var s1 = [84486, 74987, 120249];

see the working version at: http://jsfiddle.net/x7Lyj5t6/13/ 请参阅以下工作版: http//jsfiddle.net/x7Lyj5t6/13/

This way X axis will always be automatically setting the maximum value. 这样X轴将始终自动设置最大值。

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

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