@@ -45,7 +45,7 @@ export class Tip extends Mark {
4545 frameAnchor,
4646 format,
4747 textAnchor = "start" ,
48- textOverflow,
48+ textOverflow = "ellipsis" ,
4949 textPadding = 8 ,
5050 title,
5151 pointerSize = 12 ,
@@ -90,7 +90,7 @@ export class Tip extends Mark {
9090 const mark = this ;
9191 const { x, y, fx, fy} = scales ;
9292 const { ownerSVGElement : svg , document} = context ;
93- const { anchor, monospace, lineHeight, lineWidth} = this ;
93+ const { anchor, monospace, lineHeight, lineWidth, textOverflow } = this ;
9494 const { textPadding : r , pointerSize : m , pathFilter} = this ;
9595 const { marginTop, marginLeft} = dimensions ;
9696
@@ -185,13 +185,11 @@ export class Tip extends Mark {
185185 title = value . trim ( ) ;
186186 value = "" ;
187187 } else {
188- if ( label || ( ! value && ! swatch ) ) value = " " + value ;
189- const [ k ] = cut ( value , w - widthof ( label ) , widthof , ee ) ;
190- if ( k >= 0 ) {
191- // value is truncated
192- title = value . trim ( ) ;
193- value = value . slice ( 0 , k ) . trimEnd ( ) + ellipsis ;
194- }
188+ const space = label || ( ! value && ! swatch ) ? " " : "" ;
189+ const text = clipper ( { monospace, lineWidth : lineWidth - widthof ( label + space ) / 100 , textOverflow} ) ( value ) ;
190+ // value is truncated
191+ if ( text !== value ) title = value . trim ( ) ;
192+ value = space + text ;
195193 }
196194 const line = selection . append ( "tspan" ) . attr ( "x" , 0 ) . attr ( "dy" , `${ lineHeight } em` ) . text ( "\u200b" ) ; // zwsp for double-click
197195 if ( label ) line . append ( "tspan" ) . attr ( "font-weight" , "bold" ) . text ( label ) ;
0 commit comments