我想頂層動態設置yAxis的標題,具體取決於yAxis是顯示Gbps還是Mbps。Highcharts - 動態設置yAxis標題
儘管找不到標題的格式化函數,但我嘗試過的所有其他方法都失敗了。
有關如何做到這一點的任何建議?
這是y軸選項代碼:
yAxis: [{
labels: {
formatter: function() {
maxDataValue = ((this.chart.yAxis["0"].dataMax * 8)/300)/1024;
if (maxDataValue < 1000) {
return Math.floor(((this.value * 8)/300)/1024) + " Mbps";
} else {
return Math.floor(((this.value * 8)/300)/1048576) + " Gbps";
}
}
},
title: {
enabled: true,
text: unit,
style:{
fontWeight:'bold'
}
},
tickmarkPlacement: 'on',
plotLines: [{
value: 0,
width: 2,
color: '#333333'
}]
}],