Using HighCharts I want to delete all of the points from a series, so that I can add a new dataset. Is there a better approach than looping through all of the points, and removing them one by one like this?:
for(var i=0; i < chart.series[0].points.length; i++){
chart.series[0].points[i].remove()
}
I have also seen references to ways of removing the entire series chart.series[0].remove();
This seems quicker to remove the points, but I don't understand how to create an empty series with the same properties and name that points can be added to, which is why I chose to delete the points.
If you want to delete some points from your serie I sugest you to store your serie points, remove the points you want and then use
setData
to set your serie data again.If you want to remove all points without remove the serie you can use
chart.series[0].setData([]);
.You can use
addPoint
to add points one by one orsetData
for more than one.There're some examples which shows how to do it.
demo
reference