How to trigger callback with a click on plot annotation

I have a plot with some text annotations, added using fig.add_annotation(). How can I trigger a callback when the annotation is clicked? clickData property of the graph doesn’t trigger

Hey @kiteme, there are no events fired when clicking annotations. The only event I know of is the relayoutData if changing a annatation:

Suppose you have a rectangular shape and change it’s dimension or position by dragging the shape.

You could also add an EventListener either JS or dash-extensions and trigger a callbcak if the click coordinates are within the coordinate range of your annotation.

1 Like