Skip to content

Instantly share code, notes, and snippets.

@winston
Created July 30, 2012 15:55
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/3207978 to your computer and use it in GitHub Desktop.
Save winston/3207978 to your computer and use it in GitHub Desktop.
GoogleVisualr Gem - Stepped Area Chart Creation Example
# http://code.google.com/apis/chart/interactive/docs/gallery/steppedareachart.html#Example
def stepped_area_chart
data_table = GoogleVisualr::DataTable.new
data_table.new_column('string' , 'Director (Year)')
data_table.new_column('number' , 'Rotten Tomatoes')
data_table.new_column('number' , 'IMDB')
data_table.add_rows( [
['Alfred Hitchcock (1935)', 8.4, 7.9],
['Ralph Thomas (1959)', 6.9, 6.5],
['Don Sharp (1978)', 6.5, 6.4],
['James Hawes (2008)', 4.4, 6.2]
])
opts = { :width => 800, :height => 500, :title => "The decline of 'The 39 Steps'", :vAxis => { :title => 'Accumulated Rating'}, :isStacked => true }
@chart = GoogleVisualr::Interactive::SteppedAreaChart.new(data_table, opts)
end
<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