You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The `DashApp` struct represents a dashboard application.
59
-
* To make `DashApp` struct use `dash(layout_maker::Function, name::String; external_stylesheets::Vector{String} = Vector{String}(), url_base_pathname="/", assets_folder::String = "assets")`` where `layout_maker` is a function with signature ()::Component
59
+
* To make `DashApp` struct use `dash(layout_maker::Function, name::String; external_stylesheets::Vector{String} = Vector{String}(), url_base_pathname="/", assets_folder::String = "assets")` where `layout_maker` is a function with signature ()::Component
60
60
* Unlike the Python version where each Dash component is represented as a separate class, all components in Dash.jl are represented by struct `Component`.
61
61
* You can create `Component` specific for concrete Dash component by the set of functions in the form ``lowercase(<component package>)_lowercase(<component name>)``. For example, in Python html `<div>` element is represented as `HTML.Div` in Dashboards it is created using function `html_div`
62
62
* The list of all supported components is available in docstring for Dashboards module.
63
63
* All functions for a component creation have the signature `(;kwargs...)::Component`. List of key arguments specific for the concrete component is available in the docstring for each function.
64
64
* Functions for creation components which have `children` property have two additional methods ``(children::Any; kwargs...)::Component`` and ``(children_maker::Function; kwargs..)::Component``. `children` must by string or number or single component or collection of components.
65
65
*``make_handler(app::Dash; debug::Bool = false)`` makes a handler function for using in HTTP package.
66
66
67
-
68
67
__Once you have run the code to create the Dashboard, go to `http://127.0.0.1:8080` in your browser to view the Dashboard!__
dcc_input(id = "my-id", value="initial value", type = "text"),
81
-
html_div(id = "my-div")
81
+
html_div(id = "my-div")
82
82
end
83
83
84
84
julia> callback!(app, Output("my-div", "children"), Input("my-id", "value")) do input_value
@@ -87,22 +87,24 @@ end
87
87
88
88
julia> run_server(app, "0.0.0.0", 8080)
89
89
```
90
+
90
91
* You can make your dashboard interactive by register callbacks for changes in frontend with function ``callback!(func::Function, app::Dash, output, input, state)``
91
92
* Inputs and outputs (and states, see below) of callback can be `Input`, `Output`, `State` objects or vectors of this objects
92
93
* Callback function must have the signature(inputs..., states...), and provide a return value comparable (in terms of number of elements) to the outputs being updated.
Be careful - in Dash.jl states come first in an arguments list.
172
182
173
183
### JSON:
174
-
I use JSON2.jl for JSON serialization/deserialization, so in callbacks all JSON objects are `NamedTuples` rather than dictionaries. Within component properties you can use both `Dict` and `NamedTuple` for JSON objects.
184
+
185
+
I use JSON2.jl for JSON serialization/deserialization, so in callbacks all JSON objects are `NamedTuples` rather than dictionaries. Within component properties you can use both `Dict` and `NamedTuple` for JSON objects.
175
186
176
187
Note when declaring elements with a single properly that `layout = (title = "Test graph")` is not interpreted as a `NamedTuple` by Julia - you'll need to add a comma when declaring the layout, e.g. `layout = (title = "Test graph",)`
Copy file name to clipboardExpand all lines: docs/src/index.md
+17-5
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,6 @@ Julia backend for [Plotly Dash](https://github.com/plotly/dash)
8
8
*[dash-bootstrap-components](https://github.com/facultyai/dash-bootstrap-components) added with prefix dbc. Examples of use will be soon
9
9
* pass_changed_props argument added to [`callback!`](@ref) function. For details see docs of [`callback!`](@ref)
10
10
11
-
12
11
## Version 0.2.5 released
13
12
14
13
* Now you can use `PlotlyBase.Plot` to work with the `figure` property of the `dcc_graph` component. Examples are: [Plot usage in layout](https://github.com/waralex/DashboardsExamples/blob/master/dash_tutorial/2_dash_layout_4.jl), [Plot usage in callback](https://github.com/waralex/DashboardsExamples/blob/master/dash_tutorial/3_basic_dash_callbacks_2.jl)
* The `Dash` struct represent dashboard application.
56
56
* The constructor for `Dash` struct is ``Dash(layout_maker::Function, name::String; external_stylesheets::Vector{String} = Vector{String}(), url_base_pathname="/", assets_folder::String = "assets")`` where `layout_maker` is a function with signature ()::Component
57
57
* Unlike the python version where each Dash component is represented as a separate class, all components in Dashboard are represented by struct `Component`.
* Functions for creation components which have `children` property have two additional methods ``(children::Any; kwargs...)::Component`` and ``(children_maker::Function; kwargs..)::Component``. `children` must by string or number or single component or collection of components
62
62
*``make_handler(app::Dash; debug::Bool = false)`` makes handler function for using in HTTP package
63
63
64
-
65
64
__Once you have run the code to create the Dashboard, go to `http://127.0.0.1:8080` in your browser to view the Dashboard!__
66
65
67
66
### Basic Callback
67
+
68
68
```jldoctest
69
69
julia> import HTTP
70
70
julia> using Dashboards
71
71
julia> app = Dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]) do
72
72
html_div() do
73
73
dcc_input(id = "my-id", value="initial value", type = "text"),
74
-
html_div(id = "my-div")
74
+
html_div(id = "my-div")
75
75
end
76
76
end
77
77
julia> callback!(app, callid"my-id.value => my-div.children") do input_value
* You can make your dashboard interactive by register callbacks for changes in frontend with function ``callback!(func::Function, app::Dash, id::CallbackId)``
84
85
* Inputs and outputs (and states, see below) of callback are described by struct `CallbackId` which can easily created by string macro `callid""`
85
86
*`callid""` parse string in form ``"[{state1 [,...]}] input1[,...] => output1[,...]"`` where all items is ``"<element id>.<property name>"``
86
87
* Callback function must have the signature(states..., inputs...) and return data for output
87
88
88
89
### States and Multiple Outputs
90
+
89
91
```jldoctest
90
92
julia> import HTTP
91
93
julia> using Dashboards
92
94
julia> app = Dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]) do
93
95
html_div() do
94
96
dcc_input(id = "my-id", value="initial value", type = "text"),
95
97
html_div(id = "my-div"),
96
-
html_div(id = "my-div2")
98
+
html_div(id = "my-div2")
97
99
end
98
100
end
99
101
julia> callback!(app, callid"{my-id.type} my-id.value => my-div.children, my-div2.children") do state_value, input_value
=> output.children""" ) do state1, state2, n_clicks
159
169
.....
160
170
end
161
171
```
172
+
162
173
Be careful - in Dashboards states came first in arguments list
163
174
164
175
### json:
176
+
165
177
I use JSON2 for json serialization/deserialization, so in callbacks all json objects are NamedTuples not Dicts. In component props you can use both Dicts and NamedTuples for json objects. But be careful with single property objects: `layout = (title = "Test graph")` is not interpreted as NamedTuple by Julia - you need add comma at the end `layout = (title = "Test graph",)`
0 commit comments