Can I filter data based on an intersection (and) in crossfilter/dc.js?

Viewed 502

I have the following example on jsfiddle: https://jsfiddle.net/woolycew65/bp5eavxy/ and am curious if I can select pie slices TP-0 and TP-2 to mean find the patients that have both timepoint 0 and timepoint 2, not 0 or 2.

A sample of the dataset is shown below:

    let data = [
        {patientId: 101, site: "AAA", timepoints: [0, 2, 4, 6, 8, 12, 18, 24]},
        {patientId: 102, site: "AAA", timepoints: [0, 2, 4, 6]},
        {patientId: 103, site: "AAA", timepoints: [8, 12, 18, 24]},
        {patientId: 104, site: "AAA", timepoints: [0, 4, 8, 18]},
        {patientId: 105, site: "AAA", timepoints: [2, 6, 12, 24]},
        {patientId: 501, site: "BBB", timepoints: [0]},
        {patientId: 502, site: "BBB", timepoints: [2]},
        {patientId: 503, site: "BBB", timepoints: [4]},
        {patientId: 504, site: "BBB", timepoints: [6]},
        {patientId: 505, site: "BBB", timepoints: [8]},
        {patientId: 506, site: "BBB", timepoints: [12]},
        {patientId: 507, site: "BBB", timepoints: [18]},
        {patientId: 508, site: "BBB", timepoints: [24]}
    ];

I would like the resulting intersection filter to produce "AAA" (2), "BBB" (0) since there are two patients at site AAA (101 and 102) that have timepoints 0 AND 2 and no patients at site BBB that meet the intersection filter criteria.

Obviously the resulting dataset returns "AAA" (4), "BBB" (2) since there are four patients at site AAA (101, 102, 104, and 105) that have timepoints 0 OR 2 and two patients at site BB that meet the union filter criteria.

If it is not possible via crossfilter then I assume I need to capture some event on the tpPie chart and perform my own filtering and then re-populate crossfilter with the new data.

Any help would be appreciated.

1 Answers
Related