I’m trying to record a statemap to include an interactive streamplot in a web page. Is there a way to pull out the actual Float64 value from the observable?
Thanks in advance.
using WGLMakie, JSServe
WGLMakie.activate!()
open("index.html", "w") do io
println(io, """
<html>
<head>
</head>
<body>
""")
show(io, MIME"text/html"(), Page(exportable=true, offline=true))
show(io, MIME"text/html"(),App() do session::Session
param_slider = Slider(0.1:0.1:1.0)
fig = Figure(resolution = (700, 700), fontsize = 18, font = "sans")
ax = Axis(fig[1,1],backgroundcolor = :black)
p = vcat([param_slider.value,1.0]',[1.1,1.0]')
function f(x,y)
u = [x,y]
du = (u .*(1 .-u) .*(p[:,1] .-p[:,2])) ./ ((u .*p[:,1]) .+ ((1 .-u) .*p[:,2]))
return Point(du...)
end
stplt = streamplot!(ax, f, 0..1, 0..1, colormap = :plasma,
gridsize= (20,20), arrow_size = 10)
slider = DOM.div("z-index: ", param_slider, param_slider.value)
return JSServe.record_states(session, DOM.div(slider, fig))
end)
println(io, """
</body>
</html>
""")
end
Produces
ERROR: MethodError: no method matching adjoint(::Observable{Float64})
Closest candidates are:
adjoint(::StrideArraysCore.PtrArray{S, D, T, 1, C, B, R, X, O}) where {S, D, T, C, B, R, X, O} at C:\Users\arn203\.julia\packages\StrideArraysCore\8rPwH\src\adjoints.jl:45
adjoint(::LinearAlgebra.Transpose{var"#s155", var"#s154"} where {var"#s155"<:Real, var"#s154"<:Union{StaticArrays.StaticVector{N, T} where {N, T}, StaticArrays.StaticMatrix{N, M, T} where {N, M, T}}}) at C:\Users\arn203\.julia\packages\StaticArrays\0yhGP\src\linalg.jl:73
adjoint(::LinearAlgebra.Transpose{var"#s832", S} where {var"#s832"<:Real, S}) at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\adjtrans.jl:166
...
Stacktrace:
[1] getindex
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\adjtrans.jl:202 [inlined]
[2] iterate(A::LinearAlgebra.Adjoint{Any, Vector{Any}}, state::Tuple{Base.OneTo{Int64}})
@ Base .\abstractarray.jl:1096
[3] iterate
@ .\abstractarray.jl:1094 [inlined]
[4] _unsafe_setindex!(::IndexLinear, ::Matrix{Any}, ::LinearAlgebra.Adjoint{Any, Vector{Any}}, ::UnitRange{Int64}, ::Base.Slice{Base.OneTo{Int64}})
@ Base .\multidimensional.jl:897
[5] _setindex!
@ .\multidimensional.jl:887 [inlined]
[6] setindex!
@ .\abstractarray.jl:1267 [inlined]
[7] _typed_vcat(#unused#::Type{Any}, A::Tuple{LinearAlgebra.Adjoint{Any, Vector{Any}}, LinearAlgebra.Adjoint{Float64, Vector{Float64}}})
@ Base .\abstractarray.jl:1561
[8] typed_vcat
@ .\abstractarray.jl:1567 [inlined]
[9] vcat
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\SparseArrays\src\sparsevector.jl:1114 [inlined]
[10] (::var"#53#55")(session::Session)
@ Main .\REPL[70]:18
[11] (::JSServe.var"#1#5"{var"#53#55"})(session::Session, request::NamedTuple{(:show,), Tuple{String}}) @ JSServe C:\Users\arn203\.julia\packages\JSServe\E7QrV\src\types.jl:15
[12] #invokelatest#2
@ .\essentials.jl:708 [inlined]
[13] invokelatest
@ .\essentials.jl:706 [inlined]
[14] show_in_page(page::Page, app::App)
@ JSServe C:\Users\arn203\.julia\packages\JSServe\E7QrV\src\display.jl:288
[15] show(io::IOStream, m::MIME{Symbol("text/html")}, app::App)
@ JSServe C:\Users\arn203\.julia\packages\JSServe\E7QrV\src\display.jl:377
[16] (::var"#52#54")(io::IOStream)
@ Main .\REPL[70]:10
[17] open(::var"#52#54", ::String, ::Vararg{String, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base .\io.jl:330
[18] open(::Function, ::String, ::String)
@ Base .\io.jl:328
[19] top-level scope
@ REPL[70]:1