✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
📊 Dash 2.0 is Arriving. Register here.

2 input from radio items for one graph?

Hi there,
I have question about radioitems and graphs.
So I have two radioitems and one graph that I want to show different values
it looks like that:
26
and for each radioitem there is different dataframe attached.
But there is a problem I want to select free and then aggregate it by month, but I dont know how to do it.
My sample code is like that:

@app.callback(Output('closed_accounts', 'figure'),
              [Input('interval-component', 'n_intervals'),
               Input('closed_account_options', 'value'),
               Input('aggregation_closed', 'value')])
def update_graph(n, selected_df, aggregation):
    selected = closed_account_options[selected_df]
    aggregations = closed_account_aggregations[aggregation]
        return {
        'data': [
            go.Scatter(
                x=aggregations.index,
                y=aggregations.xxx,
                opacity=0.8),
            go.Scatter(
                x=aggregations.index,
                y=aggregations.xxx,
                opacity=0.8),
            go.Scatter(
                x=aggregations.index,
                y=aggregations.xxx,
                opacity=0.8),
            go.Scatter(
                x=aggregations.index,
                y=aggregations.xxx,
                opacity=0.8),
            go.Scatter(
                x=aggregations.index,
                y=aggregations.xxx,
                opacity=0.8)
        ],
 

Anyone have any idea how to do it?

For this you can use State instead of Input, State will not be triggering the callback when the prop linked is changed.


@app.callback(
     Output('closed_accounts', 'figure'),
      [
          Input('interval-component', 'n_intervals'),
          Input('aggregation_closed', 'value')
      ],
      [
          State('closed_account_options', 'value'),
      ]
)
def update_graph(n, aggregation, selected_df): #note here I switched the two variables name