添加新HighChart系列 [英] Adding new HighChart Series
问题描述
目前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屋!