Skip to content
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

Allow clickable legend group titles when group has no pie-like traces #5771

Merged
merged 7 commits into from
Jul 17, 2021

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Jun 25, 2021

Resolves #5765.

@plotly/plotly_js

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@archmoj archmoj added this to the NEXT milestone Jun 25, 2021
@nicolaskruchten
Copy link
Contributor

The title-clicking is fine, but actually if you look at this pen https://codepen.io/nicolaskruchten/pen/LYyPvMq you'll see that when you have a mixture of pies and scatters we already have some weird bug where the pie disappears and leaves a black square.

My vote would be to have clicking on a title behave exactly like clicking on a non-pie legend item, including when pies are present, and then to log a bug for the weird black-square behaviour and solve it all at once. Let's not introduce new behaviour for the title, let's just follow the current (buggy) pattern.

@nicolaskruchten
Copy link
Contributor

(note: the black-square behaviour exists in 2.1.0 also, so it's not new here)

@archmoj
Copy link
Contributor Author

archmoj commented Jun 28, 2021

So you suggest that when a legend group has a title,

  1. clicking on the group title show/hide all traces within that group, and
  2. clicking on the trace legend show/hide only that trace.
    Right?

@nicolaskruchten
Copy link
Contributor

No, I'm saying that clicking on the title should have the same effect as clicking on a non-pie trace marker.

@archmoj archmoj modified the milestones: NEXT, v2.3.0 Jun 28, 2021
@rithwikjc
Copy link

2. clicking on the trace legend show/hide only that trace.

Since the legendgrouptitle would be a toggle for the whole group, it would be really really awesome if the individual trace legends now act as independent toggles for that trace only, instead of an all-traces-within-group toggle. 👀

@nicolaskruchten
Copy link
Contributor

@rithwikjc yes, your enthusiasm for this feature is noted :) That specific behaviour change request is tracked in this issue #3135 and once implemented it will not be on by default, rather it will be opt-in with a specific attribute in layout.

@rithwikjc
Copy link

Thank you so much @nicolaskruchten. I am a student and hence by no means capable of sponsoring anything. But I do program, but am yet to venture deep into JS. And once I am capable I hope to contribute to this and other open source projects.
And although this would be a neat feature addition to have on a project I am working on, it is far from required. I'm also just enthusiastic about making this newly added feature set intuitive and well rounded. :)

@archmoj archmoj changed the title Clickable legend group titles when group has no pie-like traces Clickable legend group titles Jul 14, 2021
@archmoj archmoj added bug something broken and removed feature something new labels Jul 14, 2021
archmoj added 2 commits July 14, 2021 17:41

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…oup-titles

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@alexcjohnson
Copy link
Collaborator

This works great for non-pie traces. But for pie-only situations this makes the bug much worse so I'm not really in favor of merging this as is. Either we should exclude pies entirely for now or we should sort it all out at once.

For example if I hide both of the slices in Third Group I get this:
Screen Shot 2021-07-16 at 7 05 35 PM
But if I hide the group, the item names and colors disappear, I just see a black square (which isn't even faded) and no label:
Screen Shot 2021-07-16 at 7 09 44 PM
Worse, if I hide the first group, its title disappears and I can't get the group back:
Screen Shot 2021-07-16 at 7 11 52 PM

When we do fix this, I'd think hiding all slices in a group should be exactly equivalent to hiding the whole group, such that in both cases the group title fades, all slices are still in the legend but faded as well, and in both cases you can click a single slice to bring just that one back (which unfades the title). When you've hidden one slice in a group, clicking the title should hide them all (Because it's not faded when you click it) but then clicking it again should show all slices, not bring you back to one hidden slice.

@nicolaskruchten
Copy link
Contributor

I agree this behaviour is bad but I'm very skeptical that anyone is using pies and legend groups in the wild.

@alexcjohnson
Copy link
Collaborator

Then can we just disable clicking the group title when there are any pies in the plot?

@nicolaskruchten
Copy link
Contributor

That was the original implementation in this PR... I can live with it.

@archmoj archmoj changed the title Clickable legend group titles Allow clickable legend group titles when group has no pie-like traces Jul 17, 2021
archmoj added 2 commits July 17, 2021 10:17

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
This reverts commit 4c4a11b.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃 Thanks @archmoj, looks great. And @nicolaskruchten my apologies for not digging into this earlier, could have saved some of this whiplash.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…oup-titles
@archmoj archmoj merged commit 06d4d2d into master Jul 17, 2021
@archmoj archmoj deleted the clickable-legend-group-titles branch July 17, 2021 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clickable legend group title
4 participants