@@ -21,8 +21,8 @@ const root = '#d2f5e3';
2121//
2222
2323const clusterData = { } ;
24- let memoizeObjSelectors = { } ;
25-
24+
25+ let isFired = false
2626function clusterDataPopulate ( props ) {
2727 let atomCompObj = reorganizedCompObj ( props ) ;
2828 console . log ( props )
@@ -36,12 +36,14 @@ function clusterDataPopulate(props) {
3636 //we'll first handle AtomSelectors
3737 if ( Object . entries ( props [ 0 ] . atomSelectors ) . length !== 0 ) {
3838 if ( ! clusterData . children ) clusterData . children = [ ]
39+
3940 for ( let key in props [ 0 ] . atomSelectors ) {
4041 let outerobj = { }
4142 outerobj . name = key
4243
4344 if ( props [ 0 ] . atomSelectors [ key ] . length ) {
4445 for ( let i = 0 ; i < props [ 0 ] . atomSelectors [ key ] . length ; i ++ ) {
46+
4547 if ( ! outerobj . children ) outerobj . children = [ ]
4648 let innerobj = { }
4749 innerobj . name = props [ 0 ] . atomSelectors [ key ] [ i ]
@@ -53,20 +55,22 @@ function clusterDataPopulate(props) {
5355 innerobj . children . push ( { name :atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] } )
5456 }
5557 }
56-
5758 outerobj . children . push ( innerobj )
58- //selector to component directly
59- if ( atomCompObj [ key ] ) {
60- outerobj . children . push ( { name :key } )
61- }
62-
63-
6459 }
6560 }
6661
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 )
6770 }
6871 }
69-
72+ console . log ( clusterData )
73+ isFired = true
7074}
7175
7276function reorganizedCompObj ( props ) {
@@ -166,8 +170,11 @@ export default function Example({
166170 margin = defaultMargin ,
167171 snapshots,
168172} ) {
169- clusterDataPopulate ( snapshots ) ;
170173
174+ if ( ! isFired ) {
175+ clusterDataPopulate ( snapshots ) ;
176+ }
177+
171178 const data = useMemo ( ( ) => hierarchy ( clusterData ) , [ ] ) ;
172179 const xMax = width - margin . left - margin . right ;
173180 const yMax = height - margin . top - margin . bottom ;
0 commit comments