From 320c682d03d5baad05e639b68052850c36bb26f0 Mon Sep 17 00:00:00 2001 From: Martin Hansen Date: Thu, 25 Apr 2019 10:23:21 +0200 Subject: [PATCH] Replace all usages of newPlot --- src/Plotly.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Plotly.vue b/src/Plotly.vue index e375e1b..e8e0664 100644 --- a/src/Plotly.vue +++ b/src/Plotly.vue @@ -83,7 +83,7 @@ export default { methods: { initEvents() { if (this.autoResize) { - this.__resizeListener = debounce(this.newPlot, 200) + this.__resizeListener = debounce(this.react, 200) window.addEventListener('resize', this.__resizeListener) } @@ -123,9 +123,9 @@ export default { return Plotly.downloadImage(this.$refs.container, opts) }, plot() { - return Plotly.plot(this.$refs.container, this.data, this.internalLayout, this.options) + return Plotly.plot(this.$refs.container, this.data, this.internalLayout, this.getOptions()) }, - newPlot() { + getOptions() { let el = this.$refs.container let opts = this.options @@ -134,10 +134,13 @@ export default { if (!opts.toImageButtonOptions) opts.toImageButtonOptions = {} if (!opts.toImageButtonOptions.width) opts.toImageButtonOptions.width = el.clientWidth if (!opts.toImageButtonOptions.height) opts.toImageButtonOptions.height = el.clientHeight - return Plotly.newPlot(this.$refs.container, this.data, this.internalLayout, opts) + return opts + }, + newPlot() { + return Plotly.newPlot(this.$refs.container, this.data, this.internalLayout, this.getOptions()) }, react() { - return Plotly.react(this.$refs.container, this.data, this.internalLayout, this.options) + return Plotly.react(this.$refs.container, this.data, this.internalLayout, this.getOptions()) } } }