Created
April 4, 2010 12:23
-
-
Save winston/355362 to your computer and use it in GitHub Desktop.
GoogleVisualr::Table 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/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 |
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