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