Переглянути джерело

cleanup: remove unnecessary conditions and resize method

Falko Schindler 1 рік тому
батько
коміт
58cbedd3b6
2 змінених файлів з 4 додано та 23 видалено
  1. 4 16
      nicegui/elements/echart.js
  2. 0 7
      nicegui/elements/echart.py

+ 4 - 16
nicegui/elements/echart.js

@@ -3,29 +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);
-    new ResizeObserver(this.resize_chart).observe(this.$el);
+    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);
-      }
-    },
-    resize_chart() {
-      if (this.chart) {
-        this.chart.resize();
-      }
-    },
-    destroyChart() {
-      if (this.chart) {
-        this.chart.dispose();
-      }
+      this.chart.setOption(this.options);
     },
     },
   },
   },
   props: {
   props: {

+ 0 - 7
nicegui/elements/echart.py

@@ -25,10 +25,3 @@ class EChart(Element, component='echart.js', libraries=['lib/echarts/echarts.min
     def update(self) -> None:
     def update(self) -> None:
         super().update()
         super().update()
         self.run_method('update_chart')
         self.run_method('update_chart')
-
-    def resize(self) -> None:
-        """Resize the chart to fit the container.
-
-        Usually, this does not need to be called manually, as the chart is resized automatically when the window is resized.
-        """
-        self.run_method('resize_chart')