Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 57a2214

Browse filesBrowse files
authored
Merge pull request #7314 from plotly/bugfix/backport-set-container-height
[Bugfix Backport] Fix Container Height
2 parents 22efc2f + 98b66a8 commit 57a2214
Copy full SHA for 57a2214

File tree

3 files changed

+28
-1
lines changed
Filter options

3 files changed

+28
-1
lines changed

‎draftlogs/7314_fix.md

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Set height and width on the `.plotly-container` div to 100% [[#7314](https://github.com/plotly/plotly.js/pull/7314)]

‎src/plot_api/plot_api.js

Copy file name to clipboardExpand all lines: src/plot_api/plot_api.js
+19-1Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3704,7 +3704,25 @@ 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+
// So, for responsive plots without a height or width set, if the plot
3713+
// container's height is left to 'auto', its height will be dictated by
3714+
// its childrens' height. (The plot container's only child is the paper
3715+
// div.)
3716+
// In this scenario, the paper div's height will be set to 100%,
3717+
// which will be 100% of the plot container's auto height. That is
3718+
// meaninglesss, so the browser will use the paper div's children to set
3719+
// the height of the plot container instead. However, the paper div's
3720+
// children do not have any height, because they are all positioned
3721+
// absolutely, and therefore take up no space.
3722+
.style({
3723+
width: "100%",
3724+
height: "100%"
3725+
});
37083726

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

‎src/plot_api/subroutines.js

Copy file name to clipboardExpand all lines: src/plot_api/subroutines.js
+8Lines changed: 8 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.