Then why are you here asking for help if you want to do it yourself without accepting the help given?
The point I am making here is that you can download the JPGraph app, and pick it apart to see how they are making their pie chart... or just use their app, and don't reinvent the wheel...
Bah, I will bow out gracefully now, and let you dig into the manual's [man]image[/man] functions... Good Luck with it.