Hi @plotlek,
The trace.on_*
methods are only designed for use in the Jupyter Notebook with the FigureWidget
class. If youâre using Dash, as in your code example, then youâll need to use the @app.callback
approach like you have in your example. The reason that youâre not seeing a callback in response to clicking the legend is that this is considered a restyle
rather than relayout
event.
Unfortunately, it looks like Dash doesnât have support for restyle events yet. See https://github.com/plotly/dash-core-components/issues/197 for current status.
Hope that helps clear things up.
-Jon