Highcharts: yAxis标题=当前系列名称

Highcharts: yAxis title = current series name

本文关键字:系列 yAxis 标题 Highcharts      更新时间:2023-09-26

如何使yAxis标题与当前选定的系列相同?

yAxis: [{
    min: 0,
    title: {
        text: 'Hits', <-- this value should be based on selected series name
    },
    labels: {
        formatter: function () {
            return this.value;
        },
        style: {
            color: '#4572A7'
        }
    }
}]

这样应该可以工作。当单击系列时,它将yAxis的标题设置为系列的名称。这里jsfiddle

plotOptions: {
    series: {
        events: {
            click: function() {
                this.chart.yAxis[0].setTitle({text: this.name});
            }
        }
    }
}