user2330278
user2330278

Reputation: 87

using data from multiple series in tooltip

I have 2 series in my charts

  1. 'Actual Impressions'
  2. 'Booked Impressions'

There is a shared tooltip which shows data for both series. In the tooltip I want to also show (actualImpression/bookedImpression) as a percentage. Below is what I want to achieve. (This just shows my intent, not actual code)

Formatter = function(){
       return '<b>'+ 'Total' +'</b><br/>'+': '  
         + if (this.series['Booked Impresssions'].Point.y !=0 ) 
 {this.series['Actual Impresssions'].Point.y/ this.series['Booked Impresssions'].Point.y +'%';}
    else {'-';} 
 }

Thanks

Upvotes: 0

Views: 627

Answers (1)

Mark
Mark

Reputation: 108567

I think you want something like this:

      tooltip: {
        formatter: function() {
            var s = '<b>Ratio: </b>';
            if (this.points[1] != 0)
            {
                s += (this.points[0].y / this.points[1].y).toFixed(2);
            }
            else
            {
                s += " - ";
            }
            s += "%";
            return s;
        },
        shared: true
    },

Fiddle here.

enter image description here

Upvotes: 1

Related Questions