@@ -18,9 +18,9 @@ const Map = (props) => {
18
18
// this state allows the canvas to stay at the zoom level on multiple re-renders
19
19
const [ { x, y, k } , setZoomState ] : any = useState ( { x : 0 , y : 0 , k : 0 } ) ;
20
20
21
- useEffect ( ( ) => {
22
- setZoomState ( d3 . zoomTransform ( d3 . select ( '#canvas' ) . node ( ) ) ) ;
23
- } , [ snapshot ] ) ;
21
+ // useEffect(() => {
22
+ // setZoomState(d3.zoomTransform(d3.select('#canvas').node()));
23
+ // }, [snapshot]);
24
24
25
25
// this only clears the canvas if Visualizer is already rendered on the extension
26
26
useEffect ( ( ) => {
@@ -37,33 +37,39 @@ const Map = (props) => {
37
37
. append ( 'g' )
38
38
. attr ( 'transform' , `translate(${ x } , ${ y } ), scale(${ k } )` ) ; // sets the canvas to the saved zoomState
39
39
40
- // atomState is the object that is passed into d3.hierarchy
41
- const childrenArr = [ ] ;
42
- if ( snapshot . children [ 0 ] . state . hooksState ) {
43
- snapshot . children [ 0 ] . state . hooksState [ 0 ] . undefined . forEach ( ( el ) =>
44
- childrenArr . push ( el )
45
- ) ;
46
- }
47
- console . log ( childrenArr ) ;
40
+ //RE-WRITE ALGORITHIM
48
41
49
- const atomState : any = {
42
+ // appState is the object that is passed into d3.hierarchy
43
+ // const childrenArr = [];
44
+ // if (snapshot.children[0].state.hooksState) {
45
+ // snapshot.children[0].state.hooksState.forEach((el) =>
46
+ // childrenArr.push(el)
47
+ // );
48
+ // }
49
+ // console.log('CHILDREN', childrenArr);
50
+
51
+ const appState : any = {
50
52
name : ' Root' ,
51
53
// pass in parsed data here
52
54
// call the helper function passing in the most recent snapshot
53
- children : childrenArr ,
55
+ children : snapshot . children ,
54
56
} ;
55
57
56
- console . log ( 'STATE' , atomState ) ;
58
+ console . log ( 'STATE' , appState ) ;
57
59
// creating the tree map
58
60
const treeMap : any = d3 . tree ( ) . nodeSize ( [ width , height ] ) ;
59
61
60
62
// creating the nodes of the tree
61
63
// pass
62
- const hierarchyNodes : any = d3 . hierarchy ( atomState ) ;
64
+ const hierarchyNodes : any = d3 . hierarchy ( appState ) ;
65
+
66
+ console . log ( 'Hierarchy NODES' , hierarchyNodes ) ;
63
67
64
68
// calling the tree function with nodes created from data
65
69
const finalMap : any = treeMap ( hierarchyNodes ) ;
66
70
71
+ console . log ( 'FINAL MAP' , finalMap ) ;
72
+
67
73
// renders a flat array of objects containing all parent-child links
68
74
// renders the paths onto the component
69
75
let paths : any = finalMap . links ( ) ;
0 commit comments