Pie chart display

Hello, I’m trying to work out a method of displaying a pie chart depending on the values in an array by looping for a different value of $i, here’s what I have so far:

for($i = 0; $i < 11; $i++)
$colour = $i;
$fraction = ($pie_data[$i]/$total);
$pie_angle = $fraction*360;
ImageFilledArc($myImage, 100, 100, 200, 180, STARTANGLE, ENDANGLE, $colour, IMG_ARC_PIE);

As you can see I’ve got fractions, which I’m converting into an angle. However, I can’t think of a way to have the startangle and endangle parameters of the ImageFilledArc function depend on all of the previous pie angles, because currently the only thing I can do is have all of the wedges begin from the same angle, which does not look much like a pie chart. Can anybody help with this?

Thank you so much for your help, if any clarification is needed please tell me.

Hi there,

I haven’t done much with with ImageFilledArc in the gdlib, but if you post the rest of the code so i can emulate the whole set of code I’d be more than happy to learn my way around it and try to help you in the process!

Look forward to hearing from you.

Sponsor our Newsletter | Privacy Policy | Terms of Service