Skip to content

Commit 8062823

Browse files
committed
Merge branch 'master' of https://github.com/jonseymour/d3 into 2.9.0
2 parents 4a01fb1 + f161415 commit 8062823

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/layout/histogram.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ d3.layout.histogram = function() {
2828
x = values[i];
2929
if ((x >= range[0]) && (x <= range[1])) {
3030
bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
31-
bin.y += k;
32-
bin.push(data[i]);
31+
if (bin) {
32+
bin.y += k;
33+
bin.push(data[i]);
34+
}
3335
}
3436
}
3537

test/layout/histogram-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ suite.addBatch({
6868
{x: 1, y: 1, dx: 1},
6969
{x: 2, y: 2, dx: 1}
7070
]);
71+
},
72+
"can handle degenerate domain": function(histogram) {
73+
var h = histogram().bins(d3.scale.linear().domain([0,0]).ticks(3));
74+
assert.deepEqual(h([0]), []);
7175
}
7276
}
7377
});

0 commit comments

Comments
 (0)