Having recently discovered how to produce bar charts from SharePoint data we have been getting requests for Pie Charts. Bar charts are no great shakes, just an XSLT stylesheet controlling the relative width of two cells in a table, one with a coloured background and one with a transparent background, pie charts are altogether more complex (unless you have MOSS and so Excel services, but we don't).
Initially we found an article on EndUserSharePoint on how to do this using a service from Google. This works well but has the disadvantage that the data has to be sent to Google's servers which then return the piechart so the user has to be connected to the internet and there's a chance of data leakage.
What caught us out the second time around is line 71 which sets the value of the variable chartkeyword. Set this to the name of the field you are grouping by in the view.
Paste the resulting code into the Content Editor Web Part (use Code view) the original blog told you to put on the page, making sure to put it between the <![CDATA and ]] tags. You should be ready to go and able to view the pie chart in IE.
We found that initially after pasting in the code Sharepoint Designer 2007 crashed when we clicked back in the Display pane. If this happens to you see if Microsoft Office Diagnostics starts up and if it does let it run and fix your installation. This happened on 3 different machines so we figure there was some patch or fix that was missing (or possibly it was because we had Sharepoint Designer 2007 installed along side Office 2003 an there was some library mismatch). If Microsoft Office Diagnostics doesn't start up make sure you're got the latest patchsets for SharePoint Designer 2007.
The question we're looking at now is if we can control the colours of the pie chart segments. A number of the lists we're looking to have pie chart views on are for things that have colour coded statuses and that's what we want to display (how many red, how many amber and how many green).
This could be really cool and useful.