plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

Allow legend to use bottom margin space?

Open rpaskowitz opened this issue 9 years ago • 8 comments

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

rpaskowitz avatar Jan 27 '17 22:01 rpaskowitz

Sounds like a solid idea :+1:

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 avatar Jan 30 '17 17:01 etpinard

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

rpaskowitz avatar Jan 30 '17 17:01 rpaskowitz

@rpaskowitz yep, that sounds about right.

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

etpinard avatar Jan 30 '17 17:01 etpinard

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

etpinard avatar Feb 08 '17 21:02 etpinard

I need this .. is there any way we can get this working in v1.26.1 ?

saimaparveen avatar May 30 '17 18:05 saimaparveen

I need this .. is there any way we can get this working in v1.26.1 ?

@saimaparveen ... if only life was that easy.

etpinard avatar May 30 '17 21:05 etpinard

+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, https://github.com/plotly/plotly.js/issues/1244 would be awesome to have)

cpsievert avatar Feb 06 '20 23:02 cpsievert

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 avatar Jun 06 '24 15:06 gvwilson