Live example:
I have a set up where I have a chart with four series. I want to allow the user to select a different data set, and then
- remove the existing series
- add the new series
I am stuck at the 'remove' phase, however, because after the first two series are removed, it tells me the next 2 are undefined.
The function to remove the series:
function updateData(chart, dataSet) {
console.log(chart);
$.each(chart.series, function(i,ser) {
if(typeof(ser) != 'undefined') {
console.log(ser);
ser.remove();
}
});
}
Which leaves 2 series still on the chart.
When I console.log the chart object, it only lists two series.
The questions:
- Am I doing this wrong? Is there a better way to remove all of the series?
- Why does the chart only show two series instead of four?