Skip to content

Commit 12e8fd9

Browse files
committed
(add,modified) Modified existing color gradients and added filling for the nodes
1 parent 8d8597c commit 12e8fd9

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/app/components/AtomsRelationship.jsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import { Cluster, hierarchy } from '@visx/hierarchy';
55
import { LinkVertical } from '@visx/shape';
66
import { LinearGradient } from '@visx/gradient';
77

8-
const citrus = '#ddf163';
9-
const white = '#ffffff';
10-
export const green = '#79d259';
11-
const aqua = '#37ac8c';
8+
const blue = '#acdbdf';
9+
const white = '#f0ece2';
10+
11+
export const red = '#D7816A';
12+
const orange = '#BD4F6C';
13+
1214
const merlinsbeard = '#f7f7f3';
1315
export const background = '#242529';
16+
const root = '#d2f5e3';
1417

1518
// interface NodeShape {
1619
// name: string;
@@ -39,7 +42,7 @@ function clusterDataPopulate(props) {
3942
if (!memoizeObj[key].includes(atomCompObj[key][i])) {
4043
if (!clusterData.children[counter].children)
4144
clusterData.children[counter].children = [];
42-
clusterData.children[counter].children.push({
45+
clusterData.children[counter].children.push({
4346
name: atomCompObj[key][i],
4447
});
4548
}
@@ -77,8 +80,8 @@ function Node({ node }) {
7780
{node.depth !== 0 && (
7881
<circle
7982
r={12}
80-
fill={background}
81-
stroke={isParent ? white : citrus}
83+
fill={isParent ? white : blue}
84+
stroke={isParent ? white : blue}
8285
// onClick={() => {
8386
// alert(`clicked: ${JSON.stringify(node.data.name)}`);
8487
// }}
@@ -89,9 +92,9 @@ function Node({ node }) {
8992
fontSize={9}
9093
fontFamily="Arial"
9194
textAnchor="middle"
92-
y = "-20"
95+
y="-20"
9396
style={{ pointerEvents: 'none' }}
94-
fill={isParent ? white : citrus}
97+
fill={isParent ? white : blue}
9598
>
9699
{node.data.name}
97100
</text>
@@ -106,18 +109,21 @@ function RootNode({ node }) {
106109
const centerY = -height / 2;
107110

108111
return (
109-
<Group top = {node.y} left = {node.x}>
112+
<Group top={node.y} left={node.x}>
110113
<rect
111114
width={width}
112115
height={height}
116+
fill={root}
113117
y={centerY}
114118
x={centerX}
119+
rx="10"
120+
ry="10"
115121
fill="url('#top')"
116122
/>
117123
<text
118124
dy=".33em"
119-
top= {node.y}
120-
left = {node.x}
125+
top={node.y}
126+
left={node.x}
121127
fontSize={9}
122128
fontFamily="Arial"
123129
textAnchor="middle"
@@ -130,7 +136,7 @@ function RootNode({ node }) {
130136
);
131137
}
132138

133-
const defaultMargin = { top: 40, left: 0, right: 0, bottom: 40};
139+
const defaultMargin = { top: 40, left: 0, right: 0, bottom: 40 };
134140

135141
// export type DendrogramProps = {
136142
// width: number;
@@ -144,7 +150,6 @@ export default function Example({
144150
margin = defaultMargin,
145151
snapshots,
146152
}) {
147-
148153
clusterDataPopulate(snapshots);
149154

150155
const data = useMemo(() => hierarchy(clusterData), []);
@@ -153,7 +158,8 @@ export default function Example({
153158

154159
return width < 10 ? null : (
155160
<svg width={width} height={height}>
156-
<LinearGradient id="top" from={green} to={aqua} />
161+
<LinearGradient id="top" from={red} to={orange} />
162+
157163
<rect width={width} height={height} rx={14} fill={background} />
158164

159165
<Cluster root={data} size={[xMax, yMax]}>

0 commit comments

Comments
 (0)