瀏覽代碼

Merge pull request #2505 from bmaranville/plotly_event_handler_fix

Register plotly event handlers only once, at mount
Falko Schindler 1 年之前
父節點
當前提交
02376e9230
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      nicegui/elements/plotly.vue

+ 5 - 3
nicegui/elements/plotly.vue

@@ -23,8 +23,13 @@ export default {
         Plotly.react(this.$el.id, this.options.data, this.options.layout);
         Plotly.react(this.$el.id, this.options.data, this.options.layout);
       } else {
       } else {
         Plotly.newPlot(this.$el.id, this.options.data, this.options.layout, options.config);
         Plotly.newPlot(this.$el.id, this.options.data, this.options.layout, options.config);
+        this.set_handlers();
       }
       }
 
 
+      // store last options
+      this.last_options = options;
+    },
+    set_handlers() {
       // forward events
       // forward events
       for (const name of [
       for (const name of [
         // source: https://plotly.com/javascript/plotlyjs-events/
         // source: https://plotly.com/javascript/plotlyjs-events/
@@ -60,9 +65,6 @@ export default {
           this.$emit(name, args);
           this.$emit(name, args);
         });
         });
       }
       }
-
-      // store last options
-      this.last_options = options;
     },
     },
   },
   },
   data() {
   data() {