-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Horizontal legend wrapping is broken when legendgroups are used #1913
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
Comments
plotly.js/src/components/legend/draw.js Lines 521 to 636 in 9a79056
It looks like this is the issue, in the code structure below, if isGrouped is true, it blocks the regular horizontal legend code if(helpers.isVertical(opts)) { |
@jzthree Could it be as easy as refactoring this bit and horizontal legend groups would work again? EDIT: Really in demand of this feature... I just can't use legendgroups in a productive fashion if I want to have a responsive legend =/... |
It's not perfect at all, but you can change they legend orientation on relayout depending on the window width as a workaround until this is fixed. (Only a choice between horizontal and vertical, tho. No wrapping of two items in a row possible this way.) |
Just FYI everyone: If you set |
Extending on this issue, with multiple legend groups you end up with one vertical column in the legend for each group. Which I guess is not a bad way of representing a grouped legend, but I'd guess not intentional! |
I am using rplotly with plotly version 4.8.0. Unfortunately there is no legend$traceorder variable for barplots: https://plot.ly/r/reference/#bar. I would highly appreciate any solution for the alignment/wrapping of horizontal legend of barplots in R. |
@tobiasblasberg it's not a trace property, it's in layout https://plot.ly/r/reference/#layout-legend-traceorder |
Great! That works perfect - thanks a lot! |
+1 for this I may even make a PR if I get a chance to implement a fix using a refactored version of the mentioned draw.js file. |
@antoinerg could you take a look at this one? |
@plotly/plotly_js is the behavior mentionned above intentional and would the following change be acceptable: e84bcb9?short_path=3367b6a#diff-3367b6ae7c2fe5d6fbdfd3a6630f48a1 ? If so, I could submit a fix that only 🔪 suspcious code which is a win imho. Draft PR: https://github.com/plotly/plotly.js/compare/pr-1913 |
…roups Fix #1913 by pushing overflowed legend items to a new line
jsfiddle repro here: https://jsfiddle.net/6oq39dpy/3/
Normally, when a horizontal legend contains many items, they get wrapped onto multiple lines.
However, if legend groups are used at all -- even if only a single item is assigned to its own legend group -- nothing is wrapped, and legend items extending beyond the width of the plot are invisible and inaccessible.
To make wrapping appear again in the jsfiddle repro, just comment out line 10, which sets a legend group for the first trace.
While searching for an already open issue for this, I found #769, which led to the original PR that added support for wrapping horizontal legends in the first place, and mentions legend groups, but only as a workaround for the original problem. I've only skimmed the related code so far so I don't know exactly what causes the bug. :-)
The text was updated successfully, but these errors were encountered: