SlideShare a Scribd company logo
Dash
Appsilon tech talks | Damian | 04/04/2018
Overview of Dash framework for building dashboards
What is Dash?
● Dash is a productive Python framework for building web applications.
● Created and maintained by Plotly. https://plot.ly/products/dash/.
● Written on top of Flask, Plotly.js, and React.js.
● Dashboard is implemented in pure Python.
● Dash is an open source library, released under the permissive MIT license.
What you get with Dash
● Frontend generated in Python
● Reactive computations abstraction
● Component class for every HTML tag as well as keyword arguments for all of the HTML arguments implemented in
dash_html_components package
● Interactive html elements implemented in dash-core-components
● Plotly python API implemented in dash-core-components available through Graph class
Dash demo
https://github.com/DamianRodziewicz/dash_example
app.py
What you see in the code
● The layout is composed of a tree of "components" like html.Div and dcc.Graph.
● The dash_html_components library has a component for every HTML tag. The html.H1(children='Hello Dash') component
generates a <h1>Hello Dash</h1> HTML element in your application.
● Not all components are pure HTML. The dash_core_components describe higher-level components that are interactive and are
generated with JavaScript, HTML, and CSS through the React.js library.
● Each component is described entirely through keyword attributes. Dash is declarative: you will primarily describe your
application through these attributes.
● The children property is special. By convention, it's always the first attribute which means that you can omit it:
html.H1(children='Hello Dash') is the same as html.H1('Hello Dash'). Also, it can contain a string, a number, a single component,
or a list of components.
● Attribute 'class' is replaced with 'className'.
● Style attribute can be a python dictionary.
● Attributes cannot have hyphen in name. If you need to write something like 'margin-left', you have to write 'marginLeft' instead.
● Attribute values must be serializable to JSON.
Interactivity
● The "inputs" and "outputs" of our application interface are described declaratively through the app.callback decorator.
● The inputs and outputs of our application are simply the properties of a particular component.
● Any "Output" can have multiple "Input" components.
○ @app.callback(Output('indicator-graphic', 'figure'),
[Input('xaxis-column', 'value'), Input('yaxis-column', 'value'), Input('year--slider', 'value')])
def update_graph(xaxis_value, yaxis_value, year_slider_value): …
● Each Dash callback function can only update a single Output property.
○ To update multiple Outputs, you have to write multiple functions.
● "State" allows you to pass along extra values without firing the callbacks.
○ @app.callback(Output('indicator-graphic', 'figure'),
[Input('xaxis-column', 'value'), Input('yaxis-column', 'value')],
[State('year--slider', 'value')])
def update_graph(xaxis_value, yaxis_value, year_slider_value): …
● There are no intermediate values in the reactive graph.
○ You have to add hidden div with intermediate data (as suggested by plotly)
○ Or you have to use redis to store intermediate values (as suggested by plotly)
How does this work?
● Declare app layout. It will generate react code that will be run in the browser.
● Each element has attributes that describe its state.
○ You can change them which makes the app re-render itself.
○ You can listen on any changes to those attributes and run callbacks.
● Frontend sends HTTP request every time an input is changed.
● Backend recalculates the graph of dependencies and sends back the list of changes to frontend.
One more look
into the code
https://github.com/DamianRodziewicz/dash_example
app.py
Dash core components
● Dropdown
● Slider
● RangeSlider
● Input
● TextArea
● Checkboxes
● RadioItems
● Button
● DatePickerSingle
● DatePickerRange
● Markdown
● Upload component
● Tabs
● Graph - component shares the same syntax as the open-source plotly.py library. See https://plot.ly/python/ for reference
● Interactive Table - under development in https://github.com/plotly/dash-table-experiments repository
Dash custom components - Dash semantic
● You can implement your own components in Dash. For more information on how to do that visit https://dash.plot.ly/plugins
● We have started implementing our own components and helpers in https://github.com/Appsilon/dash-semantic
○ Leaflet map
○ Timeline (react horizontal timeline port)
○ Mixpanel hook (to allow using Mixpanel with frontend plugin that identifies user by cookie)
○ IncludeScript (includes and runs an external script on demand - useful if app runs in local mode)
● We’ll cover this library (and instructions on using it in your project) in separate tech talk.
Dash blocking
computations demo
https://github.com/DamianRodziewicz/dash_example
longer_computations_app.py
Single threaded Dash
● Graph recalculation is blocking and is single threaded
● However we can extract the flask server that is generated and use gunicorn to make the computations concurrent
● http://gunicorn.org/ - Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model. The
Gunicorn server is broadly compatible with various web frameworks, simply implemented, light on server resources, and fairly
speedy.
● Seems to still have a limit on concurrent users.
Dash threading
with gunicorn
https://github.com/DamianRodziewicz/dash_example
longer_computations_app.py
Dash limitations
● We don’t know how it scales for many concurrent users
● At some point you will need more sophisticated components than Dash provides by default
○ You’ll have to write your own components in React.js
○ Or you’ll have to port already existing components from React.js to Dash
● You’ll quickly find out that some quick wins are still under development (Mapbox raster example)
● There are no intermediate values in the reactive graph.
○ You have to add hidden div with intermediate data (as suggested by plotly)
● You have to write separate function for every Output which forces you to restructure the code
● There are some issues we may not be able to resolve without getting to know the way Dash works by heart
● There may be still some issues with Dash that we don’t know about - we have to add a margin to our work
Thanks!

