pat310 / quick-pivot

Quickly format data to create a pivot table
https://www.npmjs.com/package/quick-pivot
MIT License
63 stars 21 forks source link

Should filters stack / are they chainable? #52

Closed turnerniles closed 7 years ago

turnerniles commented 7 years ago

Should filters stack / are they chainable? Or do we only allow one filter at a time?

const dataArray = [ ['name', 'gender', 'house', 'age'], ['Jon', 'm', 'Stark', 14], ['Arya', 'f', 'Stark', 10], ['Cersei', 'f', 'Baratheon', 38], ['Tywin', 'm', 'Lannister', 67], ['Tyrion', 'm', 'Lannister', 34], ['Joffrey', 'm', 'Baratheon', 18], ['Bran', 'm', 'Stark', 8], ['Jaime', 'm', 'Lannister', 32], ['Sansa', 'f', 'Stark', 12] ];

const testPivot = new pivot(dataArray, ['age'], ['house','gender'], [], 'sum'); testPivot.filter("house", ["Stark"], 'exclude') testPivot.filter("gender", ["m"], 'exclude')

returns

"[{"value":["sum ","Stark","Baratheon"],"depth":0,"type":"colHeader","row":0},{"value":["sum ","f","f"],"depth":1,"type":"colHeader","row":1},{"value":["10",null,""],"type":"data","depth":0,"row":2},{"value":["12",null,""],"type":"data","depth":0,"row":3},{"value":["38","",null],"type":"data","depth":0,"row":4}]"

Which is the result of the second filter (first filter is not applied).

pat310 commented 7 years ago

Closed in #54

turnerniles commented 7 years ago

Reopened wrong issue.