Good for now
This commit is contained in:
parent
e991e8e876
commit
f58ee891b3
@ -31,7 +31,7 @@ import scipy.signal as sig
|
||||
import plotly.express as px
|
||||
from plotly.subplots import make_subplots
|
||||
# import plotly.graph_objects as go
|
||||
from dash import Dash, html, dcc, callback, Output, Input, no_update
|
||||
from dash import Dash, html, dcc, callback, Output, Input, State, no_update
|
||||
from waitress import serve
|
||||
import json
|
||||
import io
|
||||
@ -858,6 +858,7 @@ if __name__ == "__main__":
|
||||
style={'height':'85vh'}
|
||||
),
|
||||
dcc.Store(id="signal"),
|
||||
# dcc.Store(id="dropdown-index"),
|
||||
dcc.Interval(
|
||||
id='interval-component',
|
||||
interval=3*1000, # in milliseconds
|
||||
@ -869,22 +870,28 @@ if __name__ == "__main__":
|
||||
# start button callback
|
||||
@callback(Output('interval-component', 'disabled'),
|
||||
Output("start-button", "children"),
|
||||
Input("start-button", "n_clicks"))
|
||||
Output('controls-and-radio-item', 'disabled'),
|
||||
Input("start-button", "n_clicks"),)
|
||||
|
||||
def start_cycle(n):
|
||||
if n:
|
||||
if n%2 == 0:
|
||||
return True, "Auto Play"
|
||||
return True, "Auto Play", False
|
||||
else:
|
||||
return False, "Pause"
|
||||
return False, "Pause", True
|
||||
return no_update
|
||||
|
||||
# interval callback
|
||||
@callback(Output('controls-and-radio-item', 'value'), Input("interval-component", "n_intervals"))
|
||||
def cycle_syms(n):
|
||||
# if not n:
|
||||
# return no_update
|
||||
syms=["AMZN", "GOOGL", "AAPL", "SPY"]
|
||||
return syms[n % 4]
|
||||
@callback(Output('controls-and-radio-item', 'value'),
|
||||
Input("interval-component", "n_intervals"),
|
||||
State('controls-and-radio-item', 'options'),
|
||||
# State('dropdown-index', 'data'),
|
||||
)
|
||||
def cycle_syms(n, syms):
|
||||
if syms:
|
||||
return syms[n % len(syms)]
|
||||
else:
|
||||
return no_update
|
||||
|
||||
@cache.memoize(timeout=14400) # cache timeout set to 4 hours
|
||||
def global_store():
|
||||
@ -930,6 +937,7 @@ if __name__ == "__main__":
|
||||
|
||||
# Add controls to build the interaction
|
||||
|
||||
# callback when data retrieve finishes triggered by signal
|
||||
@callback(
|
||||
Output(component_id='controls-and-radio-item', component_property='options'),
|
||||
Output(component_id='button', component_property='disabled'),
|
||||
@ -950,12 +958,16 @@ if __name__ == "__main__":
|
||||
|
||||
return sorted(all_plot_sym), False, False
|
||||
|
||||
# dropdown callback
|
||||
@callback(
|
||||
Output(component_id='controls-and-graph', component_property='figure'),
|
||||
# Output("dropdown-index", "data"),
|
||||
Input(component_id='controls-and-radio-item', component_property='value'),
|
||||
# State('controls-and-radio-item', 'options')
|
||||
# Input(component_id='signal', component_property='data'),
|
||||
)
|
||||
|
||||
# def update_graph(col_chosen, syms):
|
||||
def update_graph(col_chosen):
|
||||
if not col_chosen:
|
||||
raise PreventUpdate
|
||||
@ -1047,6 +1059,7 @@ if __name__ == "__main__":
|
||||
fig.update_layout(margin=dict(l=30, r=20, t=50, b=20))
|
||||
|
||||
return fig
|
||||
# return fig, syms.index(col_chosen)
|
||||
|
||||
serve(app.server, host="0.0.0.0", port=8050, threads=7)
|
||||
# app.run(debug=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user