添加新HighChart系列 [英] Adding new HighChart Series

查看:95
本文介绍了添加新HighChart系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前code的javascrip给出错误

At this code javascrip give an error

$.each(JSON, function(i, array) {                        
chart.series[i].name = array.teamName;
chart.series[i].setData(array.teamPower, true);
});

,因为它说不能未定义的属性设置名称我必须定义chart.series [I]
但我不能为了做到这一点找到一个方法。

I must define the chart.series[i] because it say "Cannot set property 'name' of undefined" but i can't find a way in order to do this.

由于它与fonction运行的RequestData所以它的图表后,带着选项确定

Because it fonction runs with requestData so it came after chart determine with options

function showGraph() {  
chart = new Highcharts.Chart(option);       
}


chart: {
renderTo: 'graphicShow',
type: 'spline',
events: {
load: requestData
}


...在选项...


...in option...

title: {
text: 'Power %'
},
series: []
};

...

推荐答案

您需要在API的方法和属性部分looka。请参见 http://api.highcharts.com/highcharts#Chart (还有就是文档页面上的jsfiddle以及)

You need to looka at the "Methods and Properties" part of the API. See http://api.highcharts.com/highcharts#Chart (There is an jsFiddle on the documentation page as well).

var chart = new Highcharts.Chart(options);
chart.addSeries({                        
    name: array.teamName,
    data: array.teamPowher
});

如果您要添加几个系列,你应该在重绘标志设置为false,然后调用后手动重绘,这将是快得多。

If you are going to add several series you should set the redraw flag to false and then call redraw manually after as that will be much faster.

var chart = new Highcharts.Chart(options);
chart.addSeries({                        
    name: array.teamName,
    data: array.teamPower
}, false);
chart.addSeries({                        
    name: array.teamName,
    data: array.teamPower
}, false);
chart.redraw();

这篇关于添加新HighChart系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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