我已经使用 Column 和 Line 系列创建了图表,我正在使用 chart.addSeries 动态添加系列。
问题:单击线系列图例时,线系列消失。第二次单击它时,只有绘图点可见,而线条不可见。
我收到以下 JS 异常:
行:65 字符:237 代码:0 错误消息:对象不支持属性或方法“加入” URL:http ://pfmonline.fidelitypfm.com:8098/moneycenter/js/js/rbc/highcharts.js?d =1592588911
下面是代码:
chart = new Highcharts.Chart({
chart: {
renderTo: 'spendingChart',
width: spendingChart.width*0.8,
height: spendingChart.height*0.8,
plotBorderColor:'#000000',
plotBorderWidth:1
},
xAxis: {
categories: subCategories,
labels: {
rotation: 0
}
},
credits: {
enabled: false
},
tooltip: {
borderColor: '#000',
backgroundColor: '#FFF',
borderRadius: 0,
borderWidth: 1,
formatter: function() {
var s;
s = ''+this.series.name+', '+this.x +', $'+Highcharts.numberFormat(this.y,2,'.',',');
return s;
}
},
title: {
text: ''
},
yAxis: {
lineWidth: 1,
title: {
text: ''
}
},
series: []
});
for(var i=0;i<data[index].drilldown.length;i++){
if(data[index].drilldown[i].name == "Actual")
chtType = "column";
else
chtType = "spline";
subCategories = [];
versionsData = [];
var color = "";
for (var j = 0; j < data[index].drilldown[i].data.length; j++) {
versionsData.push(data[index].drilldown[i].data[j].y);
subCategories.push(data[index].drilldown[i].categories[j]);
color = (data[index].drilldown[i].data[j].color);
}
chart.xAxis[0].setCategories(subCategories, false);
chart.addSeries({type:chtType, name :data[index].drilldown[i].name, data : versionsData ,color:color},'true');
}