如何在Crossfilter.js中使用多个键处理维度

时间:2018-07-23 11:32:24

标签: dc.js crossfilter

我有与下面的json相似的数据。

data = [
    {"student_id":  1, "clubs": ["Photography", "Drama"  ],   "sports": ["Soccer", "Baseball", "Biking"],     "gender": "Male",   "age" : 12},
    {"student_id":  2, "clubs": ["Debating", "Drama", "Art"  ],   "sports": [ "Basketball", ],     "gender": "Male",   "age" : 15},
    {"student_id":  3, "clubs": ["Math Club",  "Drama"  ],   "sports": ["Swimming", "Running", "Biking"],     "gender": "Male",   "age" : 12},
    {"student_id":  4, "clubs": [ "Drama", "Art"  ],   "sports": [ "Baseball", ],     "gender": "Male",   "age" : 11},
    {"student_id":  5, "clubs": ["Math Club", "Photography"  ],   "sports": ["Basketball", "Biking"],     "gender": "Female",   "age" : 12},
    {"student_id":  6, "clubs": ["Drama", "Art"  ],   "sports": [ "Volleyball", ],     "gender": "Female",   "age" : 16},

]

我可以使用crossfilter.js回答问题(本质上是组数或总和),例如有多少学生是摄影俱乐部的成员并打篮球。

本质上,俱乐部使用一张图表,运动时使用一张图表。 显示每个属性(维度)的计数并在它们之间进行过滤。 是的,学生可能会重复计算,因为他们可能是许多俱乐部的成员或参加许多运动。

0 个答案:

没有答案