How can I delete all of the points from a highcharts series
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 or setData
for more than one.
There're some examples which shows how to do it.
demo
reference
Related videos on Youtube
djq
Currently working for a large tech company in Dublin. Previously, a co-founder of a technology startup; there I worked with a small team using Python, Django, Django-Rest-Framework, Pandas (and more!). I've a background in urban analysis (geospatial data), stats (R) and data visualization (ggplot2, D3) Excited about how technology can be used for social good.
Updated on September 27, 2022Comments
-
djq over 1 year
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. -
djq over 11 years
chart.series[0].setData([]);
worked - I did not realize an empty array could be passed in.