How to use the same component id twice as output with callback_context?

Sorry Bryan,
I have a question here. when I used the callback_context to use one component id as an output multiple times, how I can have another output? For example, in this part of my code, I want to get df_min_json as an output as well and store it in a new dcc.Store(id=‘table_min_slice’)

def update_with_rangeslider(js_df, feature, ranges):
    if (feature is None) or (ranges == []):
        return dash.no_update
        dff = pd.read_json(js_df, orient='split')
        df_sliced_min = dff[(dff[feature] < ranges[0])]
        df_min_json = df_sliced_min.to_json(date_format='iso', orient='split')

What do you mean by json?

If you do df_min_json.to_dict('records') it will be a json dictionary.

like the thing I did here in my code:

def store_df(chosen_dataset):
    if chosen_dataset is None:
        return dash.no_update
        df = pd.read_csv(path + chosen_dataset + '.csv')
        df_json = df.to_json(date_format='iso', orient='split')
    return df_json

You can return the dfs you want from the function by using comma’s.

return fig, df_json,..

but in here, I have introduced only one output, and when I add multiple outputs, everything mess up.

    Output('graph3', 'figure'),
    Input('dropdown1', 'value'),
    Input('my_rangeslider', 'value'),
    Input('table1', 'data'),
    Input('dropdown2', 'value'),
def group1(b1, b2, js_df, feature):

Having multiple outputs does add complexity.

But, just remember, when you add an output, all of your returns have to have that additional output, and you should be fine. :slight_smile:

1 Like

Thank you very very much. :pray: :pray:

1 Like