How to get multiple series data in tooltip highcharts?
Asked Answered
I

3

22

I want to display multiple series Data in tooltip on every column

tooltip: {
    formatter: function() {
        return '<span style="color:#D31B22;font-weight:bold;">' +this.series.name +': '+ this.y +'<br/>'+
               '<b style="color:#D31B22;font-weight:bold;">'+this.x +'</b><span>';
    }
},

and Data

series: [{
    showInLegend: false,
    name: 'Total Click',
    data: [3000,200,50,4000],
    color: '#9D9D9D'
}, {
    showInLegend: false,
    name: 'Total View',
    data: [100,2000,3000,4000],
    color: '#D8D8D8'
}]

I am using like this but in tool tip only one series data is showing at a time. I want to display Data like this (Total View:100 and Total Click:3000 )

Ivory answered 11/10, 2013 at 7:14 Comment(4)
add your code, so i can help you :)Downwards
hey, mohit please check my code i think this is what you need jsfiddle.net/pintu31/AcNUM/2Downwards
nice Work ...............PragneshIvory
Is there a way to do this without setting backgroundColor to null? This be default removes the pointer arrow #42772538Wadley
D
34

please try using this code

updated DEMO

tooltip: {
        formatter: function() {
            var s = [];

            $.each(this.points, function(i, point) {
                s.push('<span style="color:#D31B22;font-weight:bold;">'+ point.series.name +' : '+
                    point.y +'<span>');
            });

            return s.join(' and ');
        },
        shared: true
    },
Downwards answered 11/10, 2013 at 9:46 Comment(1)
s.push('<span style="color:" '+ point.series.color +' ";font-weight:bold;">'Passant
D
13

You need to use shared parameter http://api.highcharts.com/highcharts#tooltip.shared and then in formater iterate on each point.

Diddle answered 11/10, 2013 at 8:51 Comment(0)
P
3

If anybody looking for scatterplot, here is solution to show shared tooltip.

formatter: function(args) {
    var this_point_index = this.series.data.indexOf( this.point );
    var this_series_index = this.series.index;
    var that_series_index = this.series.index == 0 ? 1 : 0; // assuming 2 series
    var that_series = args.chart.series[that_series_index];
    var that_point = that_series.data[this_point_index];
    return 'Client: ' + this.point.name +
           '<br/>Client Health: ' + this.x +
           '<br/>' + this.series.name + ' Bandwidth: ' + this.y + 'Kbps' +
           '<br/>' + that_series.name + ' Bandwidth: ' + that_point.y + 'Kbps';
}

Jsfiddle link to Solution

Pashm answered 12/6, 2014 at 6:44 Comment(1)
Is there a solution like this for column sharts?Wadley

© 2022 - 2024 — McMap. All rights reserved.