Graphviz SVG/DPI problems

Материал из свободной русской энциклопедии «Традиция»
Перейти к: навигация, поиск

Consider following simple graph «d.dot»:

 digraph G{ rankdir=TB; size="7,6";
  black ->goldenrod1 [color=goldenrod1]
 }

<graph>

 digraph G{ rankdir=TB; size="7,6";
  black ->goldenrod1 [color=goldenrod1]
}

</graph>

The problems appers with:

  • Graphviz version >"2.2"
  • SVG-output
  • Nonstandard (>96) «Dpi» parameter.

Graphviz 2.2 - correct, all ok[править]

If we run

c:/app/graphviz22/Graphviz/bin/dot.exe -Tsvg -o example-graphviz-22.svg -Gdpi=192 d.dot

When we have «example-graphviz-22.svg»:

<code-xml> <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svg width="300px" height="360px"

viewBox = "-1 -1 99 119"
xmlns="http://www.w3.org/2000/svg">

<g id="graph0" class="graph" style="font-family:Times-Roman;font-size:14.00;"> <title>G</title> <g id="node1" class="node"><title>black</title> <ellipse cx="49" cy="22" rx="29" ry="18" style="fill:none;stroke:black;"/> <text text-anchor="middle" x="49" y="27">black</text> </g> <g id="node3" class="node"><title>goldenrod1</title> <ellipse cx="49" cy="94" rx="44" ry="18" style="fill:none;stroke:black;"/> <text text-anchor="middle" x="49" y="99">goldenrod1</text> </g> <g id="edge2" class="edge"><title>black->goldenrod1</title> <path style="fill:none;stroke:#ffbe25;" d="M49,40C49,48 49,57 49,66"/> <polygon style="fill:#ffbe25;stroke:#ffbe25;" points="53,66 49,76 46,66 53,66"/> </g> </g> </svg> </code-xml> Which looks like: <pic-svg> <svg width="300px" height="360px"

viewBox = "-1 -1 99 119"
xmlns="http://www.w3.org/2000/svg">

<g id="graph0" class="graph" style="font-family:Times-Roman;font-size:14.00;"> <title>G</title> <g id="node1" class="node"><title>black</title> <ellipse cx="49" cy="22" rx="29" ry="18" style="fill:none;stroke:black;"/> <text text-anchor="middle" x="49" y="27">black</text> </g> <g id="node3" class="node"><title>goldenrod1</title> <ellipse cx="49" cy="94" rx="44" ry="18" style="fill:none;stroke:black;"/> <text text-anchor="middle" x="49" y="99">goldenrod1</text> </g> <g id="edge2" class="edge"><title>black->goldenrod1</title> <path style="fill:none;stroke:#ffbe25;" d="M49,40C49,48 49,57 49,66"/> <polygon style="fill:#ffbe25;stroke:#ffbe25;" points="53,66 49,76 46,66 53,66"/> </g> </g> </svg> </pic-svg>

Graphviz 2.4, 2.6, 2.8 - incorrect[править]

If we run graphviz (>=2.4 - we test 2.4, 2.6, 2.8)

c:/app/graphviz24/Graphviz/bin/dot.exe -Tsvg -o example-graphviz-24.svg -Gdpi=192 d.dot

When we have «example-graphviz-24.svg»:

<code-xml> <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"

"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
<!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">

]> <svg width="696px" height="840px"

viewBox = "0 0 261 315"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

<g id="graph0" class="graph" style="font-family:Times-Roman;font-size:14.00;"> <title>G</title> <g id="node1" class="node"><title>black</title> <ellipse style="fill:none;stroke:black;" cx="131" cy="62" rx="29" ry="18"/> <text text-anchor="middle" x="131" y="75">black</text> </g> <g id="node3" class="node"><title>goldenrod1</title> <ellipse style="fill:none;stroke:black;" cx="131" cy="254" rx="44" ry="18"/> <text text-anchor="middle" x="131" y="267">goldenrod1</text> </g> <g id="edge2" class="edge"><title>black->goldenrod1</title> <path style="fill:none;stroke:#ffbe25;" d="M131,110C131,131 131,155 131,179"/> <polygon style="fill:#ffbe25;stroke:#ffbe25;" points="141,179 131,206 123,179 141,179"/> </g> </g> </svg> </code-xml>

Which looks like: <pic-svg> <svg width="696px" height="840px"

viewBox = "0 0 261 315"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

<g id="graph0" class="graph" style="font-family:Times-Roman;font-size:14.00;"> <title>G</title> <g id="node1" class="node"><title>black</title> <ellipse style="fill:none;stroke:black;" cx="131" cy="62" rx="29" ry="18"/> <text text-anchor="middle" x="131" y="75">black</text> </g> <g id="node3" class="node"><title>goldenrod1</title> <ellipse style="fill:none;stroke:black;" cx="131" cy="254" rx="44" ry="18"/> <text text-anchor="middle" x="131" y="267">goldenrod1</text> </g> <g id="edge2" class="edge"><title>black->goldenrod1</title> <path style="fill:none;stroke:#ffbe25;" d="M131,110C131,131 131,155 131,179"/> <polygon style="fill:#ffbe25;stroke:#ffbe25;" points="141,179 131,206 123,179 141,179"/> </g> </g> </svg> </pic-svg>

Bug[править]

Bug registered and fixed. http://www.graphviz.org/bugs/b958.html