Google Chart API

by Marty Alchin on December 7, 2007 about Django and numbers

So, I was surprised to see my news this morning, when information aesthetics spread the news of the new Google Chart API. Looks like they’ve been reading my blog, and they decided to save me the trouble of installing matplotlib or anything.

It’s not interactive, which still makes Dojo charting a very useful alternative, but it’s good to have a quick, easy API for just embedded charts for simple data. As an example, here’s a chart of the number of visits this site got during the first 12 days of National Blog Posting Month:

Unfortunately, I can’t show stats for the whole month, because I simply don’t have them. I must’ve screwed up my template somehow, because the urchin tracker disappeared at some point, so from the 13th on, all my stats flatlined. I suppose I could represent that on the chart, but it would make me sad.

The lowdown

It’s missing a number of features I would like, but for an initial offering of a free service, it’s pretty well stocked. It’s got a variety of graph types available, including line, bar, scatter and the infamous pie. It supports axis labels, including labels on the top and/or right sides of a chart, and even multiple sets of labels per axis, which can be used (as shown above) to give an overall title to a horizontal axis. It can technically be done for vertical axes as well, but it doesn’t rotate, so it looks a little weird compared to traditional charts. Colors are fully configurable, which is especially useful when including multiple data sets, which is also supported.

Unfortunately, I was shocked, horrified and moderately surprised to see that nowhere is there any mention of how to encode negative numbers. Google, I appreciate you trying to help, and I understand that this grew out of needs for Google Finance, where stock prices can never dip below zero. But there’s really not that much data out there in the real world that always exists solely above the origin. This limitation alone puts me into a wait-and-see mode, because if Google doesn’t do something about it soon, there’s not much real-world value in the service.

One other particular feature I was hoping for, and was sadly lacking, is the ability to turn off axis lines entirely. Given the ability to create a simple line graph at small image sizes, this API would be immensely useful in the generation of sparklines. A simple Django template tag could generate a sparkline-type chart inline in a template, and many complex tables could be quickly made much more reasonable to interpret.

Of course, in the shadow of the negative number problem, this one is quite trivial:

Finally, a decent use for pie charts.


I’ll definitely be keeping my eye on this. It’d be a great way to embed simple graphs in blog posts, if nothing else, so it’s certainly worth learning. But if Google gets just those two features included, this could actually be quite a powerful service.