Getting an event from the legend

I wonder if someone might be kind enough to help. I have multiple traces on the graph and annotations that are associated with each trace.
When the legend for a trace is selected to make it the trace invisible I would like to make my associated annotations invisible also.
Is there any way of getting an event from the legend that identifies the selected “invisible” trace so that I can then remove its annotations?

1 Like

Hi @Nick.V, any luck figuring this out? having the same issue now.

Here’s a hacky way to do this:


Used this hack to trap clicks to the legend. The “visible” attribute is boolean ‘true’ when it comes to the ‘attach’ function. Then, it becomes ‘legendonly’ string the next time you toggle it… (Adding this note as FYI)

Is there a hack way to call the legenclick event outside the script of the plot ???
I got two plots who have the same legend and I want to link the legends so that when you click on one legend the other legend responds too !!