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.

4

1 回答 1

1

如果我正确理解您的问题,您应该使用以下方法访问额外数据:

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

另请参阅此答案:将附加数据添加到 Highcharts 系列以用于格式化程序

还有这个:将附加数据设置为 highcharts 系列

于 2013-02-05T16:04:03.043 回答