export class GraphUtils { addText ( svg , x , y , text , maxChars = 0 ) { const fittedText = maxChars > 0 && text && text . length > maxChars ? `${ text . slice ( 0 , maxChars - 3 ) }...` : text ; svg . append ( 'text' ) . attr ( 'x' , x ) . attr ( 'y' , y ) . text ( fittedText ) ; } addCircle ( svg , x , y , r , clazz , mouseOverFn ? , mouseOutFn ? ) { svg . append ( 'circle' ) . attr ( 'cx' , x ) . attr ( 'cy' , y ) . attr ( 'r' , r ) . attr ( 'stroke-width' , 1 ) . attr ( 'class' , clazz ) . on ( 'mouseover' , mouseOverFn ? mouseOverFn : ( ) => null ) . on ( 'mouseout' , mouseOutFn ? mouseOutFn : ( ) => null ) ; } addLine ( svg , x1 , y1 , x2 , y2 , clazz ) { svg . append ( 'line' ) . attr ( 'x1' , x1 ) . attr ( 'y1' , y1 ) . attr ( 'x2' , x2 ) . attr ( 'y2' , y2 ) . attr ( 'class' , 'link ' + ( clazz || '' ) ) ; } }