Skip to content

Commit f576848

Browse files
committed
changed mouse-over
1 parent 8e4c4ed commit f576848

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/components/Map.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ const Map = (props) => {
1212
console.log('MAP SNAPSHOT', snapshot);
1313

1414
// 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;
1717

1818
// this state allows the canvas to stay at the zoom level on multiple re-renders
1919
const [{ x, y, k }, setZoomState]: any = useState({ x: 0, y: 0, k: 0 });
2020

2121
useEffect(() => {
2222
setZoomState(d3.zoomTransform(d3.select('#canvas').node()));
23-
}, [snapshot]);
23+
}, [snapshot.children]);
2424

2525
// this only clears the canvas if Visualizer is already rendered on the extension
2626
useEffect(() => {
@@ -31,9 +31,9 @@ const Map = (props) => {
3131
.select('#canvas')
3232
.attr('width', width)
3333
.attr('height', height);
34-
3534
// creating a pseudo-class for reusability
3635
const g: any = svgContainer
36+
3737
.append('g')
3838
.attr('transform', `translate(${x}, ${y}), scale(${k})`); // sets the canvas to the saved zoomState
3939

@@ -46,13 +46,12 @@ const Map = (props) => {
4646
// childrenArr.push(el)
4747
// );
4848
// }
49-
49+
5050
// console.log('CHILDREN', childrenArr);
5151

5252
const appState: any = {
5353
name: ' Root',
5454
// pass in parsed data here
55-
// call the helper function passing in the most recent snapshot
5655
children: snapshot.children,
5756
};
5857

@@ -96,6 +95,7 @@ const Map = (props) => {
9695
// returns a flat array of objects containing all the nodes and their information
9796
// renders nodes onto the canvas
9897
let nodes: any = hierarchyNodes.descendants();
98+
console.log("NODES",nodes)
9999

100100
// const node is used to create all the nodes
101101
// this segment places all the nodes on the canvas
@@ -111,13 +111,16 @@ const Map = (props) => {
111111
.attr('class', 'atomNodes');
112112

113113
// 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);
115118

116119
// for each node that got created, append a text element that displays the name of the node
117120
node
118121
.append('text')
119122
.attr('dy', '.31em')
120-
.attr('x', (d: any) => (d.children ? -75 : 75))
123+
.attr('x', (d: any) => (d.children ? -50 : 50))
121124
.attr('text-anchor', (d: any) => (d.children ? 'end' : 'start'))
122125
.text((d: any) => d.data.name)
123126
.style('font-size', `2rem`)
@@ -136,9 +139,10 @@ const Map = (props) => {
136139
.append('text')
137140
.text(JSON.stringify(d.data, undefined, 2))
138141
.style('fill', 'white')
139-
.attr('x', 75)
140-
.attr('y', 60)
142+
.attr('x', -999)
143+
.attr('y', 100)
141144
.style('font-size', '3rem')
145+
.style('text-align', 'center')
142146
.attr('stroke', '#646464')
143147
.attr('id', `popup${i}`);
144148
}
@@ -166,7 +170,7 @@ const Map = (props) => {
166170
[0, 0],
167171
[width, height],
168172
])
169-
.scaleExtent([0, 8])
173+
.scaleExtent([0, 5])
170174
.on('zoom', zoomed)
171175
);
172176

@@ -192,7 +196,6 @@ const Map = (props) => {
192196
}
193197
});
194198

195-
console.log('208');
196199
return (
197200
<div data-testid="canvas">
198201
<div className="Visualizer">

0 commit comments

Comments
 (0)