Skip to content

fix legend when figures has large margins #2983

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 3 commits into from
Sep 7, 2018
Merged

Conversation

antoinerg
Copy link
Contributor

Fixes #2971

Simple fix: the width of a legend was compared to user-supplied margins instead of computed margins.

For testing, I added a baseline image. Should I do this in jasmine instead?

@etpinard @alexcjohnson

@antoinerg antoinerg added bug something broken status: in progress labels Sep 7, 2018
@@ -639,12 +639,12 @@ function computeLegendDimensions(gd, groups, traces) {
});

// check if legend fits in one row
oneRowLegend = (fullLayout.width - (fullLayout.margin.r + fullLayout.margin.l)) > borderwidth + fullTracesWidth - traceGap;
oneRowLegend = (fullLayout.width - (fullLayout._size.r + fullLayout._size.l)) > borderwidth + fullTracesWidth - traceGap;
Copy link
Collaborator

Choose a reason for hiding this comment

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

fullLayout.width - (fullLayout._size.r + fullLayout._size.l) === fullLayout._size.w

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing gets by you :) Thank you again for the quick review!

@alexcjohnson
Copy link
Collaborator

For testing, I added a baseline image. Should I do this in jasmine instead?

An image is the way to go here, since it's a presentation element, so it's harder (and more fragile in case we change element structure) in jasmine to be sure we're testing the right thing.

@alexcjohnson
Copy link
Collaborator

Looks great! Nice detective work @antoinerg 💃

@antoinerg antoinerg merged commit 9070705 into master Sep 7, 2018
@antoinerg antoinerg deleted the 2971-legend_large_margin branch September 7, 2018 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Horizontal legend wrap calculated before automargin
2 participants