-
Notifications
You must be signed in to change notification settings - Fork 185
If an ordinal domain is specified, any corresponding values that are not in the domain should be considered undefined. #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If we want to generalize this issue, a scale that returns NaN for a datum should never have that datum pass the "filter" stage, and no element should be created in the selectAll().join. But in the current model the scales are applied after the filter. So the change might look like this (here I fixed only x, but the real fix would happen in all the Marks and for all the dimensions): diff --git a/src/marks/bar.js b/src/marks/bar.js
index f38a589..09aa0e3 100644
--- a/src/marks/bar.js
+++ b/src/marks/bar.js
@@ -41,7 +41,9 @@ export class AbstractBar extends Mark {
render(I, scales, channels, options) {
const {color} = scales;
const {z: Z, fill: F, stroke: S} = channels;
- const index = filter(I, ...this._positions(channels), F, S);
+ let index = filter(I, ...this._positions(channels), F, S);
+ const x = Array.from(index, this._x(scales, channels, options));
+ index = filter(I, x);
if (Z) index.sort((i, j) => ascending(Z[i], Z[j]));
return create("svg:g")
.call(applyIndirectStyles, this)
@@ -50,7 +52,7 @@ export class AbstractBar extends Mark {
.data(index)
.join("rect")
.call(applyDirectStyles, this)
- .attr("x", this._x(scales, channels, options))
+ .attr("x", i => x[i])
.attr("width", this._width(scales, channels, options))
.attr("y", this._y(scales, channels, options))
.attr("height", this._height(scales, channels, options)) alternatively diff --git a/src/marks/bar.js b/src/marks/bar.js
index f38a589..0822bf2 100644
--- a/src/marks/bar.js
+++ b/src/marks/bar.js
@@ -41,7 +41,8 @@ export class AbstractBar extends Mark {
render(I, scales, channels, options) {
const {color} = scales;
const {z: Z, fill: F, stroke: S} = channels;
- const index = filter(I, ...this._positions(channels), F, S);
+ const x = Array.from(I, this._x(scales, channels, options));
+ const index = filter(I, ...this._positions(channels), F, S, x);
if (Z) index.sort((i, j) => ascending(Z[i], Z[j]));
return create("svg:g")
.call(applyIndirectStyles, this)
@@ -50,7 +51,7 @@ export class AbstractBar extends Mark {
.data(index)
.join("rect")
.call(applyDirectStyles, this)
- .attr("x", this._x(scales, channels, options))
+ .attr("x", i => x[i])
.attr("width", this._width(scales, channels, options))
.attr("y", this._y(scales, channels, options))
.attr("height", this._height(scales, channels, options)) The second option makes a few more computations by applying _x to all indices, including those that would be rejected by the first filtering—but as a benefit the index i is true if the function to be called is (d,i) => something. Systematically rejecting all elements for which whichever attribute would be computed as NaN (or null or undefined) probably makes sense? |
Yes, that sounds right: we should pass values through the scale to determine whether the scaled value is defined. |
For example,
Expected

Actual

The text was updated successfully, but these errors were encountered: