Javascript 如何通过ID有效地从交叉筛选中删除/修改数据
当从交叉过滤器中删除数据点时,我遇到了性能问题。每次我都要做以下事情:Javascript 如何通过ID有效地从交叉筛选中删除/修改数据,javascript,crossfilter,Javascript,Crossfilter,当从交叉过滤器中删除数据点时,我遇到了性能问题。每次我都要做以下事情: dimension.filter(tmpReportId); var tmpReport = dimension.top(1)[0]; //Because after removal I have to modify the "report" (the data point) and add it back to the crossfilter reportsVis.getCrossfilter().
dimension.filter(tmpReportId);
var tmpReport = dimension.top(1)[0]; //Because after removal I have to modify the "report" (the data point) and add it back to the crossfilter
reportsVis.getCrossfilter().remove();
dimension.filter(null);
问题是,filter()在整个交叉过滤器上应用了两次,这使得在大型数据集上的操作非常昂贵filter(null)
不是一个昂贵的操作,因为它只清除过滤器,不执行过滤器。委员会:
filter(null)
和filterAll()
是相同的操作,正如您所看到的,它只返回维度中的每个值。这是正确的,但实际问题是dimension.filter(tmprepartid)代码>,这是一个相对昂贵的操作。有一个交叉过滤器在讨论这个问题,我在那个问题中提到了一个fork,它提供了直接删除单个记录的能力。谢谢Ethan,这实际上是我真正的问题。但是你认为,你提到的叉子能提高拆卸性能吗?我的意思是,这是一个添加到remove()的简单过滤函数,它覆盖了整个数据集,不是吗?
function crossfilter_filterAll(values) {
return [0, values.length];
}