@@ -8,8 +8,9 @@ import { LinearGradient } from '@visx/gradient';
8
8
const blue = '#acdbdf' ;
9
9
const white = '#f0ece2' ;
10
10
11
- export const lightorange = '#F9D976' ;
12
- const orange = '#F39F86' ;
11
+ export const lightgreen = '#0BAB64' ;
12
+ const green = '#3BB78F'
13
+ const selectOrange = '#F39F86' ;
13
14
14
15
const merlinsbeard = '#f7f7f3' ;
15
16
export const background = '#242529' ;
@@ -23,7 +24,7 @@ const root = '#d2f5e3';
23
24
const clusterData = { } ;
24
25
const selectorsCache = { }
25
26
26
- let isFired = false
27
+ let initialFire = false
27
28
function clusterDataPopulate ( props ) {
28
29
let atomCompObj = reorganizedCompObj ( props ) ;
29
30
@@ -82,8 +83,7 @@ function clusterDataPopulate(props) {
82
83
clusterData . children . push ( outObj )
83
84
}
84
85
}
85
-
86
- isFired = true
86
+ initialFire = true
87
87
}
88
88
89
89
function reorganizedCompObj ( props ) {
@@ -103,10 +103,12 @@ function reorganizedCompObj(props) {
103
103
}
104
104
105
105
function Node ( { node } ) {
106
+ const selector = node . depth === 1 && node . height === 2
106
107
const isRoot = node . depth === 0 ;
107
108
const isParent = ! ! node . children ;
108
109
109
110
if ( isRoot ) return < RootNode node = { node } /> ;
111
+ if ( selector ) return < SelectorNode node = { node } /> ;
110
112
111
113
return (
112
114
< Group top = { node . y } left = { node . x } >
@@ -169,6 +171,35 @@ function RootNode({ node }) {
169
171
) ;
170
172
}
171
173
174
+ function SelectorNode ( { node } ) {
175
+
176
+ return (
177
+ < Group top = { node . y } left = { node . x } >
178
+ { node . depth !== 0 && (
179
+ < circle
180
+ r = { 12 }
181
+ fill = { selectOrange }
182
+ stroke = { selectOrange }
183
+ // onClick={() => {
184
+ // alert(`clicked: ${JSON.stringify(node.data.name)}`);
185
+ // }}
186
+ />
187
+ ) }
188
+ < text
189
+ dy = ".33em"
190
+ fontSize = { 9 }
191
+ fontFamily = "Arial"
192
+ textAnchor = "middle"
193
+ y = "-20"
194
+ style = { { pointerEvents : 'none' } }
195
+ fill = { orange }
196
+ >
197
+ { node . data . name }
198
+ </ text >
199
+ </ Group >
200
+ ) ;
201
+ }
202
+
172
203
const defaultMargin = { top : 40 , left : 0 , right : 0 , bottom : 40 } ;
173
204
174
205
// export type DendrogramProps = {
@@ -184,7 +215,7 @@ export default function Example({
184
215
snapshots,
185
216
} ) {
186
217
187
- if ( ! isFired ) {
218
+ if ( ! initialFire ) {
188
219
clusterDataPopulate ( snapshots ) ;
189
220
}
190
221
@@ -194,7 +225,7 @@ export default function Example({
194
225
195
226
return width < 10 ? null : (
196
227
< svg width = { width } height = { height } >
197
- < LinearGradient id = "top" from = { lightorange } to = { orange } />
228
+ < LinearGradient id = "top" from = { lightgreen } to = { green } />
198
229
199
230
< rect width = { width } height = { height } rx = { 14 } fill = { background } />
200
231
0 commit comments