@@ -8,8 +8,9 @@ import { LinearGradient } from '@visx/gradient';
88const blue = '#acdbdf' ;
99const white = '#f0ece2' ;
1010
11- export const lightorange = '#F9D976' ;
12- const orange = '#F39F86' ;
11+ export const lightgreen = '#0BAB64' ;
12+ const green = '#3BB78F'
13+ const selectOrange = '#F39F86' ;
1314
1415const merlinsbeard = '#f7f7f3' ;
1516export const background = '#242529' ;
@@ -23,7 +24,7 @@ const root = '#d2f5e3';
2324const clusterData = { } ;
2425const selectorsCache = { }
2526
26- let isFired = false
27+ let initialFire = false
2728function clusterDataPopulate ( props ) {
2829 let atomCompObj = reorganizedCompObj ( props ) ;
2930
@@ -82,8 +83,7 @@ function clusterDataPopulate(props) {
8283 clusterData . children . push ( outObj )
8384 }
8485 }
85-
86- isFired = true
86+ initialFire = true
8787}
8888
8989function reorganizedCompObj ( props ) {
@@ -103,10 +103,12 @@ function reorganizedCompObj(props) {
103103}
104104
105105function Node ( { node } ) {
106+ const selector = node . depth === 1 && node . height === 2
106107 const isRoot = node . depth === 0 ;
107108 const isParent = ! ! node . children ;
108109
109110 if ( isRoot ) return < RootNode node = { node } /> ;
111+ if ( selector ) return < SelectorNode node = { node } /> ;
110112
111113 return (
112114 < Group top = { node . y } left = { node . x } >
@@ -169,6 +171,35 @@ function RootNode({ node }) {
169171 ) ;
170172}
171173
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+
172203const defaultMargin = { top : 40 , left : 0 , right : 0 , bottom : 40 } ;
173204
174205// export type DendrogramProps = {
@@ -184,7 +215,7 @@ export default function Example({
184215 snapshots,
185216} ) {
186217
187- if ( ! isFired ) {
218+ if ( ! initialFire ) {
188219 clusterDataPopulate ( snapshots ) ;
189220 }
190221
@@ -194,7 +225,7 @@ export default function Example({
194225
195226 return width < 10 ? null : (
196227 < svg width = { width } height = { height } >
197- < LinearGradient id = "top" from = { lightorange } to = { orange } />
228+ < LinearGradient id = "top" from = { lightgreen } to = { green } />
198229
199230 < rect width = { width } height = { height } rx = { 14 } fill = { background } />
200231
0 commit comments