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 105
105
mouseX = parseInt ( event . clientX - selectionCanvas . offsetLeft ) ;
106
106
mouseY = parseInt ( event . clientY - selectionCanvas . offsetTop ) ;
107
107
showGuideLines ( ) ;
108
- if ( selectionCanvasContext != undefined ) {
108
+ if ( selectionCanvasContext !== undefined ) {
109
109
selectionCanvasContext . beginPath ( ) ;
110
110
selectionCanvasContext . setLineDash ( [ ] ) ;
111
111
const width = mouseX - lastMouseX ;
180
180
}
181
181
}
182
182
183
-
184
183
function storeCoordinates ( cy ) {
185
184
cy . elements ( ) . forEach ( ele => {
186
185
if ( ele . isNode ( ) ) {
206
205
if ( node . data . label && node . data . label . length > 0 ) {
207
206
let labelText = node . data . label ;
208
207
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.
210
209
let longestStringLength = 0 ;
211
210
const lines = node . data . label . split ( '\n' ) ;
212
211
lines . forEach ( s => {
218
217
metrics = txtCtx . measureText ( labelText ) ;
219
218
node . data . height = ( metrics . fontBoundingBoxAscent + metrics . fontBoundingBoxDescent ) * ( lines . length + 2 ) ;
220
219
}
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.
222
221
}
223
222
} ) ;
224
223
}
You can’t perform that action at this time.
0 commit comments