@@ -49,91 +49,97 @@ interface TreeNode {
49
49
50
50
const data : TreeNode = {
51
51
name : {
52
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
53
- type : " computedString" ,
54
- value : " Reactime MVP"
52
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
53
+ type : ' computedString' ,
54
+ value : ' Reactime MVP' ,
55
55
} ,
56
56
backendDOMNodeId : 1 ,
57
57
childIds : [ '46' ] ,
58
58
ignored : false ,
59
- children : [ {
59
+ children : [
60
+ {
60
61
name : {
61
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
62
- type : " computedString" ,
63
- value : ""
62
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
63
+ type : ' computedString' ,
64
+ value : '' ,
64
65
} ,
65
66
backendDOMNodeId : 7 ,
66
67
childIds : [ '47' ] ,
67
68
ignored : true ,
68
- } , {
69
+ } ,
70
+ {
69
71
name : {
70
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
71
- type : " computedString" ,
72
- value : " Tic-Tac-Toe"
72
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
73
+ type : ' computedString' ,
74
+ value : ' Tic-Tac-Toe' ,
73
75
} ,
74
76
backendDOMNodeId : 8 ,
75
77
childIds : [ '48' ] ,
76
78
ignored : false ,
77
- } ] ,
79
+ } ,
80
+ ] ,
78
81
} ;
79
82
80
83
const nodeAxArr = [
81
84
{
82
85
name : {
83
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
84
- type : " computedString" ,
85
- value : " Reactime MVP"
86
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
87
+ type : ' computedString' ,
88
+ value : ' Reactime MVP' ,
86
89
} ,
87
90
backendDOMNodeId : 1 ,
88
91
childIds : [ '46' ] ,
89
92
ignored : false ,
90
- children : [ {
93
+ children : [
94
+ {
91
95
name : {
92
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
93
- type : " computedString" ,
94
- value : ""
96
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
97
+ type : ' computedString' ,
98
+ value : '' ,
95
99
} ,
96
100
backendDOMNodeId : 7 ,
97
101
childIds : [ '47' ] ,
98
102
ignored : true ,
99
- } , {
103
+ } ,
104
+ {
100
105
name : {
101
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
102
- type : " computedString" ,
103
- value : " Tic-Tac-Toe"
106
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
107
+ type : ' computedString' ,
108
+ value : ' Tic-Tac-Toe' ,
104
109
} ,
105
110
backendDOMNodeId : 8 ,
106
111
childIds : [ '48' ] ,
107
112
ignored : false ,
108
- } ] ,
113
+ } ,
114
+ ] ,
109
115
} ,
110
116
{
111
117
name : {
112
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
113
- type : " computedString" ,
114
- value : ""
118
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
119
+ type : ' computedString' ,
120
+ value : '' ,
115
121
} ,
116
122
backendDOMNodeId : 7 ,
117
123
childIds : [ '47' ] ,
118
124
ignored : true ,
119
125
} ,
120
126
{
121
127
name : {
122
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
123
- type : " computedString" ,
124
- value : " Tic-Tac-Toe"
128
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
129
+ type : ' computedString' ,
130
+ value : ' Tic-Tac-Toe' ,
125
131
} ,
126
132
backendDOMNodeId : 8 ,
127
133
childIds : [ '48' ] ,
128
134
ignored : false ,
129
- }
130
- ]
135
+ } ,
136
+ ] ;
131
137
132
- const defaultMargin = {
138
+ const defaultMargin = {
133
139
top : 30 ,
134
140
left : 30 ,
135
141
right : 55 ,
136
- bottom : 70 ,
142
+ bottom : 70 ,
137
143
} ;
138
144
139
145
const nodeCoords : object = { } ;
@@ -150,12 +156,7 @@ export type LinkTypesProps = {
150
156
} ;
151
157
152
158
export default function AxTree ( props ) {
153
- const {
154
- currLocation,
155
- axSnapshots,
156
- width,
157
- height
158
- } = props ;
159
+ const { currLocation, axSnapshots, width, height } = props ;
159
160
160
161
let margin = defaultMargin ;
161
162
let totalWidth = width ;
@@ -207,7 +208,7 @@ export default function AxTree(props) {
207
208
// currNode.children = [];
208
209
// // checks if there is more than 1 child
209
210
// if (currNode.childIds.length > 1) {
210
- // for (let m = 0; m < currNode.childIds.length; m++) {
211
+ // for (let m = 0; m < currNode.childIds.length; m++) {
211
212
// for (let j = 0; j < currAxSnapshot.length; j++) {
212
213
// if (currNode.childIds.includes(currAxSnapshot[j].nodeId)) {
213
214
// currNode.children.push(currAxSnapshot[j]);
@@ -228,21 +229,20 @@ export default function AxTree(props) {
228
229
// organizeAxTree([rootAxNode], currAxSnapshot);
229
230
const organizeAxTree = ( currNode , currAxSnapshot ) => {
230
231
if ( currNode . childIds && currNode . childIds . length > 0 ) {
231
- currNode . children = [ ] ;
232
+ currNode . children = [ ] ;
232
233
for ( let j = 0 ; j < currAxSnapshot . length ; j ++ ) {
233
234
for ( const childEle of currNode . childIds ) {
234
235
if ( childEle === currAxSnapshot [ j ] . nodeId ) {
235
236
currNode . children . push ( currAxSnapshot [ j ] ) ;
236
237
organizeAxTree ( currAxSnapshot [ j ] , currAxSnapshot ) ;
237
238
}
238
239
}
239
-
240
240
}
241
241
}
242
- }
242
+ } ;
243
243
244
244
organizeAxTree ( rootAxNode , currAxSnapshot ) ;
245
-
245
+
246
246
console . log ( 'rootAxNode: ' , rootAxNode ) ;
247
247
248
248
// store each individual node, now with children property in nodeAxArr
@@ -267,7 +267,7 @@ export default function AxTree(props) {
267
267
console . log ( 'nodeAxArr: ' , nodeAxArr ) ;
268
268
269
269
const {
270
- containerRef // Access to the container's bounding box. This will be empty on first render.
270
+ containerRef, // Access to the container's bounding box. This will be empty on first render.
271
271
} = useTooltipInPortal ( {
272
272
// Visx hook
273
273
detectBounds : true , // use TooltipWithBounds
@@ -291,12 +291,12 @@ export default function AxTree(props) {
291
291
< svg ref = { containerRef } width = { totalWidth } height = { totalHeight + 0 } >
292
292
< LinearGradient id = 'root-gradient' from = '#488689' to = '#3c6e71' />
293
293
< LinearGradient id = 'parent-gradient' from = '#488689' to = '#3c6e71' />
294
- < rect
294
+ < rect
295
295
className = 'componentMapContainer'
296
296
width = { sizeWidth / aspect }
297
297
height = { sizeHeight / aspect + 0 }
298
298
rx = { 14 }
299
- />
299
+ />
300
300
< Group transform = { `scale(${ aspect } )` } top = { margin . top } left = { margin . left } >
301
301
< Tree
302
302
root = { hierarchy ( nodeAxArr [ 0 ] , ( d ) => ( d . isExpanded ? null : d . children ) ) }
@@ -310,12 +310,11 @@ export default function AxTree(props) {
310
310
key = { i }
311
311
data = { link }
312
312
percent = { stepPercent }
313
- stroke = " rgb(254,110,158,0.6)"
314
- strokeWidth = "1"
315
- fill = " none"
313
+ stroke = ' rgb(254,110,158,0.6)'
314
+ strokeWidth = '1'
315
+ fill = ' none'
316
316
/>
317
317
) ) }
318
-
319
318
// code relating to each node in tree
320
319
{ tree . descendants ( ) . map ( ( node , key ) => {
321
320
const widthFunc = ( name ) : number => {
@@ -480,4 +479,3 @@ export default function AxTree(props) {
480
479
</ div >
481
480
) ;
482
481
}
483
-
0 commit comments