user393267
user393267

Reputation:

How do you add to tooltip, a series in HighCharts?

I would like to use a series as extra info, so when the user hover on the point, the tooltip will display the extra series

Example of file:

a,b,c,d
1,2,3,4
X1,X2,X3,X4

I have #1 on X and #2 on Y, and would like #3 only in the tooltip.

How do you tell the tooltip about that series? I know how to use this.x and this.y, but the series is not on either axis; is saved in a different array

Upvotes: 1

Views: 112

Answers (1)

Rob Schmuecker
Rob Schmuecker

Reputation: 8954

Demo:http://jsfiddle.net/robschmuecker/PAM3K/

$(function () {
    var myOtherData = [1,2,3,4,5,6,7,8,9,10,11,12];
    $('#container').highcharts({

        tooltip: {
            formatter: function() {
                return 'The value for <b>myOtherData</b> is: ' + myOtherData[this.point.x];
            }
        },

        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },

        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]        
        }, {
            data: [194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4]        
        }]
    });
});

Upvotes: 1

Related Questions