Skip to content

Commit

Permalink
Use data URL for local plotly asset
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Jan 5, 2024
1 parent 806641a commit 7a46e9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/backends/plotly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ html_body(plt::Plot{PlotlyBackend}) = plotly_html_body(plt)

plotly_url() =
if _use_local_dependencies[]
"file:///" * _plotly_local_file_path[]
_plotly_data_url()
else
"https://cdn.plot.ly/$_plotly_min_js_filename"
end
Expand Down
7 changes: 7 additions & 0 deletions src/init.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
using Scratch
using REPL
import Base64

const _plotly_local_file_path = Ref{Union{Nothing,String}}(nothing)
const _plotly_data_url_cached = Ref{Union{Nothing,String}}(nothing)
_plotly_data_url() = if _plotly_data_url_cached[] === nothing

Check warning on line 7 in src/init.jl

View workflow job for this annotation

GitHub Actions / check

[JuliaFormatter] reported by reviewdog 🐶 Raw Output: src/init.jl:7:-_plotly_data_url() = if _plotly_data_url_cached[] === nothing src/init.jl:7:+_plotly_data_url() = src/init.jl:8:+ if _plotly_data_url_cached[] === nothing
_plotly_data_url_cached[] = "data:text/javascript;base64,$(Base64.base64encode(read(_plotly_local_file_path)))"
else
_plotly_data_url_cached[]
end
# 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"
Expand Down

0 comments on commit 7a46e9b

Please sign in to comment.