@@ -4,28 +4,44 @@ import { Cluster, hierarchy } from '@visx/hierarchy';
4
4
//import { HierarchyPointNode, HierarchyPointLink } from '@visx/hierarchy/lib/types';
5
5
import { LinkVertical } from '@visx/shape' ;
6
6
import { LinearGradient } from '@visx/gradient' ;
7
+ import { StateRouteProps } from './StateRoute'
7
8
8
9
const blue = '#acdbdf' ;
9
- const white = '#f0ece2' ;
10
+ const selectWhite = '#f0ece2' ;
10
11
11
12
export const lightgreen = '#0BAB64' ;
12
13
const green = '#3BB78F'
13
- const selectOrange = '#F39F86 ' ;
14
+ const orange = '#FED8B1 ' ;
14
15
15
16
const merlinsbeard = '#f7f7f3' ;
16
17
export const background = '#242529' ;
17
18
const root = '#d2f5e3' ;
18
19
19
- // interface NodeShape {
20
- // name: string;
21
- // children?: NodeShape[];
22
- //
20
+ interface clusterShape {
21
+ name ?: string ;
22
+ children ?: clusterShape [ ]
23
+ }
23
24
24
- const clusterData = { } ;
25
- const selectorsCache = { }
25
+ interface outerObjShape {
26
+ name ?:string ;
27
+ children ?: outerObjShape [ ]
28
+ }
29
+
30
+ interface innerObjShape {
31
+ name ?:string ;
32
+ children ?: innerObjShape [ ]
33
+ }
34
+
35
+ interface selectorsCache {
36
+ [ key :string ] : any
37
+ }
38
+
39
+
40
+ const clusterData : clusterShape = { } ;
41
+ const selectorsCache :selectorsCache = { }
26
42
27
43
let initialFire = false
28
- function clusterDataPopulate ( props ) {
44
+ function clusterDataPopulate ( props : StateRouteProps ) {
29
45
let atomCompObj = reorganizedCompObj ( props ) ;
30
46
31
47
//this is to set the root name property
@@ -38,15 +54,15 @@ function clusterDataPopulate(props) {
38
54
if ( ! clusterData . children ) clusterData . children = [ ]
39
55
40
56
for ( let key in props [ 0 ] . atomSelectors ) {
41
- let outerobj = { }
57
+ let outerobj : outerObjShape = { }
42
58
outerobj . name = key
43
59
selectorsCache [ key ] = true
44
60
45
61
if ( props [ 0 ] . atomSelectors [ key ] . length ) {
46
62
for ( let i = 0 ; i < props [ 0 ] . atomSelectors [ key ] . length ; i ++ ) {
47
63
48
64
if ( ! outerobj . children ) outerobj . children = [ ]
49
- let innerobj = { }
65
+ let innerobj : innerObjShape = { }
50
66
innerobj . name = props [ 0 ] . atomSelectors [ key ] [ i ]
51
67
selectorsCache [ props [ 0 ] . atomSelectors [ key ] [ i ] ] = true
52
68
@@ -73,7 +89,7 @@ function clusterDataPopulate(props) {
73
89
}
74
90
75
91
for ( let key in atomCompObj ) {
76
- let outObj = { } ;
92
+ let outObj : outerObjShape = { } ;
77
93
if ( ! selectorsCache [ key ] ) {
78
94
outObj . name = key
79
95
for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
@@ -84,8 +100,11 @@ function clusterDataPopulate(props) {
84
100
}
85
101
}
86
102
initialFire = true
103
+
87
104
}
88
105
106
+
107
+
89
108
function reorganizedCompObj ( props ) {
90
109
let atomsComponentObj = props [ 0 ] . atomsComponents ;
91
110
let reorganizedCompObj = { } ;
@@ -115,8 +134,8 @@ function Node({ node }) {
115
134
{ node . depth !== 0 && (
116
135
< circle
117
136
r = { 12 }
118
- fill = { isParent ? white : blue }
119
- stroke = { isParent ? white : blue }
137
+ fill = { isParent ? orange : blue }
138
+ stroke = { isParent ? orange : blue }
120
139
// onClick={() => {
121
140
// alert(`clicked: ${JSON.stringify(node.data.name)}`);
122
141
// }}
@@ -129,7 +148,7 @@ function Node({ node }) {
129
148
textAnchor = "middle"
130
149
y = "-20"
131
150
style = { { pointerEvents : 'none' } }
132
- fill = { isParent ? white : blue }
151
+ fill = { isParent ? orange : blue }
133
152
>
134
153
{ node . data . name }
135
154
</ text >
@@ -178,8 +197,8 @@ function SelectorNode({ node }) {
178
197
{ node . depth !== 0 && (
179
198
< circle
180
199
r = { 12 }
181
- fill = { selectOrange }
182
- stroke = { selectOrange }
200
+ fill = { selectWhite }
201
+ stroke = { selectWhite }
183
202
// onClick={() => {
184
203
// alert(`clicked: ${JSON.stringify(node.data.name)}`);
185
204
// }}
@@ -192,7 +211,7 @@ function SelectorNode({ node }) {
192
211
textAnchor = "middle"
193
212
y = "-20"
194
213
style = { { pointerEvents : 'none' } }
195
- fill = { orange }
214
+ fill = { selectWhite }
196
215
>
197
216
{ node . data . name }
198
217
</ text >
0 commit comments