Google charts for Christmas

It must be Christmas, 24 Ways is opening its advent calendar doors to any web designers who care to listen. The entire site is worth a read but what caught my eye, yesterday, was an article about Google Charts and how easy it is to use to generate your own charts on the fly.

To generate your own chart, start with:

<img src="" />

which produces the following chart.

You can see that the image tag references the Google Charts API, passes it a few parameters which Google outputs as an image – Done.

The article then explains how to create, pie, bar and line graph, all by passing different parameters and values. Creating something as complex as:

<img src=",4BB74C,EE2C2C,CC3232,33FF33,66FF66,9AFF9A,C1FFC1,CCFFCC&chl=Egg+nog|Christmas+Ham|Milk+(not+including+egg+nog)|Cookies|Roast+Chestnuts|Chocolate|Various+Other+Beverages|Various+Other+Foods|Snacks&chtt=Food+and+Drink+Consumed+Christmas+2007&cht=p&chs=600x300&chd=s:KUIZFDPJF" />

Heres a summary of the parameters:

  • cht – Chart type (lc is a line chart, p is a pie chart, bhg is a bar chart etc.).
  • chs – Chart size (height and width).
  • chd – Chart data. (Tricky, Google uses simple encoding)
  • chtt – Chart title (use + in place of spaces)
  • chco – Chart Colours (use hex value, but not prefixed with # as in CSS).
  • chl – Chart labels (separate by a pipe | character)

Further Reading: Google Charts API

Where Am I?

I’ve always had a bit of an interest in maps – I have a bookshelf full of walking maps – and so any time when mapping and the web comes together I find it pretty cool. Take Geograph for example – a project aiming to collect photoraphs of every square kilometre of the British Isles – it’s interesting to look around places you’ve been and see what other people think is important enough to take photos of!

Back to what I was going to blog about! Yesterday, and I nearly missed it, Google announced that their Geocoder will support the UK. There’s been a bit of a hack using another Google service for a little while, but this time it uses the correct APIs. This is hugely significant – previously the Royal Mail, who basically own the only source of this data, have charged a lot of money. There are companies who make this data available more easily on a pay as you go basis, but it was still a significant amount if you have no income from users or advertising.

Now Google will do it for free, on the client machine using Ajax calls to their servers meaning you can pass the postcode (or placename if you don’t have much detail) and it will pass back the long/lat coordinates and a bunch of other information about the address. So well done, Google, for negotiating an affordable contract with the Royal Mail, or maybe you’re just absorbing the cost in return for locking people into your system!