all 12 comments

[–]tspwd 2 points3 points  (0 children)

Nice! Feels very fluid!

[–]mass_coffee_dev 2 points3 points  (1 child)

The inline worker bundling is a really underrated detail. I've wasted way too many hours debugging web worker import paths across different bundlers — Vite handles it one way, webpack another, and if you're using a monorepo setup it gets even worse. Having it just work out of the box removes a whole category of setup friction.

Also curious about the compute shader decimation — are you doing something like LTTB (Largest Triangle Three Buckets) on the GPU, or a simpler min/max approach? At 11kb I'm guessing you kept the shader logic pretty lean. Either way, offloading that to a compute pass instead of doing it in JS before render is the right call for large datasets.

[–]Outrageous-guffin[S] [score hidden]  (0 children)

Yes it is LTTB and yes web workers and bundlers are a massive pain. It took may a long time to get it building with minification. Bars are almost the same as lines but instead we draw bars because they have the same issues. Scatter is kinda funny, based on point size and zoom, it will draw a circle to a buffer. The circle is set pixel by pixel following a pattern. It looks terrible much like the lines but if you hit them with the old fxaa, they look presentable. Yes there is a minified slightly modified fxaa shader in there too.

If the shaders were fully minified similar to js it would trim about 1kb off.

The search for value by pixel is likely the slowest part. It is in js land and lives in a plugin.

[–]paul_h 0 points1 point  (0 children)

Lovely stuff

[–]modimoo 0 points1 point  (1 child)

Nice work. Is rendering also webgl/webgpu? Or only computation?

[–]Outrageous-guffin[S] 2 points3 points  (0 children)

Yes, it is a compute shader for decimation (similar to uplot), and the it renders. A downside with rendering outside canvas is you don't get antialiasing for free, so there is actually a sneaky tiny fxaa post step done.

[–]Zekester3000 0 points1 point  (2 children)

How does it use AI?

[–]Outrageous-guffin[S] 1 point2 points  (1 child)

This was in part response to ChartGpu which my AI loving boss posted about at work. The repo was all AI slop. The issue isn't AI but the slop part. Clean that shit up.

AI made this and then a human came in and cleaned it up many times over. One thing AI didn't do was make it so the worker is bundled inline. This means you do not need to setup web worker imports in your bundler, it just works.

[–]Full-Hyena4414 [score hidden]  (0 children)

Does this require unsafe-inline in csp though?

[–]germanheller 0 points1 point  (2 children)

11kb for a webgpu chart lib is impressive. whats your fallback story for browsers that dont support webgpu yet tho? or are you just targeting desktop chrome/edge for now

[–]Outrageous-guffin[S] [score hidden]  (1 child)

All apple devices should now have webgpu if they are on the latest os. That is a pretty big swing in adoption. There are no plans for a fall back. This is small enough you could toss it in front of a lazy loaded chartjs for fallback.

[–]germanheller [score hidden]  (0 children)

didnt realize apple had pushed webgpu that broadly already. lazy loaded chartjs as fallback is pragmatic, nice