Skip to content

Commit 17e0199

Browse files
committed
filter on x(X[i]) to brush ordinal dimensions
1 parent 377fff8 commit 17e0199

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/marks/brush.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,18 @@ export class Brush extends Mark {
4747
let index = filter(I, X, Y);
4848
if (selection) {
4949
if (x) {
50-
const e = y ? [selection[0][0], selection[1][0]] : selection;
51-
const [x0, x1] = extent(e.map(x.invert));
52-
index = index.filter(i => X[i] >= x0 && X[i] <= x1);
50+
const [x0, x1] = y ? [selection[0][0], selection[1][0]] : selection;
51+
index = index.filter(i => {
52+
const c = x(X[i]);
53+
return c >= x0 && c <= x1;
54+
});
5355
}
5456
if (y) {
55-
const e = x ? [selection[0][1], selection[1][1]] : selection;
56-
const [y0, y1] = extent(e.map(y.invert));
57-
index = index.filter(i => Y[i] >= y0 && Y[i] <= y1);
57+
const [y0, y1] = x ? [selection[0][1], selection[1][1]] : selection;
58+
index = index.filter(i => {
59+
const c = y(Y[i]);
60+
return c >= y0 && c <= y1;
61+
});
5862
}
5963
}
6064
const dots = selection ? Array.from(index, i => J[i]) : data;

0 commit comments

Comments
 (0)