Column Chart

This widget function displays a column chart whenever you call it. You can pass in multiple data sets if you wish to have multiple data sets displayed on chart.

Structure

showColumnChart($chartTitle = "Title Of The Bar Chart", $chartData, $datasetLabel, $chartSize = "col-md-12")

Parameters

The function accepts 4 parameters that are illustrated below

  • Chart Title- This is the title of the chart

  • Chart Data- An array with multiple sql queries as values, each query needs to have 2 fields to be used that is: label and value

  • Dataset Label- An array with all the labels for your datasets provided

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

Example Usage

echo showColumnChart("ORDERS SUMMARY", [sql("SELECT COUNT(*) AS value,YEAR(OrderDate) AS label FROM orders GROUP BY YEAR(OrderDate) ORDER BY YEAR(OrderDate) DESC", $eo), sql("SELECT COUNT(DISTINCT CustomerID) AS value, YEAR(OrderDate) AS label FROM orders GROUP BY YEAR(OrderDate) ORDER BY YEAR(OrderDate) DESC", $eo)], ['Total Orders', 'Total Customers'], "col-md-6");

In the above chart I have passed in only 2 queries as array values for my chart data and 2 labels as array values for my dataset label. If you wish to have a single dataset, you just provide 1 query and 1 dataset label.

Output

Column Chart Output

Last updated