activity-browser
activity-browser copied to clipboard
Exported SVG sankey is invalid
Sankey diagrams exported in SVG format cannot be opened in the browser. The latest version of Firefox gives this error:
XML Parsing Error: duplicate attribute
Location: file:///C:/Users/.../svg_export.svg
Line Number 1, Column 43:
Upon checking the file content, I realized that the default namespace attribute is declared twice, causing the parser to crash:
<svg xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/2000/svg" ...
I wrote a quick python module which looks through a directory and fixes all svg files with the above error:
import glob
path = r"C:\path\to\*.svg"
files = glob.glob(path)
for file in files:
with open(file, "r") as f:
text = f.read()
text = text.replace('xmlns="http://www.w3.org/1999/xhtml"','xmlns:xhtml="http://www.w3.org/1999/xhtml"')
with open(file, "w") as f:
f.write(text)
@BenPortner Thanks for both reporting and contributing to the issue! Really great that you've taken the time to look at this.
@nabilahmed739 I've added you as reviewer as you know more about this. Would you have time? Otherwise please let me know!