pat310 / quick-pivot

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

'Include' filtering with values that are a part of the unique values of that field throws error #46

Closed turnerniles closed 7 years ago

turnerniles commented 7 years ago
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 pivot = new pivot(dataArray, ['gender'], [], 'age', 'count');

pivot.filter('gender', ['dogman'], 'include')

image

turnerniles commented 7 years ago

Similarly

pivot.filter('dogman', ['dogman'], 'include')

Throws the same error.

I think for both of these scenarios, it should return an 'empty' pivot (headers, no data). Exclude works in both scenarios.

turnerniles commented 7 years ago

Well I'm not sure about the second scenario. Perhaps pivot.filter('dogman', ['dogman'], 'include') should throw an error

pat310 commented 7 years ago

Closed in #49

pat310 commented 7 years ago

@turnerniles I think #49 fixes this but please reopen if it's still an issue!