An unofficial blog that watches Google's attempts to move your operating system online since 2005. Not affiliated with Google.

Send your tips to

December 6, 2007

Dynamically Generated Charts

I've always wondered what's behind, the strange directory used by Google to dynamically generate charts. They use this charts at Google Video to show stats like this one (if you're brave, look at the image location):

The problem is that Google also adds a hash to the URL so you can't play around with the parameters and create your own charts. But now there's Google Chart API, a way to make these charts available to everyone.

"The Google Chart API returns a PNG-format image in response to a URL. Several types of image can be generated: line, bar, and pie charts for example. For each image type you can specify attributes such as size, colors, and labels. You can include a Chart API image in a webpage by embedding a URL within an <img> tag. When the webpage is displayed in a browser the Chart API renders the image within the page."

All these charts can be created dynamically by building some admittedly complicated URLs.

Let's look at the 3D pie chart's URL:|B|C|D

cht indicates the chart type, chd provides the plotted data that's encoded using letters and digits (for example, U represents 20, f - 31, 9 - 61, a - 26), chs is used for chart's size, while chl separates labels using the pipe character.

This is a great way to create simple charts programmatically and I'm sure many web apps will use them. The query limit of 50,000 queries per user per day is more than sufficient.

Update: It seems that the limit is not that generous. "The user is the webpage that links to the chart. We would like to make sure that all users get their charts fast and reliably. Therefore we may temporarily block users (websites) that exceed the limit. A chart request is not counted if the chart image is cached by the browser or by a proxy," clarified Uwe Maurer from Google Z├╝rich.

This blog is not affiliated with Google.