gpt4 book ai didi

javascript - 为什么从第二个开始的条形图在 x 轴上向前移动?

转载 作者:行者123 更新时间:2023-11-28 09:27:24 24 4
gpt4 key购买 nike

我正在处理的图表有以下代码:

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

渲染如下:

Chart for sales data

此处的条形图从 x 轴上的点 2 向前移动了一点。因此,“客户数量”的最后一个栏不可见。

有人可以指导我这里发生的事情吗?

最佳答案

您应该尝试使用空栏宽度来自动计算宽度。我认为 barmargin 的默认值 (10) 太高,因为宽度接近 50。

关于javascript - 为什么从第二个开始的条形图在 x 轴上向前移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14174143/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com