@@ -21,8 +21,8 @@ const root = '#d2f5e3';
21
21
//
22
22
23
23
const clusterData = { } ;
24
- let memoizeObjSelectors = { } ;
25
-
24
+
25
+ let isFired = false
26
26
function clusterDataPopulate ( props ) {
27
27
let atomCompObj = reorganizedCompObj ( props ) ;
28
28
console . log ( props )
@@ -36,12 +36,14 @@ function clusterDataPopulate(props) {
36
36
//we'll first handle AtomSelectors
37
37
if ( Object . entries ( props [ 0 ] . atomSelectors ) . length !== 0 ) {
38
38
if ( ! clusterData . children ) clusterData . children = [ ]
39
+
39
40
for ( let key in props [ 0 ] . atomSelectors ) {
40
41
let outerobj = { }
41
42
outerobj . name = key
42
43
43
44
if ( props [ 0 ] . atomSelectors [ key ] . length ) {
44
45
for ( let i = 0 ; i < props [ 0 ] . atomSelectors [ key ] . length ; i ++ ) {
46
+
45
47
if ( ! outerobj . children ) outerobj . children = [ ]
46
48
let innerobj = { }
47
49
innerobj . name = props [ 0 ] . atomSelectors [ key ] [ i ]
@@ -53,20 +55,22 @@ function clusterDataPopulate(props) {
53
55
innerobj . children . push ( { name :atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] } )
54
56
}
55
57
}
56
-
57
58
outerobj . children . push ( innerobj )
58
- //selector to component directly
59
- if ( atomCompObj [ key ] ) {
60
- outerobj . children . push ( { name :key } )
61
- }
62
-
63
-
64
59
}
65
60
}
66
61
62
+ // selector to component directly
63
+ if ( atomCompObj [ key ] && atomCompObj [ key ] . length ) {
64
+ for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
65
+ outerobj . children . push ( { name :atomCompObj [ key ] [ i ] } )
66
+ }
67
+ }
68
+
69
+ clusterData . children . push ( outerobj )
67
70
}
68
71
}
69
-
72
+ console . log ( clusterData )
73
+ isFired = true
70
74
}
71
75
72
76
function reorganizedCompObj ( props ) {
@@ -166,8 +170,11 @@ export default function Example({
166
170
margin = defaultMargin ,
167
171
snapshots,
168
172
} ) {
169
- clusterDataPopulate ( snapshots ) ;
170
173
174
+ if ( ! isFired ) {
175
+ clusterDataPopulate ( snapshots ) ;
176
+ }
177
+
171
178
const data = useMemo ( ( ) => hierarchy ( clusterData ) , [ ] ) ;
172
179
const xMax = width - margin . left - margin . right ;
173
180
const yMax = height - margin . top - margin . bottom ;
0 commit comments