Skip to content

Commit 2cc9c1c

Browse files
committed
simpler
1 parent 312b477 commit 2cc9c1c

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/interactions/brush.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,11 @@ export class Brush extends Mark {
117117
return;
118118
}
119119
const {x1, x2, y1, y2, fx, fy} = value;
120-
const node =
121-
this._brushNodes.length === 1
122-
? this._brushNodes[0]
123-
: this._brushNodes.find((n) => {
124-
const d = n.__data__;
125-
return d && (fx === undefined || d.x === fx) && (fy === undefined || d.y === fy);
126-
});
127-
if (!node) throw new Error("No brush node found for the specified facet");
120+
const node = this._brushNodes.find((n) => {
121+
const d = n.__data__;
122+
return (fx === undefined || d?.x === fx) && (fy === undefined || d?.y === fy);
123+
});
124+
if (!node) throw new Error(fx === undefined && fy === undefined ? "No brush node found" : "No brush node found for the specified facet");
128125
const px1 = this._applyX(x1);
129126
const px2 = this._applyX(x2);
130127
const py1 = this._applyY(y1);

0 commit comments

Comments
 (0)