GoogleVisualr - Stepped Area Chart


Overview

A stepped area chart that is rendered within the browser using SVG or VML. Displays tips when hovering over steps.

Please refer to Google's documentation for details on Data Format and Configuration Options. However, Methods and Events are not implemented.


Example


Code

In your controller, create the data_table object, set new columns, add row values, then instantiate the chart with configuration options.

  # 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

In your view, use the render_chart method to generate JavaScript, during rendering of the view.

  <div id='chart'></div>
  <%= render_chart @chart, 'chart' %>