@@ -8,9 +8,8 @@ import React, { useState, useEffect } from 'react';
8
8
import * as d3 from 'd3' ;
9
9
10
10
const Map = ( props ) => {
11
-
12
- const { snapshot, snapshots} = props ;
13
- const lastSnap = snapshots . length - 1
11
+ const { snapshots } = props ;
12
+ const lastSnap = snapshots . length - 1 ;
14
13
15
14
// set the heights and width of the tree to be passed into treeMap function
16
15
const width : number = 900 ;
@@ -20,11 +19,10 @@ const Map = (props) => {
20
19
const [ { x, y, k } , setZoomState ] : any = useState ( { x : 0 , y : 0 , k : 0 } ) ;
21
20
useEffect ( ( ) => {
22
21
setZoomState ( d3 . zoomTransform ( d3 . select ( '#canvas' ) . node ( ) ) ) ;
23
- } , [ snapshot . children ] ) ;
22
+ } , [ snapshots [ lastSnap ] ] ) ;
24
23
25
24
// Create D3 Tree Diagram
26
25
useEffect ( ( ) => {
27
-
28
26
document . getElementById ( 'canvas' ) . innerHTML = '' ;
29
27
30
28
// creating the main svg container for d3 elements
@@ -136,11 +134,11 @@ const Map = (props) => {
136
134
// allows the canvas to be zoom-able
137
135
// d3 zoom functionality
138
136
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
- ) ;
137
+ // svgContainer.call(
138
+ // zoom.transform,
139
+ // // Changes the initial view, (left, top)
140
+ // d3.zoomIdentity.translate(150, 250).scale(0.2)
141
+ // );
144
142
// allows the canvas to be zoom-able
145
143
svgContainer . call (
146
144
d3
@@ -168,6 +166,9 @@ const Map = (props) => {
168
166
function dragEnded ( ) : any {
169
167
g . attr ( 'cursor' , 'grab' ) ;
170
168
}
169
+
170
+
171
+
171
172
} ) ;
172
173
173
174
return (
0 commit comments