@@ -45,7 +45,7 @@ export class Tip extends Mark {
45
45
frameAnchor,
46
46
format,
47
47
textAnchor = "start" ,
48
- textOverflow,
48
+ textOverflow = "ellipsis" ,
49
49
textPadding = 8 ,
50
50
title,
51
51
pointerSize = 12 ,
@@ -90,7 +90,7 @@ export class Tip extends Mark {
90
90
const mark = this ;
91
91
const { x, y, fx, fy} = scales ;
92
92
const { ownerSVGElement : svg , document} = context ;
93
- const { anchor, monospace, lineHeight, lineWidth} = this ;
93
+ const { anchor, monospace, lineHeight, lineWidth, textOverflow } = this ;
94
94
const { textPadding : r , pointerSize : m , pathFilter} = this ;
95
95
const { marginTop, marginLeft} = dimensions ;
96
96
@@ -185,13 +185,11 @@ export class Tip extends Mark {
185
185
title = value . trim ( ) ;
186
186
value = "" ;
187
187
} 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 ;
195
193
}
196
194
const line = selection . append ( "tspan" ) . attr ( "x" , 0 ) . attr ( "dy" , `${ lineHeight } em` ) . text ( "\u200b" ) ; // zwsp for double-click
197
195
if ( label ) line . append ( "tspan" ) . attr ( "font-weight" , "bold" ) . text ( label ) ;
0 commit comments