@@ -58,9 +58,9 @@ function brushTransform(mode, {selectionMode = "data", ...options}) {
58
58
S = S . filter ( ( i ) => y0 <= Ym [ i ] && Yl [ i ] <= y1 ) ;
59
59
}
60
60
// Only one facet can be active at a time; clear the others.
61
- if ( type === "start" ) for ( let i = 0 ; i < cancels . length ; ++ i ) if ( i !== ( d . index . fi ?? 0 ) ) cancels [ i ] ( ) ;
61
+ if ( type === "start" ) for ( const target of targets ) if ( target !== this ) target . _cancelBrush ( ) ;
62
62
63
- d . display . replaceWith ( ( d . display = next . call ( this , S ?? [ ] , scales , values , dimensions , context ) ) ) ;
63
+ d . display ? .replaceWith ( ( d . display = next . call ( this , S ?? [ ] , scales , values , dimensions , context ) ) ) ;
64
64
65
65
// Update the plot’s value if the selection has changed.
66
66
if ( selectionMode === "data" ) {
@@ -84,19 +84,25 @@ function brushTransform(mode, {selectionMode = "data", ...options}) {
84
84
}
85
85
} ) ;
86
86
87
- states . set ( svg , ( state = { brush, cancels : [ ] , selection : null } ) ) ;
87
+ states . set ( svg , ( state = { brush, targets : [ ] , selection : null } ) ) ;
88
88
}
89
- const { brush, cancels } = state ;
89
+ const { brush, targets } = state ;
90
90
const display = next . call ( this , [ ] , scales , values , dimensions , context ) ;
91
91
92
92
// Create a wrapper for the elements to display, and a target that will
93
93
// carry the brush. Save references to the display and index of the current
94
94
// facet.
95
- const wrapper = create ( "svg:g" , context ) . attr ( "aria-label" , display . getAttribute ( "aria-label" ) ) ;
95
+ const wrapper = create ( "svg:g" , context ) ;
96
96
const target = create ( "svg:g" , context ) . attr ( "aria-label" , "brush" ) . datum ( { display, index} ) . call ( brush ) ;
97
- display . removeAttribute ( "aria-label" ) ;
98
- wrapper . append ( ( ) => display ) ;
99
- cancels [ index . fi ?? 0 ] = ( ) => target . call ( brush . move , null ) ;
97
+ const node = target . node ( ) ;
98
+ node . _cancelBrush = ( ) => target . call ( brush . move , null ) ;
99
+ targets . push ( node ) ;
100
+
101
+ if ( display ) {
102
+ const al = display . getAttribute ( "aria-label" ) ;
103
+ al && ( wrapper . attr ( "aria-label" , al ) , display . removeAttribute ( "aria-label" ) ) ;
104
+ wrapper . append ( ( ) => display ) ;
105
+ }
100
106
101
107
// When the plot is complete, append the target element to the top
102
108
// (z-index), translate it to match the facet’s frame position, and
0 commit comments