Hosting and developing a Dash Application

Introduction

In this tutorial, we demonstrate how to deploy a dashboard using Dash.jl, a dashboarding system powered by Plotly.

Getting Started

To start, install Dash.jl with the following command:

using Pkg
Pkg.add("Dash")

Developing with JuliaHub IDE

Here we will start with a simple example:


using Dash
using Sockets

port = 8000

app = dash(requests_pathname_prefix="/proxy/$port/")

app.layout = html_div() do
    html_h1("Hello Dash"),
    html_div("Dash.jl: Julia interface for Dash"),
    dcc_graph(
        id = "example-graph",
        figure = (
            data = [
                (x = [1, 2, 3], y = [4, 1, 2], type = "bar", name = "SF"),
                (x = [1, 2, 3], y = [2, 4, 5], type = "bar", name = "Montréal"),
            ],
            layout = (title = "Dash Data Visualization",)
        )
    )
end

run_server(app, Sockets.localhost, port)

Once you run this script in the JuliaHub IDE, you should see the following dialog on the bottom right side of the screen:

Port Forward Dialog

Once you click on "Open in Browser" you should see the dashboard correctly rendered:

Dash App Preview

Note

The default dash initialization call should be changed from:

app = dash()

to:

port = 8888
app = dash(requests_pathname_prefix="/proxy/$port/")

By default, JuliaHub IDE proxies the requests, so we need to specify this path name to the Dash.jl so it may respond correctly.

Note

The run_server call should be changed from:

run_server(app, 0.0.0.0, port, debug=true)

to:

using Sockets
run_server(app, Sockets.localhost, port, debug=true)

This will allow the server to respond correctly.

Resources and Examples