Referencing to the primary issue of this topic (as the title says: "Removing series causes javascript on mouseout errors"), errors you were receiving were appearing because you wanted to delete the series in the middle of other actions it refers to. Precisely, I have the point events on my mind.
In your example on
http://jsfiddle.net/Q8e8D/, there was a situation i will try to explain.
When you start selecting you can hover another points at once. Then, when you release the mouse button to confirm selected range, the
selection event is being fired. In your event handler you remove series[0] while some point events are still enqueued to be fired up on
onMouseOut. Then, after the series[0] have disappeared, those events are refering to it but it's already gone. This causes the error you had reported. It can be easily fixed by removing all points of the series[0] before removing it in your event handler, so events don't need to be called after series[0] removing.
- Code: Select all
events: {
"selection": function(e) {
e.preventDefault();
this.series[0].setData([]);
this.series[0].remove();
}
}
Another thing is that you don't need to use setTimeout really. Though you should take care of repeating series[0] remove, because the
selection event is attached to the chart, not series, so it doesn't disappear with removed series. In this case you can just check if there is a series you want to remove:
- Code: Select all
events: {
"selection": function(e) {
e.preventDefault();
if (this.series.length) {
this.series[0].setData([]);
this.series[0].remove();
}
}
}
Sorry for such a long answer, but your posts are a little chaotic so I had to tidy all those thoughts up :)