Google Chart API Review
Posted by Jon Beattie January 3rd, 2008Turning data into pretty charts and graphs has never been an easy task for web developers. For some reason, this has never been a standard part of any of the major web frameworks. We have always had to buy third party software or more recently leverage a reporting system like Crystal or Microsoft Reporting Services.
Google has recently launched another free API (Application Programming Interface) called Google Chart.
The following types of charts are available:
What makes Google Chart so notably is that it is very, very easy to implement. All you need to do is pass a URL to their servers and it will return you a PNG image.
Take a look at this sample 3D pie chart I have created:
In code this looks like just an HTML image tag, no web service calls, nothing tricky whatsoever:
<img src=" http://chart.apis.google.com/chart? cht=p3 &chd=s:ZB &chs=480x200 &chl=Yes|No &chtt=Is Google Charts The Easiest Charting Solution?" alt="Sample 3D Pie chart" />
Let’s break this down to explain the URL format in more detail:
<img src=" http://chart.apis.google.com/chart? URL to the Google Chart server cht=p3 Type of chart, in this case 3D Pie &chd=s:ZB Type of data. I've used Simple Encoding where Z = 25 and B = 1 which is suitable for simple charts. Text and Extended encoding are also available. &chs=480x200 Size of the chart in pixels. In this case 480 pixels wide by 200 pixels high &chl=Yes|No Labels separated by the pipe character | &chtt=Is Google Charts The Easiest Charting Solution? Optional chart title "alt="Sample 3D Pie chart" />
This is a very simple example, but this does scale to quite complex charts with larger data sets, and you have the ability to customise the colours. It wouldn’t be that difficult to turn this into a server side .NET control that would allow you to just pass the variables to a function and let it render the correct URL for your requirements.
The ease of use and the fact that it is free must make this a viable option for all but the most complex charting and graphing requirements.
Technorati Tags: google, googlechart, webdev
Categories: Development, Technology, Web 2.0






