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
############################## | |
# Table with Constructor Format | |
data_table = GoogleVisualr::DataTable.new({ | |
:cols => [ { :id => 'A', :label => 'NEW A' , :type => 'string' }, | |
{ :id => 'B', :label => 'B-label', :type => 'number' }, | |
{ :id => 'C', :label => 'C-label', :type => 'date' } | |
], | |
:rows => [ { :c => [ {:v => 'a'}, {:v => 1.0, :f => 'One'} , {:v => Date.parse('2008-02-28 00:31:26'), :f => '2/28/08 12:31 AM'} ] }, | |
{ :c => [ {:v => 'b'}, {:v => 2.0, :f => 'Two'} , {:v => Date.parse('2008-03-30 00:31:26'), :f => '3/30/08 12:31 AM'} ] }, | |
{ :c => [ {:v => 'c'}, {:v => 3.0, :f => 'Three'}, {:v => Date.parse('2008-04-30 00:31:26'), :f => '4/30/08 12:31 AM'} ] } |
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
############################## | |
# Table with Number Format | |
data_table_5 = GoogleVisualr::DataTable.new | |
data_table_5.new_column('string', 'Department' ) | |
data_table_5.new_column('number', 'Revenues Change' ) | |
data_table_5.add_rows([ | |
['Shoes' , 10700 ], | |
['Sports' , -15400], | |
['Toys' , 12500 ], | |
['Electronics', -2100 ], |
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
############################## | |
# Table with Date Format | |
data_table_4 = GoogleVisualr::DataTable.new | |
data_table_4.new_column('string', 'Employee Name') | |
data_table_4.new_column('date', 'Start Date (L)' ) | |
data_table_4.new_column('date', 'Start Date (M)' ) | |
data_table_4.new_column('date', 'Start Date (S)' ) | |
data_table_4.add_rows([ | |
['Mike' , Date.parse('2008-02-28 00:31:26'), Date.parse('2008-02-28 00:31:26'), Date.parse('2008-02-28 00:31:26') ], | |
['Bob' , Date.parse('2007-06-01 00:00:00'), Date.parse('2007-06-01 00:00:00'), Date.parse('2007-06-01 00:00:00') ], |
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
############################## | |
# Table with Color Format | |
data_table_3 = GoogleVisualr::DataTable.new | |
data_table_3.new_column('string', 'Department' ) | |
data_table_3.new_column('number', 'Revenues Change' ) | |
data_table_3.add_rows([ | |
['Shoes' , 10700 ], | |
['Sports' , -15400], | |
['Toys' , 12500 ], | |
['Electronics', -2100 ], |
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
############################## | |
# Table with Bar Formatter | |
data_table_2 = GoogleVisualr::DataTable.new | |
data_table_2.new_column('string', 'Department' ) | |
data_table_2.new_column('number', 'Revenues Change' ) | |
data_table_2.add_rows([ | |
['Shoes' , 10700 ], | |
['Sports' , -15400], | |
['Toys' , 12500 ], | |
['Electronics', -2100 ], |
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
############################## | |
# Table with Arrow Formatter | |
data_table_1 = GoogleVisualr::DataTable.new | |
data_table_1.new_column('string', 'Department' ) | |
data_table_1.new_column('number', 'Revenues Change' ) | |
data_table_1.add_rows([ | |
['Shoes' , { :v => 12 , :f => '12.0%' }], | |
['Sports' , { :v => -7.3 , :f => '-7.3%' }], | |
['Toys' , { :v => 0 , :f => '0%' }], | |
['Electronics', { :v => -2.1 , :f => '-2.1%' }], |
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'}) |
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/scatterchart.html#Example | |
def scatter_chart | |
data_table = GoogleVisualr::DataTable.new | |
data_table.new_column('number', 'Age') | |
data_table.new_column('number', 'Weight') | |
data_table.add_rows(6) | |
data_table.set_cell( 0, 0, 8 ) | |
data_table.set_cell( 0, 1, 12 ) | |
data_table.set_cell( 1, 0, 4 ) |
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/piechart.html#Example | |
def pie_chart | |
data_table = GoogleVisualr::DataTable.new | |
data_table.new_column('string', 'Task') | |
data_table.new_column('number', 'Hours per Day') | |
data_table.add_rows(5) | |
data_table.set_cell(0, 0, 'Work' ) | |
data_table.set_cell(0, 1, 11 ) | |
data_table.set_cell(1, 0, 'Eat' ) |
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/orgchart.html#Example | |
def org_chart | |
data_table = GoogleVisualr::DataTable.new | |
data_table.new_column('string', 'Name' ) | |
data_table.new_column('string', 'Manager') | |
data_table.new_column('string', 'ToolTip') | |
data_table.add_rows( [ | |
[ {:v => 'Mike', :f => 'Mike<div style="color:red; font-style:italic">President</div>' }, '' , 'The President' ], | |
[ {:v => 'Jim' , :f => 'Jim<div style="color:red; font-style:italic">Vice President<div>'}, 'Mike', 'VP' ], |