Skip to content

Allow legend to use bottom margin space? #1340

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
rpaskowitz opened this issue Jan 27, 2017 · 8 comments
Closed

Allow legend to use bottom margin space? #1340

rpaskowitz opened this issue Jan 27, 2017 · 8 comments
Labels
feature something new

Comments

@rpaskowitz
Copy link
Contributor

Would the team accept a PR to optionally allow the legend to expand in to the bottom margin area?

image

Currently this space is un-used since there will never be x-axis labels in this place, and it would allow for more legend entries to be shown before scrolling.

Visually, some people may prefer to have the legend entries align entirely with the graph area, but in my case, it would be preferable to use the space to show more.

Here is an example of the legend_scroll mock with 100% of the bottom margin used. (I'd probably preserve some margin, also maybe configurable so it doesn't go right to the bottom of the div).

image

@etpinard
Copy link
Contributor

Sounds like a solid idea 👍

I'd vote for adding a len attribute (short for length) similar to what we use current for configuring the span of colorbars and sliders. By default, its maximum value would be 1 corresponding in pixels to:

// for vertical legends
layout.height - (layout.margin.t + layout.margin.b) 

// for horizontal legends
layout.width - (layout.margin.l + layout.margin.r) 

This len attribute would allow users to specify e.g.

layout = {
  len: 1.2
}

which would make the legend span into the bottom margin.

@etpinard etpinard added the feature something new label Jan 30, 2017
@rpaskowitz
Copy link
Contributor Author

To achieve the effect I showed, I had modified:

-        legendHeightMax = gs.h;
+        legendHeightMax = fullLayout.height - gs.t;

I think gs.h works out to layout.height - (layout.margin.t + layout.margin.b) as you mention.

Would you recommend that (roughly):

x = layout.height - (layout.margin.t + layout.margin.b) 
legendHeightMax = x * opts.layout.len

@etpinard
Copy link
Contributor

@rpaskowitz yep, that sounds about right.

Would you mind making a PR so that we can test this solution in detail?

@etpinard
Copy link
Contributor

etpinard commented Feb 8, 2017

In doing so, we should try to make updatemenus re-use @n-riesco 's brilliant scrollbox module.

@saimaparveen

This comment has been minimized.

@etpinard

This comment has been minimized.

@cpsievert
Copy link

cpsievert commented Feb 6, 2020

+1 for a len attribute. It would also be useful to have this in ggplotly() when trying to layout colorbar(s) with a legend (relatedly, #1244 would be awesome to have)

@gvwilson
Copy link
Contributor

gvwilson commented Jun 6, 2024

Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson

@gvwilson gvwilson closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

No branches or pull requests

5 participants