Conditional Dash layout graph item

I have an app layout which originally included a dcc.Graph item. It bothered me that the the graph axes were displayed even before I selected anything to plot (from a dropdown item).

I then changed the graph item to a html.Div, with a callback where it’s output children property either gets returned an empty list or [dcc.Graph(...)].

The problem I’m having now is that since this graph is now nested in the layout, I can’t seem to access its clickData. Is there an alternative way to only show a dcc.Graph object conditionally, but also access its clickData?

You try try hiding it by setting it’s style “display” value to “none”.

@app.callback(Output('graph', 'style'), [Input('drop-down', 'value')])
def toggle_container(dropdown_value):
    if something
        return {'display': 'none'}
    else:
        return {'display': 'block'}
2 Likes

Exactly what I needed, thanks!!