I'm using dc.js to render a nice bubble chart of a dataset. Underlying dc.js is crossfilter.
I'd like to smoothly refresh my chart with new data from the server. This issue on Github makes it clear that it is possible to do this by:
- deleting all the data from the crossfilter
- adding in the new data
- calling
dc.redrawAll()
.
I've got this working but in order to delete all the data, you first have to clear all the filters (because crossfilter.remove
only removes the records matching the current filter).
I'd like to 'remember' how my data was filtered before, so I can reconstruct the filter again once I've replaced all the data. I'm willing to get into the guts of the crossfilter
code, but any pointers would be helpful.
Additionally: if anyone knows a way of updating crossfilter data based on a unique key, that'd be gold dust!
Thanks to @londonrob's Answer all data is now removed from the index. Here is a more functional approach for the resetting of data.
Here's what I ended up hacking together. It works perfectly well, although I'm sure it's ludicrously inefficient because all the dimensions have to be created from scratch: