Blog

Home/Websevices/Api/Using Google Chart API in your website

Using Google Chart API in your website

Charts are useful and more informative way of representing data in a website. There are many commercial and opensource components and libraries available to implement charts in a website. Most of them are flash based and very attractive. There may be cases where you don’t want or can’t use flash based charts. So what are the alternatives? Write your own library using gd or any other image manipulation library or Use Google Chart API. Yes, google chart api is here to rescue you from all the tedious coding you will do to create your own library.

Google Chart API is simple and easy to implement and produces nifty chart in your website with the data you supplied to the API. The API generates a PNG-format image in response to a url. The API generates different kinds of Charts like bar, line, pie, 3D pie and that too in different color and sizes. isn’t that cool?

As already mentioned the google chart API is simple and easy to implement. (Read more about the chart API at http://code.google.com/apis/chart/) You just need to form a url in following format and send it to google.

http://chart.apis.google.com/chart? & &

e.g. http://chart.apis.google.com/chart?chs=350x150&chd=t:70,30&cht=p3&chl=Joomla|Drupal

Yes generating chart is that simple. Just copy the above example and see for yourself. Now let me explain the chart parameters.

http://chart.apis.google.com/chart? is the Chart API’s location.
& separates parameters.
chs=350x150 is the chart’s size in pixels.
chd=t:70,30 is the chart’s data.
cht=p3 is the chart’s type.
chl=Joomla|Drupal is the chart’s label.

You must at least provide chs, chd, cht parameters to the API. Now let us discuss some variations of  parameters

To know more about the Google Chart API, refer to google code at http://code.google.com/apis/chart/. The API docs provides all the information on how to use the Chart API in your website.

Happy Reading!

http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/digg_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/reddit_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/delicious_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/blogmarks_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/google_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/myspace_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/facebook_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/yahoobuzz_32.png http://www.sanjeevshrestha.com.np/wp-content/plugins/sociofluid/images/twitter_32.png

Written by

Sanjeev is opensource enthusiast and loves to work with Joomla. He is co-founder of Alchemist Pvt Ltd, A multi disciplinary Development Studio based out of Kathmandu, Nepal. He loves to read and sometimes blog about technology

Leave a Comment