Skip to content

Commit f8828e4

Browse files
committed
merged with dev
2 parents 590a81b + ab6ec22 commit f8828e4

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/app/components/Chart.jsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,30 @@ class Chart extends Component {
3535
duration=0;
3636

3737
var margin = {top: 20, right: 120, bottom: 20, left: 120},
38-
width = 960 - margin.right - margin.left,
39-
height = 800 - margin.top - margin.bottom;
38+
width = 600 - margin.right - margin.left,
39+
height = 600 - margin.top - margin.bottom;
4040

4141
var i = 0;
4242

4343
var tree = d3.layout.tree()
44-
.size([400, 400]);
44+
.nodeSize([20,])
45+
.separation(function separation(a, b) {
46+
return a.parent == b.parent ? 3 : 1;
47+
});
4548

4649
var diagonal = d3.svg.diagonal()
4750
.projection(function(d) { return [d.y, d.x]; });
4851

4952
var svg = d3.select(this.refs.anchor).append("svg")
50-
.attr("width", width + margin.right + margin.left)
51-
.attr("height", height + margin.top + margin.bottom)
52-
.append("g")
53-
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
53+
.attr("width", "100%")
54+
.attr("height","100%")
55+
.attr("cursor", "-webkit-grab")
56+
.attr("preserveAspectRatio", "xMinYMin slice")
57+
.call(d3.behavior.zoom().on("zoom", function () {
58+
svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")")
59+
}))
60+
.append("g")
61+
.attr("transform", "translate(" + 60 + "," + height/2 + ")")
5462

5563
// Add tooltip div
5664
var div = d3.select("body").append("div")
@@ -215,7 +223,7 @@ class Chart extends Component {
215223
}
216224

217225
render() {
218-
return <div ref="anchor" className="d3Container" width="100%" />;
226+
return <div ref="anchor" className="d3Container" />;
219227
}
220228
}
221229

src/app/styles/components/_d3Tree.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.d3Container{
2-
display: flex;
3-
align-items: center;
4-
justify-content: center;
2+
height: 100%;
3+
width: 100%;
54
}
65

76
.node {
@@ -12,7 +11,6 @@
1211
fill: #fff;
1312
stroke: black;
1413
stroke-width: 2px;
15-
1614
}
1715

1816
.node text {

0 commit comments

Comments
 (0)