Is it possible to change data already inserted in crossfilter?

Looking at the Crossfilter API , I see no mention of how to modify rows already added to Crossfilter.

Is it absolutely forbidden / impossible to modify existing lines? Say by adding a few more fields or changing the value of a field in a row? It seems that deleting all data and reading it on a crossfilter is the only way, but that would mean losing all current filters, sizes, etc.

+4
source share
1 answer

If you create a โ€œunique dimensionโ€ that returns a unique value for each record in your dataset (for example, an identifier column), you can have a function to make changes to one record without dropping all:

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
}
+2
source

Source: https://habr.com/ru/post/1525279/


All Articles