When I use the below code
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
from datetime import datetime
plotly.tools.set_credentials_file(username='***', api_key='***')
trace = go.Candlestick(x=date,
open=open_price,
high=high_price,
low=low_price,
close=close_price)
data = [trace]
layout = {
'title': 'forex pairs',
'yaxis': {'title': 'AAPL Stock'},
}
layout_two = {
'shapes': [{
'x0': '2015-12-09', 'x1': '2016-02-09',
'y0': 0, 'y1': 1, 'xref': 'x', 'yref': 'paper',
'line': {'color': 'rgb(30,30,30)', 'width': 1}
}],
}
fig = {'data':data, 'layout':layout}
py.plot(fig, filename='aapl-recession-candlestick')
My code works as expected, and returns this in my browser,
But when I try and use Dash with the same exact code
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
from datetime import datetime
plotly.tools.set_credentials_file(username='hockeyblades66', api_key='Ggxhe9Y4TSxmEOVKuiaR')
trace = go.Candlestick(x=date,
open=open_price,
high=high_price,
low=low_price,
close=close_price)
data = [trace]
layout = {
'title': 'forex pairs',
'yaxis': {'title': 'AAPL Stock'},
}
layout_two = {
'shapes': [{
'x0': '2015-12-09', 'x1': '2016-02-09',
'y0': 0, 'y1': 1, 'xref': 'x', 'yref': 'paper',
'line': {'color': 'rgb(30,30,30)', 'width': 1}
}],
}
fig = {'data':data, 'layout':layout}
#py.plot(fig, filename='aapl-recession-candlestick')
app = dash.Dash()
app.layout = html.Div([
dcc.Graph(id="my-graph", figure=fig, config={"editable": True})
])
#if name == "main":
app.run_server(debug=True)
My output in my console returns,
runfile('/Users/bennicholl/Desktop/web_apps/value_area/dashboard.py', wdir='/Users/bennicholl/Desktop/web_apps/value_area')
Running on ://127.0.0.1:8050/
Debugger PIN: 593-302-216
* Serving Flask app "dashboard" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
Traceback (most recent call last):
File "/Users/bennicholl/Desktop/web_apps/value_area/dashboard.py", line 29, in <module>
trace = go.Candlestick(x=date,
NameError: name 'date' is not defined
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1
/Users/bennicholl/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py:3299: UserWarning:
To exit: use 'exit', 'quit', or Ctrl-D.
It’s claiming ‘date’ is not defined, but it obviously is. Anyone know of the reason for this happening?