Activate your free membership today | Log-in

Tuesday, February 5th, 2008

Canvas Pie Chart from datatable

Category: Canvas, Unobtrusive JS

I love it when a plan comes together (removes cigar): After I played with Google charts and porting the idea of generating charts from accessible table data over to YUI charts Stoyan Stevanof had to use the same idea to generate his own, home-made Canvas-driven charts:

Example chart generated from a data table using canvas

His solution shows in a few lines not only how to get the data from a table, but also how to do a pie chart in canvas.

Posted by Chris Heilmann at 1:24 pm

+++--
3.4 rating from 16 votes

5 Comments »

Comments feed TrackBack URI

Fu*k IE. Really. This lil code block is beautiful and works in Opera, FF, and Safari. To get it to work in IE, you’ll have to double the amount of code.

Comment by emehrkay — February 5, 2008

Chris is being modest by not plugging the book to which he contributed, but I’m happy to — Cameron Adams has written a chapter on creating pie charts with canvas in The Art & Science of JavaScript, published by SitePoint. It covers using to get the ExplorerCanvas script, which converts your code to VML for IE. Without any extra code.

Comment by mattymcg — February 5, 2008

More than a year ago I did piechart without canvas or Flash. Just pure HTML, CSS & JavaScript: Piechart. To do it in canvas is too easy. :)

Comment by DmitryBaranovskiy — February 5, 2008

I made an AJAX GUI for the google charts API. It works ok but it needs more development to be honest. It doesn’t yet include every feature of the API. Google Charts

Comment by JonWinstanley — February 6, 2008

I’ve wrapped up a rough JQuery plugin around this, in case someone is interested: http://blogs.atalayasec.org/dev/?p=9

Comment by drvillo — February 7, 2008

Leave a comment

You must be logged in to post a comment.