Open LouDnl opened 2 years ago
Hi @LouDnl. Thanks for posting here.
The problem here is that oz is trying to generate a static image to embed in the page, which then gets replaced by the live/interactive vega visualization once the dom loads up. To do this, it's incidentally calling out to the which
command, which is a linux command.
I'm happy to accept a PR to make this code Windows compatible, but I don't use Windows, so I'm probably not the best person to work on this.
If you're fine not having the statically embedded image (which, to be honest, is a pretty minor convenience in most scenarios; it's mostly there so that if js is turned off, you can still see the plots, such as in Dropbox previews, or for converting to PDF), you can just keep using the existing code unaltered. If it's important to you though, you could try using the WSL for Windows, which was getting pretty good last time I tried it, and to my understanding has only gotten better.
Please let me know if I can be of further help with this.
Thanks again!
PS I think the correct behavior here would be for Oz to try to use darkstar to compile a static svg instead of png via the vega npm cli(s) if it's not able to find the latter. The default/fallback behavior here could probably use a review and revamp, as it doesn't always do what you'd want at the moment.
Hi @metasoarous , thanks for your reply. Is it possible to disable the local generation of a static image by supplying an option? I have tried to find it but failed. For security reasons I'm not really into code accessing local filesystems in a production environment.
I think I found a workaround, will use this:
(embed-vega-form {:vega-embed-opts {:live-embed? true :static-embed false}}
{:mode :hiccup
:doc [:vega-lite {:description "Bar chart with text labels. Set domain to make the frame cover the labels.",
:data {:values [{:a "A", :b 28},
{:a "B", :b 55},
{:a "C", :b 43}]},
:encoding {:y {:field "a", :type "nominal"},
:x {:field "b", :type "quantitative", :scale {:domain [0, 60]}}},
:layer [{:mark "bar"}, {:mark {:type "text",
:align "left",
:baseline "middle",
:dx 3},
:encoding {:text {:field "b", :type "quantitative"}}}]}]})
Almost, this works:
(oz/embed-vega-form {:vega-embed-opts {:live-embed? true :static-embed false}}
[:vega-lite {:description "Bar chart with text labels. Set domain to make the frame cover the labels.",
:data {:values [{:a "A", :b 28},
{:a "B", :b 55},
{:a "C", :b 43}]},
:encoding {:y {:field "a", :type "nominal"},
:x {:field "b", :type "quantitative", :scale {:domain [0, 60]}}},
:layer [{:mark "bar"}, {:mark {:type "text",
:align "left",
:baseline "middle",
:dx 3},
:encoding {:text {:field "b", :type "quantitative"}}}]}])
If you set :static-embed :svg
it will use darkstar instead of npm, so won't touch the filesystem.
Hi @metasoarous ,
As requested here is the info for this issue.
Description:
I can create a nice vega-lite bar graph, works fine. But for some reason I keep getting the following stacktrace in the background and I'm not even asking it to use CLI. And I am not using a static ambed afaik?
OS:
Os is Windows (development system), have not yet tried on linux deployment box.
Error:
Codeblock:
I can't share the whole codeblock due to code being private
Hiccup part embedded in clojure file