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

Use data URL for local plotly asset #4863

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 additions & 0 deletions src/init.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
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
_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
Loading