How to use 'scatter.on_change' to grab event?

Hello.

Iā€™d like to find some examples for ā€œon_changeā€ function for ā€œScatterā€ plot. Just need to send some event when plot is changed (eg. series are hide) to trigger some function which will update another plot (eg. resolve average).

I tried to use it similarly to what Iā€™ve found for ā€˜scatter.on_clickā€™ but dunno how to get it work. However, this example https://plot.ly/python/click-events/ as well doesnā€™t work for my case, because I use ā€˜iplotā€™. I hope ā€˜on_changeā€™ donā€™t worry about ā€˜iplotā€™.

Any suggestgions?

Later on, Iā€™ve found I could use @callbacks with relayoutData property.

@app.callback(Output('data-bars', 'figure'), [Input('data-lines', 'relayoutData')])
def upd_graph(reldata):    
    ...
    title = str(np.random.randn(1))    
    print(reldata)
    return { 'data': data, 'layout': layout.update({'title': title}) }

Yes, it triggers events but doesnā€™t interact with legend. I get print messages about tools activity but not while hiding series in my legend. Which property should I try?

Best for #api:python

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