My apologies for a redundant question but I’m relatively new to python and certainly new to dash and plotly. Basically, I’m kind of new to all of this computer stuff. Anyways, I’m stuck on embedding a dash graph into a webpage using an iframe and do not know where the issue resides. Can someone please help. The below is what I’m trying to do:
*Embed dash into flask and deploy using elastic bean stalk
*I’ve successfully deployed my application.py and requirements.txt files using elastic bean stalk see (http://mydash-env-1.6fp3pk4uin.us-east-2.elasticbeanstalk.com/) but when I try to embed the url in an
application.py contains the following:
#!/usr/bin/env python3
-- coding: utf-8 --
“”"
Created on Sat Jun 8 15:40:58 2019
“”"
import flask
import plotly.graph_objs as go
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
y1 = [0,1,2,3,4]
y2 = [0,2,4,6,8]
y3 = [0,4,-1,2,3]
server = flask.Flask(name)
app = dash.Dash(name,server=server)
application = app.server
app.layout = html.Div([
html.Label(‘Select Trend(s) to Plot’),
dcc.Dropdown(id = ‘my-dropdown’,
options = [
{‘label’: ‘Y1’, ‘value’: ‘y1’},
{‘label’: ‘Y2’, ‘value’: ‘y2’},
{‘label’: ‘Y3’, ‘value’: ‘y3’},
],
value = [‘y1’],
multi = True,
),
dcc.Graph(id=‘my-graph’)
])
@app.callback(Output(‘my-graph’, ‘figure’),
[Input(‘my-dropdown’, ‘value’)])
def update_fig(selected_dropdown_value):
trace = []
for name in selected_dropdown_value:
dropdown = {‘y1’: y1,‘y2’: y2,‘y3’: y3}
y = dropdown[name]
trace.append(go.Scatter(y=y,mode=‘lines’,name=f’{name}’))
figure = {'data': trace,
'layout': go.Layout(
xaxis={'title':'X-axis'},
yaxis={'title':'Y-axis'},
title = 'Simple Plot'),
}
return figure
if name == ‘main’:
application.run(debug=True, port = 8080)