Created
July 1, 2011 06:14
-
-
Save winston/1057971 to your computer and use it in GitHub Desktop.
GoogleVisualr Gem - 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/chart/interactive/docs/gallery/table.html#Example | |
def table | |
data_table = GoogleVisualr::DataTable.new | |
data_table.new_column('string' , 'Name') | |
data_table.new_column('number' , 'Salary') | |
data_table.new_column('boolean' , 'Full Time Employee') | |
data_table.add_rows(4) | |
data_table.set_cell(0, 0, 'Mike' ) | |
data_table.set_cell(0, 1, {:v => 10000, :f => '$10,000'}) | |
data_table.set_cell(0, 2, true ) | |
data_table.set_cell(1, 0, 'Jim' ) | |
data_table.set_cell(1, 1, {:v => 8000 , :f => '$8,000' }) | |
data_table.set_cell(1, 2, false ) | |
data_table.set_cell(2, 0, 'Alice' ) | |
data_table.set_cell(2, 1, {:v => 12500, :f => '$12,500'}) | |
data_table.set_cell(2, 2, true ) | |
data_table.set_cell(3, 0, 'Bob' ) | |
data_table.set_cell(3, 1, {:v => 7000 , :f => '$7,000' }) | |
data_table.set_cell(3, 2, true ) | |
opts = { :width => 600, :showRowNumber => true } | |
@chart = GoogleVisualr::Interactive::Table.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