diff --git a/Project.toml b/Project.toml index eb4cb35b..d4cdc8d1 100644 --- a/Project.toml +++ b/Project.toml @@ -5,7 +5,6 @@ version = "0.18.10" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" -Blink = "ad839575-38b3-5650-b840-f874b8c74a25" DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" JSExpr = "97c1335a-c9c5-57fe-bc5d-ec35cebe8660" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" @@ -19,7 +18,6 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df" WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29" [compat] -Blink = "0.12" JSExpr = "0.5, 1" JSON = "0.20, 0.21" PlotlyBase = "0.8.15" diff --git a/src/PlotlyJS.jl b/src/PlotlyJS.jl index 9d3e514e..80daa1f1 100644 --- a/src/PlotlyJS.jl +++ b/src/PlotlyJS.jl @@ -17,7 +17,6 @@ import PlotlyBase: using WebIO using JSExpr using JSExpr: @var, @new -using Blink using Pkg.Artifacts using Requires @@ -30,8 +29,6 @@ const _js_cdn_path = "https://cdn.plot.ly/plotly-latest.min.js" const _mathjax_cdn_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_SVG" -struct PlotlyJSDisplay <: AbstractDisplay end - # include the rest of the core parts of the package include("display.jl") include("util.jl") @@ -41,29 +38,6 @@ make_subplots(;kwargs...) = plot(Layout(Subplots(;kwargs...))) @doc (@doc Subplots) make_subplots -function docs() - schema_path = joinpath(dirname(dirname(@__FILE__)), "deps", "schema.html") - if !isfile(schema_path) - msg = "schema docs not built. Run `Pkg.build(\"PlotlyJS\")` to generate" - error(msg) - end - w = Blink.Window() - wait(w.content) - Blink.content!(w, "html", open(f -> read(f, String), schema_path), fade=false, async=false) -end - - -@enum RENDERERS BLINK IJULIA BROWSER DOCS - -const DEFAULT_RENDERER = Ref(BLINK) - -function set_default_renderer(s::RENDERERS) - global DEFAULT_RENDERER - DEFAULT_RENDERER[] = s -end - -@inline get_renderer() = DEFAULT_RENDERER[] - list_datasets() = readdir(joinpath(artifact"plotly-artifacts", "datasets")) function check_dataset_exists(name::String) ds = list_datasets() @@ -102,34 +76,6 @@ function __init__() include(joinpath(_pkg_root, "deps", "build.jl")) end - # set default renderer - # First check env var - env_val = get(ENV, "PLOTLY_RENDERER_JULIA", missing) - if !ismissing(env_val) - env_symbol = Symbol(uppercase(env_val)) - options = Dict(v => k for (k, v) in collect(Base.Enums.namemap(PlotlyJS.RENDERERS))) - renderer_int = get(options, env_symbol, missing) - if ismissing(renderer_int) - @warn "Unknown value for env var `PLOTLY_RENDERER_JULIA` \"$(env_val)\", known options are $(string.(keys(options)))" - else - set_default_renderer(RENDERERS(renderer_int)) - end - else - # we have no env-var - # check IJULIA - isdefined(Main, :IJulia) && Main.IJulia.inited && set_default_renderer(IJULIA) - end - - # set up display - insert!(Base.Multimedia.displays, findlast(x -> x isa Base.TextDisplay || x isa REPL.REPLDisplay, Base.Multimedia.displays) + 1, PlotlyJSDisplay()) - - atreplinit(i -> begin - while PlotlyJSDisplay() in Base.Multimedia.displays - popdisplay(PlotlyJSDisplay()) - end - insert!(Base.Multimedia.displays, findlast(x -> x isa REPL.REPLDisplay, Base.Multimedia.displays) + 1, PlotlyJSDisplay()) - end) - @require JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3" JSON2.write(io::IO, p::SyncPlot) = JSON2.write(io, p.plot) @require JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" begin JSON3.write(io::IO, p::SyncPlot) = JSON.print(io, p.plot) diff --git a/src/display.jl b/src/display.jl index ba1c50ad..f6265455 100644 --- a/src/display.jl +++ b/src/display.jl @@ -4,7 +4,6 @@ mutable struct SyncPlot plot::PlotlyBase.Plot scope::Scope - window::Union{Nothing,Blink.Window} end Base.getindex(p::SyncPlot, key) = p.scope[key] # look up Observables @@ -15,9 +14,6 @@ end function Base.show(io::IO, mm::MIME"text/html", p::SyncPlot) # if we are rendering docs -- short circuit and display html - if get_renderer() == DOCS - return show(io, mm, p.plot, full_html=false, include_plotlyjs="require-loaded", include_mathjax=missing) - end show(io, mm, p.scope) end Base.show(io::IO, mm::MIME"application/prs.juno.plotpane+html", p::SyncPlot) = show(io, mm, p.scope) @@ -146,7 +142,7 @@ function SyncPlot( # to us on(scope["image"]) do x end - SyncPlot(p, scope, nothing) + SyncPlot(p, scope) end function plot(args...; kwargs...) @@ -157,25 +153,6 @@ end Base.size(sp::SyncPlot) = size(sp.plot) Base.copy(sp::SyncPlot) = SyncPlot(copy(sp.plot)) -Base.display(::PlotlyJSDisplay, p::SyncPlot) = display_blink(p::SyncPlot) - -function display_blink(p::SyncPlot) - sizeBuffer = 1.15 - plotSize = size(p.plot) - windowOptions = Dict( - "width" => floor(Int, plotSize[1] * sizeBuffer), - "height" => floor(Int, plotSize[2] * sizeBuffer) - ) - p.window = Blink.Window(windowOptions) - Blink.body!(p.window, p.scope) -end - -function Base.close(p::SyncPlot) - if p.window !== nothing && Blink.active(p.window) - close(p.window) - end -end - function send_command(scope, cmd, args...) # The handler for _commands is set up when plot is constructed scope["_commands"][] = [cmd, args...]