I would like to display a vega-lite-api generated chart and be able to save it as an SVG file or a PNG file.
I go for instance to https://observablehq.com/@ericmauviere/seasonality-of-weddings-in-france
which displays at the top an SVG vega-lite bar chart
then try and export via the download SVG item in the Observable cell menu.
When i open the file (in a browser like Chrome or Edge) i get:
This page contains the following errors:
error on line 1 at column 226: Attribute xmlns redefined
Below is a rendering of the page up to the first error.
And indeed, this appears repeated in the svg root node:
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
Actually, vega-lite SVG renderer generates these attributes, and it looks like the Observable SVG export functionality add them a second time.
There is also an error on PNG export (via the cell menu) āOops, downloading failed. Try again?ā
Eventually, i try the custom SVG and PNG export showcased in https://observablehq.com/@mbostock/saving-svg.
The āSave as SVGā button generates a proper SVG file,
The āSave as PNGā button doesnāt do anything