使用 highcharts 在折线图中自定义标签

问题描述 投票:0回答:1

我正在使用折线图,其中添加了绘图带范围。我想返回绘图带中存在的 y 轴标签。

labels: {
formatter: function () {
if ([-12, -10, 0.0, 6.5, 10, 20].includes(this.value)) {
return this.value;
}
return "";
},
},

我已将此标签对象添加到 y 轴

而且我也无法设置 y 轴的最小值和最大值 最大:20, 分钟:-12,

并且在 x 轴和图表之间添加了我不想要的额外空白

https://jsfiddle.net/bhagyeshbodhe/5x8cypqg/2/

reactjs charts highcharts linechart react-functional-component
1个回答
0
投票

使用

tickPositions
而不是
labels.formatter
。例如:

tickPositions: [-12, -10, 0.0, 6.5, 10, 20]

现场演示:https://jsfiddle.net/BlackLabel/vz5ychx0/

API 参考: https://api.highcharts.com/highcharts/yAxis.tickPositions

© www.soinside.com 2019 - 2024. All rights reserved.