Skip to content

Commit 0b7fe2c

Browse files
committed
Apply scales.
Since we don't receive the scaled channels (because we don't want to participate in setting the scales' domains), we have to compute them in reder. We do it once for all the facets, and store the result in the object.
1 parent 4fbe16b commit 0b7fe2c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/marks/brush.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export class Brush extends Mark {
3737
const g = create("svg:g");
3838
const data = this.data;
3939

40+
// compute the scaled channels
41+
if (x && this.X === undefined) this.X = X.map(x);
42+
if (y && this.Y === undefined) this.Y = Y.map(y);
43+
({X, Y} = this);
44+
4045
const bounds = [
4146
[Math.floor(marginLeft), Math.floor(marginTop)],
4247
[Math.ceil(width - marginRight), Math.ceil(height - marginBottom)]
@@ -48,17 +53,11 @@ export class Brush extends Mark {
4853
if (selection) {
4954
if (x) {
5055
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-
});
56+
index = index.filter(i => X[i] >= x0 && X[i] <= x1);
5557
}
5658
if (y) {
5759
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-
});
60+
index = index.filter(i => Y[i] >= y0 && Y[i] <= y1);
6261
}
6362
}
6463
const dots = selection ? Array.from(index, i => J[i]) : data;

0 commit comments

Comments
 (0)