在工具提示中的高图总数 [英] highchart total in tooltip

查看:113
本文介绍了在工具提示中的高图总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码来显示共享工具提示:

 工具提示:{
crosshairs:true,
shared:true,
headerFormat:'KW {point.key}< table>,
pointFormat:'< tr>< td style = \color:{series。颜色} \> {series.name}:< b>< / td>< td> {point.y} USD< / b>< / td>< / tr>',
useHTML:true,
footerFormat:'< / table>',
valueDecimals:2
},

现在我想添加所有point.y值作为该点的总值。但如何循环每个系列的point.y来计算总值?

href =http://jsfiddle.net/65bpvudh/7/ =nofollow> http://jsfiddle.net/65bpvudh/7/

 工具提示:{
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;
},
共享:true
},


i am using this code to display a shared tooltip:

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
},

Now i like to add all point.y values as a total value of the point. But how can i loop the point.y of each series to calculate the total value?

解决方案

Excatly, see example: 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
},

这篇关于在工具提示中的高图总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