Reputation: 5552
With HighCharts, is there a way for my tooltip formatter to use the selected y axis formatter? In this jsfiddle, I've added a y axis formatter (divide by thousand), but the tooltip contents remain unformatted.
Edit: I have a dynamic number of y-axis and series.
.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'
}]
});
Upvotes: 2
Views: 1312
Reputation: 4114
You must set the tooltip formatter
Api like that :
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;
}
}
Edit for multiple yAxis
Upvotes: 1