I have been trying to re-size plotly plots that I have on a web application that I am building. We are using AngularJS for the front-end and using plotly for our plots.
At the moment I have a page view with three boxplot plotly plots next to each other (inside a div with class set to col-md-8). These three boxplots visibility should be able to be turned on/off while centering the boxplots that are visible. I have come as far as drawing the boxplots, and centering the divs which contain the boxplots, but for some reason the actual canvas on which the plotly plot is, sometimes doesn’t scale/resize properly, and stays to “stretched” out.
In the attached image, I have forced the canvas width to remain within the parent div by setting the width to 100% (not sure if it is a bad idea or bad practise, but it seemed to work.) However, my issue now is that the actual boxplot inside, goes “underneath” the parent div, and some of the plot is “missing”. I have added (as you can see in the image) a “Scale” button, which I tied up so that a new plot is created (relayout, restyle and redraw didn’t help either). Any help here? (Code is below)
While debugging my problem, I came upon two tags, both with a class of “main-svg”. They looked very similar to me, and I couldn’t figure out what makes them different?
// Need to redraw the boxplots everytime a "re-scaling" is done, otherwise, the plot won't re-scale
scope.$on('redraw_boxplots', function () {
var graph, layout, options, data;
graph = plotlyProcessing.makeGraph(scope.plots,
scope.graphType,
scope.params);
data = graph[0];
// Merges while maintaining the original data in graph[1]/[2]
layout = angular.merge({}, defaultLayout, graph[1]);
options = angular.merge({}, defaultOptions, graph[2]);
Plotly.newPlot(graphDiv, data, layout, options);
});