@@ -17,6 +17,7 @@ export class Text extends Mark {
17
17
text = indexOf ,
18
18
textAnchor,
19
19
lineAnchor = "middle" ,
20
+ lineHeight = 1 ,
20
21
fontFamily,
21
22
fontSize,
22
23
fontStyle,
@@ -41,6 +42,7 @@ export class Text extends Mark {
41
42
this . rotate = crotate ;
42
43
this . textAnchor = impliedString ( textAnchor , "middle" ) ;
43
44
this . lineAnchor = keyword ( lineAnchor , "lineAnchor" , [ "top" , "middle" , "bottom" ] ) ;
45
+ this . lineHeight = + lineHeight ;
44
46
this . fontFamily = string ( fontFamily ) ;
45
47
this . fontSize = cfontSize ;
46
48
this . fontStyle = string ( fontStyle ) ;
@@ -79,7 +81,7 @@ export class Text extends Mark {
79
81
}
80
82
}
81
83
82
- function applyMultilineText ( selection , { lineAnchor} , T ) {
84
+ function applyMultilineText ( selection , { lineAnchor, lineHeight } , T ) {
83
85
if ( ! T ) return ;
84
86
const format = isTemporal ( T ) ? isoFormat : isNumeric ( T ) ? formatNumber ( ) : string ;
85
87
selection . each ( function ( i ) {
@@ -90,7 +92,7 @@ function applyMultilineText(selection, {lineAnchor}, T) {
90
92
for ( let i = 0 ; i < n ; ++ i ) {
91
93
const tspan = document . createElementNS ( namespaces . svg , "tspan" ) ;
92
94
tspan . setAttribute ( "x" , 0 ) ;
93
- tspan . setAttribute ( "y" , `${ y + i } em` ) ;
95
+ tspan . setAttribute ( "y" , `${ y + i * lineHeight } em` ) ;
94
96
tspan . textContent = lines [ i ] ;
95
97
this . appendChild ( tspan ) ;
96
98
}
0 commit comments