如何在具有嵌套值的交叉过滤器组中使用 .top() 方法
How to use .top() method in a crossfilter group with nested values
我正在使用一组crossfilter
当交叉过滤器组中的值是这样的:
{ key:"A", value: 2 }
{ key:"B", value: 5 }
{ key:"C", value: 1 }
然后 group.top(2)
returns 基于 value 的前 2 个键值对即 ({key:"B", value: 5}
, {key:"A", value: 2}
)
但是当群是这样的时候:
{ key: "A", value: {count:2} }
{ key: "B", value: {count:5} }
{ key: "C", value: {count:1} }
然后group.top(2)
returns根据key得到前2个键值对({key: "A", value: {count:2}}
,{key: "B", value: {count:5}}
)
我有这样的群:
{ key: "A", value: {count:2} }
{ key: "B", value: {count:5} }
{ key: "C", value: {count:1} }
我希望根据值的计数返回前 2 个键值对。输出应该是这样的:
{ key: "B", value: {count:5} }
{ key: "A", value: {count:2} }
我该如何实现?
Specifies the order value for computing the top-K groups. The default order is the identity function, which assumes that the reduction values are naturally-ordered (such as simple counts or sums).
group.order(v => v.count)
我正在使用一组crossfilter
当交叉过滤器组中的值是这样的:
{ key:"A", value: 2 }
{ key:"B", value: 5 }
{ key:"C", value: 1 }
然后 group.top(2)
returns 基于 value 的前 2 个键值对即 ({key:"B", value: 5}
, {key:"A", value: 2}
)
但是当群是这样的时候:
{ key: "A", value: {count:2} }
{ key: "B", value: {count:5} }
{ key: "C", value: {count:1} }
然后group.top(2)
returns根据key得到前2个键值对({key: "A", value: {count:2}}
,{key: "B", value: {count:5}}
)
我有这样的群:
{ key: "A", value: {count:2} }
{ key: "B", value: {count:5} }
{ key: "C", value: {count:1} }
我希望根据值的计数返回前 2 个键值对。输出应该是这样的:
{ key: "B", value: {count:5} }
{ key: "A", value: {count:2} }
我该如何实现?
Specifies the order value for computing the top-K groups. The default order is the identity function, which assumes that the reduction values are naturally-ordered (such as simple counts or sums).
group.order(v => v.count)