-
Notifications
You must be signed in to change notification settings - Fork 120
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
Mosaic vgplot #1015
Mosaic vgplot #1015
Conversation
Note: it's not active, only here for reference. To make this data loader work in CI, you have to install the proper duckdb binary on the $PATH, and I'd recommend to use a dedicated $TMPDIR rather than write in the root folder.
Co-authored-by: Mike Bostock <mbostock@gmail.com>
Super cool to see this coming natively! Btw, I found that the |
Thanks @domoritz! It looks like our I can’t figure out how to write SQL expressions in the vgplot specification. I just wanted to try showing vg.plot(vg.raster(vg.from("gaia"), {x: "-ra", y: "dec", fill: "density"})) Then I tried using a vg.plot(vg.raster(vg.from("gaia"), {x: vg.sql`-ra`, y: "dec", fill: "density"})) I also tried vg.plot(vg.raster(vg.from("gaia").select({u: "-ra", v: "dec"}), {x: "u", y: "v", fill: "density"})) And vg.plot(vg.raster(vg.Query.select({u: "ra", v: "dec"}).from("gaia"), {x: "u", y: "v", fill: "density"})) Is there a way to pass SQL expressions to channels? Is this a bug in how we’ve configured Mosaic here? |
Maybe the problem is that I’m passing in a DuckDB instance that already has the tables defined, and so Mosaic doesn’t know which tables exist? (Though vg.coordinator().exec(vg.loadCSV("stocks", "stock-data.csv")); but what if the DuckDB instance I pass to |
Mosaic can work with tables loaded externally to Mosaic. That is not an issue. You just need to reference extant table and column names. For custom SQL, we currently don't do any extra parsing. As a result we need to explicitly indicate what is a column reference in order to appropriately track dependencies, pre-load stats, etc. This should work for you: { x: vg.sql`-${vg.column("ra")}`, ... } Admittedly the syntax could be nicer and more ergonomic here! |
The difference here is that |
Thanks for the suggestion, @jheer. That one evaluates but unfortunately I get zeroes for everything: vg.plot(vg.raster(vg.from("gaia"), {x: vg.sql`-${vg.column("ra")}`, y: "dec", fill: "density", pixelSize: 1})) However, it works correctly if I use vg.plot(vg.raster(vg.from("gaia"), {x: vg.sql`360 - ${vg.column("ra")}`, y: "dec", fill: "density", pixelSize: 1})) Maybe the raster mark is inferring the wrong x-domain when given an expression? It seems to think that the domain is [0, 360] even when it’s [-360, 0]. |
Yes, that is also what I think, and will be part of what I'll look into as noted above. Thanks for your time digging in and flagging this. |
Okay, this is ready! There’s some followup work to address duplicate library loads:
As a result, we get three (3!) versions of apache-arrow loaded, and two (2!) versions of duckdb-wasm loaded. Also, only two versions (14 and 15) of apache-arrow are preloaded, and only one version of duckdb-wasm (1.28.1) is preloaded. 😞 This is another bug… Ultimately, I think we’ll have to rewrite the imports that jsDelivr generates to match what we resolve locally. And I think we’ll have to disregard semantic versioning in the case of apache-arrow (as they don’t use semantic versioning) to ensure that we always get a consistent version of apache-arrow. These are pre-existing problems, though, so shouldn’t be tied to this PR. |
The next version of DuckDB-WASM uses Arrow 15, so hopefully all the dependencies line up soon: https://github.com/duckdb/duckdb-wasm/blob/main/packages/duckdb-wasm/package.json |
If uv is the natural earth projection, you can compute them in the client; you just need to make the chart fenced code block dependent on the result of the projection.
|
No, they are not a projection but a rotation so that the milky way is along the horizontal. |
Then we'll have to use the rotation matrix J2000 (https://observablehq.com/@fil/galactic-rotations). 😓 |
Oh, that's a nice notebook. I tried to do the rotation in sql some time ago but gave up and just used the correctly rotated variables instead but it'd be cool to see how the rotation can be done in sql. |
Fixes #1011. Pretty awesome how concise it is!
TODO: Live-reload ofDone.vg
when the SQL front matter is edited.