Google is offering a new API to dynamically generate charts in PNG files, and it’s easy to use. So you may come back here in a week and find I’ve randomly generated charts and stuck them in everywhere. The documentation for the chart tool is available at http://code.google.com/apis/chart/ .
You generate the chart by adding things to a URL. You start here:
http://chart.apis.google.com/chart?
To this you add your parameters, separating them with ampersands. They’re at the URL in the first paragraph, but for a basic chart you only need a few:
cht= — Chart type. You can specify one of several chart types including line, bar, scatter, and pie.
chd= — Chart data. There are three different ways to encode the chart data, depending on what you’re trying to do. This is probably the most complicated part of the chart.
chs= — Chart size, specified by width in pixels by height in pixels. The maximum size of a chart is 300,000 pixels.
If I wanted to generate a 200×200 (pixel) line chart with two sets of data, the URL would look like this:
http://chart.apis.google.com/chart?cht=lc&chs=200×200&chd=t:3,8,33,1|70,6,4,2
and the image itself would look like this:
Of course, there’s not much information in this chart. You can add a lot of additional items to the URL like chart title, legend, and axis labels (depending on what kind of chart you’re creating, of course.) You can also add colors to the chart, format the text, and so on. (There are a lot of options here. There are so many options I’m kind of jealous when I consider creating charts in Google Spreadsheet.)
Aside from size, the only limit to the chart generator is the number of times you can use it per day — and at the moment that limit is 50,000. (Since no key is required to use the chart, I’m guessing that Google is going by IP address. There’s a very brief FAQ for the service at http://code.google.com/support/bin/topic.py?topic=13605 .
Categories: News