Google Chart API

This is the coolest thing I’ve seen in a long time: Google Chart API.

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.

Here’s a chart that is generated on the fly:

And here’s the URL that creates it:

http://chart.apis.google.com/chart?cht=lc&chd=s:
pqokeYONOMEBAKPOQVTXZdecaZcglprqxuux393ztpoonkeggjp&chco
=FF0000&chls=4.0,3.0,0.0&chs=200Ă—125&chx
t=x,y&chxl=0:%7CJun%7CJuly%7CAug%7C1
:%7C%7C20%7C30%7C40%7C50&chf=bg,s,efefef

You’ll find more examples here.

I wonder how difficult it would be to write VBA code that analyzes an Excel chart, and then creates a Google Chart API URL to reproduce it?

(Cross-posted at J-Walk Blog)

18 Comments

  1. Somebody is working on a Web-based front end:

    http://tikirobot.net/TikiChart/

  2. Mike Woodhouse says:

    “coolest thing I’ve seen in a long time”

    Second that. Something’s gonna get written this weekend…

  3. Juan Pablo Gonzalez says:

    I’m sure Andy has it already :)

  4. I was playing around with it today. It’s definitely do-able. I’ve got it working for column and line charts. The tricky part is scaling the data so it’s converted to a 1-100 scale.

    One problem is that there seems to be no way to correctly display negative values in a column chart.

  5. Cool API. It may be the future, but I doubt it.

    I don’t know what to think about Google apps anymore. Although the stuff they build is impressive, they are either in perpetual Beta or too impractical for real-world use. I get the sense their developers get together to see what “cool stuff they can build this month”. Which is ok, but they never really make it good.

    Look at G-mail for example. Is anyone here ready to say that G-mail doesn’t suck? How long has it been out? I signed up for G-mail to get the email address I wanted. But I rarely use it now because it’s horrible. How about a folder? How about the option of not reading emails in a thread? You get the sense they built Gmail and forgot it.

    Anyway, back to the charting API. I’m sure some developers will find a way to brute force this new API into their daily lives. I’ll wait.

  6. Gmail works fine for me 98% of the time. I’ve had a few problems in the past, but it’s been very reliable for the past year or so. That said, I absolutely hate the Gmail site, and hardly ever use it. I access it via POP in Outlook Express.

    I’ve spent 5-6 hours working on this Chart API stuff, and I’m rather impressed. Except for the inexplicable lack of support for negative values in a column chart, it’s amazingly powerful and flexible. I’ve written a VBA macro that examines the active chart and creates a URL to reproduce the chart. Not sure how practical it was, but it’s fun.

  7. Jan says:

    I love gmail and use it all of the time. If you are comparing an internet app against a fat client then the app is bound to look a bit basiz but gmail is far superior to the tool we use at work and I would ttrade ours in for gmail any day.

    as for google docs it is very good, and vba is all that it is lacking. For example the array formula are easier to understand than excels and it has all the same formulas plus the google lookup formula which is great fun if a little unpredictable.

    I would tell my Grandma/non-IT person to use google apps above MS apps 9 times out of 10.

    I disagree with the comments about Google giving up on their apps. The google docs are always getting better and soon the Google Gears will change the way apps are written.

  8. ross says:

    >>I wonder how difficult it would be to write VBA code that analyzes an Excel chart, and then creates a Google Chart API URL to reproduce it?
    >>Not sure how practical it was, but it’s fun.

    Well, very neat it is John, but like you say not sure what you would do with it. Maybe to shear data over the net??? maybe? I wrote some geo-coding functions ( http://www.blog.methodsinexcel.co.uk/2007/11/12/geocoding-in-excel-using-google-maps-api/ ) which i have used and are quite usefully using a goggle API, I think the big one will be when and if they write a db app?

    [b]Mike[b], re g-mail, yeah the web part sucks, i think they tried to make it work differently, but it doesn’t work, it works well with outlook, but that just makes it a mail account so nothing special, but some of the Google stuff is totally amazing theres no 2 way about it – maps anyone?

    Re Google Docs, I think its very good from a techy pov, but as a product it totally sucks, I could not recommend it to anyone. – but it is a start…

  9. Fencliff says:

    What’s with the gmail bashing? I’ve used different web mail services for some 10 years now, and gmail is by far the best out of any I have used, free or not. I acknowledge it lacks features available in some more traditional rich apps, but it is not supposed to compete on the same market.

    Instead of folders, I use tags that keep all my mails grouped just the same. Besides, there is fairly little use for actually spending time categorizing mails, I only do it because I am anal about these things. The gmail search engine is far superior to any app, be it web or rich client, and I can find my mails multiple times faster than I do in Outlook at work.

    What matters to me is a pleasant user experience, and while the new-fangled spiff of AJAX has worn out, it still provides to be an amazingly responsive UI for a web app.

    Mike Alexander, what service would you recommend for a free web mail if gmail is such an inferior product?

  10. Fencliff: I use yahoo which provides a much richer interface with the ability to categorize and search mail, in my opinion, much better than G-mail. Also, Yahoo allows me to POP my other email accounts.

    I’m not Google bashing. I’m simply making an observation. Gmail has been out for at least 3 years now. It’s still BETA! Google tags the word “Beta” next to the Gmail logo.

    When I say Google apps go into perpetual Beta, I’m implying that Google lets its products languish in incompleteness. That may not be the case for some products, but it’s definitely the case for Gmail which has remained unchanged for at least two years now.
    The minimalist look and feel, typical of Google, feels cheap to me. The tagging system they provide feels cheap. The fact that Google Adwords shows up on the right, while I’m reading email feels cheap. When Gmail came out, it was supposed to bury Yahoo and Microsoft’s Hotmail. It’s obvious Google is not out to do that anymore.

    Google has now set its sights on the Microsoft Suite of applications. Maybe Google will take over the world with Google Docs, maybe not. I guess you could consider Google Docs a good start. I personally think Docs will be in Beta for a very long time, and Microsoft will provide a service of their own in the next year or two.

    If you want me to show Google some love, Google Maps is an extraordinary product. Google Earth is very cool. Google Gears is an interesting start to the thin client generation of apps. Well done Google! As Ross said, “some of the Google stuff is totally amazing there’s no 2 way about it”.

  11. Zach says:

    Aw, come on, Mike, you mean you’re not impressed by the color-coded tags?

    Seriously, I don’t know if anyone is as disappointed by gmail as I am. If you remember when it first was released it was by invitation only. I was not invited. But there was a “gmail lottery” web page that people would donate their invites to and you could go there and refresh the page for hours until you got one…or you could add about 40 IE controls to an Excel workbook with the window positioned so you could the little text box that would tell you if you won or not, and add a button to refresh them all at once. Then you only had to refresh for 20 minutes or so before you won one.

    Yes, I wanted one that bad. I transitioned my ISP email over thinking it’d be the last account I’d ever have. Now almost 4 years later I’m too far invested to jump ship, but it is really disappointing. Since I got a PDA phone I am even more disappointed by the fact that their mobile site is garbage and the don’t have a WM application so you have to use the crummy Java applet or hook up via IMAP. The whole thing is practically abandonware.

  12. Adam says:

    We’ve actually written a wrapper class for the Google Chart API if you click the link in my name.

  13. Tushar Mehta says:

    Google is constantly working on new applications with out-of-the-norm technologies or UIs or whatever. I find myself using more — far more — new Google-delivered technologies than new MS-delivered technologies. One classic example for me is how easy Google made it to create widgets for its custom home page, and how trivial it was to use the same widget as a seemingly standalone app on a Windows machine that had Google Desktop installed on it. By contrast, after jumping through several hoops I finally figured out how to read the requirements for how one could create a widget for Windows Live and never gave it a second thought. Not gonna happen!

    I find maps.google.com phenomenal. Nothing else even comes close to it. Not only can I find directions from point A to point B without knowing the address of either but I can even pick a particular route by simply dragging a point on the proposed route.

    As far as charts go, my first thought was I can create a Excel chart with Google charts. Embed a webbrowser ActiveX control in a Excel worksheet and create a chart in it. My next thought was I could create a richer document in the WebBrowser with iframes (or divs or spans?) and embed multiple charts in the same browser! The first I have done (single chart), the 2nd (multiple charts) I haven’t had the time to experiment with.

    As an aside, after you create a chart in the webbrowser, click on it and drag it outside the browser. You will get a static image of the chart!

    I also create (and sell) interactive management simulations for use in MBA programs and for executive education. So far, I have been restricted to column and bar charts (which can be simulated with just rectangles). Now, I can get all kinds of charts into my simulations (for reasons related to my perceived customer base, I ruled out the use of Java a long time ago).

    So, I think Google is on to yet something else that has the potential to be very interesting and useful.

  14. Jon says:

    Hi,

    I’ve also written a bit of script to build Google Charts. Let me know what you think.

    Google Charts

    Thanks!

  15. Jon, that would be MUCH more useful if you allowed the user to enter actual numbers (rather than codes), and if you scaled the values to fit better in the plot.

    I’ve written VBA code that does that, and I’d be happy to share it. Not sure what language you’re using, but you should be able to convert it very easily.

  16. rapidadverbssuck says:

    Using Excel is a great idea! Talk about making it easy and accessible for all… Someone has actually already put the API to good use, if you want to see an example of an application–it’s kind of dorky but pretty cool. Really illustrates the power and simplicity of the API. Also, the proprietary algorithm they use here is amazingly accurate! It’s at http://lovegraph.thefootnotes.com — worth checking out. By the way, love the blog, keep up the good work!

  17. rapidadverbssuck says:

    I know it’s not classy to double post, but I gave the wrong address; it’s actually: http://lovegraph.thefootnotes.net
    Sorry!

  18. MT says:

    In case someone still stumbles here, I have created a UDF which takes a range as its argument and return a URL for a chart: http://www.automateanalytics.com/2010/06/publish-excel-data-to-net-via-google.html

Posting code or formulas in your comment? Use <code> tags!

  • <code lang="vb">Block of code goes here</code>
  • <code lang="vb" inline="true">Inline code goes here</code>
  • <code>Formula goes here</code>

Leave a Reply

Here's how to update your reports of company and nearly any web data: