Submit Your Site For Free!

Email Address:
* URL:
*
*Indicates Mandatory Field

Terms & Conditions

ClicksToday
SearchNewz
SEOarticles











Google's Chart Serving API

By Nathan Weinberg
Expert Author
Article Date: 2007-12-10

Google has this really cool new API that you can use to generate charts. By simply including parameters in a URL, you get a chart image with the chart coming out as whatever type and values you need.

The basic URL format is http://chart.apis.google.com/chart?cht=p3&chd=t:90,49&chs=350x150&chl=Foo|Bar, and you change it up by altering some of the parameters.

There are five types of charts:

Line (by changing cht= to lc):



That creates a chart with only x values for each point on the line. You can create more than one line, and each point is evenly spaced. If you need points that are not evenly spaced and have both x and y values, use lxy instead of lc, like so:



Next up are bar charts, by changing the parameter to bhs for a horizontal bar chart and bvs for a vertical bar chart, plus chco= for the chart colors. Examples:





There are also non-stacked side-by-side bars, and different bar widths.

You can also make pie charts, with p, or p3 for 3D pie chart. Take a look:





Plus you can get a Venn diagram with the v chart type. What's a Venn diagram? This:



And finally, scatter plots, with the s chart type:



There are so many ways you can mess with the code, including colors, background fill colors,





Background linear gradients,



Background linear stripes,

Chart titles,



Chart legends,



Different line styles,



and much more. This is really an amazing and capable API. Publishers and app creators should examine all the cool ways they can use this to create amazing charts for their sites. Sadly, it is limited to only 50,000 uses per site per day (and I'm sure the images in this post will stop working after a while). I'm pretty sure someone can figure out how to use Ionut's image caching Google Gadget and wrap it around your chart to limit gadget API calls, so let me know. Otherwise, use the API to get the chart, then cache it on your server.

If this sounds like something you'd be interested in using for your site, read the documentation to get started.

Comments

About the Author:
Nathan Weinberg writes the popular InsideGoogle blog, offering the latest news and insights about Google and search engines.

Visit the InsideGoogle blog.




Newsletter Archive | Article Archive | Submit Article | Advertising Information | About Us | Contact