Article: Intro to Google Charts and gchartrb

| by Werner Schuster Follow 9 Followers on Jun 04, 2008. Estimated reading time: less than one minute |
In this article, Matthew Bass, explains the Google Charts web service, which allows to create a wide range of charts very easily. The specification and data for the chart is encoded in the URL for the web service, which then returns the charts as image file.

Matthew continues to show the gchartrb library, which provides a Ruby interface for creating the Google Charts URLs.  This is followed by an explanation of how to use Capistrano to cache the Google Charts created charts locally.

Read "Intro to Google Charts and gchartrb".

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Thanks by Deepak Jois

Thanks for the plug! I was not very happy with my initial version of gchartrb, so I moved the project to github and made some backwards incompatible changes to it. I also added some new features that Google released recently (like text markers and new chart types like Sparklines and Radar Charts).

The API is now more Rubyish and has much cleaner code. Unfortunately I havent had time to document it and make a release. This should motivate me, hopefully :).

Re: Thanks by Matthew Bass

Excellent! The plugin is really nice. Thanks for building it.

Commercial use of Google Charts by Dean Schulze

Section 5.6 of the Terms of Service seem to prevent the use of Google charts in commercial software:

5.6 Unless you have been specifically permitted to do so in a separate agreement with Google, you agree that you will not reproduce, duplicate, copy, sell, trade or resell the Services for any purpose.

I wonder if Google gives permission to use Google Charts to commercial software vendors.

Another show stopper is section 4.3 where Google can interrupt or stop the chart service at any time. You just can't build anything reliable with terms like that.

You mentioned that we can download and serve the charts ourselves. I didn't see anything about that in the Terms of Service. Does Google make a binary available that we can use without threat of interruption?

With the terms in sections 4.3 and 5.6 this looks like it was not intended for use in commercial software.

Another example... by Lyle Johnson

Thanks for the introduction to this library, Matthew! I cooked up a quick example to show how easy it is to integrate this into an FXRuby application and blogged about it here.

Google Chart in Flex by siva prasanna kumar P

After reading this impressive article I wanted to use these charts in flex and found a way to use them, I posted that article here.


Siva Prasanna Kumar .P

Re: Commercial use of Google Charts by Matthew Bass

Dean, I take their wording as meaning that we can't directly sell the charts we generate, not that they can't be used indirectly in a commercial app. But you're right, it's not particularly clear. That's unfortunate.

Regarding Google interrupting the service, they pretty much have to put that in to protect themselves. Their overarching terms of service that cover their other apps has similar wording, but realistically, are they very likely to cut off service to Gmail, etc. without warning? Probably not.

When I mentioned serving the charts ourselves, I was referring to downloading the PNGs and putting them on a personal server. There isn't a binary available (that I know of).

problems by Rich S

Hey Deepak, nice work -- I've implemented it in my current project. Seems like one needs to "unpack" the gem in the the vendor/gems folder and then add the config.load_path to the environment.rb. If I have that correct, it would be great to add that to the documentation. Also, I found setting the title to nil in the pie chart to fail. Cheers, Rich

Re: problems by Bill Boyden

I believe the solution to requiring the gem in a rails app is simpler than what you suggest. What you add to environment.rb is

config.gem 'gchartrb', :lib => 'google_chart'

If you think about this it makes sense. You installed a gem by the name of 'gchartrb' but in order to use it in your ruby code you require 'google_chart'.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

8 Discuss