Skip to content

Commit 3f57c47

Browse files
committed
fix: don't set default x/y channels when brush has no data
Plot.brush() without data should not call maybeTuple, which would set default channel accessors and require scales to exist.
1 parent 9d7131f commit 3f57c47

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/interactions/brush.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export class Brush extends Mark {
313313
export function brush(data, options = {}) {
314314
if (arguments.length === 1 && !isIterable(data)) (options = data), (data = undefined);
315315
let {x, y, ...rest} = options;
316-
[x, y] = maybeTuple(x, y);
316+
if (data != null) [x, y] = maybeTuple(x, y);
317317
return new Brush(data, {...rest, x, y});
318318
}
319319

test/brush-test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,8 @@ it("brushX reused across two plots syncs in data space", () => {
395395

396396
it("two brush marks in the same plot throws", () => {
397397
assert.throws(() => {
398-
const data = [{x: 1, y: 1}];
399398
Plot.plot({
400-
marks: [Plot.dot(data, {x: "x", y: "y"}), Plot.brush(), Plot.brush()]
399+
marks: [Plot.brush(), Plot.brush()]
401400
});
402401
}, /only one brush per plot/);
403402
});

0 commit comments

Comments
 (0)