Basically all the sliders are populated using dcc.Input
. The program works where input boxes populate the min/max of the slider. The x-axis of the graph that will displayed is based on the last slider that is changed
@app.callback(
[Output('pieces', 'min'),
Output('pieces', 'max'),
Output('ups', 'min'),
Output('ups', 'max'),
Output('labor', 'min'),
Output('labor', 'max'),
Output('production', 'min'),
Output('production', 'max'),
Output('setup', 'min'),
Output('setup', 'max'),
Output('delivery', 'min'),
Output('delivery', 'max'),
Output('foil_markup', 'min'),
Output('foil_markup', 'max'),
Output('labor_markup', 'min'),
Output('labor_markup', 'max'),
Output('overall_markup', 'min'),
Output('overall_markup', 'max')],
[Input('submit-val', 'n_clicks'),
State('pieces_low', 'value'),
State('pieces_high', 'value'),
State('ups_low', 'value'),
State('ups_high', 'value'),
State('labor_low', 'value'),
State('labor_high', 'value'),
State('production_low', 'value'),
State('production_high', 'value'),
State('setup_low', 'value'),
State('setup_high', 'value'),
State('delivery_low', 'value'),
State('delivery_high', 'value'),
State('foil_markup_low', 'value'),
State('foil_markup_high', 'value'),
State('labor_markup_low', 'value'),
State('labor_markup_high', 'value'),
State('overall_markup_low', 'value'),
State('overall_markup_high', 'value')])
def pieces_low_value(n_clicks, pieces_min, pieces_max, ups_min, ups_max, labor_min, labor_max, production_min, production_max,
setup_min, setup_max, delivery_min, delivery_max, foil_markup_min, foil_markup_max,
labor_markup_min, labor_markup_max, overall_markup_min, overall_markup_max):
return pieces_min, pieces_max, ups_min, ups_max, labor_min, labor_max, production_min, production_max, \
setup_min, setup_max, delivery_min, delivery_max, foil_markup_min, foil_markup_max, labor_markup_min, \
labor_markup_max, overall_markup_min, overall_markup_max
Is there a way to obtain the min and max of a dcc.Slider
object without including both of them as an Input
to the callback function? Or if it is not possible is there a way to only add the 'min' and 'max' of the slider of interest?
It seems lengthy to actually include an Input('component_id', 'max')
and Input('component_id', 'min')
for all the 14 Inputs with the slider values since I will need the 'min' and 'max' of a slider that was last changed which is found by doing ctx = dash.callback_context
and last_changed = ctx.triggered[0]['prop_id'].split(".")[0]
@app.callback(
Output('graph', 'figure')
[Input('foil_price', 'value'),
Input('UOM_foil_length', 'value'),
Input('UOM_foil_width', 'value'),
Input('piece_length', 'value'),
Input('piece_width', 'value'),
Input('pieces', 'value'),
Input('ups', 'value'),
Input('labor', 'value'),
Input('production', 'value'),
Input('setup', 'value'),
Input('delivery', 'value'),
Input('foil_markup', 'value'),
Input('labor_markup', 'value'),
Input('overall_markup', 'value')])
def update_figure(price_per_roll, foil_length, foil_width,
piece_length, piece_width, pieces, ups,
labor_rate, production_rate, setup,
delivery, foil_markup, labor_markup, overall_markup):
ctx = dash.callback_context
last_changed = ctx.triggered[0]['prop_id'].split(".")[0]