Skip to content

Commit 207fa05

Browse files
committed
set the plotly-container div to full width & height
1 parent f8c7b5d commit 207fa05

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/plot_api/plot_api.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -3671,7 +3671,15 @@ function makePlotFramework(gd) {
36713671
fullLayout._container.enter()
36723672
.insert('div', ':first-child')
36733673
.classed('plot-container', true)
3674-
.classed('plotly', true);
3674+
.classed('plotly', true)
3675+
// The plot container should always take the full with the height of its
3676+
// parent (the graph div). This ensures that for responsive plots
3677+
// without a height or width set, the paper div will take up the full
3678+
// height & width of the graph div.
3679+
.style({
3680+
width: "100%",
3681+
height: "100%"
3682+
});
36753683

36763684
// Make the svg container
36773685
fullLayout._paperdiv = fullLayout._container.selectAll('.svg-container').data([0]);

src/plot_api/subroutines.js

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ function lsInner(gd) {
5252
var axList = Axes.list(gd, '', true);
5353
var i, subplot, plotinfo, ax, xa, ya;
5454

55+
// Set the width and height of the paper div ('.svg-container') in
56+
// accordance with the users configuration and layout.
57+
// If the plot is responsive and the user has not set a width/height, then
58+
// the width/height of the paper div is set to 100% to fill the parent
59+
// container.
60+
// We can't leave the height or width unset because all of the contents of
61+
// the paper div are positioned absolutely (and will therefore not take up
62+
// any space).
5563
fullLayout._paperdiv.style({
5664
width: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroWidth && !gd.layout.width) ? '100%' : fullLayout.width + 'px',
5765
height: (gd._context.responsive && fullLayout.autosize && !gd._context._hasZeroHeight && !gd.layout.height) ? '100%' : fullLayout.height + 'px'

0 commit comments

Comments
 (0)