diff --git a/Project.toml b/Project.toml index 234ef8aa..a30170e5 100644 --- a/Project.toml +++ b/Project.toml @@ -63,6 +63,7 @@ Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" PGFPlotsX = "8314cec4-20b6-5062-9cdb-752b83310925" +PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" @@ -73,4 +74,4 @@ UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92" [targets] -test = ["Distributions", "FileIO", "Gtk", "ImageMagick", "Images", "LibGit2", "OffsetArrays", "PGFPlotsX", "HDF5", "RDatasets", "StableRNGs", "StaticArrays", "StatsPlots", "Test", "TestImages", "UnicodePlots", "VisualRegressionTests"] +test = ["Distributions", "FileIO", "Gtk", "ImageMagick", "Images", "LibGit2", "OffsetArrays", "PGFPlotsX", "PlotlyJS", "HDF5", "RDatasets", "StableRNGs", "StaticArrays", "StatsPlots", "Test", "TestImages", "UnicodePlots", "VisualRegressionTests"] diff --git a/src/backends/plotlyjs.jl b/src/backends/plotlyjs.jl index f6f07e80..a75feb60 100644 --- a/src/backends/plotlyjs.jl +++ b/src/backends/plotlyjs.jl @@ -39,8 +39,7 @@ _show(io::IO, ::MIME"text/html", plt::Plot{PlotlyJSBackend}) = write(io, standal _display(plt::Plot{PlotlyJSBackend}) = display(plotlyjs_syncplot(plt)) function PlotlyJS.WebIO.render(plt::Plot{PlotlyJSBackend}) - plt_html = sprint(show, MIME("text/html"), plt) - return PlotlyJS.WebIO.render(PlotlyJS.WebIO.dom"div"(innerHTML=plt_html)) + return PlotlyJS.WebIO.render(plotlyjs_syncplot(plt)) end function closeall(::PlotlyJSBackend) diff --git a/test/runtests.jl b/test/runtests.jl index b31c1674..4548ee47 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -139,6 +139,15 @@ const IMG_TOL = VERSION < v"1.4" && Sys.iswindows() ? 1e-1 : is_ci() ? 1e-2 : 1e @test isa(display(p), Nothing) == true end + @testset "PlotlyJS" begin + @test plotlyjs() == Plots.PlotlyJSBackend() + @test backend() == Plots.PlotlyJSBackend() + + p = plot(rand(10)) + @test isa(p, Plots.Plot) == true + @test_broken isa(display(p), Nothing) == true + end + end @testset "Axes" begin @@ -156,6 +165,10 @@ end end @testset "NoFail" begin + #ensure backend with tested display + @test unicodeplots() == Plots.UnicodePlotsBackend() + @test backend() == Plots.UnicodePlotsBackend() + @testset "Plot" begin plots = [histogram([1, 0, 0, 0, 0, 0]), plot([missing]),