Skip to content

Instantly share code, notes, and snippets.

@winston
winston / area_chart.html.erb
Created April 2, 2010 10:05
GoogleVisualr::AreaChart Creation Example
<div id='chart'></div>
<%= @chart.render('chart') %>
@winston
winston / bar_chart.html.erb
Created April 2, 2010 10:36
GoogleVisualr::BarChart Creation Example
<div id='chart'></div>
<%= @chart.render('chart') %>
@winston
winston / column_chart.html.erb
Created April 4, 2010 10:26
GoogleVisualr::ColumnChart Creation Example
<div id='chart'></div>
<%= @chart.render('chart') %>
@winston
winston / example_controller.rb
Created April 4, 2010 10:49
GoogleVisualr::LineChart Creation Example
# http://code.google.com/apis/visualization/documentation/gallery/linechart.html#Example
def line_chart
@chart = GoogleVisualr::LineChart.new
@chart.add_column('string', 'Year')
@chart.add_column('number', 'Sales')
@chart.add_column('number', 'Expenses')
@chart.add_rows(4)
@chart.set_value(0, 0, '2004')
@chart.set_value(0, 1, 1000)
@winston
winston / example_controller.rb
Created April 4, 2010 11:41
GoogleVisualr::PieChart Creation Example
# http://code.google.com/apis/visualization/documentation/gallery/piechart.html#Example
def pie_chart
@chart = GoogleVisualr::PieChart.new
@chart.add_column('string', 'Task')
@chart.add_column('number', 'Hours per Day')
@chart.add_rows(5)
@chart.set_value(0, 0, 'Work' )
@chart.set_value(0, 1, 11 )
@chart.set_value(1, 0, 'Eat' )
@winston
winston / example_controller.rb
Created April 4, 2010 12:23
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')
@winston
winston / example_controller.rb
Created April 4, 2010 12:40
GoogleVisualr::ImageSparkLine Creation Example
# http://code.google.com/apis/visualization/documentation/gallery/image_spark_line.html#Example
def image_spark_line
@chart = GoogleVisualr::ImageSparkLine.new
@chart.add_column("number", "Revenue" )
@chart.add_column("number", "Licenses")
@chart.add_rows(10)
@chart.set_value(0,0,435)
@winston
winston / example_controller.rb
Created April 4, 2010 13:38
GoogleVisualr::Gauge Creation Example
# http://code.google.com/apis/visualization/documentation/gallery/gauge.html#Example
def gauge
@chart = GoogleVisualr::Gauge.new
@chart.add_column('string' , 'Label')
@chart.add_column('number' , 'Value')
@chart.add_rows(3)
@chart.set_value(0, 0, 'Memory' )
@chart.set_value(0, 1, 80)
@chart.set_value(1, 0, 'CPU' )
@winston
winston / example_controller.rb
Created April 4, 2010 14:58
GoogleVisualr::OrgChart Creation Example
# http://code.google.com/apis/visualization/documentation/gallery/orgchart.html#Example
def org_chart
@chart = GoogleVisualr::OrgChart.new
@chart.add_column('string', 'Name' )
@chart.add_column('string', 'Manager')
@chart.add_column('string', 'ToolTip')
@chart.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' ],
@winston
winston / annotated_time_line.html.erb
Created April 4, 2010 15:40
GoogleVisualr::AnnotatedTimeLine Creation Example
<!-- Specify the size of the Container element explicitly! -->
<div id='chart' style='width: 700px; height: 240px;'></div>
<%= @chart.render('chart') %>