Export a chart as SVG or PNG
Capture the complete chart component, including the HTML around canvas or SVG chart output.
Select the chart wrapper—not only its canvas—and call snapdom.toSvg(wrapper).
Export the chart wrapper as SVG
Install @zumer/snapdom, select the rendered element, and capture it:
import { snapdom } from '@zumer/snapdom'
const chart = document.querySelector('.chart-card')
const svgImage = await snapdom.toSvg(chart, { embedFonts: true })
document.querySelector('#preview').appendChild(svgImage)The wrapper includes legends and annotations
Capturing the wrapper includes HTML legends, titles, filters and annotations that a chart library’s own exporter may omit.
Export a complete chart card
The capture includes the title, HTML legend and chart—not only the plot.
Revenue by channel
Limits and common mistakes
A canvas-based chart remains raster content inside the SVG capture. For editable chart paths, use the chart library’s native SVG renderer. The Vector plugin converts supported DOM content into editable SVG; canvas pixels remain embedded bitmaps.
Frequently asked questions
Will a canvas chart become vector paths?
No. SnapDOM preserves its visual output but does not reconstruct canvas pixels as SVG geometry.
When should I export PNG?
Use PNG for broad portability or when the chart contains raster content and no scalable wrapper is needed.