[SOLVED] Callback error in Plotly/Dash app – Python


I have this code for my dash application which is supposed to display one graph out of 3 graphs based on the dropdown menu (id = ‘graph-selector’). The excel file will get updated on a daily basis, therefore I am using the Interval component:

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

        df = pd.read_excel('/Results.xls')
        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
                return fig_concentration

It gives me this error though:

"TypeError: update_figures() takes 1 positional argument but 2 were given."

Does anyone know how to solve it? I definitely messed up with the callback order/logic here..


You callback has two inputs, but the function signature has only one argument n; it must have two to match the inputs. Hence, you should change the function signature to something like,

 def update_figures(n, m):

Answered By – emher

Answer Checked By – Jay B. (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *