Skip to content

Commit 08d581f

Browse files
committed
minor code flow changes no change to functionality
1 parent 4a5689c commit 08d581f

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

src/app/components/Map.tsx

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ const Map = (props) => {
4040

4141
// creating the tree map
4242
const treeMap: any = d3.tree().nodeSize([width, height]);
43-
4443
// creating the nodes of the tree
4544
const hierarchyNodes: any = d3.hierarchy(snapshots[lastSnap]);
46-
4745
// calling the tree function with nodes created from data
4846
const finalMap: any = treeMap(hierarchyNodes);
49-
50-
// renders a flat array of objects containing all parent-child links
5147
// renders the paths onto the component
5248
let paths: any = finalMap.links();
49+
// returns a flat array of objects containing all the nodes and their information
50+
let nodes: any = hierarchyNodes.descendants();
5351

5452
// this creates the paths to each node and its contents in the tree
5553
g.append('g')
@@ -68,8 +66,7 @@ const Map = (props) => {
6866
.y((d: any) => d.x)
6967
);
7068

71-
// returns a flat array of objects containing all the nodes and their information
72-
let nodes: any = hierarchyNodes.descendants();
69+
7370

7471
// this segment places all the nodes on the canvas
7572
const node: any = g
@@ -124,47 +121,49 @@ const Map = (props) => {
124121
d3.select(`#popup${i}`).remove();
125122
});
126123

127-
// allows the canvas to be draggable
128-
node.call(
129-
d3
130-
.drag()
131-
.on('start', dragStarted)
132-
.on('drag', dragged)
133-
.on('end', dragEnded)
134-
);
124+
125+
126+
//______________ZOOM______________\\
127+
128+
// Sets starting zoom but breaks keeping currents zoom on state change
129+
130+
// let zoom = d3.zoom().on('zoom', zoomed);
131+
// svgContainer.call(
132+
// zoom.transform,
133+
// // Changes the initial view, (left, top)
134+
// d3.zoomIdentity.translate(150, 250).scale(0.2)
135+
// );
135136

136-
// allows the canvas to be zoom-able
137-
// d3 zoom functionality
138-
let zoom = d3.zoom().on('zoom', zoomed);
139-
svgContainer.call(
140-
zoom.transform,
141-
// Changes the initial view, (left, top)
142-
d3.zoomIdentity.translate(150, 250).scale(0.2)
143-
);
144137
// allows the canvas to be zoom-able
145138
svgContainer.call(
146139
d3
147140
.zoom()
148141
.scaleExtent([0.05, 0.9]) // [zoomOut, zoomIn]
149142
.on('zoom', zoomed)
150143
);
151-
// helper function that allows for zooming
152144
function zoomed(d: any) {
153145
g.attr('transform', d3.event.transform);
154146
}
155147

156-
// helper functions that help with dragging functionality
148+
//_____________DRAG_____________\\
149+
// allows the canvas to be draggable
150+
node.call(
151+
d3
152+
.drag()
153+
.on('start', dragStarted)
154+
.on('drag', dragged)
155+
.on('end', dragEnded)
156+
);
157+
157158
function dragStarted(): any {
158159
d3.select(this).raise();
159160
g.attr('cursor', 'grabbing');
160161
}
161-
162162
function dragged(d: any): any {
163163
d3.select(this)
164164
.attr('dx', (d.x = d3.event.x))
165165
.attr('dy', (d.y = d3.event.y));
166166
}
167-
168167
function dragEnded(): any {
169168
g.attr('cursor', 'grab');
170169
}

0 commit comments

Comments
 (0)