Id attribute is not used in linearGradient
Steps to reproduce
Example input:
digraph Tree {
overlap = false;
tooltip = " ";
id = "G2";
bgcolor = "#ffffff00";
e17e21fbdb233f2d9c26769c3e5 [shape=box style=filled fillcolor="beige: yellow" gradientangle=315 label="xxx
xxx
xxx" tooltip=" " href="xxx"]
e17e1a62c7e692fdee219e2a59f [shape=box style=filled fillcolor="beige: turquoise" gradientangle=315 label="xxx
xxx
xxx" tooltip=" " href="xxx"]
e17e21fbdb233f2d9c26769c3e5 -> e17e1a62c7e692fdee219e2a59f [style=solid tooltip=" "]
}
Using dot.exe with -Tsvg Example result:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 5.0.0 (20220707.1540)
-->
<!-- Title: Tree Pages: 1 -->
<svg width="145pt" height="150pt"
viewBox="0.00 0.00 145.00 150.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="G2" class="graph" transform="scale(1 1) rotate(0) translate(4 146)">
<title>Tree</title>
<g id="a_G2"><a xlink:title=" ">
<polygon fill="transparent" stroke="transparent" points="-4,4 -4,-146 141,-146 141,4 -4,4"/>
</a>
</g>
<!-- e17e21fbdb233f2d9c26769c3e5 -->
<g id="G2_node1" class="node">
<title>e17e21fbdb233f2d9c26769c3e5</title>
<g id="a_G2_node1"><a xlink:href="xxx" xlink:title=" ">
<defs>
<linearGradient id="l_0" gradientUnits="userSpaceOnUse" x1="20.06" y1="-134.24" x2="116.94" y2="-96.76" >
<stop offset="0" style="stop-color:beige;stop-opacity:1.;"/>
<stop offset="1" style="stop-color:#ffff00;stop-opacity:1.;"/>
</linearGradient>
</defs>
<polygon fill="url(#l_0)" stroke="black" points="137,-142 0,-142 0,-89 137,-89 137,-142"/>
<text text-anchor="middle" x="68.5" y="-126.8" font-family="Times New Roman,serif" font-size="14.00">xxx</text>
<text text-anchor="middle" x="68.5" y="-111.8" font-family="Times New Roman,serif" font-size="14.00">xxx</text>
<text text-anchor="middle" x="68.5" y="-96.8" font-family="Times New Roman,serif" font-size="14.00">xxx</text>
</a>
</g>
</g>
<!-- e17e1a62c7e692fdee219e2a59f -->
<g id="G2_node2" class="node">
<title>e17e1a62c7e692fdee219e2a59f</title>
<g id="a_G2_node2"><a xlink:href="xxx" xlink:title=" ">
<defs>
<linearGradient id="l_1" gradientUnits="userSpaceOnUse" x1="20.06" y1="-45.24" x2="116.94" y2="-7.76" >
<stop offset="0" style="stop-color:beige;stop-opacity:1.;"/>
<stop offset="1" style="stop-color:#40e0d0;stop-opacity:1.;"/>
</linearGradient>
</defs>
<polygon fill="url(#l_1)" stroke="black" points="137,-53 0,-53 0,0 137,0 137,-53"/>
<text text-anchor="middle" x="68.5" y="-37.8" font-family="Times New Roman,serif" font-size="14.00">xxx</text>
<text text-anchor="middle" x="68.5" y="-22.8" font-family="Times New Roman,serif" font-size="14.00">xxx</text>
<text text-anchor="middle" x="68.5" y="-7.8" font-family="Times New Roman,serif" font-size="14.00">xxx</text>
</a>
</g>
</g>
<!-- e17e21fbdb233f2d9c26769c3e5->e17e1a62c7e692fdee219e2a59f -->
<g id="G2_edge1" class="edge">
<title>e17e21fbdb233f2d9c26769c3e5->e17e1a62c7e692fdee219e2a59f</title>
<g id="a_G2_edge1"><a xlink:title=" ">
<path fill="none" stroke="black" d="M68.5,-88.87C68.5,-80.89 68.5,-71.93 68.5,-63.38"/>
<polygon fill="black" stroke="black" points="72,-63.25 68.5,-53.25 65,-63.25 72,-63.25"/>
</a>
</g>
</g>
</g>
</svg>
Expected Behaviour
I believe the attribute id = "G2" should affect all id:s
Actual Behaviour
"G2" is included in id:s for graph, nodes etc. but not in linearGradients. That messes up the gradient fill when more than one graph svg is included on a web page.
OS Version
Windows 11
Graphviz Version
5.0.0 Also tested with 2.44.1 and got the same problem.
Additional info
My current workaround on generated svg:
return svg
.Replace("<linearGradient id=\"", "<linearGradient id=\"" + idPrefix)
.Replace("<polygon fill=\"url(#", "<polygon fill=\"url(#" + idPrefix);