Skip to content

Automargin fixes #2681

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

Merged
merged 17 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,13 @@ plots.autoMargin = function(gd, id, o) {
delete pushMarginIds[id];
}
else {
var pad = o.pad === undefined ? 12 : o.pad;
var pad = o.pad;
if(pad === undefined) {
var margin = fullLayout.margin;
// if no explicit pad is given, use 12px unless there's a
// specified margin that's smaller than that
pad = Math.min(12, margin.l, margin.r, margin.t, margin.b);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@etpinard seem reasonable? I started looking into this due to test failures at d02c76b - where some colorbars that were previously not able to expand the margin because they were internally pixel-sized suddenly became able to expand it when I switched it to plot-fraction-sized as described in #2681 (comment)... but then this 12px padding overrode user-supplied margins that were smaller - and that didn't seem right to me. Some of the baseline images with small explicit margins changed as a result.

The 12px here is an odd hard-coded feature - I suppose an alternative would be to make this an attribute in its own right (layout.margin.autopad?) and put the min(12, margin.l...) logic in supplyDefaults.

Copy link
Contributor

Choose a reason for hiding this comment

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

seem reasonable?

Very reasonable. 🥇

I suppose an alternative would be to make this an attribute in its own right (layout.margin.autopad?) and put the min(12, margin.l...) logic in supplyDefaults.

Maybe down the road, but no need in this PR.


// if the item is too big, just give it enough automargin to
// make sure you can still grab it and bring it back
Expand Down
Binary file modified test/image/baselines/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/dendrogram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_cufflinks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_ibm-plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_opacity-scaling-spikes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.