Skip to content

Commit 7225d36

Browse files
committed
Completed D3 Visualization Algorithm that dynamically generates a children/parent relationship for atoms and components and populates into clusterData
1 parent ee9eb2f commit 7225d36

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

src/app/components/AtomsRelationship.jsx

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,43 @@ export const background = '#242529';
1818
//
1919

2020
const clusterData = {};
21+
let memoizeObj = {};
2122

2223
function clusterDataPopulate(props) {
23-
console.log(props)
2424
let atomCompObj = reorganizedObj(props);
25-
26-
console.log(atomCompObj);
25+
console.log(atomCompObj)
2726

2827
if (props[0].name) {
2928
clusterData.name = props[0].name;
3029
}
31-
3230

33-
let memoizeObj = {}
34-
let counter = 0
31+
let counter = 0;
3532

36-
for(let key in atomCompObj){
37-
if(atomCompObj[key].length){
38-
for(let i=0; i<atomCompObj[key].length;i++){
39-
33+
for (let key in atomCompObj) {
4034

35+
if (atomCompObj[key].length) {
36+
37+
for (let i = 0; i < atomCompObj[key].length; i++) {
4138

39+
if (!memoizeObj[key]) {
40+
memoizeObj[key] = [];
41+
if (!clusterData.children) clusterData.children = [];
42+
clusterData.children.push({ name: key });
43+
}
4244

45+
if (!memoizeObj[key].includes(atomCompObj[key][i])) {
46+
47+
if (!clusterData.children[counter].children) clusterData.children[counter].children = []
48+
clusterData.children[counter].children.push({name: atomCompObj[key][i]});
49+
}
50+
memoizeObj[key].push(atomCompObj[key][i]);
51+
}
52+
}
53+
counter++;
54+
}
55+
console.log(clusterData)
56+
}
4357

44-
if(!clusterData.children) clusterData.children = []
45-
clusterData.children.push({name: key})}
46-
if(!clusterData.children[counter].children) {
47-
clusterData.children[counter].children = []
48-
clusterData.children[counter].children.push ({name:atomCompObj[key][i]})}
49-
50-
if (!memoizeObj[key]){
51-
memoizeObj[key] = []
52-
memoizeObj[key].push[atomCompObj[key][i]]
53-
}
54-
}
55-
counter++
56-
}
57-
console.log(clusterData)
58-
}
5958

6059
function reorganizedObj(props) {
6160
let atomsComponentObj = props[0].atomsComponents;
@@ -71,8 +70,7 @@ function reorganizedObj(props) {
7170
}
7271
}
7372
return reorganizedObj;
74-
}
75-
73+
}
7674

7775

7876
function Node({ node }) {

src/app/components/StateRoute.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const StateRoute = (props: StateRouteProps) => {
8484

8585
const renderAtomsRelationship = () => (
8686

87-
<ParentSize>{({ width, height }) =>
87+
<ParentSize>{({ width, height }) =>
8888
<Example
8989
width={width}
9090
height={height}

0 commit comments

Comments
 (0)