Explorar o código

fixing dynamically adding/removing chart series

Rodja Trappe %!s(int64=2) %!d(string=hai) anos
pai
achega
4a8661680b
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      nicegui/elements/chart.js

+ 4 - 1
nicegui/elements/chart.js

@@ -8,7 +8,10 @@ export default {
   },
   methods: {
     update_chart() {
-      this.chart.update(this.options);
+      while (this.chart.series.length > this.options.series.length) this.chart.series[0].remove();
+      while (this.chart.series.length < this.options.series.length) this.chart.addSeries({}, false);
+      this.chart.update(this.options, false);
+      this.chart.redraw();
     },
   },
   props: {