查看Crossfilter API,我没有看到任何关于如何修改已经添加到Crossfilter中的行的内容。
是否绝对禁止/不可能修改现有行?例如,通过添加更多字段或通过修改行的字段值?似乎删除所有数据并将其读取到crossfilter是唯一的方法,但这将意味着丢失所有当前的过滤器,维度等。
发布于 2014-06-26 20:51:23
如果您创建了一个“唯一维度”,为数据集中的每个条目(如ID列)返回唯一的值,则可以使用如下函数对单个条目进行更改,而不会抛出所有内容:
function editEntry(id, changes) {
uniqueDimension.filter(id); // filter to the item you want to change
var selectedEntry = uniqueDimension.top(1)[0]; // get the item
_.extend(selectedEntry, changes); // apply changes to it
ndx.remove(); // remove all items that pass the current filter (which will just be the item we are changing
ndx.add([selectedEntry]); // re-add the item
uniqueDimension.filter(null); // clear the filter
dc.redrawAll(); // redraw the UI
}https://stackoverflow.com/questions/21559056
复制相似问题