-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Horizontal legend layouts with long series names become vertical #960
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
Looks like this is in fact the intended behavior as per the discussion following #769 (comment) and implemented in #786. In brief, the current implementation gives one width value for all legend items. That width value is maximum text width of trace I understand that the current behavior may not be ideal for all. I wouldn't be opposed to making the trace item layout you're referring to available as a new feature. Perhaps we should add a boolean attribute Alternatively, we should come up with a more granular solution similar to what's proposed in #881 - where we could make the dimension of each legend item configurable. |
You could also come up with different semantics at the top level besides 'v' & 'h'. For example: horizontal To me the current implementation of horizontal is more clearly represented by the word "columns", because of the unintended consequences of spacing being tied to word length. Clear semantics is the most important aspect when creating a package with a less steep learning curve. |
So given that this was intentional behavior, we should presumably avoid changing the behavior of
|
@mboorstin thanks very much for your input. I vote personally vote 👎 on adding a
Good point here. Attributes that only have effect when an other attribute is set to a particular value aren't uncommon in plotly.js. Adding something like @markwatabe made a good point about a possible |
Yes, I agree on the downvote for adding a |
Oh right. That's even better than my suggestion. 👍
Good point here. Maybe |
I'm still not sure of what the correct value is for a |
Also running into this issue, and willing to create a PR but not sure what ya'll deem the best way to do this. I'm actually having the same need as #1193 --- if there is only one row in a horizontal legend then using the max width doesn't look too pretty, BUT for me I would want to use the max width if it went to multiple lines. wonder if this should be a separate option on the legend like "renderInline" (needs a better name) that you could force to be true for all traces. (for the case like @mboorstin's) but then also change current functionality so that if you can fit all the traces in one row in the legend's area -- and in that case we would also ignore maxwidth. i generally think that's a better outcome for everyone, but I could be thinking about this narrowly with my use cases. |
I am also running into a combination of this issue and #771 since every legend item is in its own row, the legend takes up the entire space of the graph. I got around this by making the legend font size smaller. But I hope that this is a temporary work around. |
This comment has been minimized.
This comment has been minimized.
From @gilles-crealp 's #4394 I do not know if this is the expected behavior but when you set legends horizontally and you group some legends, the grouped legends are displayed vertically. See traces 0 to 4 in the screen capture. |
This issue has been tagged with A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort. Sponsorship range: $5k-$10k What Sponsorship includes:
Please include the link to this issue when contacting us to discuss. |
The simplest workaround to avoid this problem is to |
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 |
Repro cases: http://codepen.io/anon/pen/RGozGE
I've encountered an odd behavior on horizontal legends with long series names. If the series names are relatively short, setting
layout.legend.orientation
to'h'
does indeed produce a reasonably laid out horizontal legend where each line of the legend is filled with as many series as possible (first example in the codepen). If, however, a series has a very long name, each series is placed on its own row in the legend (effectively becoming a vertical legend), even though there's clearly room for series with shorter names to be placed on the same rows (second example in the codepen). I think the more logical behavior should be something like this, where the series are packed into rows as closely as their names allow.I'm happy to make a PR to improve this (it should just involve fiddling with the logic near legend/draw.js:603). Should the current behavior be preserved via a new legend attribute whose default is the current behavior and has an option for the new behavior, or is the current behavior never reasonable and should be replaced?
CC to @markwatabe who originally discussed this issue with me and helped with the proposed solution.
The text was updated successfully, but these errors were encountered: