Reputation: 755
I have a graph with 2 yaxis and i am tying to get the yaxis title for each series in the tooltip formatter.
This is my formatter function:
formatter: function() {
var s = '<b>'+ Highcharts.dateFormat('$hc_date_long', this.x) +'</b><table>';
sum = 0;
var abweichung = 0;
var stellen = 0;
$.each(this.points, function(i, point) {
var prev = jQuery.inArray(point.x, point.series.processedXData)-1;
var percent = 0;
if(prev>=0){
prev = point.series.points[prev];
percent = (point.y - prev.y) * 100 / point.y;
}
s += '<tr><td style=\"color: '+point.series.color+';padding:2px;\">'+ point.series.name +':</td><td style=\"text-align:right;padding:2px;\"> '+ extround(point.y,100) +' !!GETYAXISTITLE!!</td><td style=\"text-align:right;padding:2px;\">'+percent+'</td></tr>';
sum += point.y;
});
s += '</table>';
return s;
},
The api only contains the function "setTitle()" there is no getTitle() function?
Upvotes: 4
Views: 9209
Reputation: 5371
Correct way to get Y Axis title in tooltip formatter is :
this.point.series.yAxis.axisTitle.textStr
Upvotes: 9
Reputation: 15866
To get title in function
chart.options.yAxis[0].title.text
Or set title like this:
yAxis: {
title: {
enabled: true,
text: 'Custom with <b>simple</b> <i>markup</i>',
style: {
fontWeight: 'normal'
}
}
},
Upvotes: 6