Last active
February 21, 2019 20:00
-
-
Save okomarov/f07a7e67d321f03487c043f6e00453c0 to your computer and use it in GitHub Desktop.
layout.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime as dt | |
import pandas_datareader as pdr | |
from dash.dependencies import Input | |
from dash.dependencies import Output | |
def register_callbacks(dashapp): | |
@dashapp.callback(Output('my-graph', 'figure'), [Input('my-dropdown', 'value')]) | |
def update_graph(selected_dropdown_value): | |
df = pdr.get_data_yahoo(selected_dropdown_value, start=dt(2017, 1, 1), end=dt.now()) | |
return { | |
'data': [{ | |
'x': df.index, | |
'y': df.Close | |
}], | |
'layout': {'margin': {'l': 40, 'r': 0, 't': 20, 'b': 30}} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dash_core_components as dcc | |
import dash_html_components as html | |
layout = html.Div([ | |
html.H1('Stock Tickers'), | |
dcc.Dropdown( | |
id='my-dropdown', | |
options=[ | |
{'label': 'Coke', 'value': 'COKE'}, | |
{'label': 'Tesla', 'value': 'TSLA'}, | |
{'label': 'Apple', 'value': 'AAPL'} | |
], | |
value='COKE' | |
), | |
dcc.Graph(id='my-graph') | |
], style={'width': '500'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment