Hacker News new | ask | show | jobs
by wilsonfiifi 1703 days ago
Slightly off topic but does anyone work with server generated charts at all? Or is there not much demand for pdf reports?

Last I checked, converting Javascript charts to PNG is still a hacky/convoluted process.

2 comments

If it's pure Javascript and canvas (2D or WebGL) and no HTML/CSS (often the first thing you'll reach for when drawing and styling text) then it's pretty straightforward to render to JPG/PNG using node-canvas. WebGL on the server is a bit more cumbersome with setting up an X virtual frame buffer (xvfb).

SVG is a lot more finicky, but I've used React to generate SVG that imagemagick can then rasterize. If you limit yourself to primitives, you can have an interactive React UI and be able to render any state snapshot to .svg, .jpg, and/or .png.

I think things just get tricky if you want to use a browser-only library or something that mixes canvas, svg, and/or html+css.

I have a need for this as well. Many of the go-to packages from years ago seem abandoned.