Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Plots.jl #128

Closed
JinraeKim opened this issue Sep 18, 2021 · 9 comments
Closed

Support Plots.jl #128

JinraeKim opened this issue Sep 18, 2021 · 9 comments

Comments

@JinraeKim
Copy link

JinraeKim commented Sep 18, 2021

Hi, Dash.jl developers :)

I’m looking forward to how to use Dash.jl conveniently.
For interactive plotting, I found that PlotlyJS.Plot object should be returned in a callback of Dash.jl
like this examples.
And I’m familiar with Plots.jl so I’d like to keep using the APIs of Plots.jl.
So is there any way of extracting PlotlyJS.Plot object from Plots.Plot object?

(The original question can be found in Julia Discourse).

@JinraeKim
Copy link
Author

I found a remedy but there is a bit annoying rendered figure problem.
Please see this issue for more details.

@JinraeKim JinraeKim reopened this Sep 18, 2021
@JinraeKim
Copy link
Author

In short, it would be very useful if callbacks receive a plt::Plots.Plot object and produce the backend object plt::PlotlyJS.Plot internally.

@terasakisatoshi
Copy link

Examples #50 help you?

@JinraeKim
Copy link
Author

JinraeKim commented Sep 19, 2021

Examples #50 help you?

Yes :) And I found a similar solution here.

@terasakisatoshi
Copy link

Examples #50 help you?

Yes :) And I found a similar solution here.

great. good to know

@waralex
Copy link
Collaborator

waralex commented Oct 24, 2021

Hi all!
Can I close this issue?

@waralex waralex closed this as completed Oct 24, 2021
@diegozea
Copy link

diegozea commented Feb 2, 2022

Hi @waralex ! I have seen that this is not working anymore in the latest version of Dash. I have just commented on that in this issue: JuliaPlots/Plots.jl#3827 (comment)

@waralex
Copy link
Collaborator

waralex commented Feb 2, 2022

Hi @diegozea !
Sorry, I really haven 't had time to work on Dash at all in the last 3 months due to the workload at my main job and some accumulated household chores . The problem you wrote about is not new, you can read about it and the workaround here #153.

P.S. I will definitely return to active Dash development, but a little later.

@diegozea
Copy link

diegozea commented Feb 3, 2022

Hi @waralex ! No problem.

Yes, thanks; the example code there looks more related to that issue.

However, when I am using the code here https://github.com/PacktPublishing/Interactive-Visualization-with-Julia/blob/main/Chapter03/dash_example/dash_example.jl I am finding an error that looks more related to #160 when using Plots, Plotly & Dash.

Cheers

