Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

inline rendering svg #64

Closed
t3ndai opened this issue Apr 16, 2020 · 3 comments
Closed

inline rendering svg #64

t3ndai opened this issue Apr 16, 2020 · 3 comments

Comments

@t3ndai
Copy link

t3ndai commented Apr 16, 2020

for example to get an svg output in pygal, I would do this

    chart = pygal.Line(disable_xml_declaration=True, x_label_rotation=45)
    return chart.render(is_unicode=True)

what's the equivalent in altair so I can get an svg embedded string, not a file that I can easily save to the db for output later ?

@cheak1974
Copy link

cheak1974 commented Apr 24, 2020

Very good question. I was about asking the same. I use PyGal and load the rendered svg output as embedded image to the background of div tags in my Web UI. There should be no need to write the image data to disk when you could keep it in memory instead.

I had a brief look into the code and found a render() function which returns a mimepackage. I haven't tried it yet, but maybe this is what we are searching for.

cheers

@jakevdp
Copy link
Member

jakevdp commented Apr 24, 2020

This will return an svg string:

import altair_saver
svg_string = altair_saver.save(chart, fmt='svg')

@joelostblom
Copy link
Member

Since Altair 5.2, the functionality of Altair Saver is now available in Altair via the vl-convert package. Most of the functionality has been available since 5.0, and the main addition in 5.2 was PDF export. See the docs on how to save charts for more details.

We are going to archive this repo, so I'm closing all the open issues and PRs before doing so. Try out the new options for saving charts mentioned above and if you run into issues, please open an issue directly in the altair or vl-convert repo.

@joelostblom joelostblom closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants