glejeune / Ruby-Graphviz

[MIRROR] Ruby interface to the GraphViz graphing tool
https://gitlab.com/glejeune/ruby-graphviz
Other
609 stars 116 forks source link

HTML-like labels supported #64

Closed lenntt closed 11 years ago

lenntt commented 11 years ago

graphviz doc says: http://www.graphviz.org/doc/info/shapes.html#html

When using this in ruby-graphviz, so setting an edge.label to something like "<some <b>label</b>>" I just get a "some label" without the markup.

Am I doing something wrong or is this not supported in the current version? I see some note in the changelog of version 1.0.0 regarding to html labels, but i cant figure out how to use it. Is there an example around?

lenntt commented 11 years ago

Could anyone verify whether I'm doing something wrong or whether this is not supported at the moment?

glejeune commented 11 years ago

See sample55.rb

lenntt commented 11 years ago

Thanks, i'm definitely going to try it out

lenntt commented 11 years ago

I've verified the example builds, but graphviz seems to ignore the HTML labels. In order to show that, I've changed the example a little bit: One node with markup, one node without, so we should see a difference in the output of both.

  n1 = g.add_nodes( "N1", :label => 'node 1')
  n2 = g.add_nodes( "N2", :label => '<<b>node 2</b>>')

gives me this when outputted to svg (tested with latest released gem, 1.0.9 and latest graphviz available for my system: 2.26.3-10ubuntu1):

<svg width="116pt" height="157pt" viewBox="0.00 0.00 116.00 157.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph1" class="graph" transform="scale(1 1) rotate(0) translate(4 153)">
<title>G</title>
<polygon fill="white" stroke="white" points="-4,5 -4,-153 113,-153 113,5 -4,5"></polygon>
<text text-anchor="start" x="8.5" y="-8.73333" font-family="Times Roman,serif" font-size="14.00">This</text>
<text text-anchor="start" x="37.5" y="-8.73333" font-family="Times Roman,serif" font-size="14.00"> is </text>
<text text-anchor="start" x="57.5" y="-8.73333" font-family="Times Roman,serif" font-size="14.00">a</text>
<text text-anchor="start" x="66.5" y="-8.73333" font-family="Times Roman,serif" font-size="14.00"> </text>
<text text-anchor="start" x="71.5" y="-8.73333" font-family="Times Roman,serif" font-size="14.00">test</text>
<!-- N1 -->
<g id="node1" class="node"><title>N1</title>
<ellipse fill="none" stroke="black" cx="54" cy="-130" rx="44.7575" ry="18.3848"></ellipse>
<text text-anchor="middle" x="54" y="-126.4" font-family="Times Roman,serif" font-size="14.00">node 1</text>
</g>
<!-- N2 -->
<g id="node2" class="node"><title>N2</title>
<ellipse fill="none" stroke="black" cx="54" cy="-41" rx="42.2463" ry="18"></ellipse>
<text text-anchor="start" x="30" y="-38.2333" font-family="Times Roman,serif" font-size="14.00">node 2</text>
</g>
<!-- N1&#45;&#45;N2 -->
<g id="edge2" class="edge"><title>N1--N2</title>
<path fill="none" stroke="black" d="M54,-111.125C54,-95.8177 54,-74.3731 54,-59.2387"></path>
<text text-anchor="start" x="54.5" y="-82.2333" font-family="Times Roman,serif" font-size="14.00">edge</text>
</g>
</g>
</svg>

Note that the example behaves correctly, because it renders a png. This functionality is working only under svg rendering. http://www.graphviz.org/doc/info/shapes.html#html

glejeune commented 11 years ago

I think it is a problem with your graphviz version. Indeed, with GV 2.31, everything looks good. Could you test with 2.30 or 2.31 ?

lenntt commented 11 years ago

I've verified it indeed was a problem with my graphviz version. I'm now using 2.31.20130522.0446-1 (from ppa:gviz-adm/graphviz-dev) and it works as expected. Thanks