Google Charts with Formula language

Google just released a new toy for us to play with, the Google Charts API. It really is very simple, just construct a URL in a particular way and it gives you a png file.

Lets say for example you have 12 months of sales figures in millions of pounds as below (these are not the actual Dominux sales figures)

sales:=12:15:16:18:25:30:28:42:32:35:36;

then you need to encode this by replacing the numbers with letters where A=0, B=1 etc.

valuecodes:="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
coded:=@Implode(@Transform(sales;"v";@Middle(valuecodes;v;1));"");

and now generate a url and put it in an img tag
"<img src=\"http://chart.apis.google.com/chart?cht=lc&chs=200x125&chd=s:"+coded+"\">"

so shove all that into some computed text and make it passthru html to get

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>