✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Multiple Graphs Update using one callback but can update seperately

I generate similar graphs with their own RadioItem using different ids, and put in layout within one html div. I want to update them using the ratio selector callback separately, but these callbacks are the exact same functions just with different output/input ids. I am doing them in list of graphs together, but this is extremely slow… I have also tried to wrote separate callback functions, but this approach is very redundant. Is there any other options?

def get_selector_graph_combo(data, app, day_range):
    return [get_time_selector(app), get_app_graph(data, app, day_range=day_range)]

def get_time_selector(app):
    selector_id = app + '_date_range'
    return dcc.RadioItems(id=selector_id,
                          options=[{'label': '30', 'value': 30},
                                   {'label': '60', 'value': 60},
                                   {'label': '90', 'value': 90}],

def get_app_graph(data, app, day_range=30):
    return dcc.Graph(id=app, figure=get_app_fig(data, app, day_range=day_range))

def construct_html_children(data, app_list=APP_LIST):
    selector_graph_combos = []
    for (app_name, bundle_id) in app_list:
        combo = get_selector_graph_combo(data, app_name, day_range=30)

    return selector_graph_combos

app_combo_list = construct_html_children(data)

app.layout = html.Div([
    ## Products Dashboard

output_list = [Output(id[0], 'figure') for id in APP_LIST]
input_list = [Input(id[0]+'_date_range', 'value') for id in APP_LIST]

@app.callback(output_list, input_list)
def update_date_range(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16):
    day_range_list = [d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16]
    graphs = [get_app_fig(data, app_name, day_range)
              for (day_range, (app_name, bundle_id))
              in zip(day_range_list, APP_LIST)]
    return graphs