我有这个cf:
const paymentsCf = crossfilter([
{id: 1, quantity: 2, total: 190, tip: 100, type: "tab"},
{id: 2, quantity: 2, total: 190, tip: 100, type: "tab"},
{id: 3, quantity: 1, total: 300, tip: 200, type: "visa"}
]);
我正在按 ID 创建一个维度并像这样过滤它:
const dimension = paymentsCf.dimension(({ id }) => id);
dimension.filter(2);
如果我这样做
console.log(paymentsCf.groupAll().value())
很公平,我看到了1
.但是如何访问整个过滤对象以获取数量、总数、小费和类型?
我知道我能做到
feedbackCf.all()
但这向我展示了所有 3 个对象。不仅是过滤的。谢谢!
最佳答案
您只需添加 top()
公开结果的方法:
const dimension = paymentsCf.dimension(({ id }) => id);
const res = dimension.filter(2);
res.top(1);
输出:
[ { id: 2, quantity: 2, total: 190, tip: 100, type: 'tab' } ]
关于javascript - 获取交叉过滤器中的所有过滤值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60002396/