IdolHands.com :: Days in the Life of an Alpha Geek
Seer is a lightweight, semantically rich Ruby on Rails gem that provides a seamless interface for the Google Visualization API. It allows you to easily create a visualization of data in a variety of formats, and displaying a chart requires only a single line of code in your view.
Seer can generate a variety of charts, including:
Support for additional chart types, including motion, geographic, and org charts, is slated for the next release.
Seer is hosted on Gemcutter, so make sure that gemcutter.org is in your gem source list:
$ gem update --system $ gem install gemcutter --source http://gemcutter.org $ gem tumble
Once you've confirmed this, install Seer as you would any other Rails gem:
$ gem install seer
Once the gem is installed, add this line to the <head> of either your layout file or the page that will be displaying your graph:
<%= Seer::init_visualization -%>
Now you're ready to leverage the graphing library.
Gather the data you want to visualize in an instance variable in your controller, then use the visualize method to insert the appropriate chart in your view. In your controller:
# @data must be an array, and each object in the array must respond to the data method specified # in the visualize call (in this example, 'quantity') @data = Widget.all
In your view:
<div id="chart" class="chart"></div> <%= Seer::visualize( @widgets, :as => :bar_chart, :in_element => 'chart', :series => { :series_label => 'name', :data_method => 'quantity' }, :chart_options => { :height => 300, :width => 200 * @widgets.size, :is_3_d => false, :legend => 'none', :colors => ["#990000"], :title => "Widget Quantities", :title_x => 'Quantity', :title_y => 'Widgets' } ) -%>
For a full introduction to Seer, please refer to the blog post announcing Seer.
For issues, source code, and more, refer to the Seer home page on GitHub.
This work is licensed under a MIT License.