Dash.jl
Version 1.5.0

建立在plotly.js,react和http.jl之上,破折号将现代的UI元素(如下拉列表,滑块和图形)直接与您的分析朱莉娅代码直接相关。
刚开始?查看朱莉娅用户指南的破折号!如果您在那里找不到文档,请查看非官方的贡献示例或查看Python中的演示应用程序的源代码,然后参考Julia Syntax样式。
可以与Python和R组件同时生成Julia组件。有兴趣参与该项目吗?赞助是加速这样的开源项目进度的好方法。请随时与我们联系!
要安装最近发布的版本:
pkg > add Dash改用最新(稳定)开发版本:
pkg > add Dash # dev using Dash
app = dash (external_stylesheets = [ " https://codepen.io/chriddyp/pen/bWLwgP.css " ])
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)然后在浏览器中访问http://127.0.0.1:8050 ,以查看DASH应用程序!
using Dash
app = dash (external_stylesheets = [ " https://codepen.io/chriddyp/pen/bWLwgP.css " ])
app . layout = html_div () do
dcc_input (id = " my-id " , value = " initial value " , type = " text " ),
html_div (id = " my-div " )
end
callback! (app, Output ( " my-div " , " children " ), Input ( " my-id " , " value " )) do input_value
" You've entered $(input_value) "
end
run_server (app)callback!功能。Input , State对象或媒介可以Output ,输出和输入(及状态,请参见下文)。(inputs..., states...) ,并提供一个返回值,其数字元素与要更新的Output数量相同。 using Dash
app = dash (external_stylesheets = [ " https://codepen.io/chriddyp/pen/bWLwgP.css " ])
app . layout = html_div () do
dcc_input (id = " my-id " , value = " initial value " , type = " text " ),
html_div (id = " my-div " ),
html_div (id = " my-div2 " )
end
callback! (app,
Output ( " my-div " , " children " ),
Output ( " my-div2 " , " children " ),
Input ( " my-id " , " value " ),
State ( " my-id " , " type " )) do input_value, state_value
return ( " You've entered $(input_value) in input with type $(state_value) " ,
" You've entered $(input_value) " )
end
run_server (app) import dash
dash . html . Div
dash . dcc . Graph
dash . dash_table . DataTable using Dash
html_div
dcc_graph
dash_datatable就像在Python中一样,声明组件的函数具有关键字参数,与Python相同。 html_div(id = "my-id", children = "Simple text") 。
对于宣布children组件,还有两个额外的签名:
(children; kwargs..)和(children_maker::Function; kwargs...)因此,可以为简单元素编写html_div("Simple text", id = "my-id") ,或者使用do语法选择复杂元素的缩写语法:
html_div (id = " outer-div " ) do
html_h1 ( " Welcome " ),
html_div (id = " inner-div " ) do
#= inner content =#
end
end app = dash . Dash ( external_stylesheets = [ "https://codepen.io/chriddyp/pen/bWLwgP.css" ])
app . layout = html . Div ( children = [....])app = dash (external_stylesheets = [ " https://codepen.io/chriddyp/pen/bWLwgP.css " ])
app . layout = html_div () do
#= inner content =#
end @ app . callback ( Output ( 'output' , 'children' ),
Input ( 'submit-button' , 'n_clicks' )],
State ( 'state-1' , 'value' ),
State ( 'state-2' , 'value' ))
def update_output ( n_clicks , state1 , state2 ):
# logic callback! (app,
Output ( " output " , " children " ),
Input ( " submit-button " , " n_clicks " )],
State ( " state-1 " , " value " ),
State ( " state-2 " , " value " )) do n_clicks, state1, state2
# logic
end破折号应用程序在JSON中运行该应用程序(又称后端)的浏览器(又称前端)之间传输数据。 Dash.jl使用JSON3.JL进行JSON序列化/避难所化。
请注意json3.jl转换
Vector S和Tuple组到JSON阵列Dict s and NamedTuple为json对象