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

Add example with WGLMakie #471

Closed
tlienart opened this issue Apr 29, 2020 · 4 comments
Closed

Add example with WGLMakie #471

tlienart opened this issue Apr 29, 2020 · 4 comments

Comments

@tlienart
Copy link
Owner

tlienart commented Apr 29, 2020

Thanks to @SimonDanisch's hard work, it's now basically possible to export standalone javascript from a Makie plot (with the constraint that, at the moment, it doesn't support much interactivity if any).

Example provided by Simon in this issue

using JSServe, WGLMakie, AbstractPlotting

function handler(session, request)
    return scatter(1:4, color=1:4)
end

dir = joinpath(@__DIR__, "test")
mkdir(dir)
JSServe.export_standalone(handler, dir)
# Then serve it with e.g. LiveServer
using LiveServer

LiveServer.serve(dir=dir)

Could be adapted to be an example along PlotlyJS.

@AlexisRenchon
Copy link

When running the code above, I currently get the following error, when running JSServe.export_standalone(handler, dir)

ERROR: MethodError: no method matching JSServe.UrlSerializer(::Bool, ::String, ::Bool, ::String
)
Closest candidates are:
  JSServe.UrlSerializer(::Bool, ::Union{Nothing, String}, ::Bool, ::String, ::Bool) at /home/al
exis/.julia/packages/JSServe/E7QrV/src/types.jl:114
  JSServe.UrlSerializer(::Any, ::Any, ::Any, ::Any, ::Any) at /home/alexis/.julia/packages/JSSe
rve/E7QrV/src/types.jl:114
Stacktrace:
 [1] export_standalone(dom_handler::Function, folder::String; clear_folder::Bool, write_index_h
tml::Bool, absolute_urls::Bool, content_delivery_url::String)
   @ JSServe ~/.julia/packages/JSServe/E7QrV/src/offline.jl:128
 [2] export_standalone(dom_handler::Function, folder::String)
   @ JSServe ~/.julia/packages/JSServe/E7QrV/src/offline.jl:123
 [3] top-level scope
   @ REPL[35]:1

@tlienart
Copy link
Owner Author

tlienart commented Sep 24, 2021

Closing as there's a demo of how to do this properly now: https://franklinjl.org/demos/#016_using_wglmakie_jsserve (https://franklinjl.org/demos/wgl/)

@EvoArt
Copy link

EvoArt commented Oct 4, 2022

The example now errors, failing to precompile wglmakie https://franklinjl.org/demos/wgl/

@tlienart
Copy link
Owner Author

tlienart commented Oct 6, 2022

Yeah WGLMakie is deprecated but thanks for flagging the issue.

This is now handled with Makie directly. Xranklin.jl (next version of Franklin, in prep) handles this. But generally, I'd probably suggest people use something else than Makie for their static site plots as it's still a bit flaky, and even when it works, it doesn't work on all browsers as webgl is not systematically on.

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

No branches or pull requests

3 participants