Created
April 4, 2010 14:58
-
-
Save winston/355451 to your computer and use it in GitHub Desktop.
GoogleVisualr::OrgChart Creation Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://code.google.com/apis/visualization/documentation/gallery/orgchart.html#Example | |
def org_chart | |
@chart = GoogleVisualr::OrgChart.new | |
@chart.add_column('string', 'Name' ) | |
@chart.add_column('string', 'Manager') | |
@chart.add_column('string', 'ToolTip') | |
@chart.add_rows( [ | |
[ {:v => 'Mike', :f => 'Mike<div style="color:red; font-style:italic">President</div>' }, '' , 'The President' ], | |
[ {:v => 'Jim' , :f => 'Jim<div style="color:red; font-style:italic">Vice President<div>'}, 'Mike', 'VP' ], | |
[ 'Alice' , 'Mike', '' ], | |
[ 'Bob' , 'Jim' , 'Bob Sponge' ], | |
[ 'Carol' , 'Bob' , '' ] | |
] ) | |
options = { :allowHtml => true } | |
options.each_pair do | key, value | | |
@chart.send "#{key}=", value | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id='chart'></div> | |
<%= @chart.render('chart') %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment