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

Specify Order of Aggregates and Derived Aggregates #13

Closed codythegreat closed 3 years ago

codythegreat commented 3 years ago

Is it possible to specify the order of aggregates so that you could do something like the following?:

key: Agg = aggregate, Der = derived aggregate

| Agg1 | Der1 | Agg2 | Der2 | Agg3 | Der3 |

Currently I only know that I can do the following:

| Agg1 | Agg2 | Agg3 | Der1 | Der2 | Der3 |

If this is possible, but not currently implemented, then perhaps I could work on adding this functionality.

codythegreat commented 3 years ago

Actually I realized that I can achieve this by doing the following:

          var aggMap = {
              'agg1': {
                  aggType: 'Sum',
                  arguments: ['VALUE_1'],
                  name: 'NAME_1',
                  varName :'a',
                  hidden : true,
                  renderEnhancement : 'heatmap'
              },
    .   .   .
              'aggN': {
                  aggType: 'Sum',
                  arguments: ['VALUE_N'],
                  name: 'NAME_N',
                  varName :'b',
                  hidden : true,
                  renderEnhancement : 'heatmap'
              },
            };

So everything in aggMap is hidden, then I can define all of my columns inside of derivedAggregates in whatever order I like:

          var derivedAggregations = [
              {
                  name : 'NAME_1',
                  description : 'DESC_1',
                  expression : 'EXPRESSION',
                  renderEnhancement : 'heatmap'
              },
    .   .   .
              {
                  name : 'NAME_N',
                  description : 'DESC_N',
                  expression : 'EXPRESSION',
                  renderEnhancement : 'heatmap'
              }, 
            ] 

Hopefully this can help anyone who wants to achieve similar functionality.