Skip to content

pie legends with conflicting colors #2858

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

Closed
alexcjohnson opened this issue Jul 30, 2018 · 5 comments
Closed

pie legends with conflicting colors #2858

alexcjohnson opened this issue Jul 30, 2018 · 5 comments
Labels
bug something broken

Comments

@alexcjohnson
Copy link
Collaborator

Pointed out by @nicolaskruchten

If you make several pie charts that share one or more labels but give them different colors, you get one legend entry per label, using the first color only:
https://codepen.io/alexcjohnson/pen/Zjvqee?editors=0010
screen shot 2018-07-30 at 4 09 30 pm
and clicking the legend entry for a label makes all copies - even the ones with a different color - disappear. This is confusing, but it's not 100% clear what the right fix is. The case I'm imagining is pies representing distinct data but expressed with the same labels. Like two survey questions, "How many scoops of ice cream do you want" and "How many cherries should there be on top", each with answers "0", "1", "2", "3 or more"

The two options that come to mind for how to resolve this:

  • Make one legend entry per label/color combination. This seems the most flexible, as you could for example show/hide each slice independently. But it could be confusing, especially since we don't have a way to split up the legend or to interleave subheadings, to have multiple entries with matching labels.
  • Show all of the colors next to each other in a single legend entry, kind of like we do for candlestick (though that's just 2 colors, this could be arbitrarily many). This would be more compact, could avoid the confusion ^^ (though could add more confusion if there are too many colors), and if the pies were related enough in meaning you might want to analyze them together - for example, yes/no/maybe questions, you want to hide all the maybes and just compare yes and no for all of them.
@etpinard
Copy link
Contributor

What if we added a piegroup attribute?

  • Traces with different or unset piegroup would (like the 1st bullet pt) have one legend entry per label+color combination.
  • Traces with the same piegroup value would behave the second bullet pt by showing all colors (maybe cap that at 4) associated with traces of the same piegroup

@alexcjohnson
Copy link
Collaborator Author

What if we added a piegroup attribute?

We already have a scalegroup attribute so would this need to be colorgroup? Or perhaps we can reuse legendgroup for this purpose? Anyway seems like the two issues are distinct, so it's not simply a matter of renaming scalegroup, we need both to exist (though I suppose we could discuss whether their defaults should be linked)

@etpinard
Copy link
Contributor

Oh right I forgot that scalegroup got implemented (proof -> here),.

so would this need to be colorgroup
we need both to exist (though I suppose we could discuss whether their defaults should be linked)

This sounds like a solid proposition 👌


But, just to think out loud ⤵️

Or perhaps we can reuse legendgroup for this purpose?

Interesting, perhaps legendgroup should lead to a single legend item per legendgroup value not just for pies, but for all trace types that support legend items? Perhaps this could be a new mode e.g. layout.legendgroupmode with values 'single item' or 'multi item'. But, would other trace other than pies really benefit from grouping their legend items together?

@etpinard
Copy link
Contributor

Merging in #3885


See https://codepen.io/etpinard/pen/arVVpg

image

for pie traces, funnelarea traces behave similarly.

Potential solution:

  • split the legend item square into two halves (in general into N parts), one half with the pie color, the other with funnelarea color

More info: #3876 (comment)

@gvwilson
Copy link
Contributor

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

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

No branches or pull requests

3 participants