Post

Last week I had the pleasure of finally releasing the #SveltePlot alpha version during my talk at the #SvelteSummit in Barcelona. It's a new visualization framework for @svelte.dev that I've been working on for the past 18 months, so it's about time for a 🧵

Like the fantastic Observable Plot -- which served as huge inspiration! -- SveltePlot was born out of the need for a plotting framework that is both flexible and concise. It comes with smart, data-driven defaults that make it easy to start coding graphics from scratch, without chart templates.

But unlike Observable Plot, SveltePlot is written as pure Svelte components and is fully reactive. When your data or plot state changes, the DOM gets updated instead of replaced, allowing for tweens and transitions in between states. Needless to say that it's powered under the hood by D3.js!

There are other great Svelte-based visualization frameworks around, each comes with its own advantages and use cases, such as LayerCake or LayerChart. SveltePlot doesn't want to be "better" but I think it's different in some regards.

0 reposts8 likes

Unlike LayerCake, SveltePlot comes with "all batteries included", featuring a rich set of data transforms and marks to shape and display your data. Helper components make it easier to add interactivity to your plot, such as tooltips or brushing.

Unlike LayerChart, SveltePlot is not built on top of a CSS framework like TailwindCSS. All styles are applied inline or (optionally) via emotion/css managed css classes. SveltePlot also follows the grammar of graphics principles more strictly, offering no "scatterplot" or "histogram" components.

SveltePlots emphasize on developer experience makes it a great pick in scenarios where you need to rapidly iterate over visualization ideas in code and then want to turn your prototypes into publishable graphics without switching languages or re-implementing them in a different framework.

It's not the best pick if you're looking for high performant data-dense displays. It also adds a lot more kB to your bundle size than if you'd just write clean Svelte + D3.js code. Perhaps that's something we can improve in the future with the coming async Svelte features!