Building Dashboards with Dash and Plotly
Alex Scriven
Data Scientist
A complete Dash app:
import dash
from dash import dcc
app = dash.Dash()
app.layout = dcc.Graph(id='example-graph', figure=bar_fig)
if __name__ == '__main__':
app.run_server(debug=True)
print("f{my_variable}")
import dash
from dash import dcc
dash
is the main library that creates the app itselfdcc
('dash core components') contains the different building blocks to create the app
app = dash.Dash()
app.layout = dcc.Graph( id='example-graph', figure=bar_fig)
dash.Dash()
app.layout
dcc.Graph()
figure
= The Plotly figure to renderid
= Important for callbacks later
if __name__ == '__main__':
app.run_server(debug=True)
python my_app.py
in the command-linedebug
for helpful feedback when testing
Script is run via the command-line (python3 script.py
), served on a local server
Access via a web browser such as Google Chrome
While served, update and save .py
file to see live updates in browser
dash.Dash(__name__)
(The __name__
not needed locally)Building Dashboards with Dash and Plotly