PivotTable's and PivotMatrix's Map

Mapping fields, headers and data cells


PivotTable::create(array(
    ...
    'map' => array(
        'dataField' => function($dataField, $fieldInfo) {
            $v = $dataField;
            if ($v === 'dollar_sales - sum')
                $v = 'Sales (in USD)';
            else if ($v === 'dollar_sales - count')
                $v = 'Number of Sales';
            else if ($v === 'dollar_sales - avg')
                $v = 'Sales Average';
            return $v;
        },
    ),
    ...
));



PivotTable::create(array(
    ...
    'map' => array(
        'dataFieldZone' => function($dataFields) {
            return implode("__", $dataFields);
        },
    ),
    ...
));



PivotMatrix::create(array(
    ...
    'map' => array(
        'rowField' => function($rowField, $fieldInfo) {
            $v = $dataField;
            if ($v === 'customerName')
                $v = 'Customer';
            else if ($v === 'productLine')
                $v = 'Category';
            else if ($v === 'productName')
                $v = 'Product';
            return $v;
        },
        'columnField' => function($colField, $fieldInfo) {
            $v = $dataField;
            if ($v === 'orderYear')
                $v = 'Year';
            else if ($v === 'orderMonth')
                $v = 'Month';
            return $v;
        },
    ),
    ...
));
 
  dollar_sales - sum  
  Year   orderQuarter  
  Customer   Category   Product  
2004
2005
Total
Total
Total
AV Stores, Co.
Total
Amica Models & Co.
Total
Anna's Decorations, Ltd
Total
Alpha Cognac
Total
Atelier graphique
Total
Total
$99,984
-
$99,984
$82,223
-
$82,223
-
$56,932
$56,932
-
$12,432
$12,432
$7,743
-
$7,743
$189,951
$69,365
$259,315
Page size:
Description