@@ -21,7 +21,7 @@ export class RuleX extends Mark {
21
21
super (
22
22
data ,
23
23
[
24
- { name : "x" , value : x , scale : "x" } ,
24
+ { name : "x" , value : x , scale : "x" , optional : true } ,
25
25
{ name : "y1" , value : y1 , scale : "y" , optional : true } ,
26
26
{ name : "y2" , value : y2 , scale : "y" , optional : true } ,
27
27
{ name : "z" , value : z , optional : true } ,
@@ -36,7 +36,7 @@ export class RuleX extends Mark {
36
36
I ,
37
37
{ x, y, color} ,
38
38
{ x : X , y1 : Y1 , y2 : Y2 , z : Z , title : L , stroke : S } ,
39
- { marginTop , height, marginBottom}
39
+ { width , height, marginTop , marginRight , marginLeft , marginBottom}
40
40
) {
41
41
const index = filter ( I , X , Y1 , Y2 , S ) ;
42
42
if ( Z ) index . sort ( ( i , j ) => ascending ( Z [ i ] , Z [ j ] ) ) ;
@@ -47,8 +47,8 @@ export class RuleX extends Mark {
47
47
. data ( index )
48
48
. join ( "line" )
49
49
. call ( applyDirectStyles , this )
50
- . attr ( "x1" , i => Math . round ( x ( X [ i ] ) ) )
51
- . attr ( "x2" , i => Math . round ( x ( X [ i ] ) ) )
50
+ . attr ( "x1" , X ? i => Math . round ( x ( X [ i ] ) ) : ( marginLeft + width - marginRight ) / 2 )
51
+ . attr ( "x2" , X ? i => Math . round ( x ( X [ i ] ) ) : ( marginLeft + width - marginRight ) / 2 )
52
52
. attr ( "y1" , Y1 ? i => y ( Y1 [ i ] ) : marginTop )
53
53
. attr ( "y2" , Y2 ? ( y . bandwidth ? i => y ( Y2 [ i ] ) + y . bandwidth ( ) : i => y ( Y2 [ i ] ) ) : height - marginBottom )
54
54
. attr ( "stroke" , S && ( i => color ( S [ i ] ) ) )
@@ -74,7 +74,7 @@ export class RuleY extends Mark {
74
74
super (
75
75
data ,
76
76
[
77
- { name : "y" , value : y , scale : "y" } ,
77
+ { name : "y" , value : y , scale : "y" , optional : true } ,
78
78
{ name : "x1" , value : x1 , scale : "x" , optional : true } ,
79
79
{ name : "x2" , value : x2 , scale : "x" , optional : true } ,
80
80
{ name : "z" , value : z , optional : true } ,
@@ -89,7 +89,7 @@ export class RuleY extends Mark {
89
89
I ,
90
90
{ x, y, color} ,
91
91
{ y : Y , x1 : X1 , x2 : X2 , z : Z , title : L , stroke : S } ,
92
- { width, marginLeft , marginRight}
92
+ { width, height , marginTop , marginRight, marginLeft , marginBottom }
93
93
) {
94
94
const index = filter ( I , Y , X1 , X2 ) ;
95
95
if ( Z ) index . sort ( ( i , j ) => ascending ( Z [ i ] , Z [ j ] ) ) ;
@@ -102,8 +102,8 @@ export class RuleY extends Mark {
102
102
. call ( applyDirectStyles , this )
103
103
. attr ( "x1" , X1 ? i => x ( X1 [ i ] ) : marginLeft )
104
104
. attr ( "x2" , X2 ? ( x . bandwidth ? i => x ( X2 [ i ] ) + x . bandwidth ( ) : i => x ( X2 [ i ] ) ) : width - marginRight )
105
- . attr ( "y1" , i => Math . round ( y ( Y [ i ] ) ) )
106
- . attr ( "y2" , i => Math . round ( y ( Y [ i ] ) ) )
105
+ . attr ( "y1" , Y ? i => Math . round ( y ( Y [ i ] ) ) : ( marginTop + height - marginBottom ) / 2 )
106
+ . attr ( "y2" , Y ? i => Math . round ( y ( Y [ i ] ) ) : ( marginTop + height - marginBottom ) / 2 )
107
107
. attr ( "stroke" , S && ( i => color ( S [ i ] ) ) )
108
108
. call ( title ( L ) ) )
109
109
. node ( ) ;
0 commit comments