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

[BUG] offline Plot in Pluto results in empty Plot #4854

Closed
pankgeorg opened this issue Dec 22, 2023 · 3 comments · Fixed by #4863
Closed

[BUG] offline Plot in Pluto results in empty Plot #4854

pankgeorg opened this issue Dec 22, 2023 · 3 comments · Fixed by #4863
Labels

Comments

@pankgeorg
Copy link
Contributor

Details

In offline mode, the plotly.min.js file is being injected with a reference to the local filesystem. Since Pluto is served over http://localhost, the file:/// paths can't be loaded. (Note that Pluto static exports do work with the offline mode, since both the HTML file and the Plotly file are served over file:/// and there is no protocol mismatch).

A fix could be to follow what PlutoPlotly does and inject the library files into the Pluto frontend distribution files, which are being served over http when Pluto is running:

https://github.com/JuliaPluto/PlutoPlotly.jl/blob/8c46e64be948899059722b74b101478c83326534/src/local_plotly_library.jl#L62-L69

and

https://github.com/JuliaPluto/PlutoPlotly.jl/blob/8c46e64be948899059722b74b101478c83326534/src/show.jl#L24-L32

Backends

Plotly

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pythonplot x
plotlyjs x
pgfplotsx x
unicodeplots x
inspectdr x
gaston x

Versions

Plots.jl version: Plots v1.39.0
Backend version (]st -m <backend(s)>): -
Output of versioninfo():

julia> versioninfo()
Julia Version 1.9.4
Commit 8e5136fa29 (2023-11-14 08:46 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, tigerlake)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_DEPOT_PATH = D:\.julia
@pankgeorg pankgeorg added the bug label Dec 22, 2023
@fonsp
Copy link
Contributor

fonsp commented Jan 5, 2024

I discussed this with @pankgeorg today, while PlutoPlotly.jl injects files into Pluto's source code, I don't think this is a good pattern, there are some alternatives that are more stable and also work in Static HTML export files, like using a data: URL instead of file:.

@fonsp
Copy link
Contributor

fonsp commented Jan 5, 2024

The relevant Plots.jl code is here:

plotly_url() =
if _use_local_dependencies[]
"file:///" * _plotly_local_file_path[]
else
"https://cdn.plot.ly/$_plotly_min_js_filename"
end

@fonsp
Copy link
Contributor

fonsp commented Jan 5, 2024

Proposed fix in #4863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants