1919import { Distance } from '../types/geometry_types' ;
2020import { Config } from '../types/config_types' ;
2121import { TAU , trueBearingToStandardPositionAngle } from '../utils/math' ;
22- import { LinkLabelVM , ShapeTreeNode , ValueGetterFunction } from '../types/viewmodel_types' ;
22+ import { LinkLabelVM , RawTextGetter , ShapeTreeNode , ValueGetterFunction } from '../types/viewmodel_types' ;
2323import { meanAngle } from '../geometry' ;
2424import { TextMeasure } from '../types/types' ;
2525import { ValueFormatter } from '../../../../utils/commons' ;
@@ -31,9 +31,10 @@ export function linkTextLayout(
3131 nodesWithoutRoom : ShapeTreeNode [ ] ,
3232 currentY : Distance [ ] ,
3333 anchorRadius : Distance ,
34- rawTextGetter : Function ,
34+ rawTextGetter : RawTextGetter ,
3535 valueGetter : ValueGetterFunction ,
3636 valueFormatter : ValueFormatter ,
37+ maxTextLength : number ,
3738) : LinkLabelVM [ ] {
3839 const { linkLabel } = config ;
3940 const maxDepth = nodesWithoutRoom . reduce ( ( p : number , n : ShapeTreeNode ) => Math . max ( p , n . depth ) , 0 ) ;
@@ -69,7 +70,8 @@ export function linkTextLayout(
6970 const stemFromY = y ;
7071 const stemToX = x + north * west * cy - west * relativeY ;
7172 const stemToY = cy ;
72- const text = rawTextGetter ( node ) ;
73+ const rawText = rawTextGetter ( node ) ;
74+ const text = rawText . length <= maxTextLength ? rawText : `${ rawText . substr ( 0 , maxTextLength - 1 ) } …` ; // ellipsis is one char
7375 const valueText = valueFormatter ( valueGetter ( node ) ) ;
7476 const labelFontSpec = {
7577 fontStyle : 'normal' ,
0 commit comments