plotly / Dash.jl

Dash for Julia - A Julia interface to the Dash ecosystem for creating analytic web applications in Julia. No JavaScript required.
MIT License
489 stars 40 forks source link

Advanced checklist #209

Open renatobellotti opened 1 year ago

renatobellotti commented 1 year ago

Hello,

The following snippet works in Python:

from dash import Dash, dcc, html

entries = [
    {
        "label": [
            html.Div(style={
                "width" : "2cm",
                "height": "1em",
                "background-color": "red",
            }),
            "my test",
        ],
        "value": "my test",
    },
]

structure_checkboxes = dcc.Checklist(options=entries, style={
    "width": "100%",
})

app = Dash()

structure_list = html.Div(className="col-6", children=[structure_checkboxes])
gui = html.Div(children=[structure_list])

app.layout = html.Div(gui)

if __name__ == '__main__':
    app.run_server(debug=True)

I have tried this simplified code, but even the simplified example gives me the following error message:

Invalid argument `options[0].label` passed into Checklist.
using Dash

entries = [
    Dict(
        "label" => ["my test"],
        "value" => "my test",
    ),
]

structure_checkboxes = dcc_checklist(options=entries)

app = dash()

structure_list = html_div(
    className="col-2",
    children=[structure_checkboxes],
)

gui = html_div(children=[structure_list])

 app.layout = html_div() do
    gui
end

run_server(app, "0.0.0.0", 8080, debug=true)

How would I translate this to Julia? Unfortunately, the corresponding section in the documentation is not translated to Julia.

etpinard commented 1 year ago

Thanks for posting!

Updating the JS deps (as in https://github.com/plotly/Dash.jl/pull/208) will get us most of the way there.

Using the https://github.com/plotly/Dash.jl/pull/208 branch, I got your Julia snippet to run

image

We can translate the original python snippet into:

using Dash

entries = [Dict("label" => [html_div(; style=Dict("width" => "2cm",
                                                  "height" => "1em",
                                                  "background-color" => "red")),
                            "my test"],
                "value" => "my test")]

structure_checkboxes = dcc_checklist(options=entries, style=Dict("width" =>"100%"))

app = dash()

structure_list = html_div( className="col-6", children=[structure_checkboxes])
gui = html_div(children=[structure_list])

app.layout = html_div(gui)

run_server(app, "0.0.0.0", 8080, debug=true)

but unfortunately even using the branch from https://github.com/plotly/Dash.jl/pull/208, I'm getting

image