我正在尝试实现一个Highcharts,以便在.NET MVC中动态地将新系列加载到同一个图表中。我只需要根据一些属性将相同的数据集分组到几个组中,并将这些组显示为多个序列。选择要分组的属性是使用单选按钮完成的。我已经使用Jquery编写了一个'on change‘事件处理程序。为了加载多个系列,我删除了所有当前系列并添加了新系列。但它们返回两个错误。
while (chart.series.length > 0) { chart.series[0].remove(false); chart.redraw();
这个块破坏了现有的系列。但是它返回下面的错误。
Uncaught TypeError: Cannot read property 'isSVG' of undefined at a.SVGElement.destroy (highcharts.js:53) at highcharts.js:212 at Array.forEach (<anonymous>) at a.each (highcharts.js:28) at a.Legend.destroyItem (highcharts.js:212) at k.destroy (highcharts.js:286) at d (highcharts.js:316) at a.fireEvent (highcharts.js:31) at k.remove (highcharts.js:316) at k.remove (highcharts.js:334) destroy @ highcharts.js:53 (anonymous) @ highcharts.js:212 a.each @ highcharts.js:28 destroyItem @ highcharts.js:212 destroy @ highcharts.js:286 d @ highcharts.js:316 a.fireEvent @ highcharts.js:31 remove @ highcharts.js:316 remove @ highcharts.js:334 (anonymous) @ StackedChart:285 dispatch @ jquery-1.10.2.js:5109 elemData.handle @ jquery-1.10.2.js:4780
以下是加载新系列的代码。
if (i != (workCenterData.length - 1)) chart.addSeries({ data: dataArray }, false); chart.addSeries({ data: dataArray }, true);
此块返回以下错误。
Uncaught TypeError: Cannot read property 'setAttribute' of undefined at a.SVGElement.fillSetter (highcharts.js:59) at a.SVGElement.<anonymous> (highcharts.js:43) at a.objectEach (highcharts.js:29) at a.SVGElement.attr (highcharts.js:42) at a.Legend.colorizeItem (highcharts.js:212) at a.Legend.renderItem (highcharts.js:217) at highcharts.js:220 at Array.forEach (<anonymous>) at a.each (highcharts.js:28) at a.Legend.render (highcharts.js:220) fillSetter @ highcharts.js:59 (anonymous) @ highcharts.js:43 a.objectEach @ highcharts.js:29 attr @ highcharts.js:42 colorizeItem @ highcharts.js:212 renderItem @ highcharts.js:217 (anonymous) @ highcharts.js:220 a.each @ highcharts.js:28 render @ highcharts.js:220 redraw @ highcharts.js:232 C @ series-label.js:9 a.(anonymous function) @ highcharts.js:19