pranjal-goswami / multifact-pivottable

A JavaScript plugin for PivotTable.js. It renders multiple aggregations simultaneously with added configurations for rendering beautiful tables http://pranjalgoswami.in/multifact-pivottable/examples/index.html
MIT License
18 stars 13 forks source link

Custom aggregator formater #20

Open security-database opened 10 months ago

security-database commented 10 months ago

Hello

I'm pretty new with pivottable.js and multifact. Guys you are awesome! I'm trying to achieve a simple things, use a custom formatter with multifact.

With Pivottable.js i use this: I's pretty simple and display 0 to - and i use this to display -1000 to (1000)

<script type="text/javascript">
$(function(){

    var fmt = function(n) { 
            if (n == "" || n == null) { 
                return '-';
            } else {
                return n.toLocaleString('en-US')
            }
    }

    var tpl = $.pivotUtilities.aggregatorTemplates;

    $("#output").pivotUI(
        [
            {Amou:0, Fund:'XXXX',T:'Projected', D:'2022/11/01'},
            {Amou:100, Fund:'XXXX',T:'Projected', D:'2022/11/01'},
            {Amou:0, Fund:'YYYY',T:'Projected', D:'2022/11/01'}
        ],
        {
            rows: ["T"],
            cols: ["Fund"],
            aggregators: {
                    "X":
                        function() { 
                            return tpl.sum(fmt)(["Amou"])
                        },
                },
        }, true)

    });
    </script>

But when using aggMap or any derivated multifactAggregatorGenerator i'm stuck. Where i can use a function to be able to custom my display ?

Thanks a lot, your work is awesome !