Skip to content

Commit d662ee7

Browse files
committed
Finished first version of algorithm to format data into D3/Visx visualization - optimization can be made, currently nested for loop
1 parent 6d5139f commit d662ee7

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/app/components/AtomsRelationship.jsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,28 @@ export const background = '#242529';
2020
function clusterDataPopulate(props) {
2121
let data = {};
2222

23+
console.log(props)
2324
let atomCompObj = reorganizedObj(props);
2425

2526
console.log(atomCompObj);
26-
console.log(props);
2727

2828
if (props[0].name) {
29-
console.log('entered')
3029
data.name = props[0].name;
3130
}
3231

32+
let counter = 0
3333
for(let key in atomCompObj){
34-
if(!data.children){
35-
data.children = []
36-
data.children.push({name: key})
37-
} else {
38-
data.children.push({name: key})
39-
}
40-
}
41-
console.log(data)
34+
if(!data.children) data.children = []
35+
data.children.push({name: key})
36+
if(atomCompObj[key].length){
37+
for(let i=0; i<atomCompObj[key].length;i++){
38+
if(!data.children[counter].children) data.children[counter].children = []
39+
data.children[counter].children.push ({name:atomCompObj[key][i]})
40+
}
41+
}
42+
counter++
43+
}
44+
console.log(data)
4245
}
4346

4447
function reorganizedObj(props) {
@@ -54,13 +57,12 @@ function reorganizedObj(props) {
5457
}
5558
}
5659
}
57-
5860
return reorganizedObj;
5961
}
6062

6163
const clusterData = {
6264
name: 'root',
63-
65+
6466
children: [
6567
{
6668
name: 'darkMode',
@@ -77,12 +79,15 @@ const clusterData = {
7779
},
7880
],
7981
},
82+
83+
8084

8185
{
8286
name: 'B',
8387
children: [{ name: 'B1' }, { name: 'B2' }, { name: 'B3' }],
8488
},
8589

90+
8691
{
8792
name: 'X',
8893
children: [

src/backend/linkFiber.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ function createTree(
374374
} else {
375375
newNode = tree;
376376
}
377-
377+
378378
// Recurse on children
379379
if (child && !circularComponentTable.has(child)) {
380380
// If this node had state we appended to the children array,

0 commit comments

Comments
 (0)