1
1
import { ascending } from "d3" ;
2
2
import { create } from "d3" ;
3
3
import { filter } from "../defined.js" ;
4
- import { Mark , maybeColor , title } from "../mark.js" ;
4
+ import { Mark , maybeColor , maybeNumber , title } from "../mark.js" ;
5
5
import { Style , applyDirectStyles , applyIndirectStyles , applyTransform , applyAttr } from "../style.js" ;
6
6
7
7
export class Link extends Mark {
@@ -15,10 +15,12 @@ export class Link extends Mark {
15
15
z,
16
16
title,
17
17
stroke,
18
+ strokeOpacity,
18
19
...options
19
20
} = { }
20
21
) {
21
22
const [ vstroke , cstroke ] = maybeColor ( stroke , "currentColor" ) ;
23
+ const [ vstrokeOpacity , cstrokeOpacity ] = maybeNumber ( strokeOpacity ) ;
22
24
super (
23
25
data ,
24
26
[
@@ -28,18 +30,23 @@ export class Link extends Mark {
28
30
{ name : "y2" , value : y2 , scale : "y" } ,
29
31
{ name : "z" , value : z , optional : true } ,
30
32
{ name : "title" , value : title , optional : true } ,
31
- { name : "stroke" , value : vstroke , scale : "color" , optional : true }
33
+ { name : "stroke" , value : vstroke , scale : "color" , optional : true } ,
34
+ { name : "strokeOpacity" , value : vstrokeOpacity , scale : "opacity" , optional : true }
32
35
] ,
33
36
options
34
37
) ;
35
- Style ( this , { stroke : cstroke , ...options } ) ;
38
+ Style ( this , {
39
+ stroke : cstroke ,
40
+ strokeOpacity : cstrokeOpacity ,
41
+ ...options
42
+ } ) ;
36
43
}
37
44
render (
38
45
I ,
39
46
{ x, y} ,
40
- { x1 : X1 , y1 : Y1 , x2 : X2 , y2 : Y2 , z : Z , title : L , stroke : S }
47
+ { x1 : X1 , y1 : Y1 , x2 : X2 , y2 : Y2 , z : Z , title : L , stroke : S , strokeOpacity : SO }
41
48
) {
42
- const index = filter ( I , X1 , Y1 , X2 , Y2 , S ) ;
49
+ const index = filter ( I , X1 , Y1 , X2 , Y2 , S , SO ) ;
43
50
if ( Z ) index . sort ( ( i , j ) => ascending ( Z [ i ] , Z [ j ] ) ) ;
44
51
return create ( "svg:g" )
45
52
. call ( applyIndirectStyles , this )
@@ -53,6 +60,7 @@ export class Link extends Mark {
53
60
. attr ( "x2" , i => X2 [ i ] )
54
61
. attr ( "y2" , i => Y2 [ i ] )
55
62
. call ( applyAttr , "stroke" , S && ( i => S [ i ] ) )
63
+ . call ( applyAttr , "stroke-opacity" , SO && ( i => SO [ i ] ) )
56
64
. call ( title ( L ) ) )
57
65
. node ( ) ;
58
66
}
0 commit comments