Coder Social home page Coder Social logo

Comments (6)

metasoarous avatar metasoarous commented on June 6, 2024 1

If you set :static-embed :svg it will use darkstar instead of npm, so won't touch the filesystem.

from oz.

metasoarous avatar metasoarous commented on June 6, 2024

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!

from oz.

metasoarous avatar metasoarous commented on June 6, 2024

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.

from oz.

LouDnl avatar LouDnl commented on June 6, 2024

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.

from oz.

LouDnl avatar LouDnl commented on June 6, 2024

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"}}}]}]})

from oz.

LouDnl avatar LouDnl commented on June 6, 2024

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"}}}]}])

from oz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.