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;
        },
    ),
    ...
));



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