Open gibiansky opened 10 years ago
It looks like there's no way around this uniqueness requirement?
It seems odd to me that the definitions aren't local to their corresponding
I don't think it's a problem in the chart svg driver - it generate unique ids within any single svg output. Rather that SVG files that are to be assembled into a single HTML file need to be processed in such a way to ensure ids are unique across the combined output.
I guess such a tools could be written in haskell or any other language.
Could it be possible to somehow pass an option to the renderer? Maybe something in the renderer options, like
opts = def{_fo_format = SVG, _fo_size = (500, 400), _fo_namespace = Just "uniquename"}
And then it would use that namespace?
Also, what is the simple way to process them? Can we just do string replacements for the glyphs somehow? Say, just something like sed 's/glyph/uniqueGlyphName/g'
?
I didn't realise until I looked at you example in more detail that you were using the cairo backend. I think it will be hard/impossible to prefix the glyph names to make them distinct in this backend, as the SVG generation is a c library. A quick look at the API:
http://cairographics.org/manual/cairo-SVG-Surfaces.html
suggests that control over the glyph names is buried in the library.
There is the SVG backend based upon the diagrams library which may give you more control, and all the code is haskell. There's a need to step through the logic in the various libraries to see where the glyph names are created - it's still a layer below the chart library. Also there's another caveat here though - SVG generation via diagrams is much slower.
That's sad. Perhaps then it's worth just documenting this somewhere, noting the img tag plus base 64 work around, and leaving it at that.
I've added a comment to the documentation for the cairo/SVG backennd combination.
It might be worth experimenting with the diagrams/SVG backend - depending on how it is called I think it won't generate glyphs in this way at all.
I am not sure that this is a
chart
orchart-cairo
bug, but I don't have the expertise to deal with this myself...If you generate two SVGs using
Chart
andchart-cairo
, and then conjoin them into one HTML file, then when you display them the second one gets messed up. I think this is because the glyphs from the first one are used in the second one, sine they share names.You can look at an example by
curl
ing and viewing this file, or here (see cell output 31).Here is some code you can use to generate this broken HTML file:
Then run
cat svg.svg svg2.svg > two.html
, and viewtwo.html
in Firefox or Chrome.Any idea what's going on? Is this a bug in browsers? Or in Chart? or what?