Multiple inputs and outputs

I’m looking to build a dashboard that involves multiple inputs (check boxes) with multiple outputs (different dcc.Graphs)

I’m thinking that I would need to have several instances of “multiple inputs to single input” - one function for each graph to be updated. Am I right?

I’ve seen the tutorial for multiple inputs and multiple outputs, but where can I see reference code for multiple inputs with multiple outputs?

Many thanks!

Are you looking on how to structure a callback with multiple inputs and multiple outputs? If so, the following is an example.

@app.callback(
    [Output('square', 'children'),
     Output('cube', 'children'),
     Output('twos', 'children'),
     Output('threes', 'children'),
     Output('x^x', 'children')],
    [Input('x1', 'value'),
     Input('y1', 'value'),
     Input('x2', 'value'),
     Input('y2', 'value'),
     Input('y3', 'value')])
def update_graph(x1, y1, x2, y2, y3):
    return x1**2, y1**3, x2**x2, y2**y2, y3**y3
3 Likes

Hi flyingcujo,

Thanks! It does make sense to combine both aspects.

How can I understand the returnof the graph though? If all the outputs are dcc.Graph objects, the return will return the data/layout in order of the Output ids?

The return statement order must match the order specified by the callback definition. So, in the above exampoe x1**2 is the return value of the compoent with square as it’s ID, x2**x2 is the return value of the compoent with twos as its ID, …

1 Like

Hi, is there a way to do that in R? In the Dash R tutorial it says there is no way to have multiple outputs, instead multiple callbacks should be used. Using multiple outputs would significantly simplify my code. Thanks.