如何在 highchart 仪表上显示特定的刻度值?

how to show specific tick value on highchart gauge?

我想显示绿色、黄色和红色 plotBands 之间的值。

在所附示例中,我想显示值 135,172(颜色正在变化)

yAxis: {
min: 0,
max: 200,

minorTickInterval: 'auto',
minorTickWidth: 1,
minorTickLength: 10,
minorTickPosition: 'inside',
minorTickColor: '#666',

tickPixelInterval: 30,
tickWidth: 2,
tickPosition: 'inside',
tickLength: 10,
tickColor: '#666',
labels: {
    step: 2,
    rotation: 'auto'
},
title: {
    text: 'km/h'
},
plotBands: [{
    from: 0,
    to: 135,
    color: '#55BF3B' // green
}, {
    from: 135,
    to: 172,
    color: '#DDDF0D' // yellow
}, {
    from: 172,
    to: 200,
    color: '#DF5353' // red
}]
},

Working Example In JSFiddle

您可以使用 tickPositioner 函数来定义将在图表上显示的报价:

    tickPositioner: function() {
        var plotBands = this.options.plotBands,
            ticks = [],
            i = 0;

        for (i; i <= 200; i += 20) {
            ticks.push(i);
        }

        for (i = 0; i < plotBands.length - 1; i++) {
            ticks.push(plotBands[i].to)
        }
        return ticks;
    }

现场演示:https://jsfiddle.net/BlackLabel/1kpt7dws/

API: https://api.highcharts.com/highcharts/yAxis.tickPositioner