PHP code example of vichaunter / chartjs
1. Go to this page and download the library: Download vichaunter/chartjs library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vichaunter / chartjs example snippets
`
$statsByDate = Customers::getDataList(); //in this case return [total,day]
$barChart = new BarChart();
$barChartData = $barChart->getData();
// $barChartOptions = $barChart->getOptions(); // you can configure colors, sizes, etc.
$barChartDataset = $barChartData->newDataset();
foreach($statsByDay as $day){
$barChartData->addLabel($day['date']);
$barChartDataset->setLabel('Label for legend for this dataset color')->addData($day['total']);
}
$barChartHtmlCanvas = $barChart->getHtmlCanvas();
$barChartHtmlScript = $barChart->getHtmlScript();