是否可以使用 .exceptionCount(true) 两次?

Is it possible to use .exceptionCount(true) twice?

我有问题,我想计算与 foo 关联的 bar 和 num 的不同元素

var data = crossfilter([
{ foo: 'one', bar: 'A', num: '1' },
{ foo: 'two', bar: 'B', num: '2' },
{ foo: 'three', bar: 'A', num: '3' },
{ foo: 'one', bar: 'B', num: '3' },
{ foo: 'one', bar: 'A', num: '2' },
{ foo: 'two', bar: 'B', num: '2' },
]);

即我想得到,例如:

[ { key: 'one', value: { exceptionCount: 2, exceptionCount2: 3 },    // 'bar' dimension has 2 values: 'A' and 'B', and has 3 values: '1' and '2' and '3'
{ key: 'two', value: { exceptionCount: 1, exceptionCount2: 1 },    // 'bar' dimension has 1 value: 'B', '2'
{ key: 'three', value: { exceptionCount: 1 , exceptionCount2: 1} ] // 'bar' dimension has 1 value: 'A', '3'

我使用带有 exceptionCount 的 reductionio 库来分隔 num 和 bar,但我无法加入仅与 foo 关联的两者。

你能帮帮我吗

是的,reductio.value 方法允许您将多个相同类型的 reducer 放在一个组中。 README 中有一个使用 exceptionSum 的示例,可以修改为使用 exceptionCount。你的小组结构会有所改变。

https://github.com/crossfilter/reductio#aggregations-standard-aggregations-reductio-b-value-b-i-propertyname-i-

谢谢,

我用

 reducer=reductio();
 reducer.value('nbar').exception(function(d){return d['bar']}.exceptionCount(true);
 reducer.value('nnum').exception(function(d){return d['num']}.exceptionCount(true);

我申请了组。

 reducer(my_group_name);