You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
That's exactly how it works, described from
docs
.
When a chart is destroyed, the array item becomes undefined.
Before creating issues on github, I advice to use our
forum
.
My mistake.
I think it's more logical to also remove the chart from that array, unless it's really necessary for some internal stuff.
Not a big deal, it's just that looping over this array needs an additional check for undefined.
Thanks for the advice.
In my app, I only ever show one plot. And after the view is changed, I want just to delete that plot. I accomplished this using array.splice() method.
if (Highcharts.charts[0] !== undefined) {
Highcharts.charts[0].destroy();
Highcharts.charts.splice(0, 1);
This will destroy the chart and then remove the undefined placeholder from the array. The 'if' statement is just so that if the array is empty (the first time this code section runs) then it will not try to run destroy() on undefined. This might be more elegantly done with some error handling, however.
EDIT: The reason I think error handling here might be more robust is because the placeholder itself is undefined. So if for some reason the chart was destroyed elsewhere, the splice would not get run! Just be mindful :)
Hi
@dss010101
! This issue is closed because the described behaviour is the expected one. More information here:
https://api.highcharts.com/class-reference/Highcharts#.charts
An array containing the current chart objects in the page. A chart's position in the array is preserved throughout the page's lifetime. When a chart is destroyed, the array item becomes undefined.