@@ -25,7 +25,7 @@ export class Brush extends Mark {
25
25
{ x : X , y : Y , picker : J } ,
26
26
{ marginLeft, width, marginRight, marginTop, height, marginBottom}
27
27
) {
28
- let svg ;
28
+ let root ;
29
29
const { onbrush} = this ;
30
30
const g = create ( "svg:g" ) ;
31
31
const data = this . data ;
@@ -52,13 +52,13 @@ export class Brush extends Mark {
52
52
53
53
if ( typeof onbrush === "function" ) {
54
54
onbrush ( event , dots ) ;
55
- } else if ( svg ) {
56
- svg . value = dots ;
57
- svg . dispatchEvent ( new CustomEvent ( 'input' ) ) ;
55
+ } else if ( root ) {
56
+ root . value = dots ;
57
+ root . dispatchEvent ( new CustomEvent ( 'input' ) ) ;
58
58
}
59
- if ( svg ) {
59
+ if ( root ) {
60
60
if ( sourceEvent && type === "start" ) {
61
- for ( const { b, g} of svg . __brushes ) {
61
+ for ( const { b, g} of root . __brushes ) {
62
62
if ( b !== brush ) g . call ( b . clear ) ;
63
63
}
64
64
}
@@ -73,12 +73,13 @@ export class Brush extends Mark {
73
73
* - register the multiple brushes (for faceting)
74
74
*/
75
75
setTimeout ( ( ) => {
76
- svg = g . node ( ) . ownerSVGElement ;
77
- if ( ! svg . __brushes ) svg . __brushes = [ ] ;
78
- svg . __brushes . push ( { b : brush , g} ) ;
76
+ const svg = g . node ( ) . ownerSVGElement ;
77
+ root = svg . parentElement ?. nodeName === "FIGURE" ? svg . parentElement : svg ;
78
+ if ( ! root . __brushes ) root . __brushes = [ ] ;
79
+ root . __brushes . push ( { b : brush , g} ) ;
79
80
80
81
// initial setup works only on one facet
81
- if ( svg . __brushes . length === 1 ) {
82
+ if ( root . __brushes . length === 1 ) {
82
83
if ( this . initialSelection ) {
83
84
const s = this . initialSelection ;
84
85
if ( X && Y ) {
0 commit comments