Hi all,
Dash looks great! I need to show the last changed slider value as a single output value “A”.
If slider 1 changes, last changed value “A” is value of slider 1.
If slider 2 changes, last changed value “A” is value of slider 2.
Any help is welcome
import dash
import dash_html_components as html
import dash_core_components as dccexternal_stylesheets = [‘https://codepen.io/chriddyp/pen/bWLwgP.css’]
app = dash.Dash(name, external_stylesheets=external_stylesheets)
app.layout = html.Div([
dcc.Slider(
id=‘slider1’,
min=0,
max=20,
step=0.5,
value=10,
),
html.Div(id=‘output1’),
dcc.Slider(
id=‘slider2’,
min=0,
max=20,
step=0.5,
value=10,
),
html.Div(id=‘output2’),
html.Div(id=‘output3’)])
@app.callback(
dash.dependencies.Output(‘output1’, ‘children’),
[dash.dependencies.Input(‘slider1’, ‘value’)])
def update_output(value):
return ‘You have selected “{}”’.format(value)@app.callback(
dash.dependencies.Output(‘output2’, ‘children’),
[dash.dependencies.Input(‘slider2’, ‘value’)])
def update_output(value):
return ‘You have selected “{}”’.format(value)@app.callback(
dash.dependencies.Output(‘output3’, ‘children’),
[dash.dependencies.Input(‘slider1’, ‘value’),
dash.dependencies.Input(‘slider2’, ‘value’)])
def update_output(slider1,slider2):
return ‘Last updated value is “{}”’.format(slider1*slider2)if name == ‘main’:
app.run_server(debug=True)