Mik*_*ike 5 tooltip highcharts
我正在使用此代码显示共享工具提示:
tooltip: {
crosshairs: true,
shared: true,
headerFormat: 'KW {point.key}<table>',
pointFormat: '<tr><td style=\"color: {series.color}\">{series.name}: <b></td><td>{point.y} USD</b></td></tr>',
useHTML: true,
footerFormat: '</table>',
valueDecimals: 2
},
Run Code Online (Sandbox Code Playgroud)
现在我想将所有point.y值添加为该点的总值.但是我如何循环每个系列的point.y来计算总价值呢?
Seb*_*han 11
兴奋地,参见示例:http://jsfiddle.net/65bpvudh/7/
tooltip: {
formatter: function() {
var s = '<b>'+ this.x +'</b>',
sum = 0;
$.each(this.points, function(i, point) {
s += '<br/>'+ point.series.name +': '+
point.y +'m';
sum += point.y;
});
s += '<br/>Sum: '+sum
return s;
},
shared: true
},
Run Code Online (Sandbox Code Playgroud)
使用footerFormat属性(自 2.2 版起){point.total}可以轻松显示总数,而无需重新定义完整formatter函数:
tooltip: {
footerFormat: 'Sum: <b>{point.total}</b>',
shared: true,
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12805 次 |
| 最近记录: |