ejain
ejain

Reputation: 3614

Can't save Altair chart as SVG from VS Code

When trying to export an Altair chart in SVG format from a Jupyter Notebook running inside Visual Studio Code, I am prompted "You'll need a new app to open this data link", but no apps are listed for handling "data" links (inc in the Microsoft Store).

No issues exporting a chart in PNG format, or exporting in SVG format when running in a browser window. Not sure whom to blame: Altair, Vega, Jupyter, or Microsoft...

Microsoft Store prompt

Upvotes: 3

Views: 1007

Answers (2)

ejain
ejain

Reputation: 3614

Looks like this bug was fixed in the latest version of the Jupyter VSCode extension!

Upvotes: 0

srinivas chilukuri
srinivas chilukuri

Reputation: 75

  • A acknowledged bug in vscode-jupyter is causing Failure to save altair chart as SVG .

Github issue : Unable to save SVG of altair chart in vs-code Jupyter .

  • Alternative workaround until bug is fixed

Altair can do this via the altair_saver package, which can be installed with:

conda install altair_saver

or

pip install altair_saver

Additional Requirements for altair_saver package : one of two backends. {Selenium / Nodejs }

Detailed Instructions for installation of Additional Requirements

To save an Altair chart object as a SVG image, you can use

alt.renderers.enable('altair_saver', fmts=['vega-lite', 'png'])   
Chart.save("chart.svg") 

Upvotes: 2

Related Questions