HighCharts:可以汇总系列数据并在标题中显示吗? [英] HighCharts: Possible to summarize series data and show in title?

查看:269
本文介绍了HighCharts:可以汇总系列数据并在标题中显示吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个答案,如果可以对HighCharts系列进行汇总并显示在标题中?我正在为该系列使用JSON数据,因此,如果数据看起来像这样:

I'm looking for an answer if it's possible to sum the HighCharts series and show it in the title? I'm using JSON data for the series, so if the data looks like this:

[0,0,0,1,1,1,2,2,2,3,3,3]

总和当然应该是:18.

The sum should of course be: 18.

我尝试询问Google,但未找到任何信息.我知道我可以在其他地方处理它,但是直接在HighCharts脚本中处理它会很好.

I've tried asking Google but I haven't found anything. I know I could handle it elsewhere but it would be nice to handle it directly inside the HighCharts script.

谢谢.

/CRH

推荐答案

如何在Javascript中对其求和,然后在创建标题时使用结果?

How about summing it in Javascript and then using the result when creating the title?

var sum = 0;
for(var i in series)
    sum += i;

然后,只需设置标题:

chart = new Highcharts.Chart({
    ...

    title: {
        text: 'SUM: ' + sum
    },

    ...
)};

应该可以,对吧?

这篇关于HighCharts:可以汇总系列数据并在标题中显示吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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