Skip to content

Commit d23842c

Browse files
committed
datum
1 parent 505c223 commit d23842c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/interactions/brush.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,17 @@ function brushTransform(mode, {selectionMode = "data", ...options}) {
3838
];
3939
const brush = (mode === "xy" ? brusher : mode === "x" ? brusherX : brusherY)()
4040
.extent(extent)
41-
.on("brush start end", function (event) {
42-
const f = select(this).datum();
41+
.on("brush start end", function (event, d) {
4342
const {type, selection} = event;
4443
let S = null;
45-
const [X, Y] = selection
46-
? mode === "xy"
47-
? transpose(selection)
48-
: mode === "x"
49-
? [selection]
50-
: [, selection]
51-
: [];
52-
if (X || Y) S = f.index;
44+
const [X, Y] = !selection
45+
? []
46+
: mode === "xy"
47+
? transpose(selection)
48+
: mode === "x"
49+
? [selection]
50+
: [, selection];
51+
if (X || Y) S = d.index;
5352
if (X) {
5453
const [x0, x1] = X;
5554
S = S.filter((i) => x0 <= Xm[i] && Xl[i] <= x1);
@@ -59,9 +58,9 @@ function brushTransform(mode, {selectionMode = "data", ...options}) {
5958
S = S.filter((i) => y0 <= Ym[i] && Yl[i] <= y1);
6059
}
6160
// Only one facet can be active at a time; clear the others.
62-
if (type === "start") for (let i = 0; i < cancels.length; ++i) if (i !== (f.index.fi ?? 0)) cancels[i]();
61+
if (type === "start") for (let i = 0; i < cancels.length; ++i) if (i !== (d.index.fi ?? 0)) cancels[i]();
6362

64-
f.display.replaceWith((f.display = next.call(this, S ?? [], scales, values, dimensions, context)));
63+
d.display.replaceWith((d.display = next.call(this, S ?? [], scales, values, dimensions, context)));
6564

6665
// Update the plot’s value if the selection has changed.
6766
if (selectionMode === "data") {
@@ -102,6 +101,7 @@ function brushTransform(mode, {selectionMode = "data", ...options}) {
102101
// When the plot is complete, append the target element to the top
103102
// (z-index), translate it to match the facet’s frame position, and
104103
// initialize the plot’s value.
104+
// TODO: cleaner.
105105
if (typeof requestAnimationFrame === "function") {
106106
requestAnimationFrame(() => {
107107
select(svg)

0 commit comments

Comments
 (0)