@@ -143,9 +143,7 @@ export const TopologyView: React.FC<TopologyViewProps> = ({
143
143
. each ( function ( subtree ) {
144
144
const tree = subtree . tree ;
145
145
const group = d3 . select ( this ) ;
146
- const gLinks = group . select ( ".links" ) ;
147
- const gNodes = group . select ( ".nodes" ) ;
148
- gLinks
146
+ group . select ( ".links" )
149
147
. selectAll ( ".link" )
150
148
. data ( tree . links ( ) , ( d : any ) => d . source ?. data ?. id + d . target ?. data ?. id )
151
149
. join ( "path" )
@@ -155,7 +153,7 @@ export const TopologyView: React.FC<TopologyViewProps> = ({
155
153
. attr ( "d" , diagonal )
156
154
. attr ( "stroke-width" , 1.5 ) ;
157
155
158
- gNodes
156
+ group . select ( ".nodes" )
159
157
. selectAll ( ".node" )
160
158
. data ( tree . descendants ( ) , ( d : any ) => d . data . id )
161
159
. join ( "circle" )
@@ -165,6 +163,17 @@ export const TopologyView: React.FC<TopologyViewProps> = ({
165
163
. attr ( "cy" , ( d : any ) => d . y )
166
164
. attr ( "r" , d => getRadius ( d . data . group ) )
167
165
. attr ( "fill" , d => colors . assign ( d . data . group ) ) ;
166
+
167
+ group . select ( ".texts" )
168
+ . selectAll ( ".text" )
169
+ . data ( tree . descendants ( ) , ( d : any ) => d . data . id )
170
+ . join ( "text" )
171
+ . filter ( d => d . data . group !== "room" && d . data . group !== "client" )
172
+ . attr ( "class" , "text" )
173
+ . text ( d => d . data . id . substring ( 0 , 6 ) )
174
+ . attr ( "x" , ( d : any ) => d . x )
175
+ . attr ( "y" , ( d : any ) => d . y )
176
+ . attr ( "font-size" , 10 )
168
177
} ) ;
169
178
}
170
179
0 commit comments