-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"rank" tag example #10
Comments
You need to create a subgraph to do this. I'll add anonymous subgraphs support and "blocks" in the next version. |
OK, you can now create anonymous subgraph. For more information, see http://github.com/glejeune/Ruby-Graphviz/blob/master/examples/sample35.rb |
Originally I tried to play with twopi. Please, have a look -what may be wrong in this sample code I played with. Looks like "rank" has no any effect - all the "planets'" placement do not depend at all on rank require "graphviz" # The goal is to set each planet to its own orbit + set some (earth+moon) to the same orbit g = GraphViz::new( "Solarsys", :type => "digraph", :use => "twopi" ) # the star sun = g.add_node( 'Sun', :shape => "circle", :penwidth => 2, :fontsize => 12, :style => :filled, :fillcolor => "orange", :label => "Sun\n" ) planets = Hash.new # The Earth and the Moon - in the same subgraph\rank g.subgraph { |c| c[:rank => 'same'] planets['Moon'] = g.add_node( 'Moon', :shape => "circle", :penwidth => 2, :fontsize => 12, :style => :filled, :fillcolor => "red", :label => "Moon\n" ) planets['Earth'] = g.add_node( 'Earth', :shape => "circle", :penwidth => 2, :fontsize => 12, :style => :filled, :fillcolor => "blue", :label => "Earth\n" ) g.add_edge( planets['Moon'], planets['Earth'], :penwidth => 2, :labeltooltip => "distance", :color => "black" ) g.add_edge( sun, planets['Earth'], :penwidth => 2, :labeltooltip => "distance", :color => "black" ) } # some more planets - each supposed having its own orbit - im trying to do it with rank ['Mercury','Venus','Mars','Jupiter','Saturn','Uranus','Neptune','Pluto'].each { |p| # set each to its own orbit # that doesnt seem to work ... g.subgraph { |c| c[:rank => "same"] planets[p] = g.add_node( p, :shape => "circle", :penwidth => 2, :fontsize => 12, :fillcolor => "green", :style => :filled, :label => "#{p}\n" ) g.add_edge( sun, planets[p], :penwidth => 2, :label => "distance", :color => "black" ) } } g.output( :svg => "sample36.svg" ) g.output( :dot => "sample36.dot" ) |
I'm not sure what you espect... But maybe this is better :
|
any sample without subgraph? |
Could you give a hint on how rank tag shall be used - Id like to declare equivalent to dot expression
{ rank = same; "node1"; "node2"; }
The text was updated successfully, but these errors were encountered: