소스 검색

Merge pull request #1570 from dabenny/patch-1

Resize method for ui.echart
Falko Schindler 1 년 전
부모
커밋
035f059103
1개의 변경된 파일4개의 추가작업 그리고 11개의 파일을 삭제
  1. 4 11
      nicegui/elements/echart.js

+ 4 - 11
nicegui/elements/echart.js

@@ -3,24 +3,17 @@ export default {
   mounted() {
     this.chart = echarts.init(this.$el);
     this.chart.setOption(this.options);
-    this.chart.resize();
+    new ResizeObserver(this.chart.resize).observe(this.$el);
   },
   beforeDestroy() {
-    this.destroyChart();
+    this.chart.dispose();
   },
   beforeUnmount() {
-    this.destroyChart();
+    this.chart.dispose();
   },
   methods: {
     update_chart() {
-      if (this.chart) {
-        this.chart.setOption(this.options);
-      }
-    },
-    destroyChart() {
-      if (this.chart) {
-        this.chart.dispose();
-      }
+      this.chart.setOption(this.options);
     },
   },
   props: {