O'Reilly logo

Core PHP Programming: Using PHP to Build Dynamic Web Sites by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required