@@ -22,39 +22,33 @@ let memoizeObj = {};
22
22
23
23
function clusterDataPopulate ( props ) {
24
24
let atomCompObj = reorganizedObj ( props ) ;
25
- console . log ( atomCompObj )
26
25
27
26
if ( props [ 0 ] . name ) {
28
27
clusterData . name = props [ 0 ] . name ;
29
28
}
30
-
31
- let counter = 0 ;
32
29
30
+ let counter = 0 ;
33
31
for ( let key in atomCompObj ) {
34
-
35
32
if ( atomCompObj [ key ] . length ) {
36
-
37
33
for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
38
-
39
34
if ( ! memoizeObj [ key ] ) {
40
35
memoizeObj [ key ] = [ ] ;
41
36
if ( ! clusterData . children ) clusterData . children = [ ] ;
42
37
clusterData . children . push ( { name : key } ) ;
43
38
}
44
-
45
39
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 ++ ;
40
+ if ( ! clusterData . children [ counter ] . children )
41
+ clusterData . children [ counter ] . children = [ ] ;
42
+ clusterData . children [ counter ] . children . push ( {
43
+ name : atomCompObj [ key ] [ i ] ,
44
+ } ) ;
45
+ }
46
+ memoizeObj [ key ] . push ( atomCompObj [ key ] [ i ] ) ;
47
+ }
54
48
}
55
- console . log ( clusterData )
49
+ counter ++ ;
56
50
}
57
-
51
+ }
58
52
59
53
function reorganizedObj ( props ) {
60
54
let atomsComponentObj = props [ 0 ] . atomsComponents ;
@@ -70,8 +64,7 @@ function reorganizedObj(props) {
70
64
}
71
65
}
72
66
return reorganizedObj ;
73
- }
74
-
67
+ }
75
68
76
69
function Node ( { node } ) {
77
70
const isRoot = node . depth === 0 ;
@@ -86,9 +79,9 @@ function Node({ node }) {
86
79
r = { 12 }
87
80
fill = { background }
88
81
stroke = { isParent ? white : citrus }
89
- onClick = { ( ) => {
90
- alert ( `clicked: ${ JSON . stringify ( node . data . name ) } ` ) ;
91
- } }
82
+ // onClick={() => {
83
+ // alert(`clicked: ${JSON.stringify(node.data.name)}`);
84
+ // }}
92
85
/>
93
86
) }
94
87
< text
@@ -112,7 +105,7 @@ function RootNode({ node }) {
112
105
const centerY = - height / 2 ;
113
106
114
107
return (
115
- < Group top = { node . y } left = { node . x } >
108
+ < Group top = { node . y } left = { node . x } >
116
109
< rect
117
110
width = { width }
118
111
height = { height }
@@ -122,6 +115,8 @@ function RootNode({ node }) {
122
115
/>
123
116
< text
124
117
dy = ".33em"
118
+ top = { node . y }
119
+ left = { node . x }
125
120
fontSize = { 9 }
126
121
fontFamily = "Arial"
127
122
textAnchor = "middle"
@@ -134,7 +129,7 @@ function RootNode({ node }) {
134
129
) ;
135
130
}
136
131
137
- const defaultMargin = { top : 40 , left : 50 , right : 50 , bottom : 40 } ;
132
+ const defaultMargin = { top : 40 , left : 0 , right : 0 , bottom : 40 } ;
138
133
139
134
// export type DendrogramProps = {
140
135
// width: number;
0 commit comments