I'm using dc.js library to generate graphs and I would like to be able to retrieve the filtered data when filters are applied.
Create another dimension and then call dimension.top(Infinity)
on it.
https://github.com/square/crossfilter/wiki/API-Reference#dimension_top
You will need the extra dimension because dimensions do not observe their own filters, only the filters on other dimensions.
Then you can use e.g. d3.csv.format
to produce text, if you need to.
https://github.com/mbostock/d3/wiki/CSV#format
In the version 4 of d3.js d3.csv.format
doesn't exist, you must use d3.csvFormat
instead.
const cf = crossfilter(data);
csvDimension = cf.dimension( x => x );
csvContent = d3.csvFormat(csvDimension.top(Infinity), [field, field2, ...]);
As Gordon said, csvDimension must be a new dimension in order for the filters to be applied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With