Pie Charts
Pie charts are a good way to see how a value represents a percentage of a whole. Each data point is a slice of a pie with a unique color. A legend associates the colors with each data point's label and value.
Since the pie chart is round, it represents a much more complex problem. PHP's image functions allow you to draw an arc or a triangle, but not a pie slice. The solution is to draw the arc at the end of the slice, then two lines that connect the center of the circle to the ends of the arc. These elements are drawn in the color of the slice and the imagefilltoborder function is used to fill the shape.
The arc itself is easy to draw, since the imagearc function will draw an arc based on starting and stopping degrees. To find the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access