QA

Q&A

Q

How do I use dynamic data to create the slices of a pie chart?

A

When creating any image, the start points and drawing lengths do not need to be statically indicatedthey can be variables whose values are determined by a database, user input, or calculations within the script. For example, this code creates a red, filled arc of 90°:

ImageFilledArc($myImage, 50, 50, 100, 50, 0, 90, $red, IMG_ARC_PIE);

You could set this up so that the red filled arc at the top of the pie will hold the percentage of the total for May Sales in a variable called $may_sales_pct. The line then becomes something like this: