소스 검색

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: {