@offline_dash wrote:
I tried to generate dynamic callbacks like this:
y_axe = [None, 'n_trips'] debug = ['debug1', 'debug2', 'debug3', 'debug4', 'debug5'] x_time = [ ('x-time-series-df-tc-all', 'x-time-filter-df-tc-all', 0, 3, 0), ('x-time-series-df-tc-1', 'x-time-dropdown-df-tc-1', 0, 3, 1), ('x-time-series-1', 'x-time-filter-1', 1, 2, 2), ('x-time-series-2', 'x-time-filter-2', 1, 2, 3), ('x-time-series-3', 'x-time-filter-3', 1, 2, 4), ] for (graph, fname, y, i, d) in x_time: @app.callback( [Output(graph, 'figure'), Output(debug[d], 'children'),], [Input('date-picker-range', 'start_date'), Input('date-picker-range', 'end_date'), Input(fname, 'value')]) def update_graphs1(start, stop, cfilter): start = int(start.split("T")[0].replace("-", "")) stop = int(stop.split("T")[0].replace("-", "")) dff = None dff = df[i].loc[(start <= df[i]['day']) & (df[i]['day'] <= stop)] if cfilter is '': cfilter = '*' if y_axe[y] is None: y_axe[y] = cfilter val = debug[d] return generate_time_series_figure(dff, cfilter, y_axe[y]), valBut this isn’t working, and my the Output of my debug children always looked like this:
- debug5
- debug5
- debug5
- debug5
- debug5
But they should look like this:
- debug1
- debug2
- debug3
- debug4
- debug5
Is there a way to use additional parameters for the function of the callback like this:
for (graph, fname, y, i, d) in x_time: @app.callback( [Output(graph, 'figure'), Output(debug[d], 'children'),], [Input('date-picker-range', 'start_date'), Input('date-picker-range', 'end_date'), Input(fname, 'value'), y, i, d ]) def update_graphs1(start, stop, cfilter, y, i, d):I want to choose my DataFrame, y_axe with an list of tuples, my first try rather looked like this but had the same issues:
x_time = [ ('x-time-series-df-tc-all', 'x-time-filter-df-tc-all', None, 3), ('x-time-series-df-tc-1', 'x-time-dropdown-df-tc-1', None, 3), ('x-time-series-1', 'x-time-filter-1', 'n_trips', 2), ('x-time-series-2', 'x-time-filter-2', 'n_trips', 2), ('x-time-series-3', 'x-time-filter-3', 'n_trips', 2), ] for (graph, fname, y_axe, i) in x_time: @app.callback( Output(graph, 'figure'), [Input('date-picker-range', 'start_date'), Input('date-picker-range', 'end_date'), Input(fname, 'value')]) def update_graphs2(start, stop, cfilter): start = int(start.split("T")[0].replace("-", "")) stop = int(stop.split("T")[0].replace("-", "")) y = y_axe dff = None dff = df[i].loc[(start <= df[i]['day']) & (df[i]['day'] <= stop)] if cfilter is '': cfilter = '*' if y is None: y = cfilter return generate_time_series_figure(dff, cfilter, y)
Posts: 5
Participants: 2







