Created
April 2, 2010 10:05
-
-
Save winston/352992 to your computer and use it in GitHub Desktop.
GoogleVisualr::AreaChart 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
<div id='chart'></div> | |
<%= @chart.render('chart') %> |
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/areachart.html#Example | |
def area_chart | |
@chart = GoogleVisualr::AreaChart.new | |
@chart.add_column('string', 'Year') | |
@chart.add_column('number', 'Sales') | |
@chart.add_column('number', 'Expenses') | |
@chart.add_rows(4) | |
@chart.set_value(0, 0, '2004') | |
@chart.set_value(0, 1, 1000) | |
@chart.set_value(0, 2, 400) | |
@chart.set_value(1, 0, '2005') | |
@chart.set_value(1, 1, 1170) | |
@chart.set_value(1, 2, 460) | |
@chart.set_value(2, 0, '2006') | |
@chart.set_value(2, 1, 1500) | |
@chart.set_value(2, 2, 660) | |
@chart.set_value(3, 0, '2007') | |
@chart.set_value(3, 1, 1030) | |
@chart.set_value(3, 2, 540) | |
options = { :width => 400, :height => 240, :title => 'Company Performance', :legend => 'bottom' } | |
options.each_pair do | key, value | | |
@chart.send "#{key}=", value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment