#julia #plotly-dash
Вопрос:
Адаптация второго примера из https://dash-julia.plotly.com/getting-started как показано ниже, я получаю ошибку StackOverflow. Является ли пример устаревшим или что-то не так с моим кодом или установкой?
Обратите внимание, что добавление рисунка в виде кортежа данных работает (закомментировано в примере кода), но использование структуры PlotlyJS.SyncPlot, возвращенной из plot, не работает. Я также могу отобразить рисунок в VSCode без каких-либо проблем.
using DataFrames, PlotlyJS
using Dash, DashHtmlComponents, DashCoreComponents
using Random
ydata = [rand() for i in 1:4]
app = dash()
app.layout = html_div() do
dcc_graph(
id="example-graph",
# figure = (data = [(y = ydata,)],) # Works
figure = plot(ydata) # Does not work
)
end
run_server(app, "0.0.0.0", debug=true)
Вот трассировка стека, как было запрошено:
┌ Error: error handling request
│ exception =
│ StackOverflowError:
│ Stacktrace:
│ [1] (::JSON2.var"#3#4"{DataType})(x::Vector{Any})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:11
│ [2] macro expansion
│ @ C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:75 [inlined]
│ [3] write(io::IOBuffer, obj::Observables.Observable{Dict{Any, Any}}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:94
│ [4] write
│ @ C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:94 [inlined]
│ [5] write(io::IOBuffer, obj::Tuple{Observables.Observable{Dict{Any, Any}}, Nothing}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:39
│ [6] write(io::IOBuffer, obj::Tuple{Observables.Observable{Dict{Any, Any}}, Nothing})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:35
│ [7] write(io::IOBuffer, obj::Dict{String, Tuple{Observables.AbstractObservable, Union{Nothing, Bool}}}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:24
│ [8] write(io::IOBuffer, obj::Dict{String, Tuple{Observables.AbstractObservable, Union{Nothing, Bool}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:17
│ [9] macro expansion
│ @ C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:75 [inlined]
│ [10] write(io::IOBuffer, obj::WebIO.Scope; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:94
│ [11] write(io::IOBuffer, obj::WebIO.Scope)
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:94
│ --- the last 3 lines are repeated 1 more time ---
│ [15] write(io::IOBuffer, obj::Vector{Any}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:39
│ [16] write(io::IOBuffer, obj::Vector{Any})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:35
│ --- the last 15 lines are repeated 2208 more times ---
│ [33137] macro expansion
│ @ C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:75 [inlined]
│ [33138] write(io::IOBuffer, obj::Observables.Observable{Dict{Any, Any}}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:94
│ [33139] write
│ @ C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:94 [inlined]
│ [33140] write(io::IOBuffer, obj::Tuple{Observables.Observable{Dict{Any, Any}}, Nothing}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:39
│ [33141] write(io::IOBuffer, obj::Tuple{Observables.Observable{Dict{Any, Any}}, Nothing})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:35
│ [33142] write(io::IOBuffer, obj::Dict{String, Tuple{Observables.AbstractObservable, Union{Nothing, Bool}}}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:24
│ [33143] write(io::IOBuffer, obj::Dict{String, Tuple{Observables.AbstractObservable, Union{Nothing, Bool}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:17
│ [33144] macro expansion
│ @ C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:75 [inlined]
│ [33145] write(io::IOBuffer, obj::WebIO.Scope; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:94
│ [33146] write(io::IOBuffer, obj::WebIO.Scope)
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:94
│ --- the last 3 lines are repeated 1 more time ---
│ [33150] write(io::IOBuffer, obj::Dict{Symbol, Any}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:24
│ [33151] write(io::IOBuffer, obj::Dict{Symbol, Any})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:17
│ [33152] macro expansion
│ @ C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:75 [inlined]
│ [33153] macro expansion
│ @ C:UsersMartin.juliapackagesJSON2ld4KqsrcJSON2.jl:0 [inlined]
│ [33154] write(io::IOBuffer, obj::Component; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ DashBase C:UsersMartin.juliapackagesJSON2ld4KqsrcJSON2.jl:127
│ [33155] write(io::IOBuffer, obj::Component)
│ @ DashBase C:UsersMartin.juliapackagesJSON2ld4KqsrcJSON2.jl:127
│ [33156] write(io::IOBuffer, obj::Dict{Symbol, Any}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:24
│ [33157] write(io::IOBuffer, obj::Dict{Symbol, Any})
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:17
│ [33158] macro expansion
│ @ C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:75 [inlined]
│ [33159] macro expansion
│ @ C:UsersMartin.juliapackagesJSON2ld4KqsrcJSON2.jl:0 [inlined]
│ [33160] write(io::IOBuffer, obj::Component; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ DashBase C:UsersMartin.juliapackagesJSON2ld4KqsrcJSON2.jl:127
│ [33161] write
│ @ C:UsersMartin.juliapackagesJSON2ld4KqsrcJSON2.jl:127 [inlined]
│ [33162] #write#5
│ @ C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:14 [inlined]
│ [33163] write(obj::Component)
│ @ JSON2 C:UsersMartin.juliapackagesJSON2ld4Kqsrcwrite.jl:14
│ [33164] process_layout(request::HTTP.Messages.Request, state::Dash.HandlerState)
│ @ Dash C:UsersMartin.juliapackagesDash66VCIsrchandlerprocessorslayout.jl:4
│ [33165] try_handle
│ @ C:UsersMartin.juliapackagesDash66VCIsrcHttpHelpersrouter.jl:51 [inlined]
│ [33166] try_handle(route::Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.StaticRoute, typeof(Dash.process_layout)}}, path::SubString{String}, request::HTTP.Messages.Request, args::Dash.HandlerState)
│ @ Dash.HttpHelpers C:UsersMartin.juliapackagesDash66VCIsrcHttpHelpersrouter.jl:97
│ [33167] _handle
│ @ C:UsersMartin.juliapackagesDash66VCIsrcHttpHelpersrouter.jl:101 [inlined]
│ [33168] handle(route_tuple::Tuple{Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.StaticRoute, typeof(Dash.process_layout)}}, Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.StaticRoute, typeof(Dash.process_dependencies)}}, Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.StaticRoute, typeof(Dash.process_reload_hash)}}, Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.DynamicRoute{Tuple{Tuple{Int64, String}}, NamedTuple{(:path, :namespace), Tuple{Int64, Int64}}}, typeof(Dash.process_resource)}}, Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.DynamicRoute{Tuple{Tuple{Int64, String}}, NamedTuple{(:file_path,), Tuple{Int64}}}, typeof(Dash.process_assets)}}, Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.StaticRoute, typeof(Dash.process_callback)}}, Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.DynamicRoute{Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Dash.process_index)}}, Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.StaticRoute, typeof(Dash.process_index)}}}, path::SubString{String}, request::HTTP.Messages.Request, args::Dash.HandlerState)
│ @ Dash.HttpHelpers C:UsersMartin.juliapackagesDash66VCIsrcHttpHelpersrouter.jl:112
│ [33169] handle(router::Dash.HttpHelpers.Router, request::HTTP.Messages.Request, args::Dash.HandlerState)
│ @ Dash.HttpHelpers C:UsersMartin.juliapackagesDash66VCIsrcHttpHelpersrouter.jl:129
│ [33170] (::Dash.HttpHelpers.var"#1#2"{Dash.HttpHelpers.Router, Dash.HandlerState})(::HTTP.Messages.Request)
│ @ Dash.HttpHelpers C:UsersMartin.juliapackagesDash66VCIsrcHttpHelpershandlers.jl:4
│ [33171] handle
│ @ C:UsersMartin.juliapackagesHTTP5e2VHsrcHandlers.jl:254 [inlined]
│ [33172] (::Dash.HttpHelpers.var"#7#8"{Dash.var"#71#73"{Dash.DashApp}, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#1#2"{Dash.HttpHelpers.Router, Dash.HandlerState}}})(::HTTP.Messages.Request)
│ @ Dash.HttpHelpers C:UsersMartin.juliapackagesDash66VCIsrcHttpHelpershandlers.jl:48
│ [33173] handle
│ @ C:UsersMartin.juliapackagesHTTP5e2VHsrcHandlers.jl:254 [inlined]
│ [33174] (::Dash.HttpHelpers.var"#4#5"{Vector{String}, Int64, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#7#8"{Dash.var"#71#73"{Dash.DashApp}, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#1#2"{Dash.HttpHelpers.Router, Dash.HandlerState}}}}})(::HTTP.Messages.Request)
│ @ Dash.HttpHelpers C:UsersMartin.juliapackagesDash66VCIsrcHttpHelpershandlers.jl:27
│ [33175] handle
│ @ C:UsersMartin.juliapackagesHTTP5e2VHsrcHandlers.jl:254 [inlined]
│ [33176] handle(::HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#4#5"{Vector{String}, Int64, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#7#8"{Dash.var"#71#73"{Dash.DashApp}, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#1#2"{Dash.HttpHelpers.Router, Dash.HandlerState}}}}}}, ::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
│ @ HTTP.Handlers C:UsersMartin.juliapackagesHTTP5e2VHsrcHandlers.jl:277
│ [33177] #4
│ @ C:UsersMartin.juliapackagesHTTP5e2VHsrcHandlers.jl:346 [inlined]
│ [33178] macro expansion
│ @ C:UsersMartin.juliapackagesHTTP5e2VHsrcServers.jl:413 [inlined]
└ @ Dash C:UsersMartin.juliapackagesDash66VCIsrchandlermake_handler.jl:110
Комментарии:
1. Можете ли вы добавить вывод об ошибке в свой вопрос?
2. Готово, спасибо, что посмотрели.
3. Не знаю, для меня это работает, так что я не могу точно проследить, что идет не так. Я думаю, вы уже проверили это, но в любом случае убедитесь, что ваши посылки обновлены. И может ли быть так, что
plot
функция также была импортирована из какого-то другого пакета, в результате чего нужная функция вообще не вызывается?4. Знание того, что код в порядке, — это большая помощь. Даже после переустановки Julia я, к сожалению, все равно получаю ту же ошибку. Функция построения графика, кажется, работает правильно, и я могу отобразить рисунок в vscode.