import dash | |
from dash.dependencies import Input, Output | |
import dash_core_components as dcc | |
import dash_html_components as html | |
from pandas_datareader import data as web | |
from datetime import datetime as dt | |
app = dash.Dash('Hello World') | |
app.layout = html.Div([ | |
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'}) | |
@app.callback(Output('my-graph', 'figure'), [Input('my-dropdown', 'value')]) | |
def update_graph(selected_dropdown_value): | |
df = web.DataReader( | |
selected_dropdown_value, | |
'google', | |
dt(2017, 1, 1), | |
dt.now() | |
) | |
return { | |
'data': [{ | |
'x': df.index, | |
'y': df.Close | |
}], | |
'layout': {'margin': {'l': 40, 'r': 0, 't': 20, 'b': 30}} | |
} | |
app.css.append_css({'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'}) | |
if __name__ == '__main__': | |
app.run_server() |
This comment has been minimized.
This comment has been minimized.
For more about how this example works and how to install the necessary dependencies, please see the official dash user guide at https://dash.plot.ly. Thank you! |
This comment has been minimized.
This comment has been minimized.
The user guide instructions for the installation at https://plot.ly/dash is very specific about which version of each library to install. Do you know if we could just install those libraries without specifying the version? |
This comment has been minimized.
This comment has been minimized.
@PierreBourgault You could install without version numbers - it works for the current setup . But may fail in the future. |
This comment has been minimized.
This comment has been minimized.
Am I the only that gets an error like this when running the example? The error seems to be from fetching the data to plot. |
This comment has been minimized.
This comment has been minimized.
It looks like Google problem, try yaho. Work fine for me |
This comment has been minimized.
This comment has been minimized.
how to run a dash application can anybody tell me coz i am getting an error while running the code on jupyter i.e. system exit and also tell me from where i can access the app |
This comment has been minimized.
This comment has been minimized.
Not 'google' nor 'yahoo' is currently working, please provide some valid source |
This comment has been minimized.
This comment has been minimized.
you can use quandl instead , ex below import dash from pandas_datareader import data as web app = dash.Dash('Hello World') app.layout = html.Div([ @app.callback(Output('my-graph', 'figure'), [Input('my-dropdown', 'value')]) app.css.append_css({'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'}) if name == 'main': |
This comment has been minimized.
This comment has been minimized.
It works |
This comment has been minimized.
This comment has been minimized.
Installed all dependencies, but I get the following error from my jupyter lab.
|
This comment has been minimized.
This comment has been minimized.
I'm running the above code using Spyder/Anaconda. When opening local host on port 8050, I only see a White window with "Loading..." on the top. Can anyone please help me? |
This comment has been minimized.
This comment has been minimized.
datasource 'yahoo' works for me currently (Google does not) |
This comment has been minimized.
This comment has been minimized.
I seem to be getting hung up at the decorator and the def update_graph. I get the * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit) and then the program hangs. Any ideas? |
This comment has been minimized.
This comment has been minimized.
How about if i would like to use a dataset on that sample code? |
This comment has been minimized.
This comment has been minimized.
How about if i would like to use a dataset on that sample code? |
This comment has been minimized.
This comment has been minimized.
HELP PLEASE! I am a student and I trying to create a graph to show volunteer impacts. Nothing fancy. I tried the simple graph and that didn't work, now I have this one and its not working :( ModuleNotFoundError Traceback (most recent call last) ModuleNotFoundError: No module named 'pandas.io.data' |
This comment has been minimized.
This comment has been minimized.
@aboucher410 please look at the basics of python before putting the hands on this code.
Now, save all the required libraries in a file called requirements.txt, in the same folder where you have the python module above, one library for each line. It would look like:
Continue from the terminal:
There is a lot, and few details of why. Do not be discouraged if something does not work at the first attempt. Look up each problem you may encounter and try to solve it with google. In any case, please read the documentation about pip and virtualenv to get the basics, and in particular to grasp the reasons why we need them. |
This comment has been minimized.
This comment has been minimized.
use the command prompt in running your code also i dont advise you use jupyter for coding or running dash. ALSO this worked for me: |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Hi, can anyone tell why google isnt working and yahoo is? |
This comment has been minimized.
This comment has been minimized.
apparently google is not available as a data source anymore, but yahoo still is pydata/pandas-datareader#768 |
This comment has been minimized.
found that this example works only after following dependencies are installed:
pip install plotly==2.0.11 pip install dash==0.17.5 pip install dash_renderer pip install dash_html_components pip install pandas_datareader