Pivottable.js shows wrong value in total column

413 views Asked by At

I am using pivottable.js, everything works fine except sorting. Problem here is, when I try to sort data using bulit-in sorting total column shows wrong value, that is actually cell value and total column cell value are different by small amount as shown in figure

Configuration

{
                rows: ["Property Name"],
                cols: ["Year",'Month'],
                aggregators: {
                "temp":      successRate,

               },
 }

 var successRate = function() {
          return function() {
            return {
              sumSuccesses: 0,
              sumTrials: 0,
              totalRecord:0,
              push: function(record) {
                if (!isNaN(parseFloat(record['temp']))) {
                  this.sumSuccesses += parseFloat(record['temp']);
                }

                this.totalRecord++;
              },
              value: function() { return (this.sumSuccesses++) },
              format: function(x) { return $filter('number')(x,2) },

              numInputs: 0
            };
          };
        };

enter image description here

1

There are 1 answers

1
nicolaskruchten On BEST ANSWER

Most likely the issue is related to value: function() { return (this.sumSuccesses++) }, which increments the value every time it is read.