Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter for multiple discrete values in crossfilter

Does anyone have an approach to filtering a crossfilter object dimension on multiple values? Something like

.filterExact(["cash","visa"])

or

.filter(["cash","visa"])

...but not the range form of it...

or

.filterAll(["cash","visa"])

...but without the clearing part.

or an equivalent workaround/approach not using

.filterRange(["cash","visa"])

??

Or am I missing something in the API?

Thanks!

Larry

like image 588
Larry Hengl Avatar asked Jun 16 '12 03:06

Larry Hengl


1 Answers

I was facing a similar problem. The way I solved it was that I wrote a filter function that would check whether the dimension lies in a particular array or not.

// Array of things you want to filter
var f = ["cash", "visa"];
// Assuming "dim" is our dimension
dim.filter(function(d){
  return f.indexOf(d) > -1;
});

This will check if the value lies in that array and filter accordingly.

Hope this helps.

like image 137
prtksxna Avatar answered Sep 21 '22 22:09

prtksxna