条形图不适合图表区域

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}
});

这是 Fiddle: http://jsfiddle.net/frelis/x7Lyj5t6/12/

您可以像这样在 X 轴上设置最大值:

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轴会一直自动设置最大值