PivotMatrix with server paging

When there are a lot of rows it's faster for PivotMatrix to use server paging to reduce rendering time

  Month   Day  
  Total Sales  
  Year  
  Customer   Category   Product  
Year 2003
Year 2004
Year 2005
All
AV Stores, Co.
Classic Cars
1949 Jaguar XK 120
1952 Citroen-15CV
1957 Ford Thunderbird
1965 Aston Martin DB5
1966 Shelby Cobra 427 S/C
1969 Chevrolet Camaro Z28
1969 Corvair Monza
1969 Ford Falcon
1970 Chevy Chevelle SS 454
1970 Triumph Spitfire
$3,556
$3,296
$0
$6,852
$5,186
$4,754
$0
$9,940
$2,604
$1,482
$0
$4,086
$4,374
$0
$0
$4,374
$1,255
$946
$0
$2,201
$2,173
$3,506
$0
$5,679
$0
$4,931
$0
$4,931
$0
$2,907
$0
$2,907
$2,593
$1,420
$0
$4,013
$0
$2,907
$0
$2,907
Page size:

When there are a lot of rows it's faster for PivotMatrix to use server paging to reduce rendering time:

<?php
PivotMatrix::create(array(
    ...
    "serverPaging" => true,
    ...
));
<?php
require_once "CustomersYears.php";
$CustomersYears = new CustomersYears;
$CustomersYears->run()->render();
?>    
<?php
require_once "../../../load.koolreport.php";
use \koolreport\processes\Filter;
use \koolreport\processes\ColumnMeta;
use \koolreport\pivot\processes\Pivot;

class CustomersYears extends koolreport\KoolReport
{
    function settings()
    {
        return array(
            "dataSources" => array(
                "dollarsales"=>array(
                    'filePath' => '../../../databases/customer_product_dollarsales2.csv',
                    'fieldSeparator' => ';',
                    'class' => "\koolreport\datasources\CSVDataSource"      
                ), 
            )
        );
    }
    function setup()
    {
        $this->src('dollarsales')
        // ->pipe(new Filter(array(
        //     array('customerName', 'startsWith', 'a'),
        //     array('orderDate', '>', 2003),
        // )))
        ->pipe(new ColumnMeta(array(
            "dollar_sales"=>array(
                'type' => 'number',
                "prefix" => "$",
            ),
        )))
        ->pipe(new Pivot(array(
            "dimensions"=>array(
                "column" => "orderYear",
                "row" => "customerName, productLine, productName",
            ),
            "aggregates"=>array(
                "sum"=>"dollar_sales",
            )
        )))
        ->pipe($this->dataStore('sales'));  
    }
}
<?php
        use \koolreport\pivot\widgets\PivotMatrix;
        use \koolreport\core\Utility;
        use \koolreport\processes\Filter;
        use \koolreport\processes\ColumnMeta;
        use \koolreport\pivot\processes\Pivot;
        use \koolreport\instant\Widget;
        use \koolreport\datasources\CSVDataSource;
?>

<div class="report-content">  
    <div class="text-center">
        <h1>PivotMatrix with server paging</h1>
        <p class="lead">When there are a lot of rows it's faster for PivotMatrix to use server paging to reduce rendering time 
        </p>
    </div>
    
    <form id='form1' class="form-inline" method="post">

        <?php
        PivotMatrix::create(array(
            "id" => "pivotMatrix1",
            'dataSource' => $this->dataStore('sales'),
            "serverPaging" => true,
            // 'rowCollapseLevels' => array(0),
            'width' => '100%',
            // 'height' => '500px',
            'headerMap' => function($v, $f) {
                switch ($v) {
                    case 'dollar_sales - sum': return 'Total Sales';
                    case 'dollar_sales - count': return 'Number of Sales';
                    case 'dollar_sales - avg': return 'Average Sales';
                    case 'orderYear': return 'Year';
                    case 'orderMonth': return 'Month';
                    case 'orderDay': return 'Day';
                    case 'customerName': return 'Customer';
                    case 'productLine': return 'Category';
                    case 'productName': return 'Product';
                }
                $r = $v;
                if ($f === 'orderYear')
                    $r = 'Year ' . $v;
                $map = array(
                    '1' => 'January',
                    '2' => 'February',
                    '3' => 'March',
                    '4' => 'April',
                    '5' => 'May',
                    '6' => 'June',
                    '7' => 'July',
                    '8' => 'August',
                    '9' => 'September',
                    '10' => 'October',
                    '11' => 'November',
                    '12' => 'December',
                );
                if ($f === 'orderMonth')
                    $r = $map[$v];
                return $r;
            },
            'totalName' => 'All',
            'waitingFields' => array(
                'orderMonth' => 'label',
                'orderDay' => 'label',
            ),
            'paging' => array(
                'size' => 10,
                'maxDisplayedPages' => 5,
                'sizeSelect' => array(5, 10, 20, 50, 100)
            )
        ));
        ?>
    </form>
</div>
customerNameproductNameproductLineorderDateorderDayorderMonthorderYearorderQuarterdollar_sales
Vitachrome Inc. 1937 Lincoln Berline Vintage Cars 2003-01-10 00:00:00 10 1 2003 1 3726.45
Vitachrome Inc. 1936 Mercedes-Benz 500K Special Roadster Vintage Cars 2003-01-10 00:00:00 10 1 2003 1 1768.3300000000002
Baane Mini Imports 1952 Alpine Renault 1300 Classic Cars 2003-01-29 00:00:00 29 1 2003 1 5571.8
Baane Mini Imports 1962 LanciaA Delta 16V Classic Cars 2003-01-29 00:00:00 29 1 2003 1 5026.14
Baane Mini Imports 1958 Setra Bus Trucks and Buses 2003-01-29 00:00:00 29 1 2003 1 3284.28
Baane Mini Imports 1940 Ford Pickup Truck Trucks and Buses 2003-01-29 00:00:00 29 1 2003 1 3307.5
Baane Mini Imports 1926 Ford Fire Engine Trucks and Buses 2003-01-29 00:00:00 29 1 2003 1 1283.48
Baane Mini Imports 1913 Ford Model T Speedster Vintage Cars 2003-01-29 00:00:00 29 1 2003 1 2489.13
Baane Mini Imports 1934 Ford V8 Coupe Vintage Cars 2003-01-29 00:00:00 29 1 2003 1 2164.4
Baane Mini Imports 18th Century Vintage Horse Carriage Vintage Cars 2003-01-29 00:00:00 29 1 2003 1 2173

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport Get KoolReport Pro