使用HighCharts,我怎样才能拥有与y轴相同的工具提示格式化程序



对于HighCharts,我的工具提示格式化程序有没有办法使用选定的Y轴格式化程序?在此 jsfiddle 中,我添加了一个 y 轴格式化程序(除以千(,但工具提示内容仍未格式化。

编辑:我有一个动态数量的y轴和系列。

.highcharts({
tooltip: {
borderWidth: 1,
borderColor: '#AAA',
formatter: function(e){
// do some magic here
}
},
yAxis: [
{
id: 'score',
min: 0,
max: 10000,
title: 'Score',
labels: {
formatter: function(e){
return e.value/1000 + 'k';
}
}
}
],
series: [{
type: 'spline',
name: 'Laurel',
data: [1000,2000,3000,8000,5000],
yAxis: 'score'
},
{
type: 'spline',
name: 'Yanni',
data: [3000,7000,3000,2000,1000],
yAxis: 'score'
}]
});

您必须像这样设置tooltip formatterAPI:

tooltip:{
...
formatter: function(){
var text = '';
if(this.series.index == 0) {
text = this.series.name + ' : ' + this.y/1000 + 'k';
} else {
text = '<b>' + this.series.name + '</b> : ' + this.y ;
}
return text;
}
}

小提琴

编辑多个 y轴

最新更新