-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Implement legendrank attribute in traces #5591
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
Conversation
var B = b[0].trace; | ||
var delta = A.legendrank - B.legendrank; | ||
if(!delta) delta = A.index - B.index; | ||
if(!delta) delta = a[0]._initID - b[0]._initID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming _initID
is important for pie traces? Anything else? OK, so the code below implies (and I just tested to confirm) that legend.traceorder
flips the order of pie entries in the legend, not just the order individual traces get added to the legend.
Based on that, I'd say the correct behavior of traceorder once we add legendrank
is to simply flip the whole thing. That's not what I thought we concluded on the call yesterday but it's what you've implemented and with the pie complication I think it's the simplest thing to explain :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming
_initID
is important for pie traces? Anything else? OK, so the code below implies (and I just tested to confirm) thatlegend.traceorder
flips the order of pie entries in the legend, not just the order individual traces get added to the legend.
I noticed some older version of Chrome (including our image test) sort the items differently.
So _initID
was added in a60a382 to address that issue.
As you mentioned pie-like
traces appear to behave differently.
In 598d60c
I was expecting that by using a higher value of legendrank
on the first pie
trace the slice legends come next.
However it is the opposite and it is rather confusing.
Looks good! Probably wants a mock (or just adding legendranks to some existing mock) and the description addition I commented on, then it'll be ready to go! |
This PR was blocked by the old baseline system using old Chrome. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 Great!
@nicolaskruchten please review and possibly give me a 🌟 to merge this feature. |
src/plots/attributes.js
Outdated
editType: 'style', | ||
description: [ | ||
'Sets the legend rank for this trace.', | ||
'Items and groups with smaller ranks would be presented on top/left side while', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace "would be" with "are" please, throughout :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a1f87b9
As far as I can tell, the specific case outlined in #5501 is not well-handled... B's legendrank of 1 should pull its entire group into the first position: |
Here's the Pen: https://codepen.io/nicolaskruchten/pen/wvJROor |
@nicolaskruchten good catch. It is now fixed by 32a890c and tested by a1abb19. |
Behaviour looks good! |
Addressing #5501.
@plotly/plotly_js