SVG gradients don't use the graph's id property to generate gradient id values

I'm using GraphViz to generate a few hundred SVG files that I'm embedding in a single HTML document. I'm setting the id of the graph to make sure that each embedded SVG can be uniquely identified. Unfortunately, if I use a gradient to color a node, gradient SVG elements are generated using non-unique identifiers, such as "r_0", and when viewing the result on Firefox, the colors used are from a different embedded SVG element, and are usually wrong. If an id is defined for a graph, then (just like for nodes and edges) that id should be used as a prefix to the gradient's id. I've poked around the source a bit, but cant figure out where SVG code is gettng generated. If someone can just point me in the right direction, I can make the change, open a issue, and include a patch. (And I would have created an issue already, but I'm having trouble accessing the tracker.)

any my examples were stripped...

To illustrate, when I generate SVG output with 'graph [ id="graph62779720" ]', I get this:

<g id="graph62779720" class="graph" transform="scale(1 1) rotate(0) translate(4 40)">

Nested within this are my nodes:

<g id="graph62779720_node1" class="node">...

And nested within that is a gradient definition:

<radialGradient id="r_0" cx="50%" cy="50%" r="75%" fx="50%" fy="50%">

That id value needs to be something like "graph62779720_r_0"

Re: SVG gradients don't use the graph's id property to generate

Greetings. Sorry for the difficulty.  The source code for the native SVG driver can be found
in graphviz/plugin/core/gvrender_core_svg.c  around line 548 in the function svg_rgradstyle().
It's basically a bunch of printfs() called from the drive-independent codegen layer,
see graphviz/lib/common/shapes.c   Hope this helps.  Not sure if gradients are supported
in the Cairo driver but it does do something called  cairo_gradient_fill()     so give it a whirl
e.g.  -Tpng:cairo
Stephen North

Recent comments