Multiple output, Callback error: Expected output type to be list or tuple

Hi Dash Community,

when using multiple outputs in a callback, I got a callback error message saying Expected the output type to be a list or tuple but got: Graph.

@app.callback(Output('div_top', 'children'),
              Output('div_bottom', 'children'),
              Input('file-select', 'value'),
              Input('slider', 'value')),            
def update_graph(file, value):
    graph = get_graph(file, value)
    cur_value = value

    return graph, cur_value
    

graph is of type dcc.Graph and value is an integer.

I think I have a syntax error here, but I can’t get my head around it. My Output is defined in a tuple, so are my return values. So what did I miss here?

Thank you so much for your help!

Hi @cody,
I don’t think you can return a dcc.Graph to a children of a div. Use the component id of dcc.Graph from your layout and return to the component property figure.

Something like this:

@app.callback(Output('my-graph', 'figure'),
              Output('div_bottom', 'children'),
              Input('file-select', 'value'),
              Input('slider', 'value')),            
def update_graph(file, value):
    graph = get_graph(file, value)
    cur_value = value

    return graph, cur_value

Hi @atharvakatre
thank you for your reply. Before adding the second Output, I could return a dcc.Graph to a children of a div.

Anyway I used a dcc.Graph component and returned figure to that component, but I still got the same error.

OMG, I feel so stupid. I have a second return in an if statement in my callback and forgot to define the return value for the second output there!

Unlike Inputs, all Outputs need to be addressed in every return statement!

@app.callback(Output('div_top', 'children'),
              Output('div_bottom', 'children'),
              Input('file-select', 'value'),
              Input('slider', 'value'),
              Input('choice', 'value'),            
def update_graph(file, value, choice):
    if choice == 0:
        graph = get_graph(file, value)
        cur_value = value

        return graph, cur_value # Attention!
    elif choice == 1:
        graph = get_graph(file, value**3)
        cur_value = value**3
        
        return graph, cur_value # Attention!