瀏覽代碼

switch method definitions

Falko Schindler 1 年之前
父節點
當前提交
4c86dc364e
共有 1 個文件被更改,包括 16 次插入16 次删除
  1. 16 16
      nicegui/elements/plotly.vue

+ 16 - 16
nicegui/elements/plotly.vue

@@ -13,6 +13,22 @@ export default {
     this.update();
     this.update();
   },
   },
   methods: {
   methods: {
+    update() {
+      // default responsive to true
+      const options = this.options;
+      if (options.config === undefined) options.config = { responsive: true };
+      if (options.config.responsive === undefined) options.config.responsive = true;
+
+      // re-use plotly instance if config is the same
+      if (JSON.stringify(options.config) == JSON.stringify(this.last_options.config)) {
+        Plotly.react(this.$el.id, this.options.data, this.options.layout);
+      } else {
+        Plotly.newPlot(this.$el.id, this.options.data, this.options.layout, options.config);
+      }
+
+      // store last options
+      this.last_options = options;
+    },
     set_handlers() {
     set_handlers() {
       // forward events
       // forward events
       for (const name of [
       for (const name of [
@@ -50,22 +66,6 @@ export default {
         });
         });
       }
       }
     },
     },
-    update() {
-      // default responsive to true
-      const options = this.options;
-      if (options.config === undefined) options.config = { responsive: true };
-      if (options.config.responsive === undefined) options.config.responsive = true;
-
-      // re-use plotly instance if config is the same
-      if (JSON.stringify(options.config) == JSON.stringify(this.last_options.config)) {
-        Plotly.react(this.$el.id, this.options.data, this.options.layout);
-      } else {
-        Plotly.newPlot(this.$el.id, this.options.data, this.options.layout, options.config);
-      }
-
-      // store last options
-      this.last_options = options;
-    },
   },
   },
   data() {
   data() {
     return {
     return {