Blogger.create { :name =>'Matt Aimonetti',
:location => 'San Diego, Ca',
:email => mattaimonetti AT gmail.com,
:linkedin => Matt's Linkedin page,
:recommend_me => HERE,
:contractor => true}

Google Chart Gem

Written by matt on December 9th, 2007

update Nov 11: the gem is finally available there or simply:


    sudo gem install googlecharts

Note that I'm working on merging this gem with another Google Charts gem. (see comments for more info about that)

gchart

I've been working on a Google Chart Gem that I have ready for a beta release but unfortunately, getting a new project setup on RubyForge takes forever. (apparently 72 hours)

It's mainly a wrapper for the great GChart API, but instead of using a helper to generate your graphs, you can simply do:

1
2
3
4
5
6
7
8
  Gchart.bar(:title => 'My Mojo', :data => [1,2,4,67,100,41,234], :max_value => 300, :bg => 'c3c3c3')
  
  Gchart.line(:title => 'My Mojo', 
              :data => [[1,2,4,67,100,41,234],[41,63,96,17,100,14,423]],
              :bg => '666666', 
              :graph_bg => 'cccccc', 
              :line_colors => 'ff0000,00ff00',
              :legend => ['morning','evening'])
1
2
3
  Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby fu', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'jordan', 'ryan'])

.

img

As far as I know this is most complete Ruby wrapper for Google Chart API, but feel free to look around.



Comments

  • Morten on 10 Dec 04:27

    Way to go! Looking forward to using this.

  • Deepak Jois on 10 Dec 06:05

    Looks like you beat me to the gem release :-). I just started a project on Google Code at http://code.google.com/p/gchartb for a Ruby wrapper around the Google code API.

    Deepak

  • Deepak Jois on 10 Dec 06:08

    Sorry, wrong link "http://code.google.com/p/gchartrb/":http://code.google.com/p/gchartrb/

  • Rahsun McAfee on 10 Dec 06:31

    Awesome - going to check this out as soon as I can.

    Hopefully it can replace some SWF charts that take a little bit longer then I like to load :( - .... oh and Google's API being "free" helps as well ;)

  • Rymaï on 10 Dec 10:25

    Can't wait for this beta release!!!!!! :)

    I took a look at the API yesterday, and today I see your post! :P

    You're too fast guy! ^^

    It seems to be a nice work!

  • Rich Corbridge on 10 Dec 11:48

    Great! Can't wait to use it. Installed the gem but get the error below in my Rails app when I cut-pasted your sample code above into a view.

    uninitialized constant ActionView::Base::CompiledTemplates::Gchart

    What did I miss?

    Rich

  • Matt on 10 Dec 15:02

    After discussing with John Barnette author of another Gchart gem, we decided to merge our projects: http://rubyforge.org/projects/gchart/ http://gchart.rubyforge.org/gchart/

    Most of the new features should be deployed sometimes tonight :)

  • Rich Corbridge on 10 Dec 16:06

    LOL.

    That was my problem. I was using John's gem with Matt's documentation.

    Looking forward to ONE gem (with matching documentation). :)

  • Christoph on 11 Dec 01:21

    cool, that didn't take long :) thanks for your work!

  • Sol on 11 Dec 02:03

    Which one will be the site of the merged project? :)

  • Matt Aimonetti on 11 Dec 17:02

    Sorry about the confusion. My original gem is available "there":http://rubyforge.org/projects/googlecharts/ while the merged gem will be available "here":http://gchart.rubyforge.org/gchart/"

  • Ian on 12 Dec 00:18

    This is great! Cheers mate.

Comments are closed