Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Add legendgroupname property to traces

Hi.

In the legend, I would like that a group of traces appear as one item, with the legendgroupname displayed, instead of a list of the traces.

In this way, when the legendgroupname is clicked on the legend, all traces from this group would be hidden/displayed.

On the plot, though, as one hovers over the traces, the regular name property would be displayed for each one.

Best regards,

Antonio

This would be equivalent to setting showlegend: false in all but the first trace of each group.

See example: http://codepen.io/etpinard/pen/Vbzxqa?editors=0010

It wouldn’t work because it would display the name of the first trace instead of the name for that group (legendgroupname).

For instance, let us say there is a chart of weight of fruit vs cultivation time. Let us say we have three traces for apples (Gala, Granny Smith, Golden) and three traces for oranges (Valencia, Castellana, Salustiana).

Then the hover tags would display the names of each, as per name. But the legend would display one of the varieties names (which makes no sense), instead of the name for the group. Therefore, it seems as a new property is required to guide a name to the groups so that it is used in the legend.

Here the chart code: https://codepen.io/ajoposor/pen/ybpOQQ

That’s been discussed in https://github.com/plotly/plotly.js/issues/276 but since the same results can easily be done using annotations it isn’t a priority for us at the moment.

Ok, thank you! I’ll take a look at annotations.

1 Like