Toggling one legend is hiding the other one legend also

example: https://codepen.io/vijaythapak/pen/wvyXrmq?editors=0010

When I toggle the one legend(Group 1), It hides the other legend(Group 2) also. Could you please someone help me to fix this?

PS: Bar graph can be multiple or single in legend-group as it depends on data.

Regards,
Vijay Thapak

The issue is still valid with simple legend (remove legendgroup and make it simple showlegend:true).

Hi,

I don’t think the issue is that they are hidding together, but that for some reason having a single bar (when you toggle one off) makes plotly miscalculate the width (probably to a super small value) and the other bar disappears. I quickly ran your example and the issue is fixed when the traces have at least two bars each.

One alternative is to specify the bar width instead of letting plotly compute it for you. You can pass width as an array like x or y, just make sure you provide values in milliseconds (as your xaxis is a date).

Hope this helps!

1 Like

Thank you so much @jlfsjunior. It’s working perfect with the width in milliseconds. Thanks :slight_smile: