Skip to content Skip to sidebar Skip to footer

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 t

Solution 1:

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 filtervar 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.

Solution 2:

The following pull request looks like it would address your needs, but it has not yet been merged in.

Multiple arguments to filter result in union of filter operations

Once merged you would be able to do something like the following.

data.total.filter("cash", "visa");

Which would result in the union of all filter criteria.

Post a Comment for "Filter For Multiple Discrete Values In Crossfilter"