PHP code example of phpro / zf-charts

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

    

phpro / zf-charts example snippets


return array(
    'modules' => array(
        'AssetManager',
        'Phpro\Chart',
        // other libs...
    ),
    // Other config
);

$options = new LineOptions(['animation' => false]);
$data = new LineData();
$data->setLabels(['January', 'February', 'March', 'April', 'May', 'June', 'July']);
$data->addDataset(new LineDataset([
    'label' => 'My first dataset',
    'fillColor' => 'rgba(220,220,220,0.2)',
    'strokeColor' => 'rgba(220,220,220,1)',
    'pointColor' => 'rgba(220,220,220,1)',
    'pointStrokeColor' => '#fff',
    'pointHighlightFill' => '#fff',
    'pointHighlightStroke' => 'rgba(220,220,220,1)',
    'data' => [65, 59, 80, 81, 56, 55, 40]
]));
$chart = new LineChart($options, $data);

$options = new DoughnutOptions(['animation' => false]);
$data = new DoughnutData();
$data->addDataset(new DoughnutDataset([
    'label' => 'label 1',
    'value' => 50,
    'color' => 'green',
    'highlight' => 'green',
]));
$data->addDataset(new DoughnutDataset([
    'label' => 'label 2',
    'value' => 50,
    'color' => 'red',
    'highlight' => 'red',
]));
$chart = new DoughnutChart($options, $data);

 echo $this->chartjs($this->chart, [
    'show_legend' => true,
    'width' => 900,
    'height' => 400,
]); 

curl -s https://getcomposer.org/installer | php
php composer.phar install