D3Trees.jl icon indicating copy to clipboard operation
D3Trees.jl copied to clipboard

Offline

Open zsunberg opened this issue 7 years ago • 11 comments

Right now the package downloads d3 on the fly, so it will not work without the internet, as I found out painfully in a presentation. I guess we should download d3 into deps

zsunberg avatar Oct 13 '17 17:10 zsunberg

Tasks are

  • [ ] make javascript load a local js file into the dom head
  • [ ] figure out where to store the js file
  • [ ] make build.jl download jquery and d3 locally when the package is built

zsunberg avatar Oct 13 '17 17:10 zsunberg

Unfortunately I have no idea about how to make the browser load a script from a local file - I think it is a security hazard of some kind. I've done a fair amount of googling, but javascript development for offline use is not a popular topic, so I am not going to fix it until I can talk to someone who has lots of javascript/jupyter experience :(.

The issue is similar to this: https://github.com/JuliaLang/IJulia.jl/issues/345

zsunberg avatar Nov 08 '17 01:11 zsunberg

Maybe it can be fixed with this https://github.com/EricForgy/Pages.jl

zsunberg avatar Sep 17 '18 19:09 zsunberg

When I used D3Tree, I find a problem but I can't solve it. Perhaps you can help me to solve it. Thank you very much! Here's my question: Traceback (most recent call last): File "C:/Users/pilgrim/Desktop/code/effecitive_python.py", line 7, in Main.include("test.jl") ImportError: Julia exception: LoadError: IOError: could not spawn cmd /C start chrome 'C:\Users\pilgrim\AppData\Local\Temp\jl_vy8tX5\tree.html': no such file or directory (ENOENT) Stacktrace: [1] _spawn_primitive(::String, ::Cmd, ::Array{Any,1}) at .\process.jl:99 [2] #550 at .\process.jl:112 [inlined] [3] setup_stdios(::Base.var"#550#551"{Cmd}, ::Array{Any,1}) at .\process.jl:196 [4] _spawn at .\process.jl:111 [inlined] [5] run(::Cmd; wait::Bool) at .\process.jl:439 [6] run at .\process.jl:438 [inlined] [7] inchrome(::D3Tree) at C:\Users\pilgrim.julia\packages\D3Trees\CDEyE\src\displays.jl:15 [8] top-level scope at C:\Users\pilgrim\Desktop\code\test.jl:10 [9] include(::String) at .\client.jl:439 [10] #invokelatest#1 at .\essentials.jl:712 [inlined] [11] invokelatest(::Any, ::Any) at .\essentials.jl:711 [12] _pyjlwrap_call(::Function, ::Ptr{PyCall.PyObject_struct}, ::Ptr{PyCall.PyObject_struct}) at C:\Users\pilgrim.julia\packages\PyCall\zqDXB\src\callback.jl:28 [13] pyjlwrap_call(::Ptr{PyCall.PyObject_struct}, ::Ptr{PyCall.PyObject_struct}, ::Ptr{PyCall.PyObject_struct}) at C:\Users\pilgrim.julia\packages\PyCall\zqDXB\src\callback.jl:49 in expression starting at C:\Users\pilgrim\Desktop\code\test.jl:10

I only use the function: inchrome.

pilgrimygy avatar Jul 03 '20 08:07 pilgrimygy

@pilgrimygy it looks like your system was not able to start chrome. Do you have google chrome installed and does the command start chrome work in the command line?

zsunberg avatar Jul 15 '20 15:07 zsunberg

If you have a different browser installed, consider using inbrowser instead of inchrome.

zsunberg avatar Jul 15 '20 15:07 zsunberg

Oh! Thank you very much! I can print the tree in jupyter notebook.

------------------ 原始邮件 ------------------ 发件人: "sisl/D3Trees.jl" <[email protected]>; 发送时间: 2020年7月15日(星期三) 晚上11:55 收件人: "sisl/D3Trees.jl"<[email protected]>; 抄送: "pilgrim"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [sisl/D3Trees.jl] Offline (#10)

If you have a different browser installed, consider using inbrowser instead of inchrome.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

pilgrimygy avatar Jul 15 '20 16:07 pilgrimygy

Unfortunately I have no idea about how to make the browser load a script from a local file - I think it is a security hazard of some kind.

Yeah, this limitation is borne out of CORS rules: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

The fix is easy, just serve all the files from a local Web server.

nsajko avatar Sep 19 '22 13:09 nsajko

If you're targeting just the Chromium/Chrome browser, a possible workaround is to specify the --disable-web-security command line flag when starting the Chromium process: https://peter.sh/experiments/chromium-command-line-switches/#disable-web-security

nsajko avatar Sep 19 '22 13:09 nsajko

Another workaround, but not just for Chromium, would be to include the JS and other dependencies in the HTML file that you generate.

nsajko avatar Sep 19 '22 16:09 nsajko

Thanks for the clarifying comments @nsajko ! I don't have time to personally work on this at the moment, but it would be nice for someone to implement one of these ideas. Would prefer something that works in all browsers and Jupyter.

zsunberg avatar Sep 20 '22 18:09 zsunberg