Skip to content

fix responsive figures with WebGL #3486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ exports.plot = function(gd, data, layout, config) {

// hook class for plots main container (in case of plotly.js
// this won't be #embedded-graph or .js-tab-contents)
d3.select(gd).classed('js-plotly-plot', true);
d3.select(gd).classed('js-plotly-plot', true)
.style('position', 'relative');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I'll call that a breaking change.

We could turn this on just when responsive is set to true. But then again, are there any other solutions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's certainly a breaking change and it breaks a lot of tests anyway.

I have another branch in which I fix the responsive issues for both WebGL #3485 and the modebar #3499 that doesn't rely on modifying the parent. I will submit a new separate PR with a cleaner commit history and I will close the current one.


// off-screen getBoundingClientRect testing space,
// in #js-plotly-tester (and stored as Drawing.tester)
Expand Down Expand Up @@ -244,8 +245,6 @@ exports.plot = function(gd, data, layout, config) {
'position': 'absolute',
'top': 0,
'left': 0,
'width': '100%',
'height': '100%',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think those two lines were ever needed since a few lines later we set the size of the canvas via its attributes anyway:

fullLayout._glcanvas
.attr('width', fullLayout.width)
.attr('height', fullLayout.height);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

'overflow': 'visible',
'pointer-events': 'none'
});
Expand Down Expand Up @@ -538,8 +537,7 @@ function plotLegacyPolar(gd, data, layout) {
var paperDiv = plotContainer.selectAll('.svg-container')
.data([0]);
paperDiv.enter().append('div')
.classed('svg-container', true)
.style('position', 'relative');
.classed('svg-container', true);

// empty it everytime for now
paperDiv.html('');
Expand Down Expand Up @@ -3744,8 +3742,7 @@ function makePlotFramework(gd) {
// Make the svg container
fullLayout._paperdiv = fullLayout._container.selectAll('.svg-container').data([0]);
fullLayout._paperdiv.enter().append('div')
.classed('svg-container', true)
.style('position', 'relative');
.classed('svg-container', true);

// Make the graph containers
// start fresh each time we get here, so we know the order comes out
Expand Down
Loading