I want to add a dcc.Graph to my Dash app only if there is data available to plot in the graph. If this is not the case I’d like to hide the dcc.Graph.
return a div without the graph from the callback as children
app.callback(Output('my-div', 'children'), [Input('some_input', 'some_value')]):
def get_graph(value):
# check if it should display graph or not, return True/False
if condition:
return html.Div(dcc.Graph(figure=figure))
else:
return html.Div('no data to plot')
1 Like