Created
April 4, 2010 11:41
-
-
Save winston/355343 to your computer and use it in GitHub Desktop.
GoogleVisualr::PieChart 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/piechart.html#Example | |
def pie_chart | |
@chart = GoogleVisualr::PieChart.new | |
@chart.add_column('string', 'Task') | |
@chart.add_column('number', 'Hours per Day') | |
@chart.add_rows(5) | |
@chart.set_value(0, 0, 'Work' ) | |
@chart.set_value(0, 1, 11 ) | |
@chart.set_value(1, 0, 'Eat' ) | |
@chart.set_value(1, 1, 2 ) | |
@chart.set_value(2, 0, 'Commute' ) | |
@chart.set_value(2, 1, 2 ) | |
@chart.set_value(3, 0, 'Watch TV' ) | |
@chart.set_value(3, 1, 2 ) | |
@chart.set_value(4, 0, 'Sleep' ) | |
@chart.set_value(4, 1, 7 ) | |
options = { :width => 400, :height => 240, :title => 'My Daily Activities', :is3D => 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