高图表工具提示不同的后缀值



嗨,我必须在Highchart(蜘蛛网图(中显示学生的排名。 在 Y 轴中,我必须为不同的等级(即第 1、2、3、4.. 100 (添加不同的后缀值。 谁能帮我解决这个问题。

提前致谢

您可以使用formatter函数作为工具提示:

Highcharts.chart('container', {
series: [{
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
}],
tooltip: {
formatter: function() {
switch (this.x) {
case 1:
return 1 + 'st'
case 2:
return 2 + 'nd'
case 3:
return 3 + 'rd'
default:
return this.x + 'th'
}
}
}
});

现场演示:http://jsfiddle.net/BlackLabel/g48mszj9/

API:https://api.highcharts.com/highcharts/tooltip.formatter

最新更新