Thursday, November 13, 2008

It's no secret I'm a big fan of Google most developers are. I've been using the Google chart API a lot lately and thought it should get some exposure in my Blog. For those of you that follow my blog you really should be using this API. It's so darn simple and has no overhead because google takes the hit on processing!




You simply use a URL to get your chart so you're ultimately limited by the URL length and their encoding. While this wont be a full featured reporting system like Jasper or Pentaho putting quick graphs on a webpage or website is a piece of cake.


http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World





Is google's chart example and it's simple and elegant. You can use any type of code to generate your URL.


Google has a javascript code that can encode the URL with values to save space.


I wrote some PHP code (below) that you can use to encode the same type of array with PHP. This has the advantage of calling a function to encode it within your PHP page.





You should use this sort of API an in any website where you dont want (or need) to have a full blown reporting engine. Stats and metrics can easily be charted with this. Additionally when you read the full API you'll see you can also change colors, control chart types and do all sorts of neat stuff with it.


These charts look great too. Since the cost is low (Free) and the use is simple this is a great way to splash up any webpage with some simple calls to a URL. Google allow you to do 250K of these requests a day which would be a lot for most websites. A little tip too this saves on your overall badwidth on your website too. 250K requests for a 4.8K chart image is about 1.2 gig in bandwidth. So google gives you that for free too. Unless you need some high customization there is no reason you shouldn't be using this everywhere.


Happy Charting!


Recent Posts


Aptana, FTP, WebDav, PDT and Eclipse - Why cant FT...
Dynamic Query Parameters for Jasper Reports
IE8 Developer Tools
Portable Ubuntu - Take Linux With You
Quote Curling Function
Same Blog, New Look
On the fly JavaScript Packing - Speed up your site...
Super Simple AJAX Forms with jQuery and JSON : dat...
Super Simple AJAX Forms with jQuery and JSON : web...
Super Simple AJAX Forms with jQuery and JSON : Int...


Archives

01/01/2005 - 02/01/2005
02/01/2006 - 03/01/2006
03/01/2006 - 04/01/2006
04/01/2006 - 05/01/2006
05/01/2006 - 06/01/2006
09/01/2006 - 10/01/2006
10/01/2006 - 11/01/2006
11/01/2006 - 12/01/2006
12/01/2006 - 01/01/2007
04/01/2007 - 05/01/2007
05/01/2007 - 06/01/2007
01/01/2008 - 02/01/2008
02/01/2008 - 03/01/2008
05/01/2008 - 06/01/2008
06/01/2008 - 07/01/2008
08/01/2008 - 09/01/2008
09/01/2008 - 10/01/2008
11/01/2008 - 12/01/2008
12/01/2008 - 01/01/2009
01/01/2009 - 02/01/2009
02/01/2009 - 03/01/2009
04/01/2009 - 05/01/2009
05/01/2009 - 06/01/2009
07/01/2009 - 08/01/2009
01/01/2010 - 02/01/2010

My Software

Blinky - GBPVR Plugin
PhotoCopy - GBPVR Plugin
QTC - Quick Test Case
rBoop - Rob's Timers

Programming Links

C# Formatter
NSIS

Other Links

Damn Small Linux

Sites I Manage

Do it yourself SEO. Cheap.
Pet Supplies
Dog toy of the month club
SqueakerZ pet Deals
Geocaching Community
Hitch hiker Tracking