Browse Source

fixing dynamically adding/removing chart series

Rodja Trappe 2 years ago
parent
commit
4a8661680b
1 changed files with 4 additions and 1 deletions
  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: {