1
1
import { brush as brusher , brushX as brusherX , brushY as brusherY , create , select } from "d3" ;
2
2
import { identity , maybeTuple } from "../options.js" ;
3
3
import { Mark } from "../plot.js" ;
4
- import { applyIndirectStyles } from "../style.js" ;
4
+ import { applyDirectStyles , applyIndirectStyles } from "../style.js" ;
5
5
6
- // TODO Allow brush styling?
7
6
// TODO Disable standard mark channels (e.g., href, title)?
8
7
const defaults = {
9
8
ariaLabel : "brush" ,
10
- fill : null ,
11
- stroke : null
9
+ fill : "#777" ,
10
+ fillOpacity : 0.3 ,
11
+ stroke : "#fff"
12
12
} ;
13
13
14
14
// TODO Initial selection?
@@ -30,13 +30,14 @@ export class Brush extends Mark {
30
30
}
31
31
render ( index , scales , { x : X , y : Y } , dimensions ) {
32
32
const { marginLeft, width, marginRight, marginTop, height, marginBottom} = dimensions ;
33
+ const { ariaLabel, ariaDescription, ariaHidden, ...options } = this ;
33
34
const left = marginLeft ;
34
35
const top = marginTop ;
35
36
const right = width - marginRight ;
36
37
const bottom = height - marginBottom ;
37
38
const mark = this ;
38
39
const g = create ( "svg:g" )
39
- . call ( applyIndirectStyles , this )
40
+ . call ( applyIndirectStyles , { ariaLabel , ariaDescription , ariaHidden } )
40
41
. call ( ( X && Y ? brusher : X ? brusherX : brusherY ) ( )
41
42
. extent ( [ [ left , top ] , [ right , bottom ] ] )
42
43
. on ( "start brush end" , function ( event ) {
@@ -66,6 +67,10 @@ export class Brush extends Mark {
66
67
this . selection = S ;
67
68
this . dispatchEvent ( new Event ( "input" , { bubbles : true } ) ) ;
68
69
} ) )
70
+ . call ( g => g . selectAll ( ".selection" )
71
+ . attr ( "shape-rendering" , null ) // reset d3-brush
72
+ . call ( applyIndirectStyles , options )
73
+ . call ( applyDirectStyles , options ) )
69
74
. node ( ) ;
70
75
g . selection = null ;
71
76
return g ;
0 commit comments