Here is a bare-bones pie chart script, useful for decorating a web page with live data from a CGI script. This works in modern browsers that support the CANVAS tag, and avoids loading Java.
Put two lines in the HEAD section of your page like so (the second line is needed to make Microsoft Internet Explorer work):
Create a chart like this:
The arguments to piechartcanvas are the ID tag of the data table, the ID tag of the canvas, an optional background color in hex, rgb(), or as a color name, and an optional flag for the data label format: label format 0 uses the label as specified; label format 1 uses "xx% label (value)". (Each ID tag should be unique in your HTML page.)
(3/18/11: When Microsoft Internet Explorer 9 came out, it didn't display the chart. One way to make it work is to change the DOCTYPE at the top of the file to
.. although this may cause issues with making the code display correctly in older browsers. I also had to make a minor change to piecanvas.js because the CANVAS tag in MSIE 9 works differently from the CANVAS tag in Firefox: in IE9, if there is text inside the CANVAS tag it is displayed after the graphic; in Firefox, text inside the CANVAS tag is treated as "fallback content" and is not displayed if the graphic is rendered. I changed the code for piechartcanvas() to hide the data table if it displayed the chart.)
Here are links to the source files. Feel free to improve on my code.