我想了解以下是否可行。如果有两个具有相同数据集的jsFiddle示例。一个包含一组对象,而另一个是扁平的。我还添加了一些没有完全范围的记录。
散点图上的滤镜是否可以正确使用“阵列对象”数据集?
数据 - 展平:jsFiddle Example
var data = [
{"_uid": 1, "business": 'Resort', "state": {name: 'Virginia', startups: 15}},
{"_uid": 1, "business": 'Resort', "state": {name: 'Maryland', startups: 6}},
{"_uid": 3, "business": 'Training', "state": {name: 'Virginia', startups: 4}},
{"_uid": 3, "business": 'Training', "state": {name: 'Maryland', startups: 2}},
{"_uid": 3, "business": 'Training', "state": {name: 'D.C.', startups: 3}},
{"_uid": 4, "business": 'Sitting'},
{"_uid": 5, "business": 'Vet', "state": {name: 'Virginia', startups: 4}},
{"_uid": 6, "business": 'Parties', "state": {}},
{"_uid": 7, "business": 'Grooming', "state": {name: 'Virginia', startups: 4}},
{"_uid": 7, "business": 'Grooming', "state": {name: 'D.C.', startups: 3}},
];
数据 - 对象数组:jsFiddle Example
var data = [
{"_uid": 1, "business": 'Resort', "states": [{state: 'Virginia', startups: 15}, {state: 'Maryland', startups: 6}]},
{"_uid": 3, "business": 'Training', "states": [{state: 'Virginia', startups: 4}, {state: 'Maryland', startups: 2}, {state: 'D.C.', startups: 3}]},
{"_uid": 4, "business": 'Sitting'},
{"_uid": 5, "business": 'Vet', "states": [{state: 'Virginia', startups: 4}]},
{"_uid": 6, "business": 'Parties', "state": {}},
{"_uid": 7, "business": 'Grooming', "states": [{state: 'Virginia', startups: 4}, {state: 'D.C.', startups: 3}]}
];
两个数据集都能正确显示数据。
如果我选择宠物业务类型 - " Grooming"并且在3上垂直刷过散点图,滤波后的数据对于Flatten数据集是正确的,但对于数组对象数据集不正确。
展平数据集 - 已过滤
正确 - 显示"培训"也具有" 3"
的启动值对象数组 - 已过滤
不正当 - 所有业务类型都与其他州"弗吉尼亚"为了#34; Grooming"。
我知道我们通过不对数据进行扁平化来解决Crossfilter和dc.js的问题,但这可能吗?