Skip to content

[WIP] Fix issue #384 (invisible legends when y is negative) #410

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 4 commits into from

Conversation

n-riesco
Copy link
Contributor

@n-riesco n-riesco commented Apr 9, 2016

TODO

  • Rename Plot.autoMarginVertical() to something more sensible (any suggestions?)
  • Add missing select('rect')
  • Debug test failure: pie hovering event data should contain the correct fields FAILED
  • Debug test failure: pie hovering event data should fire when moving from one slice to another FAILED
  • Debug test failure: the range slider when specified as visible should react to resizing the maximum handle FAILED
  • Check image test failures (currently 27, 5, autorange-tozero-rangemode, and range-selector-style. All these mocks locate the legend above the axis, i.e. y > 1).
  • New tests

console.error('Legend.draw: insufficient space to draw legend');
legend.remove();
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second thoughts, it'd be more user-friendly to provide a safe default here. For example:

  • if opts.height >= fullLayout.height, then ly = fullLayout.margin.t; scrollHeight = fullLayout.height;
  • else locate the legend the bottom.

@n-riesco n-riesco force-pushed the issue-384-legend-negative-y branch from 2388e2b to 45d5eb1 Compare April 11, 2016 08:53
* Ensure that when the margins are expended to allocate the legend,
  there is enough space to clear the layout margins.

Fixes plotly#384
* Commented out the statements to round off the legend location, in
  order to reproduce the baseline images.

* There are still 4 image tests that fail: 27, 5,
  autorange-tozero-rangemode, and range-selector-style. All these mocks
  locate the legend above the axis (i.e. y > 1).
@n-riesco n-riesco force-pushed the issue-384-legend-negative-y branch from 45d5eb1 to ca23f6c Compare April 11, 2016 11:06
@n-riesco
Copy link
Contributor Author

The location of the plot title seems to be affected by the same issue that here I'm fixing for legends.

I've checked and 3 out of the 4 failing mocks (5, 27 and autorange-tozero-rangemode) have a title that overlaps the top margin.

I haven't checked yet, but I suspect that the 4th failing mock (range-selector-style) suffers from a similar problem with the bottom margin.

// Similar to plots.autoMargin, except that it pads the request with the layout
// margins, so that an object can be drawn without reaching the layout vertical
// margins.
plots.autoMarginVertical = function(gd, id, o) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this?

@etpinard
Copy link
Contributor

I'm not convinced we should add a different auto-margin step to accommodate negative legend positions.

As fas as I know, negative legend positions were working fine before #243 (or in #365). It's really a shame that we don't have any image test for those cases.

But, it looking back at components/legend/draw.js before #243 should tells us where issue #384 was introduced.

@n-riesco
Copy link
Contributor Author

@etpinard I've checked v1.5.2 (#243 was introduced after) and the issue is not present.

I have a question though. How strict are the margins defined in layout.margin? Are components, like legends and titles, allowed to stretch into the margins. If they are not allowed to overlap the margins, then there is an issue in Plots.autoMargin. This is the reason why I introduced the ill-named Plots.autoMarginVertical.

Shall I remove Plots.autoMarginVertical?

@etpinard
Copy link
Contributor

@n-riesco

I've checked v1.5.2 (#243 was introduced after) and the issue is not presen

Thanks for the investigation 🍻

How strict are the margins defined in layout.margin

No very strict. They need to be greater than zero and not bigger than the plot width and/or height

Are components, like legends and titles, allowed to stretch into the margins

It's more like the other around: components, like legends and titles expand the margins (by default).

If they [components] are not allowed to overlap the margins, then there is an issue in Plots.autoMargin

Components are allow to overlap the margins if that's what the users sent as layout argument to Plotly.plot. That said, plotly.js should attempt to make the margins big enough to fit the component by default (as done currently in Plots.autoMargin).

Shall I remove Plots.autoMarginVertical ?

Yes. You should try to fix this issue from within the legend/draw.js.

1 similar comment
@etpinard
Copy link
Contributor

@n-riesco

I've checked v1.5.2 (#243 was introduced after) and the issue is not presen

Thanks for the investigation 🍻

How strict are the margins defined in layout.margin

No very strict. They need to be greater than zero and not bigger than the plot width and/or height

Are components, like legends and titles, allowed to stretch into the margins

It's more like the other around: components, like legends and titles expand the margins (by default).

If they [components] are not allowed to overlap the margins, then there is an issue in Plots.autoMargin

Components are allow to overlap the margins if that's what the users sent as layout argument to Plotly.plot. That said, plotly.js should attempt to make the margins big enough to fit the component by default (as done currently in Plots.autoMargin).

Shall I remove Plots.autoMarginVertical ?

Yes. You should try to fix this issue from within the legend/draw.js.

@n-riesco
Copy link
Contributor Author

Moved to #417

@n-riesco n-riesco closed this Apr 13, 2016
@n-riesco n-riesco deleted the issue-384-legend-negative-y branch April 15, 2016 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants