File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed
Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 105105 mouseX = parseInt ( event . clientX - selectionCanvas . offsetLeft ) ;
106106 mouseY = parseInt ( event . clientY - selectionCanvas . offsetTop ) ;
107107 showGuideLines ( ) ;
108- if ( selectionCanvasContext != undefined ) {
108+ if ( selectionCanvasContext !== undefined ) {
109109 selectionCanvasContext . beginPath ( ) ;
110110 selectionCanvasContext . setLineDash ( [ ] ) ;
111111 const width = mouseX - lastMouseX ;
180180 }
181181 }
182182
183-
184183 function storeCoordinates ( cy ) {
185184 cy . elements ( ) . forEach ( ele => {
186185 if ( ele . isNode ( ) ) {
206205 if ( node . data . label && node . data . label . length > 0 ) {
207206 let labelText = node . data . label ;
208207 let metrics = txtCtx . measureText ( labelText ) ;
209- if ( labelText . indexOf ( '\n' ) > - 1 ) {
208+ if ( labelText . indexOf ( '\n' ) > - 1 ) { // If the label text contains newlines, then we should find the longest line of them in order to find the width of the node.
210209 let longestStringLength = 0 ;
211210 const lines = node . data . label . split ( '\n' ) ;
212211 lines . forEach ( s => {
218217 metrics = txtCtx . measureText ( labelText ) ;
219218 node . data . height = ( metrics . fontBoundingBoxAscent + metrics . fontBoundingBoxDescent ) * ( lines . length + 2 ) ;
220219 }
221- node . data . width = metrics . width * 1.75 ; // Don't know why, but the width of node has to be about 75 % bigger than the width of the label text.
220+ node . data . width = metrics . width * 1.5 ; // Don't know why, but the width of node has to be about 50 % bigger than the width of the label text.
222221 }
223222 } ) ;
224223 }
You can’t perform that action at this time.
0 commit comments