@@ -185,16 +185,39 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
185
185
ancestors . pairs . forEach ( p => {
186
186
// Highlight ancestor and their ancestor
187
187
document . querySelector ( `#node-${ p [ 0 ] } ` ) ?. setAttribute ( "style" , "outline: 1px solid #85A2FE !important;" )
188
-
189
188
// Get edge size of parent ancestor to apply the right edge stroke
190
- const strokeSize = getEdgeSize ( parseInt ( ( document . querySelector ( `#node-${ p [ 1 ] } ` ) as HTMLElement ) ?. dataset ?. size || '' ) ) + 1
191
- document . querySelector ( `[data-cell-id='${ p [ 0 ] } -${ p [ 1 ] } ']` ) ?. childNodes . forEach ( k =>
192
- ( k as HTMLElement )
193
- . setAttribute (
194
- "style" ,
195
- `stroke: #85A2FE; stroke-linecap: butt; stroke-width: ${ strokeSize } px`
196
- )
197
- )
189
+ const edge = graph . getCellById ( `${ p [ 0 ] } -${ p [ 1 ] } ` )
190
+ edge . setAttrs ( {
191
+ line : {
192
+ stroke : '#85A2FE' ,
193
+ strokeWidth : ( edge . getAttrs ( ) as any ) ?. line ?. strokeWidth ,
194
+ targetMarker : {
195
+ name : 'block' ,
196
+ stroke : '#85A2FE' ,
197
+ fill : '#85A2FE' ,
198
+ } ,
199
+ } ,
200
+ } )
201
+ } )
202
+ } )
203
+
204
+ graph . on ( "node:mouseleave" , x => {
205
+ const { id} = x . node . getData ( )
206
+ const ancestors = GetAncestors ( data , id , { found : false , pairs : [ ] } )
207
+ ancestors . pairs . forEach ( p => {
208
+ document . querySelector ( `#node-${ p [ 0 ] } ` ) ?. setAttribute ( "style" , "" )
209
+ const edge = graph . getCellById ( `${ p [ 0 ] } -${ p [ 1 ] } ` )
210
+ edge . setAttrs ( {
211
+ line : {
212
+ stroke : isDarkTheme ? '#6B6B6B' : '#8992B3' ,
213
+ strokeWidth : ( edge . getAttrs ( ) as any ) ?. line ?. strokeWidth ,
214
+ targetMarker : {
215
+ name : 'block' ,
216
+ fill : isDarkTheme ? '#6B6B6B' : '#8992B3' ,
217
+ stroke : isDarkTheme ? '#6B6B6B' : '#8992B3' ,
218
+ }
219
+ } ,
220
+ } )
198
221
} )
199
222
} )
200
223
@@ -237,15 +260,6 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
237
260
238
261
ele ?. addEventListener ( 'mousedown' , mouseDownHandler )
239
262
240
- graph . on ( "node:mouseleave" , x => {
241
- const { id} = x . node . getData ( )
242
- const ancestors = GetAncestors ( data , id , { found : false , pairs : [ ] } )
243
- ancestors . pairs . forEach ( p => {
244
- document . querySelector ( `#node-${ p [ 0 ] } ` ) ?. setAttribute ( "style" , "" )
245
- document . querySelector ( `[data-cell-id='${ p [ 0 ] } -${ p [ 1 ] } ']` ) ?. childNodes . forEach ( k => ( k as HTMLElement ) . setAttribute ( "style" , "" ) )
246
- } )
247
- } )
248
-
249
263
resize ( )
250
264
251
265
const result = Hierarchy . compactBox ( data , {
@@ -297,6 +311,20 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
297
311
}
298
312
299
313
314
+ const portId = data . id + '-source'
315
+ let targetPort = { }
316
+ const targetItem : any = [ ]
317
+ if ( info . parentId ) {
318
+ targetItem . push ( { id : `${ info . id } -${ info . parentId } -target` , group : `${ info . parentId } -target` } )
319
+ targetPort [ info . parentId + '-target' ] = {
320
+ position : { name : 'bottom' } ,
321
+ attrs : {
322
+ circle : {
323
+ r : 0
324
+ }
325
+ }
326
+ }
327
+ }
300
328
model . nodes ?. push ( {
301
329
id : data . id ,
302
330
x : ( data . x || 0 ) + document . body . clientWidth / 2 ,
@@ -309,6 +337,25 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
309
337
stroke : 'transparent' ,
310
338
} ,
311
339
} ,
340
+ ports : {
341
+ groups : {
342
+ [ portId ] : {
343
+ position : { name : 'top' } ,
344
+ attrs : {
345
+ circle : {
346
+ r : 0
347
+ }
348
+ }
349
+ } ,
350
+ ...targetPort ,
351
+ } ,
352
+ items : [
353
+ ...data . children . map ( c => ( {
354
+ id : `${ data . id } -${ c . id } ` , group : portId
355
+ } ) ) ,
356
+ ...targetItem ,
357
+ ] ,
358
+ } ,
312
359
} )
313
360
}
314
361
if ( data . children ) {
@@ -317,8 +364,14 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
317
364
318
365
model . edges ?. push ( {
319
366
id : `${ data . id } -${ item . id } ` ,
320
- source : data . id ,
321
- target : item . id ,
367
+ source : {
368
+ cell : data . id ,
369
+ port : `${ data . id } -${ item . id } ` ,
370
+ } ,
371
+ target : {
372
+ cell : item . id ,
373
+ port : `${ data . id } -${ item . id } `
374
+ } ,
322
375
router : {
323
376
name : 'manhattan' ,
324
377
args : {
@@ -338,7 +391,11 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
338
391
line : {
339
392
stroke : isDarkTheme ? '#6B6B6B' : '#8992B3' ,
340
393
strokeWidth : getEdgeSize ( itemRecords ) ,
341
- targetMarker : null ,
394
+ targetMarker : {
395
+ name : 'block' ,
396
+ fill : isDarkTheme ? '#6B6B6B' : '#8992B3' ,
397
+ stroke : isDarkTheme ? '#6B6B6B' : '#8992B3' ,
398
+ } ,
342
399
} ,
343
400
} ,
344
401
} )
0 commit comments