PHP code example of koolreport / statistics

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

    

koolreport / statistics example snippets



//MyReport.php
use \koolreport\statistics\Statistics;

class MyReport extends \koolreport\KoolReport
{
    ...
    function setup()
    {
        $this->src('sales')
        ->pipe(new Statistics(array(
            'min' => array('2003'),
            'max' => array('2003'),
            'mean' => array('2003', '2004'),
            'median' => array('2003', '2004', '{{all}}'),
            'lowerQuartile' => array('2005'),
            'upperQuartile' => array('2005'),
            'meanDeviation' => array('{{all}}'),
            'stdDeviation' => array('{{all}}'),
            'percentile_10' => array('{{all}}'),
            'percentile_90' => array('{{all}}'),
        )))
        ->pipe($this->dataStore('salesYearMonthStatistics'));
    }
}


    //MyReport.view.php:
    use \koolreport\statistics\StatisticsReader;
    
    $stats = StatisticsReader::read($this->dataStore('salesYearMonthStatistics'));

    echo $stats['min']['2003'];
    echo $stats['median']['2004'];
    echo $stats['percentile_90']['{{all}}'];