Plotly.js: Single-toggle of grouped traces in legend

Created on 22 Oct 2018  路  8Comments  路  Source: plotly/plotly.js

_This is a feature request._

Please see default "Grouped Legend" example: https://codepen.io/plotly/pen/qjmNXa

Current behavior

It is possible to toggle single traces by clicking on them in the legend. If traces are grouped using legendgroup (like in the example above) not the single traces but the whole group is toggled.

Future behavior

It should be possible to disable the toggling of the whole group and instead toggle the single traces like in no-grouped legends. This would make it possible in the example above to only disable the "points" and only show the "avarage line" of this group.

This should be done by a new option in the legend-settings.

Related: #65, #665, #674

feature

All 8 comments

Can I ask why are you using legend groups if you don't want group toggling? I suspect you like the legend group aesthetics, but I'd like to confirm.

Thank you!

@etpinard I have a quiet complex use case, with multiple sub-charts. Each sub-chart has its own legend-group. I'm using sub-charts because I need a common spike-line and synchronized zooming/panning.
Here is a prototype: https://jsbin.com/davagaz/22/edit?js,output

It is amazing, what is possible with plotly.js already, but I could write small bug-reports and feature requests daily if I had the time... That's the price of using every cutting-edge feature that exists, I guess :smirk:

Thanks!

but I could write small bug-reports and feature requests daily if I had the time..

Please don't hesitate, if you have the time of course :wink:

This seems like a good idea for what I am doing too, but it is possible there is another way to approach my use case that I haven't seen.
So I am using subplots in order to have common x or y axis, what I would then like is for the legend to be aligned with the subplot rather than the whole group. I can split the legend up by using legend groups, but it is tricky to perfectly align them ( I can get close with judicious use of tracegroupgap ), butthen I run into the problems mojoaxel had.
Maybe there is a way of having common axis between plots rather than subplots, or some other option I haven't noticed.

I have the same issue. To me, the group legend should honor the individual toggling or make it a configurable thing. Without grouping the legend it is difficult to visually make sense of some use cases of combination such as this https://codepen.io/Codermar/pen/NWWrqRB?editors=0010

Is there any workaround alternative at this time otherwise?

Thanks.

I have the same issue too, as I suspect anyone serious about plotting data is having.
Need subplots to have common zooming, panning, etc
Therefore need legendgroup to separate legends on subplots.
Need individual toggling to identify "stuff"

The current state of play does not permit all three.
Probably easiest fix is to permit separate legends per subplot.
All should fall into place from there.

Agree with @mojoaxel, the user needs to be able to toggle on/off an individual trace in a subplot. Maybe the solution will come from first having separate legends per sublot, @OlderSchool suggests. BTW, the separate legends per subplot is an issue that can be tracked here:
[plotly/plotly.js] Support for multiple legends (#1668)

I would suggest a following behaviour: legend group would become an independent toggle with a name of a legendgroup, which would activate/deactivate all contained traces. Yet if someone needs to toggle some particular trace, he can add showlegend=True, and displayed legend for this trace would toggle only this trace.

Was this page helpful?
0 / 5 - 0 ratings