Explorar el Código

Merge pull request #1570 from dabenny/patch-1

Resize method for ui.echart
Falko Schindler hace 1 año
padre
commit
035f059103
Se han modificado 1 ficheros con 4 adiciones y 11 borrados
  1. 4 11
      nicegui/elements/echart.js

+ 4 - 11
nicegui/elements/echart.js

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