Skip to content

Commit 3d89d78

Browse files
committed
can't fix zoom bugs and node tree not fitting inside container
1 parent a54f124 commit 3d89d78

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/app/components/Chart.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,29 @@ class Chart extends Component {
3636

3737
maked3Tree() {
3838
this.removed3Tree();
39-
let width = 960;
40-
let height = 1060;
39+
let width = 600;
40+
41+
const margin = {
42+
top: 20,
43+
right: 120,
44+
bottom: 20,
45+
left: 120,
46+
};
47+
// const width = 600 - margin.right - margin.left;
48+
const height = 600 - margin.top - margin.bottom;
49+
4150
let chartContainer = d3.select(this.chartRef.current)
4251
.append('svg') // chartContainer is now pointing to svg
4352
.attr('width', width)
4453
.attr('height', height);
4554

46-
svg.call(d3.zoom()
55+
chartContainer.call(d3.zoom()
4756
.on("zoom", function () {
48-
svg.attr("transform", d3.event.transform)
57+
chartContainer.attr("transform", d3.event.transform)
4958
}))
5059
.append("g")
5160

52-
let g = chartContainer
53-
.append("g")
61+
let g = chartContainer.append("g")
5462
// this is changing where the graph is located physically
5563
.attr("transform", `translate(${width / 2 + 4}, ${height / 2 + 2})`);
5664

0 commit comments

Comments
 (0)