yos*_*423 5 javascript jquery highcharts
以下是我正在使用的内容:http://jsfiddle.net/josip0423/prJjY/171/
在过去的几个小时里,我一直在努力解决这个问题.我是javascript的新手,今天刚刚找到了高级图表.
默认情况下,堆栈标签显示两个系列的总数(this.total).我想要做的是显示其中一个系列的百分比("完整"系列的值/ this.total*100).
我无法弄清楚如何提取"完整"系列的值.
yAxis: {
stackLabels: {
style: {
color: 'black'
},
enabled: true,
formatter: function() {
**return this.total**
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以最后,我的图表看起来完全一样,除了每列上面的标签将显示"完整"系列的百分比.
提前致谢!
您可以通过从格式化程序回调函数获取系列对象来实现.
stackLabels: {
style: {
color: 'black'
},
enabled: true,
formatter: function() {
return (this.axis.series[1].yData[this.x] / this.total * 100).toPrecision(2) + '%';
}
}
Run Code Online (Sandbox Code Playgroud)
这是你的案例的jsfiddle: