处理交叉过滤数据

时间:2017-08-10 12:07:17

标签: dc.js crossfilter

previous question中,我询问了基于交叉点过滤数据的问题。根据@EthanJewett的建议,我能够按联合( OR )或交叉( AND )过滤时间点。数据结构是:

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]}
];

继续这个例子,我现在拥有与每个时间点相关的数据,我试图在我的仪表板中绘制其他数据,同时仍然允许时间点和/或过滤时间点。在我被要求允许最终用户基于交叉点( AND )过滤时间点之前,我会在将数据传递给crossfilter之前将其展平,但现在我试图保持它不变。以下是包含其他数据的数据集示例:

    let data = [
        {patientId: 101, site: "AAA", gender: 'Male',   timepoints: [{tp: 0, vol: 10, bool: true}, {tp: 2, vol: 15, ans: false}, {tp: 4, vol: 5, ans: true}]},
        {patientId: 201, site: "BBB", gender: 'Female', timepoints: [{tp: 0, vol: 15, ans: false}]},
        {patientId: 301, site: "CCC", gender: 'Male',   timepoints: [{tp: 4, vol: 25, ans: true}]}
    ];

使用上述结构,我已经能够设置我的交叉滤波器尺寸和组,并创建我的dc.js图表​​,以实现95%的解决方案。我正在处理的最后一个过滤问题仍然存在。我对Crossfilter 1.4.0进行了4次更改,以便在从resetMany和updateMany函数调用iterable if块中的reduceAdd和reduceRemove时,将g.key作为第5个参数传递。

我的问题是:人们如何处理上面的数据集?

就像我上面提到的,之前我在将数据传递给crossfilter之前将数据展平,但是根据新要求,我试图保持对象数组的摄入量,因此我知道患者101的时间点为0,2和4。

我将尝试将当前代码放入jsfiddle。

0 个答案:

没有答案