@@ -12,15 +12,15 @@ const Map = (props) => {
12
12
console . log ( 'MAP SNAPSHOT' , snapshot ) ;
13
13
14
14
// set the heights and width of the tree to be passed into treeMap function
15
- const width : number = 600 ;
16
- const height : number = 1100 ;
15
+ const width : number = 1100 ;
16
+ const height : number = 600 ;
17
17
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
21
useEffect ( ( ) => {
22
22
setZoomState ( d3 . zoomTransform ( d3 . select ( '#canvas' ) . node ( ) ) ) ;
23
- } , [ snapshot ] ) ;
23
+ } , [ snapshot . children ] ) ;
24
24
25
25
// this only clears the canvas if Visualizer is already rendered on the extension
26
26
useEffect ( ( ) => {
@@ -31,9 +31,9 @@ const Map = (props) => {
31
31
. select ( '#canvas' )
32
32
. attr ( 'width' , width )
33
33
. attr ( 'height' , height ) ;
34
-
35
34
// creating a pseudo-class for reusability
36
35
const g : any = svgContainer
36
+
37
37
. append ( 'g' )
38
38
. attr ( 'transform' , `translate(${ x } , ${ y } ), scale(${ k } )` ) ; // sets the canvas to the saved zoomState
39
39
@@ -46,13 +46,12 @@ const Map = (props) => {
46
46
// childrenArr.push(el)
47
47
// );
48
48
// }
49
-
49
+
50
50
// console.log('CHILDREN', childrenArr);
51
51
52
52
const appState : any = {
53
53
name : ' Root' ,
54
54
// pass in parsed data here
55
- // call the helper function passing in the most recent snapshot
56
55
children : snapshot . children ,
57
56
} ;
58
57
@@ -96,6 +95,7 @@ const Map = (props) => {
96
95
// returns a flat array of objects containing all the nodes and their information
97
96
// renders nodes onto the canvas
98
97
let nodes : any = hierarchyNodes . descendants ( ) ;
98
+ console . log ( "NODES" , nodes )
99
99
100
100
// const node is used to create all the nodes
101
101
// this segment places all the nodes on the canvas
@@ -111,13 +111,16 @@ const Map = (props) => {
111
111
. attr ( 'class' , 'atomNodes' ) ;
112
112
113
113
// for each node that got created, append a circle element
114
- node . append ( 'circle' ) . attr ( 'fill' , '#c300ff' ) . attr ( 'r' , 50 ) ;
114
+ node
115
+ . append ( 'circle' )
116
+ . attr ( 'fill' , ( d : any ) => ( d . children ? '#3214db' : '#c300ff' ) )
117
+ . attr ( 'r' , 50 ) ;
115
118
116
119
// for each node that got created, append a text element that displays the name of the node
117
120
node
118
121
. append ( 'text' )
119
122
. attr ( 'dy' , '.31em' )
120
- . attr ( 'x' , ( d : any ) => ( d . children ? - 75 : 75 ) )
123
+ . attr ( 'x' , ( d : any ) => ( d . children ? - 50 : 50 ) )
121
124
. attr ( 'text-anchor' , ( d : any ) => ( d . children ? 'end' : 'start' ) )
122
125
. text ( ( d : any ) => d . data . name )
123
126
. style ( 'font-size' , `2rem` )
@@ -136,9 +139,10 @@ const Map = (props) => {
136
139
. append ( 'text' )
137
140
. text ( JSON . stringify ( d . data , undefined , 2 ) )
138
141
. style ( 'fill' , 'white' )
139
- . attr ( 'x' , 75 )
140
- . attr ( 'y' , 60 )
142
+ . attr ( 'x' , - 999 )
143
+ . attr ( 'y' , 100 )
141
144
. style ( 'font-size' , '3rem' )
145
+ . style ( 'text-align' , 'center' )
142
146
. attr ( 'stroke' , '#646464' )
143
147
. attr ( 'id' , `popup${ i } ` ) ;
144
148
}
@@ -166,7 +170,7 @@ const Map = (props) => {
166
170
[ 0 , 0 ] ,
167
171
[ width , height ] ,
168
172
] )
169
- . scaleExtent ( [ 0 , 8 ] )
173
+ . scaleExtent ( [ 0 , 5 ] )
170
174
. on ( 'zoom' , zoomed )
171
175
) ;
172
176
@@ -192,7 +196,6 @@ const Map = (props) => {
192
196
}
193
197
} ) ;
194
198
195
- console . log ( '208' ) ;
196
199
return (
197
200
< div data-testid = "canvas" >
198
201
< div className = "Visualizer" >
0 commit comments