Javascript 为什么从第二个开始的杆在x轴上向前移动?
我正在处理的图表有以下代码:Javascript 为什么从第二个开始的杆在x轴上向前移动?,javascript,jquery,charts,jqplot,Javascript,Jquery,Charts,Jqplot,我正在处理的图表有以下代码: plot = $.jqplot('SalesChart2', [ [[1,5]], [[1,10]], [[1,15]], [[1,20]], [[2,25]], [[3,10]], [[4,10]],
plot = $.jqplot('SalesChart2',
[
[[1,5]],
[[1,10]],
[[1,15]],
[[1,20]],
[[2,25]],
[[3,10]],
[[4,10]],
[[5, 6]]
]
, {
// Tell the plot to stack the bars.
stackSeries: true,
series: [
{ label: 'Cash' },
{ label: 'CreditCard' },
{ label: 'DebitCard' },
{ label: 'StoreCredit' },
{ label: 'Discount', disableStack: true },
{ label: 'AverageTransaction', xaxis: 'xaxis', yaxis: 'y2axis', disableStack: true },
{ xaxis: 'xaxis', yaxis: 'y2axis', label: 'ItemsPerTransaction', disableStack: true },
{ xaxis: 'xaxis', yaxis: 'y2axis', label: 'CustomerCount', disableStack: true }
],
animate: !$.jqplot.use_excanvas,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {
highlightMouseDown: true,
barWidth: 50
},
pointLabels: { show: true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: [1,2,3,4,5]
},
yaxis: {
tickOptions: {
formatString: "$%'d"
}
},
y2axis: {
autoscale: true,
min: 0
}
},
legend: {
show: true,
location: 'e',
placement: 'outside'
},
grid: {
drawGridlines: false
}
});
其结果如下:
这里的条从x轴上的点2向前移动了一点。因此,“客户数量”的最后一个栏不可见
有人能告诉我这里发生了什么吗?您应该尝试使用空的barwidth来自动计算宽度。
我认为barmargin的默认值(10)太高了,因为您的宽度接近50。您使用的是JQPlot的最新版本吗?您是否尝试过降低
barWidth
属性?是的,但不起作用这看起来像是JQPlot中的一个bugdisableStack
是为组合条形图/线条图设计的,我从未见过它用于组合堆栈条形图/常规条形图。如果我将barwidth设置为null,结果会非常糟糕