构建Crossfilter维度/分组以汇总数据

时间:2017-08-14 12:16:40

标签: dc.js crossfilter

我有以下数据集:

    let data = [
        {patientId: 100, site: "AAA", timepoint: 0},
        {patientId: 100, site: "AAA", timepoint: 2},
        {patientId: 100, site: "AAA", timepoint: 4},
        {patientId: 100, site: "AAA", timepoint: 6},
        {patientId: 100, site: "AAA", timepoint: 8},
        {patientId: 100, site: "AAA", timepoint: 12},
        {patientId: 101, site: "AAA", timepoint: 0},
        {patientId: 101, site: "AAA", timepoint: 2},
        {patientId: 101, site: "AAA", timepoint: 4},
        {patientId: 200, site: "BBB", timepoint: 2},
        {patientId: 200, site: "BBB", timepoint: 4},
        {patientId: 200, site: "BBB", timepoint: 6},
        {patientId: 201, site: "BBB", timepoint: 0},
        {patientId: 201, site: "BBB", timepoint: 6},
        {patientId: 201, site: "BBB", timepoint: 8},
        {patientId: 201, site: "BBB", timepoint: 12},
        {patientId: 202, site: "BBB", timepoint: 0},
        {patientId: 202, site: "BBB", timepoint: 2},
        {patientId: 202, site: "BBB", timepoint: 4},
        {patientId: 202, site: "BBB", timepoint: 6},
        {patientId: 202, site: "BBB", timepoint: 8},
        {patientId: 202, site: "BBB", timepoint: 12}
    ];

我想建立一个饼图,反映出具有给定时间点数的患者数量。因此,基于上述数据得到的饼图将是:

  • 3个时间点 - 2(患者101和患者6)
  • 4个时间点 - 1(患者201)
  • 6个时间点 - 2(患者100和患者202)

我希望此维度/组能够与为crossfilter数据定义的其他基本维度/组一起使用。

0 个答案:

没有答案