javascript - 是否可以修改已插入交叉过滤器的数据?

标签 javascript crossfilter dc.js

查看 Crossfilter API ,我没有看到任何关于如何修改已添加到 Crossfilter 的行的提及。

是否绝对禁止/不可能修改现有行?比如说,通过添加更多字段或修改一行的字段值?似乎删除所有数据并将其读取到交叉过滤器是唯一的方法,但这将意味着丢失所有当前过滤器、维度等。

最佳答案

如果您创建一个“唯一维度”,它为数据集中的每个条目(如 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
}

关于javascript - 是否可以修改已插入交叉过滤器的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21559056/

相关文章:

javascript - 按类名将元素放入数组中并使用 Javascript 提醒它

javascript - 从 *ngIf Angular 5 调用函数

c# - 客户端用户确认后调用ASPX服务器端函数?

javascript - $watch on 指令,其嵌套对象的隔离范围作为 crossfilter 的属性

javascript - dc.js - 基于单个 csv 文件中单独类别的多个折线图

javascript - filterAll() 和 dc.redrawAll() 不适用于 dc.pieChart

csv - 如何使用 dc.js 创建饼图

javascript - 如何使用函数(for-loop)从按钮获取用户输入以显示在文本框中?

dc.js - 如何选择 dc.js 条形图中的 bin 数量?

javascript - 将数据从 dc.js dataTable 导出到 CSV