homecontrol-dash: properly update max slider values in callback
This commit is contained in:
parent
815bf282f6
commit
5587ac45f6
1 changed files with 9 additions and 12 deletions
|
@ -57,7 +57,7 @@ app.layout = html.Div(children=[
|
|||
dcc.Graph(
|
||||
id='graph-sensor-values',
|
||||
figure={
|
||||
'data': [ {'x': [0], 'y': [0], 'mode': 'markers', 'name': 'None'} ],
|
||||
'data': [ {'x': [0], 'y': [0], 'mode': 'line', 'name': 'None'} ],
|
||||
'layout': { 'title': 'initial values' }
|
||||
}
|
||||
)
|
||||
|
@ -115,26 +115,23 @@ def update_slider_limit(value):
|
|||
|
||||
|
||||
@app.callback(
|
||||
[Output('slider-min-txt', 'children'), Output('slider-min', 'max')],
|
||||
Output('slider-min-txt', 'children'),
|
||||
[Input('slider-min', 'value')])
|
||||
def update_slider_min(value):
|
||||
txt = "From: %s" % (time.strftime("%Y/%m/%d %H:%M", time.localtime(float(value))) if
|
||||
return "From: %s" % (time.strftime("%Y/%m/%d %H:%M", time.localtime(float(value))) if
|
||||
value > 0 else 0)
|
||||
t = time.time()
|
||||
return txt, t
|
||||
|
||||
|
||||
@app.callback(
|
||||
[Output('slider-max-txt', 'children'), Output('slider-max', 'max')],
|
||||
Output('slider-max-txt', 'children'),
|
||||
[Input('slider-max', 'value')])
|
||||
def update_slider_max(value):
|
||||
txt = "To: %s" % (time.strftime("%Y/%m/%d %H:%M", time.localtime(float(value))))
|
||||
t = time.time()
|
||||
return txt, t
|
||||
return "To: %s" % (time.strftime("%Y/%m/%d %H:%M", time.localtime(float(value))))
|
||||
|
||||
|
||||
@app.callback(
|
||||
Output('graph-sensor-values', 'figure'),
|
||||
[Output('graph-sensor-values', 'figure'), Output('slider-min', 'max'),
|
||||
Output('slider-max', 'max')],
|
||||
[Input('tabs-select-sensor', 'value'), Input('slider-min', 'value'),
|
||||
Input('slider-max', 'value'), Input('slider-limit', 'value')])
|
||||
def update_graph_sensor_values(sensorId, min_ts, max_ts, limit):
|
||||
|
@ -149,9 +146,9 @@ def update_graph_sensor_values(sensorId, min_ts, max_ts, limit):
|
|||
x = [0]
|
||||
y = [0]
|
||||
return {
|
||||
'data': [ {'x': x, 'y': y, 'mode': 'markers', 'name': "%s" % (s)} ],
|
||||
'data': [ {'x': x, 'y': y, 'mode': 'line', 'name': "%s" % (s)} ],
|
||||
'layout': { 'title': 'Data for sensor: %s (%d elements)' % (s, len(x)) }
|
||||
}
|
||||
}, time.time(), time.time()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
|
Loading…
Reference in a new issue