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

agg is not a function #4

Open sam123evers opened 4 years ago

sam123evers commented 4 years ago

Hello!

I'm trying to set up the library and I am getting this error

Uncaught TypeError: agg is not a function                                                 at multifact-pivottable.js:37

What does this mean?

my code:


var aggMap = {
     'agg1': {
             aggType: 'Sum',
             arguments: ['plannedHours'],
             name: 'Sum of Planned',
             varName: 'a',
             renderEnhancement: 'barchart'
     },
     'agg2': {
              aggType: 'Sum',
              arguments: ['scheduledHours'],
              name: 'Sum',
              varName: 'b',
              hidden: false,
              renderEnhancement: 'none'
      },
      'agg3': {
               aggType: 'SumOverSum',
               arguments: ['scheduledHours', 'plannedHours'],
               name: 'Plan vs Schedule',
                varName: 'c',
                hidden: false,
                renderEnhancement: 'heatmap'
        }
};

var customAggs = {};
customAggs['Multifact Aggregators'] = $.pivotUtilities.multifactAggregatorGenerator(aggMap, []);

var config = {
      rows: ["region", "csc", "weekEnding"],
      cols: ["dayOfWeek"],
      aggregatorName: "Multifact Aggregators",
      rendererOptions: {
                aggregations: {
                         defaultAggregations: aggMap,
                }
       },
//some other stuff...
}

$.pivotUtilities.customAggs = customAggs;

config.aggregators = $.extend($.pivotUtilities.aggregators, $.pivotUtilities.customAggs);

config.renderers = $.extend($.pivotUtilities.renderers, $.pivotUtilities.gtRenderers);

$('#pivotOutput').pivotUI(
                    response,  //<----ajax response
                    config
                );
pranjal-goswami commented 4 years ago

Hi @sam123evers Sorry for the tardy reply.

I see that you are, missing the rendererName property. Can you add that once and try - let me know if it works.

`config = {  ...
"rendererName": "GT Table Heatmap and Barchart",

... }`

sam123evers commented 4 years ago

@pranjal-goswami

Hello and thanks for the response!

Although I have gotten past this problem, I thought it would be interesting to go back and comment out the line you suggested to add

rendererName: "GT Table Heatmap and Barchart"

I was hoping that by commenting out this line that I would be able to generate the original error. Instead, no error was thrown at all and in fact the table rendered! (although not correctly as there is no data in the table).

console.log(config.rendererName); //<---undefined
$('#singleWeekOutput').pivotUI(
       responseData,
       config,
       true
);

I appreciate hearing from you although I am not having his issue anymore! I am curious how could we make the library throw this error intentionally?

AnatolyBuga commented 4 years ago

@sam123evers How did you solve agg is not a function? Could you share your code? Thanks!