Observable Plot in Astro
David Gasquez
July 6, 2024
I've been playing with Observable Framework and Evidence for a while. One thing that I keep wishing is for those data focused static site generators to have a way to render everything at build time and only ship the fully rendered charts. No DuckDB WASM and querying things at loading time!
Since I'm not very familiar with front end, I don't know how easy or hard is to get there though.
At the same time, this is an opportunity for learning. Let's see how hard it is to embed Observable Plot in Astro in a lightweight way.
The Plot
import Plot from "../../components/Plot.astro";
The Code
Start by creating a component, Plot.astro:
Then, you can use it in any .astro, .html and .mdx file like this:
Next, let's see if we can get data from external sources at buildtime and pass it to the plot in a smart way.
Discussion in the ATmosphere