Skip to content

Instantly share code, notes, and snippets.

@winston
Created April 4, 2010 12:23
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/355362 to your computer and use it in GitHub Desktop.
Save winston/355362 to your computer and use it in GitHub Desktop.
GoogleVisualr::Table Creation Example
# http://code.google.com/apis/visualization/documentation/gallery/table.html#Example
def table
@chart = GoogleVisualr::Table.new
@chart.add_column('string' , 'Name')
@chart.add_column('number' , 'Salary')
@chart.add_column('boolean' , 'Full Time Employee')
@chart.add_rows(4)
@chart.set_cell(0, 0, 'Mike' )
@chart.set_cell(0, 1, 10000, '$10,000')
@chart.set_cell(0, 2, true )
@chart.set_cell(1, 0, 'Jim' )
@chart.set_cell(1, 1, 8000, '$8,000' )
@chart.set_cell(1, 2, false )
@chart.set_cell(2, 0, 'Alice' )
@chart.set_cell(2, 1, 12500, '$12,500')
@chart.set_cell(2, 2, true )
@chart.set_cell(3, 0, 'Bob' )
@chart.set_cell(3, 1, 7000, '$7,000' )
@chart.set_cell(3, 2, true )
options = { :width => 600, :showRowNumber => 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