I found this website really helpful http://yuiblog.com/sandbox/yui/3.3.0pr3/examples/charts/charts-pie.html
But I had to download the supporting script from http://yuiblog.com/sandbox/yui/3.3.0pr3/build/yui/yui-min.js , save it the directory and then use $PAGE->requires->js('/yui-min.js', true); on the pages I was using it. Although having looked now, I see it is there in moodle\lib\yui\3.2.0\build\yui so maybe I should have used that. It had to be included in the php script either way, whereas some other YUI scripts, such as to create tabs and auto-scrolling content, seemed to work without this.
Before i started working with YUI3, I used a modified version of moodle\mod\quiz\report\overview\overviewgraph.php which uses the graphlib that Tim mentions - to build graphs that I wanted, e.g. to plot the times taken to complete quizzes, but YUI is probably the easier way to go and creates dynamic content rather than just generating an image.
The one thing that is incredibly conspicuous by its absence is labeling of axes! I would expect this to be a parameter of any graphing function, yet it doesn't look like there's any way for this to be produced within the graph itself.
I've had to use CSS to add labels around the graph - there must be a better way?