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); });