0

I am wondering if anyone can help me with getting the intersection of multiple filters. For example:

if I have following:

var ndx = crossfilter([
    {id: 1, arrayVals: [1, 2]},
    {id: 2, arrayVals: [2, 3]},
    {id: 3, arrayVals: [1, 2, 3]}
]);

how do I get items with arrayVals that have 1 and 3? And how do I get the filter value onclick? As far as I know, within a dc chart the filtering is "OR" and between dc charts, the filtering is "AND".

Thanks Millions,

Anney

Gordon
  • 19,811
  • 4
  • 36
  • 74
Anney Che
  • 97
  • 3
  • You are right, each dc.js chart ordinarily produces an OR filter over the selected items in a chart, and crossfilter combines the dimensions' filters with AND. Are you talking about using a single chart, e.g. a pie chart or bar chart, to produce an AND filter? Is this chart using a [tag / array dimension](https://github.com/crossfilter/crossfilter/wiki/API-Reference#dimension_with_arrays)? – Gordon Jun 07 '17 at 00:48
  • Hi Gordon, thank you for your quick reply. Yes, I am trying to use a single chart to produce an AND filter and yes this chart is using a array dimension. – Anney Che Jun 07 '17 at 12:19
  • As far as I can tell, this behavior is baked into crossfilter - you can't have it aggregate using array-keys, but filter using regular keys. And I think you'd need regular keys to do this - crossfilter has effectively split each row into as many rows as there are keys, and it doesn't really have any way to work with the original rows any more. I don't have too much experience with this feature, and I could be wrong about this. – Gordon Jun 07 '17 at 17:43

0 Answers0