For Example If we have data for books, authors and date information. Can we build a crossfilter for how many books are present for author per month?
I didn't find the accepted answer all that helpful.
I used the following instead.
I first made a keyed group (in your case month)
var authors = cf.dimension(function (d) {
return +d['month'];
})
Next, I used a map reduce method on the keyed dataset to compute the averages
The grouping helper function:
var monthsAvg = authors.group().reduce(reduceAddbooks, reduceRemovebooks, reduceInitialbooks).all();
The map-reduce functions:
function reduceAddbooks(p, v) {
p.author = v['author'];
p.books = +v['books'];
return p;
}
function reduceRemovebooks(p, v) {
p.author = v['author'];
p.books = +v['books'];
return p;
}
function reduceInitialbooks() {
return {
author:0,
books:0
};
}