Skip to content

Instantly share code, notes, and snippets.

@winston
Created July 5, 2011 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winston/1065169 to your computer and use it in GitHub Desktop.
Save winston/1065169 to your computer and use it in GitHub Desktop.
GoogleVisualr Gem - Combo Chart Creation Example
# 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
<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