Categories
JavaScript Answers

How to remove all series data from a HighCharts chart with JavaScript?

Spread the love

Sometimes, we want to remove all series data from a HighCharts chart with JavaScript.

In this article, we’ll look at how to remove all series data from a HighCharts chart with JavaScript.

How to remove all series data from a HighCharts chart with JavaScript?

To remove all series data from a HighCharts chart with JavaScript, we call the remove method.

For instance, we write

while (chart.series.length > 0) {
  chart.series[0].remove(true);
}

to loop through the chart series with a while loop.

Then we get the first one with chart.series[0].

And we call remove with true to remove it.

Conclusion

To remove all series data from a HighCharts chart with JavaScript, we call the remove method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *