Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Google Releases Chart API

Google Releases Chart API

This item in japanese

The Google team announced the release of the Chart API for dynamically generating charts for embedding in Web pages. According to Steve Crossan:
We actually built this originally to use internally - we use it on Google Video and Google Finance for example. It seemed like it would be a good thing to open up to other users too.
Plus, this is an example of the output from the "20% time" Google offer to their developers!

The API is relatively straightforward to use. For example , this|Rocks creates a two segment, 3D pie-chart in png format. Trivial to then embed in an img tag. More complex pie charts are logical extensions of this approach. The current release supports quite a nice range of different chart types, including line charts, bar charts, Venn diagrams, scatter plots; plus other effects are supported. Not bad for an initial release that was done on the teams "off" time!

As the documentation illustrates, it is very simple to embed images within html as well as JavaScript:
var simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

function simpleEncode(values,maxValue) {

var chartData = ['s:'];
for (var i = 0; i < values.length; i++) {
var currentValue = values[i];
if (!isNaN(currentValue) && currentValue >= 0) {
chartData.push(simpleEncoding.charAt(Math.round((simpleEncoding.length-1) * currentValue / maxValue)));
else {
return chartData.join('');
It's a nice, simple and yet powerful API that opens up some interesting possibilities. Being dynamic also means that there's potential for (relatively) real-time updates of information.

Rate this Article