julia> run_server(app)
[ Info: Listening on: 127.0.0.1:8050
┌ Error: error handling request
│   exception =NaN not allowed to be written in JSON spec
│    Stacktrace:
│      [1] error(s::String)
│        @ Base ./error.jl:33
│      [2] #write#83
│        @ ~/.julia/packages/JSON3/tqMvg/src/write.jl:225 [inlined]
│      [3] write(::StructTypes.NumberType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Float64)
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:225
│      [4] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Dict{Any, Any}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:155
│      [5] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Dict{Any, Any})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:146
│      [6] write(::StructTypes.ArrayType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Vector{Dict{Any, Any}}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:169
│      [7] write(::StructTypes.ArrayType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Vector{Dict{Any, Any}})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:165
│      [8] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Dict{Symbol, Any}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:155
│      [9] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Dict{Symbol, Any})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:146
│     [10] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Dict{Symbol, Any}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:155
│     [11] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Dict{Symbol, Any})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:146
│     [12] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Dict{String, Any}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:155
│     [13] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Dict{String, Any})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:146
│     [14] write(::StructTypes.DictType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::Dict{Symbol, Any}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:155
│     [15] write
│        @ ~/.julia/packages/JSON3/tqMvg/src/write.jl:146 [inlined]
│     [16] write(obj::Dict{Symbol, Any}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:39
│     [17] write(obj::Dict{Symbol, Any})
│        @ JSON3 ~/.julia/packages/JSON3/tqMvg/src/write.jl:37
│     [18] process_callback(request::HTTP.Messages.Request, state::Dash.HandlerState)
│        @ Dash ~/.julia/packages/Dash/soFjZ/src/handler/processors/callback.jl:78
│     [19] try_handle
│        @ ~/.julia/packages/Dash/soFjZ/src/HttpHelpers/router.jl:51 [inlined]
│     [20] try_handle(route::Dash.HttpHelpers.Route{Dash.HttpHelpers.RouteHandler{Dash.HttpHelpers.StaticRoute, typeof(Dash.process_callback)}}, path::SubString{String}, request::HTTP.Messages.Request, args::Dash.HandlerState)
│        @ Dash.HttpHelpers ~/.julia/packages/Dash/soFjZ/src/HttpHelpers/router.jl:97
│     [21] _handle
│        @ ~/.julia/packages/Dash/soFjZ/src/HttpHelpers/router.jl:101 [inlined]
│     [22] _handle (repeats 6 times)
│        @ ~/.julia/packages/Dash/soFjZ/src/HttpHelpers/router.jl:102 [inlined]
│     [23] 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.StaticRoute, typeof(Dash.process_default_favicon)}}, 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 ~/.julia/packages/Dash/soFjZ/src/HttpHelpers/router.jl:112
│     [24] handle(router::Dash.HttpHelpers.Router, request::HTTP.Messages.Request, args::Dash.HandlerState)
│        @ Dash.HttpHelpers ~/.julia/packages/Dash/soFjZ/src/HttpHelpers/router.jl:129
│     [25] (::Dash.HttpHelpers.var"#1#2"{Dash.HttpHelpers.Router, Dash.HandlerState})(::HTTP.Messages.Request)
│        @ Dash.HttpHelpers ~/.julia/packages/Dash/soFjZ/src/HttpHelpers/handlers.jl:4
│     [26] handle
│        @ ~/.julia/packages/HTTP/aTjcj/src/Handlers.jl:254 [inlined]
│     [27] (::Dash.HttpHelpers.var"#7#8"{Dash.var"#68#70"{Dash.DashApp}, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#1#2"{Dash.HttpHelpers.Router, Dash.HandlerState}}})(::HTTP.Messages.Request)
│        @ Dash.HttpHelpers ~/.julia/packages/Dash/soFjZ/src/HttpHelpers/handlers.jl:48
│     [28] handle
│        @ ~/.julia/packages/HTTP/aTjcj/src/Handlers.jl:254 [inlined]
│     [29] (::Dash.HttpHelpers.var"#4#5"{Vector{String}, Int64, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#7#8"{Dash.var"#68#70"{Dash.DashApp}, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#1#2"{Dash.HttpHelpers.Router, Dash.HandlerState}}}}})(::HTTP.Messages.Request)
│        @ Dash.HttpHelpers ~/.julia/packages/Dash/soFjZ/src/HttpHelpers/handlers.jl:27
│     [30] handle
│        @ ~/.julia/packages/HTTP/aTjcj/src/Handlers.jl:254 [inlined]
│     [31] handle(::HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#4#5"{Vector{String}, Int64, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#7#8"{Dash.var"#68#70"{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 ~/.julia/packages/HTTP/aTjcj/src/Handlers.jl:277
│     [32] #4
│        @ ~/.julia/packages/HTTP/aTjcj/src/Handlers.jl:351 [inlined]
│     [33] macro expansion
│        @ ~/.julia/packages/HTTP/aTjcj/src/Servers.jl:415 [inlined]
│     [34] (::HTTP.Servers.var"#13#14"{HTTP.Handlers.var"#4#5"{HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#4#5"{Vector{String}, Int64, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#7#8"{Dash.var"#68#70"{Dash.DashApp}, HTTP.Handlers.RequestHandlerFunction{Dash.HttpHelpers.var"#1#2"{Dash.HttpHelpers.Router, Dash.HandlerState}}}}}}}, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, HTTP.Servers.Server{Nothing, Sockets.TCPServer}, HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})()
│        @ HTTP.Servers ./task.jl:411
└ @ Dash ~/.julia/packages/Dash/soFjZ/src/handler/make_handler.jl:61
  [1b08a953] Dash v1.1.1
  [1b08a953] DashCoreComponents v2.0.0
  [1b08a953] DashHtmlComponents v2.0.0
  [91a5bcdd] Plots v1.25.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants