@@ -75,6 +75,8 @@ export function styles(
75
75
const [ vstroke , cstroke ] = maybeColorChannel ( stroke , defaultStroke ) ;
76
76
const [ vstrokeOpacity , cstrokeOpacity ] = maybeNumberChannel ( strokeOpacity , defaultStrokeOpacity ) ;
77
77
const [ vopacity , copacity ] = maybeNumberChannel ( opacity ) ;
78
+ const [ vstrokeDasharray , cstrokeDasharray ] = maybeDasharrayChannel ( strokeDasharray ) ;
79
+ const [ vstrokeDashoffset , cstrokeDashoffset ] = maybeNumberChannel ( strokeDashoffset ) ;
78
80
79
81
// For styles that have no effect if there is no stroke, only apply the
80
82
// defaults if the stroke is not the constant none. (If stroke is a channel,
@@ -110,8 +112,8 @@ export function styles(
110
112
mark . strokeLinejoin = impliedString ( strokeLinejoin , "miter" ) ;
111
113
mark . strokeLinecap = impliedString ( strokeLinecap , "butt" ) ;
112
114
mark . strokeMiterlimit = impliedNumber ( strokeMiterlimit , 4 ) ;
113
- mark . strokeDasharray = impliedString ( strokeDasharray , "none" ) ;
114
- mark . strokeDashoffset = impliedString ( strokeDashoffset , "0" ) ;
115
+ mark . strokeDasharray = impliedString ( cstrokeDasharray , "none" ) ;
116
+ mark . strokeDashoffset = impliedString ( cstrokeDashoffset , "0" ) ;
115
117
}
116
118
117
119
mark . target = string ( target ) ;
@@ -130,6 +132,8 @@ export function styles(
130
132
{ name : "fill" , value : vfill , scale : "color" , optional : true } ,
131
133
{ name : "fillOpacity" , value : vfillOpacity , scale : "opacity" , optional : true } ,
132
134
{ name : "stroke" , value : vstroke , scale : "color" , optional : true } ,
135
+ { name : "strokeDasharray" , value : vstrokeDasharray , optional : true } ,
136
+ { name : "strokeDashoffset" , value : vstrokeDashoffset , optional : true } ,
133
137
{ name : "strokeOpacity" , value : vstrokeOpacity , scale : "opacity" , optional : true } ,
134
138
{ name : "strokeWidth" , value : vstrokeWidth , optional : true } ,
135
139
{ name : "opacity" , value : vopacity , scale : "opacity" , optional : true }
@@ -154,25 +158,29 @@ export function applyTextGroup(selection, T) {
154
158
if ( T ) selection . text ( ( [ i ] ) => formatDefault ( T [ i ] ) ) ;
155
159
}
156
160
157
- export function applyChannelStyles ( selection , { target} , { ariaLabel : AL , title : T , fill : F , fillOpacity : FO , stroke : S , strokeOpacity : SO , strokeWidth : SW , opacity : O , href : H } ) {
161
+ export function applyChannelStyles ( selection , { target} , { ariaLabel : AL , title : T , fill : F , fillOpacity : FO , stroke : S , strokeOpacity : SO , strokeWidth : SW , opacity : O , href : H , strokeDasharray : SDA , strokeDashoffset : SDO } ) {
158
162
if ( AL ) applyAttr ( selection , "aria-label" , i => AL [ i ] ) ;
159
163
if ( F ) applyAttr ( selection , "fill" , i => F [ i ] ) ;
160
164
if ( FO ) applyAttr ( selection , "fill-opacity" , i => FO [ i ] ) ;
161
165
if ( S ) applyAttr ( selection , "stroke" , i => S [ i ] ) ;
162
166
if ( SO ) applyAttr ( selection , "stroke-opacity" , i => SO [ i ] ) ;
163
167
if ( SW ) applyAttr ( selection , "stroke-width" , i => SW [ i ] ) ;
168
+ if ( SDA ) applyAttr ( selection , "stroke-dasharray" , i => SDA [ i ] ) ;
169
+ if ( SDO ) applyAttr ( selection , "stroke-dashoffset" , i => SDO [ i ] ) ;
164
170
if ( O ) applyAttr ( selection , "opacity" , i => O [ i ] ) ;
165
171
if ( H ) applyHref ( selection , i => H [ i ] , target ) ;
166
172
applyTitle ( selection , T ) ;
167
173
}
168
174
169
- export function applyGroupedChannelStyles ( selection , { target} , { ariaLabel : AL , title : T , fill : F , fillOpacity : FO , stroke : S , strokeOpacity : SO , strokeWidth : SW , opacity : O , href : H } ) {
175
+ export function applyGroupedChannelStyles ( selection , { target} , { ariaLabel : AL , title : T , fill : F , fillOpacity : FO , stroke : S , strokeOpacity : SO , strokeWidth : SW , opacity : O , href : H , strokeDasharray : SDA , strokeDashoffset : SDO } ) {
170
176
if ( AL ) applyAttr ( selection , "aria-label" , ( [ i ] ) => AL [ i ] ) ;
171
177
if ( F ) applyAttr ( selection , "fill" , ( [ i ] ) => F [ i ] ) ;
172
178
if ( FO ) applyAttr ( selection , "fill-opacity" , ( [ i ] ) => FO [ i ] ) ;
173
179
if ( S ) applyAttr ( selection , "stroke" , ( [ i ] ) => S [ i ] ) ;
174
180
if ( SO ) applyAttr ( selection , "stroke-opacity" , ( [ i ] ) => SO [ i ] ) ;
175
181
if ( SW ) applyAttr ( selection , "stroke-width" , ( [ i ] ) => SW [ i ] ) ;
182
+ if ( SDA ) applyAttr ( selection , "stroke-dasharray" , ( [ i ] ) => SDA [ i ] ) ;
183
+ if ( SDO ) applyAttr ( selection , "stroke-dashoffset" , ( [ i ] ) => SDO [ i ] ) ;
176
184
if ( O ) applyAttr ( selection , "opacity" , ( [ i ] ) => O [ i ] ) ;
177
185
if ( H ) applyHref ( selection , ( [ i ] ) => H [ i ] , target ) ;
178
186
applyTitleGroup ( selection , T ) ;
@@ -339,3 +347,7 @@ export function applyFrameAnchor({frameAnchor}, {width, height, marginTop, margi
339
347
/ ^ t o p / . test ( frameAnchor ) ? marginTop : / ^ b o t t o m / . test ( frameAnchor ) ? height - marginBottom : ( marginTop + height - marginBottom ) / 2
340
348
] ;
341
349
}
350
+
351
+ function maybeDasharrayChannel ( channel ) {
352
+ return typeof channel === "function" ? [ channel ] : [ , channel ] ;
353
+ }
0 commit comments