diff --git a/Project.toml b/Project.toml index d682b7d18..920644df1 100644 --- a/Project.toml +++ b/Project.toml @@ -30,7 +30,6 @@ RecipesPipeline = "01d81517-befc-4cb6-b9ec-a95719d0359c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" RelocatableFolders = "05181044-ff0b-4ac5-8273-598c1e38db00" Requires = "ae029012-a4dd-5104-9daa-d747884805df" -Scratch = "6c6a2e73-6563-6170-7368-637461726353" Showoff = "992d4aef-0814-514b-bc4d-f2e9a6c4116f" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" @@ -75,7 +74,7 @@ PGFPlotsX = "1" PlotThemes = "2, 3" PlotUtils = "1" PlotlyBase = "0.7 - 0.8" -PlotlyJS = "0.18" +PlotlyJS = "0.18.12" PlotlyKaleido = "1" PrecompileTools = "1" PyPlot = "2" @@ -85,7 +84,6 @@ RecipesPipeline = "0.6.10" Reexport = "0.2, 1" RelocatableFolders = "0.3, 1" Requires = "1" -Scratch = "1" Showoff = "0.3.1, 1" Statistics = "1" StatsBase = "0.33, 0.34" diff --git a/ext/IJuliaExt.jl b/ext/IJuliaExt.jl index 5322c155b..0317de7f5 100644 --- a/ext/IJuliaExt.jl +++ b/ext/IJuliaExt.jl @@ -8,9 +8,7 @@ const IJulia = function _init_ijulia_plotting() # IJulia is more stable with local file - Plots._use_local_plotlyjs[] = - Plots._plotly_local_file_path[] === nothing ? false : - isfile(Plots._plotly_local_file_path[]) + Plots._use_local_plotlyjs[] = true ENV["MPLBACKEND"] = "Agg" end diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 1c251c639..4f0be045e 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -1055,7 +1055,7 @@ html_body(plt::Plot{PlotlyBackend}) = plotly_html_body(plt) plotly_url() = if _use_local_dependencies[] - "file:///" * _plotly_local_file_path[] + "file:///" * _plotly_local_file_path else "https://cdn.plot.ly/$_plotly_min_js_filename" end diff --git a/src/backends/web.jl b/src/backends/web.jl index cfa7e454c..7e912dc64 100644 --- a/src/backends/web.jl +++ b/src/backends/web.jl @@ -45,8 +45,7 @@ function standalone_html_window(plt::AbstractPlot) old = _use_local_dependencies[] # save state to restore afterwards # if we open a browser ourself, we can host local files, so # when we have a local plotly downloaded this is the way to go! - _use_local_dependencies[] = - _plotly_local_file_path[] === nothing ? false : isfile(_plotly_local_file_path[]) + _use_local_dependencies[] = true filename = write_temp_html(plt) open_browser_window(filename) # restore for other backends diff --git a/src/init.jl b/src/init.jl index b962a843f..35893e29c 100644 --- a/src/init.jl +++ b/src/init.jl @@ -1,10 +1,10 @@ -using Scratch using REPL +import PlotlyJS -const _plotly_local_file_path = Ref{Union{Nothing,String}}(nothing) +const _plotly_local_file_path = PlotlyJS._js_path # use fixed version of Plotly instead of the latest one for stable dependency # see github.com/JuliaPlots/Plots.jl/pull/2779 -const _plotly_min_js_filename = "plotly-2.6.3.min.js" +const _plotly_min_js_filename = "plotly-$(PlotlyJS._js_version).min.js" const _use_local_dependencies = Ref(false) const _use_local_plotlyjs = Ref(false) @@ -23,10 +23,6 @@ end function _plots_plotly_defaults() if bool_env("PLOTS_HOST_DEPENDENCY_LOCAL", "false") - _plotly_local_file_path[] = - fn = joinpath(@get_scratch!("plotly"), _plotly_min_js_filename) - isfile(fn) || - Downloads.download("https://cdn.plot.ly/$(_plotly_min_js_filename)", fn) _use_local_plotlyjs[] = true end _use_local_dependencies[] = _use_local_plotlyjs[] diff --git a/test/test_misc.jl b/test/test_misc.jl index 172aee38c..9a7a9edd7 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -7,15 +7,12 @@ end @testset "Plotly standalone" begin - @test Plots._plotly_local_file_path[] ≡ nothing temp = Plots._use_local_dependencies[] withenv("PLOTS_HOST_DEPENDENCY_LOCAL" => true) do Plots._plots_plotly_defaults() - @test Plots._plotly_local_file_path[] isa String - @test isfile(Plots._plotly_local_file_path[]) + @test isfile(Plots._plotly_local_file_path) @test Plots._use_local_dependencies[] = true end - Plots._plotly_local_file_path[] = nothing Plots._use_local_dependencies[] = temp end