jQuery 加载后获取 Highcharts 系列数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18840397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 22:36:12  来源:igfitidea点击:

Get Highcharts Series Data after Load

javascriptjqueryhighcharts

提问by Seán McCabe

I am trying to get the series data from a Highcharts chart once it has been called and loaded to the page.

一旦调用并加载到页面,我试图从 Highcharts 图表中获取系列数据。

So far I've only been successful in getting a bunch of strings that isn't what I am after obviously. Wonder if someone can help me with this one.

到目前为止,我只是成功地获得了一堆显然不是我想要的字符串。想知道是否有人可以帮助我解决这个问题。

jQuery Code:

jQuery代码:

success: function (chartData) {
    if(chart != undefined) {
        $('#meterloader').hide();
        $.each(chart.series[0], function(value) {
            alert(value);
        });
    } else {
        $('#meterloader').hide();
        $('#meterbox').html("<div><p class='textcentre bold red'>There was an error loading the chart.</p></div>");
    }
}

Thanks in advance.

提前致谢。

回答by Strikers

you need plotted data from the chart, then try

您需要从图表中绘制数据,然后尝试

chart.series[0].data

if you need all the options from series then try

如果您需要系列中的所有选项,请尝试

chart.series

this will return the entire series structure of the chart.

这将返回图表的整个系列结构。

I hope this is useful for you.

我希望这对你有用。