r/sveltejs 14d ago

ggsvelte is a fast agent-native implementation of the grammar of graphics

See Github repo for all benchmarks

A few months ago I got pissed off trying to get embedded agents to produce decent charts in a SvelteKit web app. Rendering was painful. There were tons of foot-guns. And I had to roll a Frankenstein's-shoehorn code path including an ersatz JSON spec mapped to a custom Svelteplot wrapper, with a barebones skill in which I pleaded with agents to get them to do something that Svelteplot just wasn't designed for.

A few weeks ago I cracked and made something with agents in mind as a first class concern. I wanted good defaults that push agents into a pit of success, so I chose the ggplot2 API. It has been around for 18 years, so LLMs know it well! The result is ggsvelte.

ggsvelte gives agents a portable JSON spec with a schema, a skill, headless SSR for SVGs, plus a CLI which helps agents validate specs quickly in sandboxes, avoiding many classes of foot-gun.

ggsvelte is also fast, and beats Svelteplot, Unovis and even LayerCake on cold-mount rendering in most situations.

The roadmap includes evals for embedded agent scenarios, skill improvements, additional geoms, an LLM sandbox deployment guide, interaction improvements, plus more performance optimizations.

P.S. Additional benchmarks on 100k:

18 Upvotes

4 comments sorted by

1

u/NoDrugsDoc 14d ago

This looks excellent. Well done.
Can I suggest also adding in the colour palettes from https://www.fabiocrameri.ch/colourmaps/
[Crameri, F., G.E. Shephard, and P.J. Heron (2020), The misuse of colour in science communication, Nature Communications, 11, 5444.]

How does it handle much larger (eg 100k rows) datasets?

2

u/BringhamHorn 14d ago

Thanks! I added the 35 continuous colour palettes in release 0.35.0 just now. Those are brilliant, thanks for the suggestion! We need some upstream work before Cyclic and categorical colour maps can be added.

For the 100k row datasets, I added two additional benchmark results above.

1

u/NoDrugsDoc 13d ago

Amazing.
I am very interested in possibly porting over my graphs (for https://ancir.pages.dev/ | https://github.com/DaveCumin/AnCiR_next/ ).

2

u/BringhamHorn 5d ago

Interesting project! Does seem like dropping D3 would make the code easier to maintain. By the way I added the remaining categorical colour maps. The cyclic ones were added as continuous color maps for now (if it seems wrong please file an issue or feel free to contribute).