PHP code example of diagro / lib_php_chart

1. Go to this page and download the library: Download diagro/lib_php_chart 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/ */

    

diagro / lib_php_chart example snippets


public function register()
{
	$this->app->singleton('charts', \Diagro\Chart\Manager::class);
}

Blade::stringable(\Diagro\Chart\Chart::class, function($chart) {
    return app('charts')->render($chart->id);
});

$chart = new Chart('messages_per_time', Chart::TYPE_BAR);
$chart->labels = array_keys($per_datetime);
$chart->datasets[0] = new \Diagro\Chart\Datasets\Bar('Aantal per tijdstip');
$chart->datasets[0]->data = array_values($per_datetime);
$chart->datasets[0]->background_color = [
	new \Diagro\Chart\Color\RGBA(255,99,132,0.2),
	new \Diagro\Chart\Color\RGBA(54,162,235,0.2)
];
$chart->datasets[0]->border_color = [
	new \Diagro\Chart\Color\RGBA(255,99,132,1),
	new \Diagro\Chart\Color\RGBA(54,162,235,1)
];
$chart->datasets[0]->border_width = 1;

$chart->options->plugins->legend->display = false;