nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.36k stars 1.08k forks source link

code conflict with Array.prototype.uniqueObjects #1164

Open pavankakumanu opened 5 years ago

pavankakumanu commented 5 years ago

PivotTable.js is amazing library. I really like to include into my project. but we are facing a small issue when we include this array prototype.

i have these lines of code in my _Layout.cshtml Array.prototype.uniqueObjects = function () { var a = this.concat(); for (var i = 0; i < a.length; ++i) { for (var j = i + 1; j < a.length; ++j) { if (a[i] === a[j]) { a.splice(j--, 1); } } } return a; }

some how pivot table picking this logic and showing like bellow image. image

but once i comment the above code things working fine. This is one small issue im facing. This info will help you to make this tool more and more grateful.

Thanks

z3d909 commented 4 years ago

Hi @pavankakumanu

Try change your code to:

Object.defineProperty(Array.prototype, 'uniqueObjects', {
  enumerable: false,
  value: function (rx) {
    var a = this.concat();
    for (var i = 0; i < a.length; ++i) {
      for (var j = i + 1; j < a.length; ++j) {
        if (a[i] === a[j]) {
          a.splice(j--, 1);
        }
      }
    }
    return a;
  }
});