Skip to content

Commit 94f6d36

Browse files
committed
beta version of d3 graph finished
1 parent 3d89d78 commit 94f6d36

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/app/components/Chart.jsx

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

3737
maked3Tree() {
3838
this.removed3Tree();
39-
let width = 600;
40-
41-
const margin = {
42-
top: 20,
43-
right: 120,
44-
bottom: 20,
45-
left: 120,
46-
};
39+
let width = 960;
40+
let height = 1060;
41+
// const margin = {
42+
// top: 0,
43+
// right: 60,
44+
// bottom: 80,
45+
// left: 120,
46+
// };
4747
// const width = 600 - margin.right - margin.left;
48-
const height = 600 - margin.top - margin.bottom;
48+
// const height = 600 - margin.top - margin.bottom;
4949

5050
let chartContainer = d3.select(this.chartRef.current)
5151
.append('svg') // chartContainer is now pointing to svg
@@ -99,24 +99,24 @@ class Chart extends Component {
9999
});
100100

101101
node.append("circle")
102-
.attr("r", 15)
102+
.attr("r", 12)
103103

104104
//creating a d3.tip method where the html has a function that returns the data we passed into tip.show from line 120
105105
let tip = d3Tip()
106106
.attr("class", "d3-tip")
107-
.html(function (d) { return "State Snapshot: " + d; })
107+
.html(function (d) { return "State: " + d; })
108108

109109
//invoking tooltip for nodes
110110
node.call(tip)
111111

112112
node
113113
.append("text")
114114
// adjusts the y coordinates for the node text
115-
.attr("dy", "0.276em")
115+
.attr("dy", "0.35em")
116116
.attr("x", function (d) {
117117
// this positions how far the text is from leaf nodes (ones without children)
118118
// negative number before the colon moves the text of rightside nodes, positive number moves the text for the leftside nodes
119-
return d.x < Math.PI === !d.children ? -5 : 9;
119+
return d.x < Math.PI === !d.children ? -4 : 5;
120120
})
121121
.attr("text-anchor", function (d) { return d.x < Math.PI === !d.children ? "start" : "end"; })
122122
// this arranges the angle of the text
@@ -131,7 +131,7 @@ class Chart extends Component {
131131
// without JSON.stringify, data will display as object Object
132132
// console.log('d.data --> ', JSON.stringify(d.data))
133133
let displayedState;
134-
tip.show(JSON.stringify(d.data.stateSnapshot), this)
134+
tip.show(JSON.stringify(d.data.stateSnapshot.children[0].state), this)
135135
})
136136
.on('mouseout', tip.hide)
137137

src/app/styles/components/d3graph.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ body {
1818
}
1919

2020
.node text {
21-
font-size: 15px;
21+
font-size: 12px;
2222
font-family: "Overpass Mono", monospace;
2323
}
2424
/* this represents text for leaf nodes aka the ones with no children */
@@ -33,7 +33,7 @@ body {
3333
/* modifies text of parent nodes (has children) */
3434
.node--internal text {
3535
fill: #fae6e4;
36-
font-size: 19px;
36+
font-size: 12px;
3737
}
3838
.link {
3939
fill: none;
@@ -48,8 +48,8 @@ body {
4848
background: #9cf4df;
4949
color: #320a5c;
5050
border-radius: 4px;
51-
font-size: 15px;
52-
width: 300px;
51+
font-size: 13px;
52+
max-width: 400px;
5353
overflow-wrap: break-word;
5454
font-family: "Overpass Mono", monospace;
5555
}

0 commit comments

Comments
 (0)