1
votes

Stacked columns in highcharts have the stacked defined in the series like so (http://www.highcharts.com/demo/column-stacked-and-grouped):

series: [{
                name: 'John',
                data: [5, 3, 4, 7, 2],
                stack: 'male'
            }, {
                name: 'Joe',
                data: [3, 4, 4, 2, 5],
                stack: 'male'
            }]

But I cannot figure out how to get a reference to the name of the stack from the series. Is there any way to get the stack from the series object? I specificially need it for the tooltip:

    tooltip: {
      formatter: function() {
        return '<b>'+ this.series.stack // is undefines
                +'</b><br/>'+ this.series.name +': '+ this.y;    
        }
    },
1
You should log this.series the see what's available to get.Ricardo Alvaro Lohmann

1 Answers

7
votes

You need to use this.series.options.stack instead.
The series.options object contains the options that were set for that series while constructing the chart

tooltip: {
    formatter: function() {
      return '<b>'+ this.series.options.stack + '</b><br/>'+ this.series.name +': '+ this.y;    
    }
}

Accessing chart/series options | Highchart & Highstock @ jsFiddle