Hello everyone,
I am currently trying to set up a dashboard of figures using the following code
using Bonito
using WGLMakie
all_figs = Dict()
function newfig(title)
fig = Figure()
if title in keys(all_figs)
all_figs[title][] = fig
else
all_figs[title] = Observable(fig)
end
fig
end
fig = newfig("rand");
ax = Axis(fig[1,1])
lines!(ax,randn(10))
App() do
content = Any[]
for t in keys(all_figs)
push!(content,DOM.h2(t))
push!(content,all_figs[t])
end
return Col(content...)
end
fig = newfig("rand");
#sleep(0.01) # <--without it, it fails because of timeout in evaljs_value
ax = Axis(fig[1,1])
lines!(ax,randn(10))
Without the small time delay between the creation of the figure and the axis the code fail with the following error:
ERROR: Timed out
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:44
[2] evaljs_value(session::Session{Bonito.SubConnection}, js::Bonito.JSCode; error_on_closed::Bool, timeout::Int64)
@ Bonito ~/.julia/packages/Bonito/9fokY/src/session.jl:348
[3] evaljs_value
@ ~/.julia/packages/Bonito/9fokY/src/session.jl:294 [inlined]
[4] insert_plot!(session::Session{Bonito.SubConnection}, scene::Scene, plot::Plot)
@ WGLMakie ~/.julia/packages/WGLMakie/FbMOf/src/display.jl:469
[5] insert!(screen::WGLMakie.Screen, scene::Scene, plot::Plot)
@ WGLMakie ~/.julia/packages/WGLMakie/FbMOf/src/display.jl:480
[6] push!(scene::Scene, plot::Plot)
@ Makie ~/.julia/packages/Makie/4JW9B/src/scenes.jl:515
[7] plot!(scene::Scene, plot::Poly{Tuple{GeometryBasics.HyperRectangle{2, Int64}}})
@ Makie ~/.julia/packages/Makie/4JW9B/src/interfaces.jl:212
[8] _create_plot!(F::Function, attributes::Dict{…}, scene::Scene, args::Observable{…})
@ Makie ~/.julia/packages/Makie/4JW9B/src/figureplotting.jl:411
[9] poly!(::Scene, ::Vararg{…}; kw::@Kwargs{…})
@ Makie ~/.julia/packages/Makie/4JW9B/src/recipes.jl:521
[10] poly!
@ ~/.julia/packages/Makie/4JW9B/src/recipes.jl:519 [inlined]
[11] initialize_block!(ax::Axis; palette::Nothing)
@ Makie ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks/axis.jl:196
[12] initialize_block!(ax::Axis)
@ Makie ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks/axis.jl:154
[13] _block(T::Type{…}, fig_or_scene::Figure, args::Vector{…}, kwdict::Dict{…}, bbox::Nothing; kwdict_complete::Bool)
@ Makie ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks.jl:405
[14] _block
@ ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks.jl:321 [inlined]
[15] #_block#1568
@ ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks.jl:266 [inlined]
[16] _block(::Type{Axis}, ::Figure)
@ Makie ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks.jl:265
[17] _block(::Type{Axis}, ::GridPosition; kwargs::@Kwargs{})
@ Makie ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks.jl:260
[18] _block
@ ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks.jl:251 [inlined]
[19] #_#1566
@ ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks.jl:242 [inlined]
[20] Axis(args::GridPosition)
@ Makie ~/.julia/packages/Makie/4JW9B/src/makielayout/blocks.jl:241
[21] top-level scope
@ REPL[528]:1
Some type information was truncated. Use `show(err)` to see complete types.
I would like to know if this time delay is necessary or if I am not approaching the problem in the right way.
Thank you in advance !