@@ -138,34 +138,31 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
138
138
graph . on ( "resize" , ( ) => graph . centerContent ( ) )
139
139
graph . on ( "node:mouseenter" , x => {
140
140
const { id} = x . node . getData ( )
141
+ // Find ancestors of a node
141
142
const ancestors = GetAncestors ( data , id , { found : false , pairs : [ ] } )
142
- if ( ancestors . found ) {
143
- ancestors . pairs . forEach ( p => {
144
- const parentNode = document . querySelector ( `#node-${ p [ 0 ] } ` )
145
- parentNode ?. classList . add ( 'ProfileContainerHover' )
146
- document . querySelector ( `[data-cell-id='${ p [ 0 ] } -${ p [ 1 ] } ']` ) ?. childNodes . forEach ( ( k : any ) => {
147
-
148
- const entityNode = document . querySelector ( `#node-${ p [ 1 ] } ` ) as any
149
-
150
- const strokeSize = getEdgeSize ( parseInt ( entityNode ?. dataset ?. size ) ) + 1 ;
151
- k . setAttribute ( "style" , `stroke: #85A2FE; stroke-linecap: butt; stroke-width: ${ strokeSize } px` )
152
- } )
153
- } )
154
- }
143
+ ancestors . pairs . forEach ( p => {
144
+ // Highlight ancestor and their ancestor
145
+ document . querySelector ( `#node-${ p [ 0 ] } ` ) ?. setAttribute ( "style" , "border: 1px solid #85A2FE !important;" )
146
+
147
+ // Get edge size of parent ancestor to apply the right edge stroke
148
+ const strokeSize = getEdgeSize ( parseInt ( ( document . querySelector ( `#node-${ p [ 1 ] } ` ) as HTMLElement ) ?. dataset ?. size || '' ) ) + 1
149
+ document . querySelector ( `[data-cell-id='${ p [ 0 ] } -${ p [ 1 ] } ']` ) ?. childNodes . forEach ( k =>
150
+ ( k as HTMLElement )
151
+ . setAttribute (
152
+ "style" ,
153
+ `stroke: #85A2FE; stroke-linecap: butt; stroke-width: ${ strokeSize } px`
154
+ )
155
+ )
156
+ } )
155
157
} )
156
158
157
159
graph . on ( "node:mouseleave" , x => {
158
160
const { id} = x . node . getData ( )
159
161
const ancestors = GetAncestors ( data , id , { found : false , pairs : [ ] } )
160
- if ( ancestors . found ) {
161
- ancestors . pairs . forEach ( p => {
162
- const parentNode = document . querySelector ( `#node-${ p [ 0 ] } ` )
163
- parentNode ?. classList . remove ( 'ProfileContainerHover' )
164
- document . querySelector ( `[data-cell-id='${ p [ 0 ] } -${ p [ 1 ] } ']` ) ?. childNodes . forEach ( k => {
165
- ( k as any ) . setAttribute ( "style" , "" )
166
- } )
167
- } )
168
- }
162
+ ancestors . pairs . forEach ( p => {
163
+ document . querySelector ( `#node-${ p [ 0 ] } ` ) ?. setAttribute ( "style" , "" )
164
+ document . querySelector ( `[data-cell-id='${ p [ 0 ] } -${ p [ 1 ] } ']` ) ?. childNodes . forEach ( k => ( k as HTMLElement ) . setAttribute ( "style" , "" ) )
165
+ } )
169
166
} )
170
167
171
168
function resize ( ) {
0 commit comments