在 Highcharts 中使用 "step" 标签选项,从 x 轴的末尾开始
Use the "step" label option in Highcharts, starting at the end of the xaxis
当我再次测试我的图表时(here is a fiddle 作为示例),我意识到在结束而不是在 x 轴的开头。对于我这个用户来说,直接知道最近可用的年份而不是第一个可用的年份更有意义。
因为我还没有成功强制显示最新年份,
endOnTick: true,
showLastLabel: true
或 with a script,我想到最好的方法可能无论如何强制 Highcharts 开始计算最新的可用年份。
有人做过吗?或者 - 更有可能 - 这是不可能的?
为什么不使用 tickPositions
或 tickPositioner
?
您可以使用它们手动告诉 xAxis 以 20 年为间隔显示标签,或者如您所说 latest year available
:
tickPositioner: function () {
var positions = [],
tick = Math.floor(this.dataMin);
while (tick < this.dataMax) {
positions.push(tick);
tick += 20;
}
positions.push(this.dataMax);
return positions;
}
这是DEMO
当我再次测试我的图表时(here is a fiddle 作为示例),我意识到在结束而不是在 x 轴的开头。对于我这个用户来说,直接知道最近可用的年份而不是第一个可用的年份更有意义。
因为我还没有成功强制显示最新年份,
endOnTick: true,
showLastLabel: true
或 with a script,我想到最好的方法可能无论如何强制 Highcharts 开始计算最新的可用年份。
有人做过吗?或者 - 更有可能 - 这是不可能的?
为什么不使用 tickPositions
或 tickPositioner
?
您可以使用它们手动告诉 xAxis 以 20 年为间隔显示标签,或者如您所说 latest year available
:
tickPositioner: function () {
var positions = [],
tick = Math.floor(this.dataMin);
while (tick < this.dataMax) {
positions.push(tick);
tick += 20;
}
positions.push(this.dataMax);
return positions;
}
这是DEMO