@@ -399,15 +399,9 @@ export default class ApexCharts {
399
399
window . removeEventListener ( 'resize' , this . windowResizeHandler )
400
400
401
401
removeResizeListener ( this . el . parentNode , this . parentResizeHandler )
402
- // remove the chart's instance from the global Apex._chartInstances
403
- const chartID = this . w . config . chart . id
404
- if ( chartID ) {
405
- Apex . _chartInstances . forEach ( ( c , i ) => {
406
- if ( c . id === Utils . escapeString ( chartID ) ) {
407
- Apex . _chartInstances . splice ( i , 1 )
408
- }
409
- } )
410
- }
402
+
403
+ this . _removeOldChartInstance ( )
404
+
411
405
new Destroy ( this . ctx ) . clear ( { isUpdating : false } )
412
406
}
413
407
@@ -545,6 +539,8 @@ export default class ApexCharts {
545
539
return resolve ( this )
546
540
}
547
541
542
+ this . _removeOldChartInstance ( )
543
+
548
544
this . lastUpdateOptions = Utils . clone ( options )
549
545
550
546
new Destroy ( this . ctx ) . clear ( { isUpdating : true } )
@@ -795,7 +791,19 @@ export default class ApexCharts {
795
791
this . _windowResize ( )
796
792
}
797
793
}
798
-
794
+ /**
795
+ * Remove the chart's old instance from the global Apex._chartInstances
796
+ */
797
+ _removeOldChartInstance ( ) {
798
+ const chartID = this . w . config . chart . id
799
+ if ( chartID ) {
800
+ Apex . _chartInstances . forEach ( ( c , i ) => {
801
+ if ( c . id === Utils . escapeString ( chartID ) ) {
802
+ Apex . _chartInstances . splice ( i , 1 )
803
+ }
804
+ } )
805
+ }
806
+ }
799
807
/**
800
808
* Handle window resize and re-draw the whole chart.
801
809
*/
0 commit comments