More efficient degenerate bin check.
This commit is contained in:
Родитель
80628239d5
Коммит
39a74f49ae
|
@ -5894,6 +5894,7 @@ d3.layout.histogram = function() {
|
|||
}
|
||||
|
||||
// Fill the bins, ignoring values outside the range.
|
||||
if (m > 0) {
|
||||
i = -1; while(++i < n) {
|
||||
x = values[i];
|
||||
if ((x >= range[0]) && (x <= range[1])) {
|
||||
|
@ -5902,6 +5903,7 @@ d3.layout.histogram = function() {
|
|||
bin.push(data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bins;
|
||||
}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -24,11 +24,11 @@ d3.layout.histogram = function() {
|
|||
}
|
||||
|
||||
// Fill the bins, ignoring values outside the range.
|
||||
if (m > 0) {
|
||||
i = -1; while(++i < n) {
|
||||
x = values[i];
|
||||
if ((x >= range[0]) && (x <= range[1])) {
|
||||
bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
|
||||
if (bin) {
|
||||
bin.y += k;
|
||||
bin.push(data[i]);
|
||||
}
|
||||
|
|
|
@ -69,8 +69,10 @@ suite.addBatch({
|
|||
{x: 2, y: 2, dx: 1}
|
||||
]);
|
||||
},
|
||||
"can handle degenerate domain": function(histogram) {
|
||||
var h = histogram().bins(d3.scale.linear().domain([0,0]).ticks(3));
|
||||
"returns the empty array with fewer than two bins": function(histogram) {
|
||||
var h = histogram().bins([1]);
|
||||
assert.deepEqual(h([0]), []);
|
||||
var h = histogram().bins([]);
|
||||
assert.deepEqual(h([0]), []);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче