Graph if empty dropdown

Hi !

I’m using dropdowns to filter my data and update my graphs. I want to have a non-filtered graph when I clear value on my dropdown.

Everyone knows how to do that ?

Thank you !

If you want to clear the graph, you can do:

@app.callback(...)
def update_graph(value):
    if value is None:
        return {'data': []}
    else:
        ...

If you don’t want your graph to update, see How to leave callback Output unchanged - #2 by nedned, e.g.

@app.callback(...)
def update_graph(value):
    if value is None:
        raise Exception()
    else:
        ...

Thank’s ! I did a thing like the first method and it worked !

1 Like