More Related Content

What's hot (20)

PPT
Java script final presentation
Adhoura Academy
 
PDF
TypeScript
Saray Chak
 
PPTX
MongoDB
nikhil2807
 
PDF
Introduction to Redux
Ignacio Martín
 
PDF
Basic Crud In Django
mcantelon
 
PDF
Spring Boot
Pei-Tang Huang
 
PPTX
Redux workshop
Imran Sayed
 
PPTX
Node.js Express
Eyal Vardi
 
PPTX
An Intro into webpack
Squash Apps Pvt Ltd
 
PPTX
Spring boot
sdeeg
 
PPTX
React js
Oswald Campesato
 
PPTX
Hive: Loading Data
Benjamin Leonhardi
 
PDF
MongoDB Aggregation Framework
Caserta
 
PPTX
Intro to React
Justin Reock
 
PPTX
Typescript ppt
akhilsreyas
 
PDF
Presto: Optimizing Performance of SQL-on-Anything Engine
DataWorks Summit
 
PDF
ELK, a real case study
Paolo Tonin
 
PDF
Practical Medium Data Analytics with Python (10 Things I Hate About pandas, P...
Wes McKinney
 
PDF
Apache Iceberg: An Architectural Look Under the Covers
ScyllaDB
 
Java script final presentation
Adhoura Academy
 
TypeScript
Saray Chak
 
MongoDB
nikhil2807
 
Introduction to Redux
Ignacio Martín
 
Basic Crud In Django
mcantelon
 
Spring Boot
Pei-Tang Huang
 
Redux workshop
Imran Sayed
 
Node.js Express
Eyal Vardi
 
An Intro into webpack
Squash Apps Pvt Ltd
 
Spring boot
sdeeg
 
Hive: Loading Data
Benjamin Leonhardi
 
MongoDB Aggregation Framework
Caserta
 
Intro to React
Justin Reock
 
Typescript ppt
akhilsreyas
 
Presto: Optimizing Performance of SQL-on-Anything Engine
DataWorks Summit
 
ELK, a real case study
Paolo Tonin
 
Practical Medium Data Analytics with Python (10 Things I Hate About pandas, P...
Wes McKinney
 
Apache Iceberg: An Architectural Look Under the Covers
ScyllaDB
 

Similar to Tech Talk - Overview of Dash framework for building dashboards (20)

PDF
Dash Intro.pdf
NgoPhuong30
 
PDF
3 - Interactive-Dashboards-with-Plotly-Dash.pdf
felipearian101978
 
PDF
Bowtie: Interactive Dashboards
Jacques Kvam
 
DOCX
What is Dask and How Does It Work?
Mel Denisse
 
PPTX
20170927 py data_n3_bokeh_plotly
Andrey Vykhodtsev
 
PPTX
Dash plotly data visualization
Charu Gupta
 
PDF
New Capabilities in the PyData Ecosystem
Turi, Inc.
 
PDF
AvalancheProject2012
fishetra
 
PPTX
Relay: Seamless Syncing for React (VanJS)
Brooklyn Zelenka
 
PDF
OSDC 2014: Devdas Bhagat - Graphite: Graphs for the modern age
NETWAYS
 
PDF
PyData Amsterdam 2018 – Building customer-visible data science dashboards wit...
Uwe Korn
 
PDF
Dask and Machine Learning Models in Production - PyColorado 2019
William Cox
 
PDF
Building interactive web app with shiny
Vivian S. Zhang
 
PDF
PyLadies Seattle - Lessons in Interactive Visualizations
Amanda Casari
 
PDF
From Pipelines to Refineries: Scaling Big Data Applications
Databricks
 
PPTX
Braxton McKee, CEO & Founder, Ufora at MLconf NYC - 4/15/16
MLconf
 
PPTX
NYAI - Scaling Machine Learning Applications by Braxton McKee
Rizwan Habib
 
PDF
Content-Driven Apps with React
Netcetera
 
PPTX
Dask: Scaling Python
Matthew Rocklin
 
PPTX
Streamlit Tutorials for Beginners - AccentFuture
Accentfuture
 
Dash Intro.pdf
NgoPhuong30
 
3 - Interactive-Dashboards-with-Plotly-Dash.pdf
felipearian101978
 
Bowtie: Interactive Dashboards
Jacques Kvam
 
What is Dask and How Does It Work?
Mel Denisse
 
20170927 py data_n3_bokeh_plotly
Andrey Vykhodtsev
 
Dash plotly data visualization
Charu Gupta
 
New Capabilities in the PyData Ecosystem
Turi, Inc.
 
AvalancheProject2012
fishetra
 
Relay: Seamless Syncing for React (VanJS)
Brooklyn Zelenka
 
OSDC 2014: Devdas Bhagat - Graphite: Graphs for the modern age
NETWAYS
 
PyData Amsterdam 2018 – Building customer-visible data science dashboards wit...
Uwe Korn
 
Dask and Machine Learning Models in Production - PyColorado 2019
William Cox
 
Building interactive web app with shiny
Vivian S. Zhang
 
PyLadies Seattle - Lessons in Interactive Visualizations
Amanda Casari
 
From Pipelines to Refineries: Scaling Big Data Applications
Databricks
 
Braxton McKee, CEO & Founder, Ufora at MLconf NYC - 4/15/16
MLconf
 
NYAI - Scaling Machine Learning Applications by Braxton McKee
Rizwan Habib
 
Content-Driven Apps with React
Netcetera
 
Dask: Scaling Python
Matthew Rocklin
 
Streamlit Tutorials for Beginners - AccentFuture
Accentfuture
 
Ad

More from Appsilon Data Science (10)

PDF
User! 2019 best practices for building shiny enterprise applications
Appsilon Data Science
 
PPTX
Styling your projects! leveraging css and r sass in r projects
Appsilon Data Science
 
PDF
SCRUM in Data Science
Appsilon Data Science
 
PDF
Introduction to Generative Adversarial Networks (GANs)
Appsilon Data Science
 
PDF
Successful Machine Learning projects in Fintech
Appsilon Data Science
 
PDF
Making shiny shine brighter
Appsilon Data Science
 
PPTX
Tech talk - Data Validation with assertr
Appsilon Data Science
 
PDF
Marek Rogala's Talk at User2017 on shiny.collections
Appsilon Data Science
 
PDF
Scaling Shiny Apps - EARL 2017 San Francisco
Appsilon Data Science
 
PDF
Open Data - Rada Innowacyjności
Appsilon Data Science
 
User! 2019 best practices for building shiny enterprise applications
Appsilon Data Science
 
Styling your projects! leveraging css and r sass in r projects
Appsilon Data Science
 
SCRUM in Data Science
Appsilon Data Science
 
Introduction to Generative Adversarial Networks (GANs)
Appsilon Data Science
 
Successful Machine Learning projects in Fintech
Appsilon Data Science
 
Making shiny shine brighter
Appsilon Data Science
 
Tech talk - Data Validation with assertr
Appsilon Data Science
 
Marek Rogala's Talk at User2017 on shiny.collections
Appsilon Data Science
 
Scaling Shiny Apps - EARL 2017 San Francisco
Appsilon Data Science
 
Open Data - Rada Innowacyjności
Appsilon Data Science
 
Ad

Recently uploaded (20)

PPTX
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
apidays
 
PPTX
ER_Model_with_Diagrams_Presentation.pptx
dharaadhvaryu1992
 
PPTX
Climate Action.pptx action plan for climate
justfortalabat
 
PDF
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
PDF
OPPOTUS - Malaysias on Malaysia 1Q2025.pdf
Oppotus
 
PPTX
AI Presentation Tool Pitch Deck Presentation.pptx
ShyamPanthavoor1
 
PPTX
The _Operations_on_Functions_Addition subtruction Multiplication and Division...
mdregaspi24
 
PPTX
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
PPTX
ER_Model_Relationship_in_DBMS_Presentation.pptx
dharaadhvaryu1992
 
PPTX
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
PDF
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
PDF
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
PDF
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
PPTX
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
PDF
Web Scraping with Google Gemini 2.0 .pdf
Tamanna
 
PDF
WEF_Future_of_Global_Fintech_Second_Edition_2025.pdf
AproximacionAlFuturo
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PPTX
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
PDF
Building Production-Ready AI Agents with LangGraph.pdf
Tamanna
 
PDF
Context Engineering for AI Agents, approaches, memories.pdf
Tamanna
 
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
apidays
 
ER_Model_with_Diagrams_Presentation.pptx
dharaadhvaryu1992
 
Climate Action.pptx action plan for climate
justfortalabat
 
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
OPPOTUS - Malaysias on Malaysia 1Q2025.pdf
Oppotus
 
AI Presentation Tool Pitch Deck Presentation.pptx
ShyamPanthavoor1
 
The _Operations_on_Functions_Addition subtruction Multiplication and Division...
mdregaspi24
 
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
ER_Model_Relationship_in_DBMS_Presentation.pptx
dharaadhvaryu1992
 
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
apidays Helsinki & North 2025 - REST in Peace? Hunting the Dominant Design fo...
apidays
 
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
Web Scraping with Google Gemini 2.0 .pdf
Tamanna
 
WEF_Future_of_Global_Fintech_Second_Edition_2025.pdf
AproximacionAlFuturo
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
apidays Helsinki & North 2025 - Vero APIs - Experiences of API development in...
apidays
 
Building Production-Ready AI Agents with LangGraph.pdf
Tamanna
 
Context Engineering for AI Agents, approaches, memories.pdf
Tamanna
 

Tech Talk - Overview of Dash framework for building dashboards

  • 1. Dash Appsilon tech talks | Damian | 04/04/2018 Overview of Dash framework for building dashboards
  • 2. What is Dash? ● Dash is a productive Python framework for building web applications. ● Created and maintained by Plotly. https://plot.ly/products/dash/. ● Written on top of Flask, Plotly.js, and React.js. ● Dashboard is implemented in pure Python. ● Dash is an open source library, released under the permissive MIT license.
  • 3. What you get with Dash ● Frontend generated in Python ● Reactive computations abstraction ● Component class for every HTML tag as well as keyword arguments for all of the HTML arguments implemented in dash_html_components package ● Interactive html elements implemented in dash-core-components ● Plotly python API implemented in dash-core-components available through Graph class
  • 5. What you see in the code ● The layout is composed of a tree of "components" like html.Div and dcc.Graph. ● The dash_html_components library has a component for every HTML tag. The html.H1(children='Hello Dash') component generates a <h1>Hello Dash</h1> HTML element in your application. ● Not all components are pure HTML. The dash_core_components describe higher-level components that are interactive and are generated with JavaScript, HTML, and CSS through the React.js library. ● Each component is described entirely through keyword attributes. Dash is declarative: you will primarily describe your application through these attributes. ● The children property is special. By convention, it's always the first attribute which means that you can omit it: html.H1(children='Hello Dash') is the same as html.H1('Hello Dash'). Also, it can contain a string, a number, a single component, or a list of components. ● Attribute 'class' is replaced with 'className'. ● Style attribute can be a python dictionary. ● Attributes cannot have hyphen in name. If you need to write something like 'margin-left', you have to write 'marginLeft' instead. ● Attribute values must be serializable to JSON.
  • 6. Interactivity ● The "inputs" and "outputs" of our application interface are described declaratively through the app.callback decorator. ● The inputs and outputs of our application are simply the properties of a particular component. ● Any "Output" can have multiple "Input" components. ○ @app.callback(Output('indicator-graphic', 'figure'), [Input('xaxis-column', 'value'), Input('yaxis-column', 'value'), Input('year--slider', 'value')]) def update_graph(xaxis_value, yaxis_value, year_slider_value): … ● Each Dash callback function can only update a single Output property. ○ To update multiple Outputs, you have to write multiple functions. ● "State" allows you to pass along extra values without firing the callbacks. ○ @app.callback(Output('indicator-graphic', 'figure'), [Input('xaxis-column', 'value'), Input('yaxis-column', 'value')], [State('year--slider', 'value')]) def update_graph(xaxis_value, yaxis_value, year_slider_value): … ● There are no intermediate values in the reactive graph. ○ You have to add hidden div with intermediate data (as suggested by plotly) ○ Or you have to use redis to store intermediate values (as suggested by plotly)
  • 7. How does this work? ● Declare app layout. It will generate react code that will be run in the browser. ● Each element has attributes that describe its state. ○ You can change them which makes the app re-render itself. ○ You can listen on any changes to those attributes and run callbacks. ● Frontend sends HTTP request every time an input is changed. ● Backend recalculates the graph of dependencies and sends back the list of changes to frontend.
  • 8. One more look into the code https://github.com/DamianRodziewicz/dash_example app.py
  • 9. Dash core components ● Dropdown ● Slider ● RangeSlider ● Input ● TextArea ● Checkboxes ● RadioItems ● Button ● DatePickerSingle ● DatePickerRange ● Markdown ● Upload component ● Tabs ● Graph - component shares the same syntax as the open-source plotly.py library. See https://plot.ly/python/ for reference ● Interactive Table - under development in https://github.com/plotly/dash-table-experiments repository
  • 10. Dash custom components - Dash semantic ● You can implement your own components in Dash. For more information on how to do that visit https://dash.plot.ly/plugins ● We have started implementing our own components and helpers in https://github.com/Appsilon/dash-semantic ○ Leaflet map ○ Timeline (react horizontal timeline port) ○ Mixpanel hook (to allow using Mixpanel with frontend plugin that identifies user by cookie) ○ IncludeScript (includes and runs an external script on demand - useful if app runs in local mode) ● We’ll cover this library (and instructions on using it in your project) in separate tech talk.
  • 12. Single threaded Dash ● Graph recalculation is blocking and is single threaded ● However we can extract the flask server that is generated and use gunicorn to make the computations concurrent ● http://gunicorn.org/ - Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model. The Gunicorn server is broadly compatible with various web frameworks, simply implemented, light on server resources, and fairly speedy. ● Seems to still have a limit on concurrent users.
  • 14. Dash limitations ● We don’t know how it scales for many concurrent users ● At some point you will need more sophisticated components than Dash provides by default ○ You’ll have to write your own components in React.js ○ Or you’ll have to port already existing components from React.js to Dash ● You’ll quickly find out that some quick wins are still under development (Mapbox raster example) ● There are no intermediate values in the reactive graph. ○ You have to add hidden div with intermediate data (as suggested by plotly) ● You have to write separate function for every Output which forces you to restructure the code ● There are some issues we may not be able to resolve without getting to know the way Dash works by heart ● There may be still some issues with Dash that we don’t know about - we have to add a margin to our work