Skip to content

Commit

Permalink
Add full d3.time aggregation support. Closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
curran committed Dec 4, 2015
1 parent d04de6e commit 3b34419
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -33,8 +33,8 @@ function ChiasmCrossfilter() {
// Generate an aggregate function by parsing the "aggregation" config option.
var aggregate;
var interval;
if(group.aggregation === "day"){
aggregate = time.day;
if(group.aggregation in time){
aggregate = time[group.aggregation];
interval = group.aggregation;
} else if(group.aggregation.indexOf("floor") === 0){
interval = parseInt(group.aggregation.substr(6));
Expand Down
32 changes: 32 additions & 0 deletions test/test.js
Expand Up @@ -112,4 +112,36 @@ describe("chiasm-crossfilter", function () {
});
}, console.log);
});

it("should compute histogram (interval of months)", function(done) {
var chiasm = initChiasm();
chiasm.setConfig({
"cf": {
"plugin": "crossfilter",
"state": {
"groups": {
"dates": {
"dimension": "date",
"aggregation": "month"
}
}
}
}
}).then(function(){
chiasm.getComponent("cf").then(function(cf){
cf.dataset = flightsDataset;
cf.when("dates", function(dataset){
expect(dataset.data.length).to.equal(3);
expect(dataset.data[1].key.getTime()).to.equal(
new Date("Thu Feb 01 2001 00:00:00 GMT-0800 (PST)").getTime());
expect(dataset.data[1].value).to.equal(324);

expect(dataset.isCube);
expect(getColumnMetadata(dataset, "key").interval).to.equal("month");

ChiasmDataset.validate(dataset).then(done, console.log);
});
});
}, console.log);
});
});

0 comments on commit 3b34419

Please sign in to comment.