Posted By: yasushi ando
Date: 2007-02-22 20:20
Summary: graphviz_r rails plugin
Project: graphviz_r
GraphvizR is graphviz wrapper for ruby, and this is now available on Rails. When you install graphviz_r gem and rdot plugin, you can easily create a controller which generate graphs.
Sample code:
class RdotGenController < ApplicationController
def index
render :rdot do
graph [:size => '1.5, 2.5']
node [:shape => :record]
node1 [:label => "<p_left> left|<p_center>center|<p_right> right"]
node2 [:label => "left|center|right"]
node1 >> node2
node1(:p_left) >> node2
node2 >> node1(:p_center)
(node2 >> node1(:p_right)) [:label => 'record']
end
end
end
The block geven to render_rdot is written in `rdot' format. It is so similar to graphviz's dot format that you must learn it very soon.
Regards,
ANDO Yasushi |
|