11 Dec 2005

graphing in javascript

for the last two weeks i've been working on using the canvas tag to draw graphs in firefox and safari using javascript. i'm finally ready to let people take a peek and try it out. i've creatively named it CanvasGraph.js as i haven't thought of another name that's cool like graphr or canv.as.gra.ph.ulat.or.

i've already been using it for my statistics page which doesn't actually have much statistics, only the ones i care about. but for the full scoop, i've also put up the canvasgraph page that explains the API and demos a couple of things you can do with it. here's an example from the page:

 Static Canvasgraph Example-Bar

this is actually a png, but on the demo page, you'll see it rendered in full CANVAStastic glory.

without x and y axis labels, it is a little meaningless so i'll have to explain it. the vertical axis is the number of blog posts per month, and the horizontal axis is date starting from when i first started to keep track of blog posts. liquidx.net was been around for 5 years, and i only started keep track of blog posts (we didn't used to call it blogging then) when i first began with drupal.

so you see there's a definite odd cycle of blogging going on. notice that december every year is always a low volume month, get around 10 blog posts. other interesting trends is the massive spike between 6/2004 and 9/2004, this is when i went to the princeton for a summer internship and ended up blogging about every hummer and limo i saw in the states!

also have a dip in blogging activity between 6/2003 and 7/2003, which i don't quite know why. i don't think i was on holiday then, but maybe i was occupied with something else. otherwise, i'm around a average 30 posts a month person, that is nearly 1 per day.

for the technical details there, this is just generated from a json file that in turn was generated from a text file that had the number of posts per day. the source that generated is here and also on the demo page, and as you can see, its pretty simple. you now too can plot simple pieces of data without resorting to opening excel, openoffice, gnuplot or matlab. hurray!

You can reply to me about this on Twitter: