我使用Chartjs有奇怪的行为。我动态收到最小和最大刻度值:
const minTicks = 9.78039983344078;
const maxTicks = 27.31399953484535;
const stepSize =(maxTicks-minTicks)/ 6; // stepSize = 2,922266617;
我具有以下刻度配置:
ticks: {
min: 9.78039983344078,
max: 27.31399953484535,
suggestedMin: 9.78039983344078,
suggestedMax: 27.31399953484535,
minRotation: 0,
maxRotation: 0,
stepSize,
callback: function(value, index, values) {
console.log('values: %o', values);
return value.toFixed(2) + ' m';
}
}
回调中的console.log 打印以下值:
0:9.78039983344078 1:11.689066467603046 2:14.611333084503809 3:17.53359970140457 4:20.455866318305333 5:23.378132935206093 6:26.300399552106853 7:27.31399953484535
值之间的步长为:
除了在值[0]和值[1]之间以及在值[6]和值[7]之间之外,还要遵守stepSize。
如何获得第一个刻度和最后一个刻度之间的stepSize?