altair
altair copied to clipboard
chart.save() method producing SVGs with corrupted characters if e.g., umlaute ü, ö, ä, are present - but export via widget works correctly
Hi,
I'd like to use altairs export function to save svg files locally. I use German labels containing umlaute (üäö) and some other special characters. The method corrupts those characters, so I believe it could be a unicode issue. Exporting via the widget (the dropdown displayed in "notebook" mode) works fine.
Would be great to fix this!
Thanks!
Try this little script to reproduce the error:
import altair as alt
import pandas as pd
source = pd.DataFrame({'Activity': ['Sleeping', 'Eäting', 'TV', 'Wörk', 'Exercise'],
'Time': [8, 2, 4, 8, 2]})
chart = alt.Chart(source).transform_joinaggregate(
TotalTime='sum(Time)',
).transform_calculate(
PercentOfTotal="datum.Time / datum.TotalTime"
).mark_bar().encode(
alt.X('PercentOfTotal:Q', axis=alt.Axis(format='.0%')),
y='Activity:N'
)
display(chart)
chart.save("test.svg")
Thanks for the report.
I ran the above script with Python 3.6, altair 4.0, selenium 3.14.1, and chromedriver 2.36.540469, and the saved output did not include any corrupted characters.
What package versions are you using?
I'm using Python 3.7.3, altair 4.0, selenium 3.141.0, and chromedriver 79.0.3945.36 (according to cromedriver --version), which matches my chrome version (79.0.3945.79).
Problem persists.
I'll test a python downgrade... but it should not depend on this, right?
Ok, tried using Python3.6 as well. The error is still there...
Again, if I use the "Save as SVG" button, the export works fine.
I tried this and it works for me, as does the example in https://github.com/altair-viz/altair/issues/2200. @christophgoebel could you confirm whether you are still experiencing this issue with Altair 4.2.0. If so, could you share with OS you are on?
Closing as issue is stale and cannot be reproduced.