✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Draw a Graph upon a click on a dcc.Graph


I want to draw a Graph in a dcc.Graph or a html.Div, upon a click on an existing dcc.Graph (that has a different id). I’m not seeking clicking on data point on the scatter, I’m seeking the handling of a click anywhere on the dcc.Graph, that should update or make a new Graph appearing.

I’ve been using Input(‘my_Id’,‘click’) + Callback function, or Input(‘my_Id’,‘n_clicks’) + Callback func, but in vain. I’m struggling with the right code to follow.

Here’s my code:

@app.callback(Output('zoomedfig', 'children'),
              [Input('graph1', 'click')])
def display_click_data(clickData):
    x1 = [1,2,3,4]
    x2 = [5,6,7,8]
    fig = go.Figure()
    fig.add_trace(go.Scatter(x=x1, y=x2,
    return fig

Please any help would be appreciated.
Thank you very much