Browse Source

Merge pull request #1570 from dabenny/patch-1

Resize method for ui.echart
Falko Schindler 1 year ago
parent
commit
035f059103
1 changed files with 4 additions and 11 deletions
  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: {