Skip to content

Commit

Permalink
The quantile scale should ignore null, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Apr 8, 2014
1 parent 92c9d9d commit 4c9f77d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 1 addition & 3 deletions d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -7703,9 +7703,7 @@
}
scale.domain = function(x) {
if (!arguments.length) return domain;
domain = x.filter(function(d) {
return !isNaN(d);
}).sort(d3_ascending);
domain = x.filter(d3_number).sort(d3_ascending);
return rescale();
};
scale.range = function(x) {
Expand Down
10 changes: 5 additions & 5 deletions d3.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/scale/quantile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "../arrays/ascending";
import "../arrays/bisect";
import "../arrays/quantile";
import "../math/number";
import "scale";

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

scale.domain = function(x) {
if (!arguments.length) return domain;
domain = x.filter(function(d) { return !isNaN(d); }).sort(d3_ascending);
domain = x.filter(d3_number).sort(d3_ascending);
return rescale();
};

Expand Down
2 changes: 1 addition & 1 deletion test/scale/quantile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ suite.addBatch({
assert.deepEqual(x.domain(), [3, 6, 7, 8, 8, 10, 13, 15, 16, 20]);
},
"non-numeric domain values are ignored": function(quantile) {
var x = quantile().domain([6, 3, NaN, undefined, 7, 8, 8, 13, 20, 15, 16, 10, NaN]);
var x = quantile().domain([6, 3, NaN, undefined, 7, 8, 8, 13, null, 20, 15, 16, 10, NaN]);
assert.deepEqual(x.domain(), [3, 6, 7, 8, 8, 10, 13, 15, 16, 20]);
},
"quantiles returns the inner thresholds": function(quantile) {
Expand Down

0 comments on commit 4c9f77d

Please sign in to comment.