2

I am generating a standard stacked bar chart for a client. But what they want for the yAxis label is not the sum of the values of the two stacked bars. This is easy is a simple bar chart, but in a stacked chart it always takes the total of the two. My existing code is:

return Highcharts.numberFormat(Math.round(this.total*100)/100, 2) + '%';

I'm setting the number I need to display in the data string like this:

data: [{y: 1.83, color: '#BBBBBB', 'QTotal': 3.37}

Where 'QTotal' is the value they want to display. I've tried the following with no luck:

return Highcharts.numberFormat(Math.round(this.QTotal*100)/100, 2) + '%';
return Highcharts.numberFormat(Math.round(this.point.QTotal*100)/100, 2) + '%';
return Highcharts.numberFormat(Math.round(this.y.QTotal*100)/100, 2) + '%';

Setting up fixed labels doesn't work cause the number of bars being shown is flexible. Any pointer would be greatly appreciated.

1 Answers1

1

If I understand your problem correctly you should access the extra data using:

return Highcharts.numberFormat(Math.round(this.series.options.QTotal*100)/100, 2) + '%';

See also this answer: Add additional data to a Highcharts series for use in formatters

And this one: Set Additional Data to highcharts series

Community
  • 1
  • 1
eolsson
  • 12,567
  • 3
  • 41
  • 43