@@ -57,91 +57,97 @@ interface TreeNode {
57
57
58
58
const data : TreeNode = {
59
59
name : {
60
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
61
- type : " computedString" ,
62
- value : " Reactime MVP"
60
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
61
+ type : ' computedString' ,
62
+ value : ' Reactime MVP' ,
63
63
} ,
64
64
backendDOMNodeId : 1 ,
65
65
childIds : [ '46' ] ,
66
66
ignored : false ,
67
- children : [ {
67
+ children : [
68
+ {
68
69
name : {
69
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
70
- type : " computedString" ,
71
- value : ""
70
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
71
+ type : ' computedString' ,
72
+ value : '' ,
72
73
} ,
73
74
backendDOMNodeId : 7 ,
74
75
childIds : [ '47' ] ,
75
76
ignored : true ,
76
- } , {
77
+ } ,
78
+ {
77
79
name : {
78
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
79
- type : " computedString" ,
80
- value : " Tic-Tac-Toe"
80
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
81
+ type : ' computedString' ,
82
+ value : ' Tic-Tac-Toe' ,
81
83
} ,
82
84
backendDOMNodeId : 8 ,
83
85
childIds : [ '48' ] ,
84
86
ignored : false ,
85
- } ] ,
87
+ } ,
88
+ ] ,
86
89
} ;
87
90
88
91
const nodeAxArr = [
89
92
{
90
93
name : {
91
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
92
- type : " computedString" ,
93
- value : " Reactime MVP"
94
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
95
+ type : ' computedString' ,
96
+ value : ' Reactime MVP' ,
94
97
} ,
95
98
backendDOMNodeId : 1 ,
96
99
childIds : [ '46' ] ,
97
100
ignored : false ,
98
- children : [ {
101
+ children : [
102
+ {
99
103
name : {
100
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
101
- type : " computedString" ,
102
- value : ""
104
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
105
+ type : ' computedString' ,
106
+ value : '' ,
103
107
} ,
104
108
backendDOMNodeId : 7 ,
105
109
childIds : [ '47' ] ,
106
110
ignored : true ,
107
- } , {
111
+ } ,
112
+ {
108
113
name : {
109
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
110
- type : " computedString" ,
111
- value : " Tic-Tac-Toe"
114
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
115
+ type : ' computedString' ,
116
+ value : ' Tic-Tac-Toe' ,
112
117
} ,
113
118
backendDOMNodeId : 8 ,
114
119
childIds : [ '48' ] ,
115
120
ignored : false ,
116
- } ] ,
121
+ } ,
122
+ ] ,
117
123
} ,
118
124
{
119
125
name : {
120
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
121
- type : " computedString" ,
122
- value : ""
126
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
127
+ type : ' computedString' ,
128
+ value : '' ,
123
129
} ,
124
130
backendDOMNodeId : 7 ,
125
131
childIds : [ '47' ] ,
126
132
ignored : true ,
127
133
} ,
128
134
{
129
135
name : {
130
- sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
131
- type : " computedString" ,
132
- value : " Tic-Tac-Toe"
136
+ sources : [ { attribute : 'aria-labelledby' , type : 'relatedElement' } ] ,
137
+ type : ' computedString' ,
138
+ value : ' Tic-Tac-Toe' ,
133
139
} ,
134
140
backendDOMNodeId : 8 ,
135
141
childIds : [ '48' ] ,
136
142
ignored : false ,
137
- }
138
- ]
143
+ } ,
144
+ ] ;
139
145
140
- const defaultMargin = {
146
+ const defaultMargin = {
141
147
top : 30 ,
142
148
left : 30 ,
143
149
right : 55 ,
144
- bottom : 70 ,
150
+ bottom : 70 ,
145
151
} ;
146
152
147
153
const nodeCoords : object = { } ;
@@ -158,18 +164,15 @@ export type LinkTypesProps = {
158
164
} ;
159
165
160
166
export default function AxTree ( props ) {
161
- const {
162
- currLocation,
163
- axSnapshots,
164
- width,
165
- height
166
- } = props ;
167
+ const { currLocation, axSnapshots, width, height } = props ;
168
+
169
+
167
170
168
171
let margin = defaultMargin ;
169
172
let totalWidth = width ;
170
173
let totalHeight = height ;
171
174
172
-
175
+ if ( axSnapshots [ currLocation . index ] === 'emptyAxSnap' ) return ;
173
176
174
177
const toolTipTimeoutID = useRef ( null ) ; //useRef stores stateful data that’s not needed for rendering.
175
178
const {
@@ -180,7 +183,7 @@ export default function AxTree(props) {
180
183
showTooltip, // function to set tooltip state
181
184
hideTooltip, // function to close a tooltip
182
185
} = useTooltip ( ) ; // returns an object with several properties that you can use to manage the tooltip state of your component
183
- console . log ( 'tool tip data: ' , tooltipData ) ;
186
+
184
187
// let nameVal = JSON.stringify(tooltipData)
185
188
// console.log('nameVal', nameVal);
186
189
const {
@@ -243,12 +246,9 @@ export default function AxTree(props) {
243
246
}
244
247
}
245
248
246
- console . log ( 'size width height ax: ' , sizeWidth , sizeHeight ) ;
247
-
248
249
const LinkComponent = getLinkComponent ( { layout, linkType, orientation } ) ;
249
250
250
251
const currAxSnapshot = JSON . parse ( JSON . stringify ( axSnapshots [ currLocation . index ] ) ) ;
251
- console . log ( 'currAxSnapshot: ' , currAxSnapshot ) ;
252
252
253
253
// root node of currAxSnapshot
254
254
const rootAxNode = JSON . parse ( JSON . stringify ( currAxSnapshot [ 0 ] ) ) ;
@@ -259,7 +259,7 @@ export default function AxTree(props) {
259
259
// currNode.children = [];
260
260
// // checks if there is more than 1 child
261
261
// if (currNode.childIds.length > 1) {
262
- // for (let m = 0; m < currNode.childIds.length; m++) {
262
+ // for (let m = 0; m < currNode.childIds.length; m++) {
263
263
// for (let j = 0; j < currAxSnapshot.length; j++) {
264
264
// if (currNode.childIds.includes(currAxSnapshot[j].nodeId)) {
265
265
// currNode.children.push(currAxSnapshot[j]);
@@ -280,22 +280,19 @@ export default function AxTree(props) {
280
280
// organizeAxTree([rootAxNode], currAxSnapshot);
281
281
const organizeAxTree = ( currNode , currAxSnapshot ) => {
282
282
if ( currNode . childIds && currNode . childIds . length > 0 ) {
283
- currNode . children = [ ] ;
283
+ currNode . children = [ ] ;
284
284
for ( let j = 0 ; j < currAxSnapshot . length ; j ++ ) {
285
285
for ( const childEle of currNode . childIds ) {
286
286
if ( childEle === currAxSnapshot [ j ] . nodeId ) {
287
287
currNode . children . push ( currAxSnapshot [ j ] ) ;
288
288
organizeAxTree ( currAxSnapshot [ j ] , currAxSnapshot ) ;
289
289
}
290
290
}
291
-
292
291
}
293
292
}
294
- }
293
+ } ;
295
294
296
295
organizeAxTree ( rootAxNode , currAxSnapshot ) ;
297
-
298
- console . log ( 'rootAxNode: ' , rootAxNode ) ;
299
296
300
297
// store each individual node, now with children property in nodeAxArr
301
298
// need to consider order, iterate through the children property first?
@@ -316,7 +313,6 @@ export default function AxTree(props) {
316
313
} ;
317
314
318
315
populateNodeAxArr ( rootAxNode ) ;
319
- console . log ( 'nodeAxArr: ' , nodeAxArr ) ;
320
316
321
317
// ax Legend
322
318
const { axLegendButtonClicked } = useSelector ( ( state : RootState ) => state . axLegend ) ;
@@ -345,7 +341,7 @@ export default function AxTree(props) {
345
341
< svg ref = { containerRef } width = { totalWidth + 0.2 * totalWidth } height = { totalHeight } >
346
342
< LinearGradient id = 'root-gradient' from = '#488689' to = '#3c6e71' />
347
343
< LinearGradient id = 'parent-gradient' from = '#488689' to = '#3c6e71' />
348
- < rect
344
+ < rect
349
345
className = 'componentMapContainer'
350
346
width = { sizeWidth / aspect }
351
347
height = { sizeHeight / aspect + 0 }
@@ -366,12 +362,11 @@ export default function AxTree(props) {
366
362
key = { i }
367
363
data = { link }
368
364
percent = { stepPercent }
369
- stroke = " rgb(254,110,158,0.6)"
370
- strokeWidth = "1"
371
- fill = " none"
365
+ stroke = ' rgb(254,110,158,0.6)'
366
+ strokeWidth = '1'
367
+ fill = ' none'
372
368
/>
373
369
) ) }
374
-
375
370
// code relating to each node in tree
376
371
{ tree . descendants ( ) . map ( ( node , key ) => {
377
372
const widthFunc = ( name ) : number => {
@@ -469,7 +464,6 @@ export default function AxTree(props) {
469
464
const handleMouseAndClickOver = ( event ) : void => {
470
465
const coords = localPoint ( event . target . ownerSVGElement , event ) ;
471
466
const tooltipObj = { ...node . data } ;
472
- console . log ( "tooltipobj: " , tooltipObj ) ;
473
467
474
468
showTooltip ( {
475
469
tooltipLeft : coords . x ,
@@ -623,4 +617,3 @@ export default function AxTree(props) {
623
617
</ div >
624
618
) ;
625
619
}
626
-
0 commit comments