Skip to content

Commit f821b3a

Browse files
committed
set the plotly-container div to full width & height
1 parent 22efc2f commit f821b3a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Diff for: src/plot_api/plot_api.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -3704,7 +3704,15 @@ function makePlotFramework(gd) {
37043704
fullLayout._container.enter()
37053705
.insert('div', ':first-child')
37063706
.classed('plot-container', true)
3707-
.classed('plotly', true);
3707+
.classed('plotly', true)
3708+
// The plot container should always take the full with the height of its
3709+
// parent (the graph div). This ensures that for responsive plots
3710+
// without a height or width set, the paper div will take up the full
3711+
// height & width of the graph div.
3712+
.style({
3713+
width: "100%",
3714+
height: "100%"
3715+
});
37083716

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

Diff for: 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)