Created
July 5, 2011 16:22
-
-
Save winston/1065169 to your computer and use it in GitHub Desktop.
GoogleVisualr Gem - Combo Chart 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/chart/interactive/docs/gallery/combochart.html | |
def combo_chart | |
data_table = GoogleVisualr::DataTable.new | |
data_table.new_column('string', 'month' ) | |
data_table.new_column('number', 'Bolivia' ) | |
data_table.new_column('number', 'Ecuador' ) | |
data_table.new_column('number', 'Madagascar' ) | |
data_table.new_column('number', 'Papua Guinea') | |
data_table.new_column('number', 'Rwanda' ) | |
data_table.new_column('number', 'Avarage' ) | |
data_table.add_rows( [ | |
['2004/05', 165, 938 , 522, 998 , 450, 614.6], | |
['2005/06', 135, 1120 , 599, 1268 , 288, 682 ], | |
['2006/07', 157, 1167 , 587, 807 , 397, 623 ], | |
['2007/08', 139, 1110 , 615, 968 , 215, 609.4], | |
['2008/09', 136, 691 , 629, 1026 , 366, 569.6] | |
] ) | |
opts = { :width => 700, :height => 400, :title => 'Monthly Coffee Production by Country', :vAxis => {:title => 'Cups'}, :hAxis => {:title => 'Month'}, :seriesType => 'bars', :series => {'5' => {:type => 'line'}} } | |
@chart = GoogleVisualr::Interactive::ComboChart.new(data_table, opts) | |
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> | |
<%= render_chart @chart, 'chart' %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment