@esfaenza/es-charts 20.3.22 → 20.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -813,11 +813,21 @@ class BaseChartComponent {
813
813
  // La deregistrazione va fatta SEMPRE, anche quando il grafico non è mai stato creato: se il componente muore mentre la sua
814
814
  // inizializzazione è ancora in coda, senza questa chiamata il nome resterebbe occupato e non sarebbe più riutilizzabile
815
815
  this.browserOnly(() => {
816
- if (this.Chart && !this.Chart.isDisposed())
817
- this.Chart.dispose();
816
+ this.disposeChart();
818
817
  this.Dispatcher.deregisterGraph(this.name);
819
818
  });
820
819
  }
820
+ /**
821
+ * Scarica il grafico corrente insieme alla sua Root di amCharts
822
+ *
823
+ * Scaricare solo il grafico non basta: la Root resterebbe registrata sul div e la graficazione successiva sullo stesso div
824
+ * fallirebbe con "You cannot have multiple Roots on the same DOM node", lasciando una Root costruita a metà e senza DOM il cui
825
+ * ticker va in errore su getComputedStyle a ogni frame. La Root scarica con sé il grafico e tutto il resto del suo contenuto
826
+ */
827
+ disposeChart() {
828
+ if (this.Chart && !this.Chart.root.isDisposed())
829
+ this.Chart.root.dispose();
830
+ }
821
831
  /**
822
832
  * Registra il grafico attuale nel Dispatcher in modo che venga caricato appena possibile
823
833
  */
@@ -844,9 +854,9 @@ class BaseChartComponent {
844
854
  this.log("Chart " + this.name + ": Graphicating after modules load");
845
855
  // Un'eventuale graficazione precedente annullata a metà può aver lasciato un grafico attivo sullo stesso contenitore:
846
856
  // va scaricato prima di crearne uno nuovo, altrimenti resterebbero due istanze amCharts sullo stesso div
847
- if (this.Chart && !this.Chart.isDisposed()) {
857
+ if (this.Chart && !this.Chart.root.isDisposed()) {
848
858
  this.log("Chart " + this.name + ": Disposing leftover chart instance before regraphicating");
849
- this.Chart.dispose();
859
+ this.disposeChart();
850
860
  }
851
861
  var castedSettings = this.getCastedSettings();
852
862
  this.fillSettings(castedSettings);
@@ -950,8 +960,7 @@ class BaseChartComponent {
950
960
  // Il dispose dev'essere null-safe: si può arrivare qui anche prima che il grafico sia stato creato (ad esempio cambiando
951
961
  // pagina su un grafico paginato mentre la prima graficazione è ancora in corso)
952
962
  this.browserOnly(() => {
953
- if (this.Chart && !this.Chart.isDisposed())
954
- this.Chart.dispose();
963
+ this.disposeChart();
955
964
  this.Dispatcher.deregisterGraph(this.name);
956
965
  });
957
966
  this.Dispatcher.register(this.name, () => { return this.loadChart(); });