Skip to content

Commit 25eb195

Browse files
committed
add coloers to branchs
1 parent 28b0790 commit 25eb195

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/app/components/Chart.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import React, { Component } from 'react';
1515
import * as d3 from 'd3';
1616

17+
const colors = ['#2C4870','#519331','#AA5039','#8B2F5F','#C5B738','#858DFF', '#FF8D02','#FFCD51','#ACDAE6','#FC997E','#CF93AD','#AA3939','#AA6C39','#226666',]
18+
1719
let root = {};
1820
class Chart extends Component {
1921
constructor(props) {
@@ -102,10 +104,16 @@ class Chart extends Component {
102104
.data(d3root.descendants())
103105
.enter()
104106
.append('g')
105-
// assigning class to the node based on whether node has children or not
106-
.attr('class', function (d) {
107-
return 'node' + (d.children ? ' node--internal' : ' node--leaf');
107+
.style('fill', function (d) {
108+
console.log('this is d', d)
109+
return colors[d.data.branch]
108110
})
111+
.attr('class', 'node--internal')
112+
// })
113+
// assigning class to the node based on whether node has children or not
114+
// .attr('class', function (d) {
115+
// return 'node' + (d.children ? ' node--internal' : ' node--leaf');
116+
// })
109117
.attr('transform', function (d) {
110118
return 'translate(' + reinfeldTidierAlgo(d.x, d.y) + ')';
111119
});

src/app/styles/components/d3graph.css

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,43 @@ body {
66

77
.node {
88
cursor: pointer;
9+
fill-opacity: 0.8;
910
}
1011

1112
/* this represents leaf nodes aka nodes with no children */
12-
.node circle {
13+
/* .node circle {
1314
fill: #5249f7;
14-
}
15+
} */
1516

1617
/* .node circle:hover {
1718
fill: #320a5c;
1819
} */
1920

2021
.node text {
22+
fill: #fae6e4;
2123
font-size: 10px;
2224
font-family: "Overpass Mono", monospace;
2325
}
2426

2527

2628
/* this represents text for leaf nodes aka the ones with no children */
27-
.node--leaf {
29+
/* .node--leaf {
2830
fill: #71e9e1;
2931
fill-opacity: 0.8;
30-
}
32+
} */
3133

3234
/* this represents those nodes that have children */
33-
.node--internal circle {
35+
/* .node--internal circle {
3436
fill: #d317c9;
35-
}
37+
} */
3638
/* modifies text of parent nodes (has children) */
3739
.node--internal text {
38-
fill: #fae6e4;
40+
fill: white;
3941
font-size: 10px;
4042
}
4143
.link {
4244
fill: none;
43-
stroke: #3853ea;
45+
stroke:#fae6e4;;
4446
stroke-opacity: 0.4;
4547
stroke-width: 3px;
4648
}

0 commit comments

Comments
 (0)