How to display a Google Pie Chart with PHP
Pie charts are a great way to display data in an appealing manner. Google charts are easy to implement and offer the user a colorful, interactive experience. The user can hover over sections of the chart to reveal specifics. The following example shows how to render a very simple Google donut style pie chart with two simple values. Our chart will show loan balance amount and loan paid amount effectively displaying the progress made against the loan.
Google offers a variety of charts each with the ability to customize the colors, values, sizes, etc. Reference Google Charts for more information.
For the purpose of this post, we’re going to display a very simple donut pie chart.
Before we display the chart we display a table of information showing the original loan amount, the amount paid, and the balance remaining. We then follow that up with an attractive donut pie chart in green and blue. We can control the size of the chart by adding height and width settings to a div that contains the chart. In our case, we’ve set the container to 400 x 400 pixels. In our example, we’ve hard-coded the values for simplicity. You would likely pull these from a database.