Skip to content

Commit 4c9f77d

Browse files
committed
The quantile scale should ignore null, too.
1 parent 92c9d9d commit 4c9f77d

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

d3.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7703,9 +7703,7 @@
77037703
}
77047704
scale.domain = function(x) {
77057705
if (!arguments.length) return domain;
7706-
domain = x.filter(function(d) {
7707-
return !isNaN(d);
7708-
}).sort(d3_ascending);
7706+
domain = x.filter(d3_number).sort(d3_ascending);
77097707
return rescale();
77107708
};
77117709
scale.range = function(x) {

d3.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/scale/quantile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "../arrays/ascending";
22
import "../arrays/bisect";
33
import "../arrays/quantile";
4+
import "../math/number";
45
import "scale";
56

67
d3.scale.quantile = function() {
@@ -24,7 +25,7 @@ function d3_scale_quantile(domain, range) {
2425

2526
scale.domain = function(x) {
2627
if (!arguments.length) return domain;
27-
domain = x.filter(function(d) { return !isNaN(d); }).sort(d3_ascending);
28+
domain = x.filter(d3_number).sort(d3_ascending);
2829
return rescale();
2930
};
3031

test/scale/quantile-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ suite.addBatch({
3030
assert.deepEqual(x.domain(), [3, 6, 7, 8, 8, 10, 13, 15, 16, 20]);
3131
},
3232
"non-numeric domain values are ignored": function(quantile) {
33-
var x = quantile().domain([6, 3, NaN, undefined, 7, 8, 8, 13, 20, 15, 16, 10, NaN]);
33+
var x = quantile().domain([6, 3, NaN, undefined, 7, 8, 8, 13, null, 20, 15, 16, 10, NaN]);
3434
assert.deepEqual(x.domain(), [3, 6, 7, 8, 8, 10, 13, 15, 16, 20]);
3535
},
3636
"quantiles returns the inner thresholds": function(quantile) {

0 commit comments

Comments
 (0)