'Null is not an object (evaluating 'r.data') in Dash app - Python

I have this script for callbacks in my Dash app:

@app.callback(Output('graph', 'figure'),
              [Input(component_id='graph-dropdown', component_property='value')],
              [Input('interval-component', 'n_intervals')])
def update_figures(interval, value):
    
    df = pd.read_excel(...)

    fig_viability = px.scatter(df, x =...)

    fig_diameter = px.scatter(df, x = ...)

    fig_concentration = px.scatter(df, x = ...)

    def select_graph(value):
        if value == 'fig_viability':
            return fig_viability
        elif value == 'fig_diameter':
            return fig_diameter
        else:
            return fig_concentration

When I run it, I get this error:

"Null is not an object (evaluating 'r.data').
(This error originated from the built-in JavaScript code that runs Dash apps. Click to see the full stack trace or open your browser's console.)"

Does anyone know how to fix this? :(



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source