grid style

This commit is contained in:
tomgwang 2024-09-26 16:07:54 -07:00
parent 7dadea010b
commit a10d6138e2

View File

@ -677,6 +677,8 @@ if __name__ == "__main__":
# App layout # App layout
app.layout = [ app.layout = [
html.Div([ html.Div([
# html.Button('Reset', id="reset-button", n_clicks=0,
# style={'font-size': '12px', 'width': '140px', 'display': 'inline-block', 'margin-bottom': '10px', 'margin-right': '5px', 'height':'36px', 'verticalAlign': 'top'}),
html.Div([ html.Div([
dcc.Dropdown(symbols, symbols[0], id='symbols_dropdown_list',), dcc.Dropdown(symbols, symbols[0], id='symbols_dropdown_list',),
], style={'width': '140px', 'text-align': 'center'}), ], style={'width': '140px', 'text-align': 'center'}),
@ -694,7 +696,8 @@ if __name__ == "__main__":
dcc.Interval( dcc.Interval(
id='interval-component', id='interval-component',
interval=3*1000, # in milliseconds interval=3*1000, # in milliseconds
n_intervals=len(symbols), n_intervals=0,
# max_intervals=len(symbols),
disabled=True, disabled=True,
), ),
] ]
@ -724,13 +727,23 @@ if __name__ == "__main__":
def start_cycle(n, value): def start_cycle(n, value):
if n: if n:
# if n%2 == 0:
if value == "Pause": if value == "Pause":
return True, "Auto Play", False return True, "Auto Play", False
else: else:
return False, "Pause", True return False, "Pause", True
return no_update return no_update
# # reset button callback
# @callback(Output('interval-component', 'n_intervals'),
# Output("start-button", "children"),
# Output('symbols_dropdown_list', 'disabled'),
# Input("reset-button", "n_clicks"),)
# def reset_cycle(n):
# if n:
# return 0, "Pause", False
# return no_update
# interval callback # interval callback
@callback(Output('symbols_dropdown_list', 'value'), @callback(Output('symbols_dropdown_list', 'value'),
Input("interval-component", "n_intervals"), Input("interval-component", "n_intervals"),
@ -815,7 +828,8 @@ if __name__ == "__main__":
x=rsi.index, x=rsi.index,
y=['_RSI', '_VoRSI'], y=['_RSI', '_VoRSI'],
) )
fig.add_traces(price_line.data + volume_line.data, rows=1, cols=1, secondary_ys=[False, False, False, False, False, False, True]) # fig.add_traces(price_line.data + volume_line.data, rows=1, cols=1, secondary_ys=[False, False, False, False, False, False, True])
fig.add_traces(price_line.data + volume_line.data, rows=1, cols=1, secondary_ys=[True, True, True, True, True, True, False])
fig.add_traces(macd_line.data + macd_hist_pos.data + macd_hist_neg.data, rows=2, cols=1) fig.add_traces(macd_line.data + macd_hist_pos.data + macd_hist_neg.data, rows=2, cols=1)
# fig.add_traces(macd_line.data, rows=2, cols=1) # fig.add_traces(macd_line.data, rows=2, cols=1)
fig.add_traces(rsi_line.data, rows=3, cols=1) fig.add_traces(rsi_line.data, rows=3, cols=1)
@ -827,15 +841,19 @@ if __name__ == "__main__":
# fig.update_layout(bargap=0, bargroupgap=0) # fig.update_layout(bargap=0, bargroupgap=0)
# fig.layout.xaxis.title="Time" # fig.layout.xaxis.title="Time"
fig.layout.yaxis.title="Price" fig.layout.yaxis.title="Volume"
fig.layout.yaxis.type="log" # fig.layout.yaxis.type="log"
fig.layout.yaxis2.title="Volume" fig.layout.yaxis2.title="Price ($)"
fig.layout.yaxis2.type="log"
fig.layout.yaxis3.title="MACD" fig.layout.yaxis3.title="MACD"
fig.layout.yaxis4.title="RSI/VoRSI" fig.layout.yaxis4.title="RSI/VoRSI"
fig.layout.yaxis.griddash="dash"
fig.update_layout(title_text=plot_ind, title_x=0.5) fig.update_layout(title_text=plot_ind, title_x=0.5,
margin=dict(l=30, r=20, t=50, b=20),
)
# fig.update_layout(showlegend=False) # fig.update_layout(showlegend=False)
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) # return fig, syms.index(col_chosen)