瀏覽代碼

fixing dynamically adding/removing chart series

Rodja Trappe 2 年之前
父節點
當前提交
4a8661680b
共有 1 個文件被更改,包括 4 次插入1 次删除
  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: {