Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jonseymour/d3 into 2.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 30, 2012
2 parents 4a01fb1 + f161415 commit 8062823
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/layout/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ d3.layout.histogram = function() {
x = values[i];
if ((x >= range[0]) && (x <= range[1])) {
bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
bin.y += k;
bin.push(data[i]);
if (bin) {
bin.y += k;
bin.push(data[i]);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions test/layout/histogram-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ suite.addBatch({
{x: 1, y: 1, dx: 1},
{x: 2, y: 2, dx: 1}
]);
},
"can handle degenerate domain": function(histogram) {
var h = histogram().bins(d3.scale.linear().domain([0,0]).ticks(3));
assert.deepEqual(h([0]), []);
}
}
});
Expand Down

0 comments on commit 8062823

Please sign in to comment.