Skip to content

Commit

Permalink
Fix plot height in refreshChart. Fixes #1805 (#1806)
Browse files Browse the repository at this point in the history
  • Loading branch information
umesh-timalsina committed Jul 25, 2020
1 parent 12608bc commit 14288bf
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/visualizers/widgets/PlotlyGraph/PlotlyGraphWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -88,9 +73,22 @@ define([
};

PlotlyGraphWidget.prototype.createChartSlider = function(plotlyJSONs) {
plotlyJSONs.forEach(plotlyJSON => {
const len = plotlyJSONs.length;
plotlyJSONs.forEach(json => {
const plotlyDiv = $('<div/>');
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);
});
Expand Down

0 comments on commit 14288bf

Please sign in to comment.