KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Pivot Table Formatting #3190

Open Katherine Wong opened this topic on on Nov 20, 2023 - 1 comments

Katherine Wong commented on Nov 20, 2023

Hi,

For the column that highlighted with yellow, may I know how set the formatting

"type" => "number", "decimals" => 0, "thousandSeparator" => ",", "decimalPoint" => ".", "align" => "right"

For the negative value, can it display bracket rather than sign "-" ?

Please advise.

David Winterburn commented on Nov 21, 2023

You can try PivotTable's map property to modify both the yellow (row header) and red (data) parts:

https://www.koolreport.com/docs/pivot/pivottable_and_pivotmatrix/#properties-map-(version-%3E=-5.0.0)

For the row header map, you can check $headerInfo parameter to see its field name to decide whether to format its to numeric type:

\koolreport\pivot\widgets\PivotMatrix::create(array(
    ...
    'map' => array(
        'rowHeader' => function($rowHeader, $headerInfo) {
            print_r($headerInfo); // for the first time run, print out $headerInfo to see its data structure and value
            return $v;
        }, 

For the data map, you can check if its numeric value is negative to convert.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Pivot