Skip to content

Instantly share code, notes, and snippets.

@winston
Created April 4, 2010 14:58
Show Gist options
  • Save winston/355451 to your computer and use it in GitHub Desktop.
Save winston/355451 to your computer and use it in GitHub Desktop.
GoogleVisualr::OrgChart Creation Example
# 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
<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