~ubuntu-branches/ubuntu/raring/ruby-graphviz/raring

« back to all changes in this revision

Viewing changes to examples/sample35.rb

  • Committer: Package Import Robot
  • Author(s): Praveen Arimbrathodiyil
  • Date: 2012-10-26 18:38:19 UTC
  • Revision ID: package-import@ubuntu.com-20121026183819-h0d3mvlu6mjasgub
Tags: upstream-1.0.8
ImportĀ upstreamĀ versionĀ 1.0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/ruby
 
2
 
 
3
$:.unshift( "../lib" )
 
4
require "graphviz"
 
5
 
 
6
GraphViz.digraph( :G ) { |g|
 
7
  g[:truecolor => true, :bgcolor => "transparent", :rankdir => "LR"]
 
8
  g.node[:label => "\N"]
 
9
 
 
10
  c1 = g.subgraph { |c|
 
11
    c[:rank => "same"]
 
12
    c.mygraph[
 
13
      :label => '# mygraph.dot\ldigraph G {\l  Hello -> World\l}\l',
 
14
      :shape => "note",
 
15
      :fontname => "Courier",
 
16
      :fontsize => 10
 
17
    ]
 
18
    c.image[ :label => "", :shape => "note", :image => "./hello.png"]
 
19
  }
 
20
 
 
21
  c2 = g.subgraph { |c|
 
22
    c[:rank => "same"]
 
23
    c.mysite[:label => "\nexample.com\n ", :shape => "component", :fontname => "Arial"]
 
24
    c.dotgraph[:label => "\ndotgraph.net\n ", :shape => "component", :fontname => "Arial"]
 
25
  }
 
26
 
 
27
  g.cluster_0 { |c|
 
28
    c[
 
29
      :label => "my_page.html",
 
30
      :fontname => "Courier",
 
31
      :fontsize => 10,
 
32
      :color => "black"
 
33
    ]
 
34
    c.zeimage[:label => "", :shape => "note", :image => "./hello.png"]
 
35
  }
 
36
 
 
37
  (c1.mygraph << c2.mysite)[:color => "blue"]
 
38
  (c2.dotgraph << c1.image)[:color => "red"]
 
39
  (c2.dotgraph << c2.mysite)[:color => "red"]
 
40
  (c2.mysite << c2.dotgraph)[:color => "blue"]
 
41
  (c1.image << c2.dotgraph)[:color => "red"]
 
42
  (c2.mysite << g.cluster_0.zeimage)[:color => "red"]
 
43
}.output( :png => "#{$0}.png", :none => "#{$0}.gv" )