Filter for multiple discrete values ​​in crossfilter

Does anyone have an approach to filtering a crossfilter object with multiple values? Sort of

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

or

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

... but not the range of its shape ...

or

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

... but without the liberating part.

or equivalent workaround / approach not using

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

??

Or am I missing something in the API?

Thanks!

Larry

+6
source share
3 answers

I had a similar problem. I decided that I wrote a filter function that checks if a dimension is in a specific 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 is in this array and if the filter is appropriate.

Hope this helps.

+11
source

The next download request looks as if it will meet your needs, but it is not yet merged.

Several arguments to filter the result in combining filter actions

After merging, you can do something like the following.

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

This will unite all filter criteria.

+2
source

The API does not seem to be anything, but if you want to avoid filterRange, you can use two main filters with it and coordinate the results:

 var paymentsByType = payments.dimension(function(d) { return d.type; }), cashAndVisaPayments = Array.prototype.concat(paymentsByType.filter('cash').top(Infinity),paymentsByType.filter('visa').top(Infinity)) 
+1
source

Source: https://habr.com/ru/post/918230/


All Articles