demo · v142

Click-A-Bar Chart Export

The motivating use case in the spec discussion: data-viz libraries that draw clickable SVG charts. Each bar is an SVG <a download> wrapping a rectangle — click it to download a per-bar CSV slice. Chrome 142+ saves the file; older Chrome just navigates to the blob URL and loses the click context.

SVGAElement.download supported
last export
click a bar

Each bar is generated by JS as <a href download><rect/></a> with a fresh blob URL set via setAttribute. In Chrome ≤141 clicking navigates the tab; in Chrome 142+ the file saves under the configured filename.

generator

const a = document.createElementNS(SVG_NS, "a");
a.setAttributeNS(null, "href", blobUrl);
a.setAttributeNS(null, "download", `${prefix}-${quarter}.csv`);
const rect = document.createElementNS(SVG_NS, "rect");
// …append rect, append a to chart

see also