From 8bfb1eec20c17bdab26572661c75b95bfc5766d9 Mon Sep 17 00:00:00 2001 From: Umesh Timalsina Date: Sat, 25 Jul 2020 00:02:11 -0500 Subject: [PATCH] Fix plot height in refreshChart. Fixes #1805 --- .../widgets/PlotlyGraph/PlotlyGraphWidget.js | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/visualizers/widgets/PlotlyGraph/PlotlyGraphWidget.js b/src/visualizers/widgets/PlotlyGraph/PlotlyGraphWidget.js index a6d43e4d3..1fd1df1bc 100644 --- a/src/visualizers/widgets/PlotlyGraph/PlotlyGraphWidget.js +++ b/src/visualizers/widgets/PlotlyGraph/PlotlyGraphWidget.js @@ -54,21 +54,6 @@ define([ if (desc) { const plotlyJSONs = Array.isArray(desc) ? desc.map(descr => descr.plotlyData) : [desc.plotlyData]; - - const len = plotlyJSONs.length; - - plotlyJSONs.forEach(json => { - if (len === 1) { - json.layout.height = this.$el.height(); - json.layout.width = this.$el.width(); - } else { - json.layout.autosize = true; - delete json.layout.width; - delete json.layout.height; - } - json.layout.plot_bgcolor = PLOT_BG_COLOR; - json.layout.paper_bgcolor = PLOT_BG_COLOR; - }); this.setTextVisibility(false); this.refreshChart(plotlyJSONs); } @@ -88,9 +73,22 @@ define([ }; PlotlyGraphWidget.prototype.createChartSlider = function(plotlyJSONs) { - plotlyJSONs.forEach(plotlyJSON => { + const len = plotlyJSONs.length; + plotlyJSONs.forEach(json => { const plotlyDiv = $('
'); - Plotly.newPlot(plotlyDiv[0], plotlyJSON); + + if (len === 1) { + json.layout.height = this.$el.height(); + json.layout.width = this.$el.width(); + } else { + json.layout.autosize = true; + delete json.layout.width; + delete json.layout.height; + } + json.layout.plot_bgcolor = PLOT_BG_COLOR; + json.layout.paper_bgcolor = PLOT_BG_COLOR; + + Plotly.newPlot(plotlyDiv[0], json); this.plots.push(plotlyDiv); this.$el.append(plotlyDiv); });