4

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?

2 Answers 2

9

Correct way to get Y Axis title in tooltip formatter is :

this.point.series.yAxis.axisTitle.textStr
6

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'
            }
        }
    },

DEMO

2
  • Thanks, and how to get the yaxis of the series? Can you give me a link to the documentation where to find chart.options.yAxis ...?
    – Mike
    Feb 12, 2013 at 17:20
  • 1
    You can use console in javascript to check all ingredients in chart object. console.log(chart); Feb 13, 2013 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.