Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Dash Tutorial

Dash Tutorial

Dash is an open-source Python-based framework for quickly building data-driven web applications.

Dash's core advantage lies in its ease of use and flexibility, allowing developers without frontend experience to get started easily.

Dash allows users to create interactive data visualization applications through simple Python code, without mastering complex frontend technologies (such as JavaScript, HTML, CSS).


Who should read this tutorial?

Dash is a powerful tool for developers who want to quickly build data-driven web applications.

Dash is especially suitable for data scientists, analysts, and engineers, who can create a powerful web application with a few lines of code to display data analysis results, machine learning model predictions, or other data-driven features.

Dash's core goal is to let users focus on data and logic rather than frontend development.

Through Dash, you can create a powerful web application with a few lines of code to display data analysis results, machine learning model predictions, or other data-driven features.

Dash can transform complex data analysis and visualization tasks into interactive web applications, making it more effective to present and share work results.


What you need to know before studying this tutorial

This tutorial is suitable for developers with a Python foundation. If you are not familiar with Python, you can refer to Python 3.x Basic Tutorial.


A Simple Dash Program

The following is a basic Dash example:

Example

Import Dash-related libraries

from

dash

import

Dash

,

dcc

,

html

,

Input

,

Output

Create a Dash application instance

app

=

Dash

(

name

)

Define the application's layout

app.

layout

=

html.

Div

(

[

   

Create a text input box

    dcc.

Input

(

       

id

=

'input'

,

       

The input box's ID, used for callbacks

        value

=

'Initial Value'

,

   

The input box's default value

       

type

=

'text'

       

The input box type is text

   

)

,

   

Create a Div for displaying output

    html.

Div

(

id

=

'output'

)

]

)

Define the Callback Function

@

app.

callback

(

    Output

(

'output'

,

'children'

)

,

 

Output to the Div's children property

    Input

(

'input'

,

'value'

)

       

Listen to the input box's value property

)

def

update_output_div

(

input_value

)

:

   

Return the formatted string

   

return

f

'You entered: {input_value}'

Run the application

if

name

==

'main'

:

    app.

run

(

debug

=

True

)

 

Dash 3.x uses app.run()

This simple application contains an input box and a display area. When the user enters content in the input box, the display area updates in real time to show what the user entered.


Related links

Official Address:https://plotly.com/dash/

GitHub open source address:https://github.com/plotly/dash

Dash Official Documentation:https://dash.plotly.com/