Content with Style

Web Technique

My take on jQuery charts

by Pascal Opitz on February 28 2009, 20:24

A while back I did a couple of posts touching the subject HTML 5 and the canvas tag. Of course I have been tinkering around with chart drawing APIs and so on, and couldn't help to write a little script myself.

I started out with pie charts, and essentially did a mashup between Jon Combes approach and Advanced Canvas Based Pie Chart by Matthew Knott, then wrapped a JQuery plugin around it.

Later I added some sidebar charts, which were much simpler to do and don't require to understand the fact that javascript does trigonometric functions in radians rather than degrees, a fact that made my brain boil when I tried to add in the labels, because I was expecting different numbers to come back from my calculations ...

I was keen on passing the chart values in as array, so I could gather data from an HTML table with a couple of lines of JS, for example. I left this out in the little demo that I mocked up, which I uploaded as a zip file as well, but I am sure you guys figure what I mean.

The whole thing is nothing new, and Plotkit or Bluff are way more advanced, but I think it's a nice little demo to read and understand, without being overwhelmed by large files of code. So I hope you enjoy it.

Comments

  • Dear Pascal, thanks for the Information, for us helpfull. Greatings from good old GERMANY. TOM

    by Reisekrankenversicherung on July 22 2009, 14:56 #

  • hello Thank u very much for the file u have uploded. It was very helpful for. I'm a java developper but beginner in javascript. With the java chart libary jfeeChart, I was able to display different charts with the results of database query or other data but I had no idea how to add some sidebar charts in my HTML site. I succeeded to get the code running.That is amazing.

    by Flug on March 9 2009, 17:16 #

  • Hey, thanks for the mention. Great bit of code!

    by Matthew Knott on May 12 2009, 09:32 #

  • Charting is one of those things which ought to be simple, but is still quite disjointed and messy on the web. I am really keen to see someone develop a charting solution which is standards compliant, easy to work with, flexible and open for everyone to use for free and does not require anything other than standard technologies which we all love to use. Linked to you just now by the way.

    by Jason Grant on April 9 2009, 12:00 #