Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

At work, we use Google Charts to chart data, then send images of those charts to users via email, inline. We are told that this functionality will be deprecated in the API some time next year. Anyone have an idea of how to mitigate that? Emails dont support javascript so not sure how to get around this. Just for some clarity, if you happen to use Sendgrid, they do the same thing. Google chart images in an email.


Google Charts are rendered through SVG, and fortunately you have two options to reliably convert any SVG to PNG. One options is "Batik Rasterizer"[1] - it is a single .jar file, fast, and accurately renders 99% of our cases. The other options is Wkhtmltopdf[2] - it comes with a companion wkhtmltoimage binary which convert SVG to PNG through a customised webkit engine. It also is fast, and can handle our most complex visualisations.

All we do is grab the SVG source with JS, post it back to the server, and get the image back (after it is scaled/watermarked/optimised). This setup has worked well for us for some years now. Further we can easily interchange charting libraries with on concern about their native exporting options because we handle the rendering ourselves.

[1] https://xmlgraphics.apache.org/batik/tools/rasterizer.html

[2] http://wkhtmltopdf.org/


If you're ok with hosting the images yourself, I'd recommend matplotlib (http://matplotlib.org/ ) as a pretty good chart library.


Something that involves this possibly? http://www.paulhammond.org/webkit2png/

Might be overkill, but would allow quite a bit of flexibility.


The general idea is to render the chart in a headless browser and grab a screenshot.

http://phantomjs.org/screen-capture.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: