PHP code example of antoineaugusti / easyphpcharts
1. Go to this page and download the library: Download antoineaugusti/easyphpcharts 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/ */
antoineaugusti / easyphpcharts example snippets
/*
// A basic example of a pie chart
*/
$pieChart = new Chart('pie', 'examplePie');
$pieChart->set('data', array(2, 10, 16, 30, 42));
$pieChart->set('legend', array('Work', 'Eat', 'Sleep', 'Listen to music', 'Code'));
$pieChart->set('displayLegend', true);
echo $pieChart->returnFullHTML();
/*
// An example of a doughnut chart with legend in percentages
*/
$doughnutChart = new Chart('doughnut', 'exampleDoughnut');
$doughnutChart->set('data', array(2, 10, 16, 30, 42));
$doughnutChart->set('legend', array('Work', 'Eat', 'Sleep', 'Listen to music', 'Code'));
$doughnutChart->set('displayLegend', true);
$doughnutChart->set('legendIsPercentage', true);
echo $doughnutChart->returnFullHTML();
/*
// An example of a bar chart with multiple datasets
*/
$barChart = new Chart('bar', 'examplebar');
$barChart->set('data', array(array(2, 10, 16, 30, 42), array(42, 30, 16, 10, 2)));
$barChart->set('legend', array('01/01', '01/02', '01/03', '01/04', '01/05'));
// We don't to use the x-axis for the legend so we specify the name of each dataset
$barChart->set('legendData', array('Annie', 'Marc'));
$barChart->set('displayLegend', true);
echo $barChart->returnFullHTML();
/*
// An example of a radar chart
*/
$radarChart = new Chart('radar', 'exampleradar');
$radarChart->set('data', array(20, 55, 16, 30, 42));
$radarChart->set('legend', array('A', 'B', 'C', 'D', 'E'));
echo $radarChart->returnFullHTML();
/*
// An example of a polar chart
*/
$polarChart = new Chart('polar', 'examplepolar');
$polarChart->set('data', array(20, 55, 16, 30, 42));
$polarChart->set('legend', array('A', 'B', 'C', 'D', 'E'));
echo $polarChart->returnFullHTML();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.