Pie Chart

This widget function displays a pie chart whenever you call it.

Structure

showPieChart($chartTitle = "Title Of The Pie Chart", $chartData, $chartSize = "col-md-12")

Parameters

The function accepts 3 parameters that are illustrated below

  • Chart Title- This is the title of the chart

  • Chart Data- sql query, the query needs to have 2 fields to be used that is: label and value

  • Chart Size= This is a bootstrap class for chart size, default is col-md-12

Example Usage

echo showPieChart("Orders Per Year", sql("SELECT COUNT(*) AS value,YEAR(OrderDate) AS label FROM orders GROUP BY YEAR(OrderDate) ORDER BY YEAR(OrderDate) DESC", $eo), "col-md-6");

In the above chart I have passed in chart title, my sql query and size class

Output

Pie Chart Output

Last updated