Javascript Chartjs在运行时设置步长
我正在运行时计算Javascript Chartjs在运行时设置步长,javascript,chart.js,chart.js3,Javascript,Chart.js,Chart.js3,我正在运行时计算步长,并将其设置为轴。 但在某些情况下,图表不会按照设置的步长显示刻度 对于具有负值的刻度,可以观察到此问题 var config = { type: 'line', data: { datasets: [], }, options: { scales: { xAxes: { beginAtZero: true, type: 'l
步长
,并将其设置为轴。但在某些情况下,图表不会按照设置的
步长显示刻度
对于具有负值的刻度,可以观察到此问题
var config = {
type: 'line',
data: {
datasets: [],
},
options: {
scales: {
xAxes: {
beginAtZero: true,
type: 'linear',
min: 0,
max: 100,
ticks: {
stepSize: 10
}
},
yAxes: {
beginAtZero: true,
type: 'linear',
min: 0,
max: 200,
ticks: {
maxTicksLimit: 3
}
}
}
}
};
在运行时,我正在计算步长,以便将步长等分:
// Divide by 2 as I have max tick count set as 3.
chart.config.options.scales["yAxes"].min = minVal;
chart.config.options.scales["yAxes"].max = maxVal;
chart.config.options.scales["yAxes"].ticks.stepSize = ((maxVal + minVal) / 2);
chart.update();
但是,当我的图表绘制任何负值时,stepSize
不会按照设置的步长值进行更新,图表只是调整大小并绘制略低于0的负值,而不调整stepSize