Closed
Description
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
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
etpinard commentedon Jul 30, 2018
What if we added a
piegroup
attribute?piegroup
would (like the 1st bullet pt) have one legend entry per label+color combination.piegroup
value would behave the second bullet pt by showing all colors (maybe cap that at 4) associated with traces of the samepiegroup
alexcjohnson commentedon Jul 30, 2018
We already have a
scalegroup
attribute so would this need to becolorgroup
? Or perhaps we can reuselegendgroup
for this purpose? Anyway seems like the two issues are distinct, so it's not simply a matter of renamingscalegroup
, we need both to exist (though I suppose we could discuss whether their defaults should be linked)etpinard commentedon Jul 30, 2018
Oh right I forgot that scalegroup got implemented (proof -> here),.
This sounds like a solid proposition 👌
But, just to think out loud⤵️
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?hiddenslices -> hiddenlabels
etpinard commentedon May 23, 2019
Merging in #3885
See https://codepen.io/etpinard/pen/arVVpg
for
pie
traces,funnelarea
traces behave similarly.Potential solution:
More info: #3876 (comment)
gvwilson commentedon Jun 11, 2024
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