Skip to content

Latest commit

 

History

History
14 lines (12 loc) · 513 Bytes

README.md

File metadata and controls

14 lines (12 loc) · 513 Bytes

SVGtoPNG

Converts or downloads an SVG element as a PNG. I use this to save charts which have been generated with Vega and had their DOM messed with, which prevents the default exporter from working.

Usage

Trigger a PNG download

Simply provide an SVG element and a filename

SVGtoPNG.downloadPNG(document.querySelector("#headc svg"), "chart.png");

Get data-uri string

SVGtoPNG.toPNGString(document.querySelector("#headc svg"), function(data) { console.log(data); });