A comment on my previous post prompted me to do a little digging on what Google’s Chart API is and isn’t capable of, and what I found gives me reason to worry.
I’ll preface the remainder of this post with a disclaimer: I do realize that Google is a corporation, and its ultimate goal is to make money. I’m not disputing that, nor do I find it offensive in any way. It’s the type of capitalism that this country is built on. What offends me is the pretense that they’re not a corporate giant, and that they’re giving back just for the sake of being nice.
Okay, now I’ve got that out of the way.
When I found out about the new API, my first stop was the FAQ, because I didn’t see a link to sign up for an API key. What I found instead was an interesting entry, which I hadn’t expected:
- So why is Google offering this service? What’s in it for you?
- We built the service originally as an internal tool to support rapid embedding of charts within our own applications (like Google Finance for example). We figured it would be a useful tool to open up to web developers.
This struck me as an unusually benevolent move on Google’s part, especially once I realized that there are no API keys at all. Apparently Google is just giving it away, perhaps using the HTTP Referer header (not very reliable) to keep track of how you’re doing on the 50,000 requests per day.
The trick here, however, is that I tend read the word “open” in this context, and without any modifiers, to mean that the entirety of the API had been opened up. There’s no mention of “partial” or “semi-” openness, it’s just “open”. Or so I thought. After I lamented the lack of basic features, Zellyn showed me an image with features I hadn’t seen in the API documentation. this intrigued me, so I dissected the URL for it to see what I could find.
Poking around in the URL, I found a few things I didn’t recognize from the API documentation. To better describe what it contains, here’s the chart in question (use your browser’s “View image location” or “Properties” option to see the full URL):
Here’s a breakdown of what I was able to decipher from that URL, and how it relates to the API documentation (or lack thereof, as is often the case):
cht(public) — Type (though the
lfitype used in this chart isn’t public)
chc(private) — Category
chs(public) — Size, in pixels
chd(public) — Data, using a variety of formats
chco(public) — Colors
chlr(private) — Labels (right-hand side) — why this is used instead of the recommended combination of
chxlis unknown, presumably something to do with the undocumented
chp(private) — Unknown — looks like some sort of configuration option, possibly for colorizing the labels or specifying which label corresponds to
sig(private) — Signature — used to validate the request originated from a Google service, rather than from the outside world. Having a valid signature seems to be the only way to access additional features not mentioned in the API documentation
As you can see, there are quite a few private features, and that’s just for this one type of chart. There’s no telling what might be available on the other chart types.
Since the API only supports values from 0 to 4095, Google clearly expects you to scale your data to fit within one of the scales provided. There’s good reason for this, too. If you have a financial report that graphs values in the millions, you don’t actually need millions worth of granularity just to display the graph. You can scale it down to something more reasonable, and just provide axis labels that illustrate what the real scale is like.
Unfortunately, this still doesn’t translate to the issue of negative numbers, because the axes are in fixed positions. If I had negative numbers, I could still create a chart with the appropriate shape, and supply values that indicate the true nature of the data, but the axis problem makes it look horribly counterintuitive. Consider the closest I was able to come to reproducing the graph shown above, using the public API.
This doesn’t look nearly as nice as the above graph, due in large part to the fact that the new zero line can’t be easily distinguished from the other lines. Of course, there are other issues, such as the visible axes on the left and right sides, as well as the inability to colorize individual axis labels, so I can’t pretend that the negative number issue is the only wart in even just this simple chart.
I also did some hunting on the official mailing list for the API, and I was pleased to see some active feedback from Google personnel, in the form of Uwe Maurer. He’s been doing a good job of helping people along, but I was intrigued when I saw his response here:
Please use only chart.apis.google.com to request the charts.
Clearly it’s possible for average people to generate charts using the same URL that Google services use, and Mr. Maurer’s response leads me to believe that the “official” URL doesn’t include the Referer check, so calls to that probably can’t be held to the quota.
I expect that they’ll soon update the code at that URL to explicitly require a valid signature in order to generate a chart. That would allow people to copy and paste URLs just fine, but wouldn’t allow that URL to generate new charts except for official Google services. But for now, it seems that the notion is simply to ask people to respect the documentation and only use the API’s public URL. I in know way disagree with this, I just expect (and hope) that Google won’t use this line for long, because I don’t expect it to hold up forever.
I’m always interested to examine the long-term goals of things like this, so I’ll repeat part of the FAQ question listed above, a question for Google: “What’s in it for you?” Personally, I think the
sig argument has a lot to do with it.
What they’ve done so far is open up part of their API to the public, while keeping more of it for themselves. I expect it’s only a matter of time before they start opening up the rest to paying customers, who will get their own secret key, linked to a site’s domain, which can be retrieved through the HTTP Referer header.
The signature would act much like an API key does today, except that by combining a secret with a product of the chart’s arguments, the signature will vary for each individual chart, and Google can trust that the person who generated it is a genuine customer, and that it hasn’t been modified along the way. It would no longer be possible to simply copy an API key and fake an IP and Referrer value, it would still require something extra, which only Google and its customer would know.
I may be wrong about their motivations, and I certainly don’t mind if I’m right (see the disclaimer above), but that’s the way I see it so far, anyway.
When it comes to whether Google opens the whole API, I say that’s up to them alone. I won’t stand on a soap-box and expect them to give everybody everything. What they hand out is their choice, I just hope that they document the fact that it’s not complete. I do, however, have a bit of a problem with which features they chose to release, and which they kept safely guarded.
As I’ve stated, being able to specify values below a center line, and being able to turn off axis lines would both be incredibly valuable features for a great many sites. We’ve seen that the software can do it, so Google seems to have made a conscious choice not to include them for public use. Instead, let’s examine some of the other gems they did include.
As I’ve said a few other times, the pie chart really isn’t all that great of a visualization tool. Stephen Few wrote an excellent article describing many of the flaws inherent to pie charts, and I couldn’t possibly explain it any better than he can. If you’re really curious, read it through, and subscribe to his blog.
I’m still keeping an eye on it, as I think it could still be useful. I’m just very surprised at Google is handling it so far. Maybe it’s just because it’s an early release, and things will get better. I certainly hope so, and I’ll be checking back periodically to see it improves.