@@ -303,27 +303,30 @@ class D3NetGraph {
303
303
// enter node: also append 'circle' element of a calculated size
304
304
elementG
305
305
. append ( "circle" )
306
- // "r" has to be set here or circles don't draw.
307
- . attr ( "r" , ( d ) => {
308
- let radius = this . data . edges . reduce ( ( acc , ed ) => {
309
- return ( ed . source === d . id || ed . target === d . id ) ? acc + 1 : acc ;
310
- } , 1 ) ;
311
-
312
- d . weight = radius
313
- d . size = radius // save the calculated size
314
- return this . defaultSize + ( this . defaultSize * d . weight / 2 )
315
- } )
316
- // .attr("r", (d) => { return this.defaultSize }) // d.size ? d.size/10 : this.defaultSize; })
317
- . attr ( "fill" , ( d ) => {
318
- // REVIEW: Using label match. Should we use id instead?
319
- // The advantage of using the label is backward compatibility with
320
- // Google Fusion table data as well as exportability.
321
- // If we save the type as an id, the data format will be
322
- // less human-readable.
323
- // The problem with this approach though is that any changes
324
- // to the label text will result in a failed color lookup!
325
- return COLORMAP [ d . attributes [ "Node_Type" ] ] ;
326
- } ) ;
306
+ // "r" has to be set here or circles don't draw.
307
+ . attr ( "r" , ( d ) => {
308
+ let radius = this . data . edges . reduce ( ( acc , ed ) => {
309
+ return ( ed . source === d . id || ed . target === d . id ) ? acc + 1 : acc ;
310
+ } , 1 ) ;
311
+
312
+ d . weight = radius
313
+ d . size = radius // save the calculated size
314
+ return this . defaultSize + ( this . defaultSize * d . weight / 2 )
315
+ } )
316
+ // .attr("r", (d) => { return this.defaultSize }) // d.size ? d.size/10 : this.defaultSize; })
317
+ . attr ( "fill" , ( d ) => {
318
+ // REVIEW: Using label match. Should we use id instead?
319
+ // The advantage of using the label is backward compatibility with
320
+ // Google Fusion table data as well as exportability.
321
+ // If we save the type as an id, the data format will be
322
+ // less human-readable.
323
+ // The problem with this approach though is that any changes
324
+ // to the label text will result in a failed color lookup!
325
+ return COLORMAP [ d . attributes [ "Node_Type" ] ] ;
326
+ } )
327
+ . style ( "opacity" , d => {
328
+ return d . isFilteredOut ? 0 : 1.0
329
+ } ) ;
327
330
328
331
// enter node: also append 'text' element
329
332
elementG
@@ -332,7 +335,10 @@ class D3NetGraph {
332
335
. attr ( "font-size" , 10 )
333
336
. attr ( "dx" , ( d => { return this . defaultSize + 5 } ) ) // 8)
334
337
. attr ( "dy" , "0.35em" ) // ".15em")
335
- . text ( ( d ) => { return d . label } ) ;
338
+ . text ( ( d ) => { return d . label } )
339
+ . style ( "opacity" , d => {
340
+ return d . isFilteredOut ? 0 : 1.0
341
+ } ) ;
336
342
337
343
// enter node: also append a 'title' tag
338
344
// we should move this to our tooltip functions, but it works for now
@@ -404,6 +410,10 @@ class D3NetGraph {
404
410
d . weight = radius
405
411
d . size = radius // save the calculated size
406
412
return this . defaultSize + ( this . defaultSize * d . weight / 2 )
413
+ } )
414
+ . style ( "opacity" , d => {
415
+ // console.log(d);
416
+ return d . isFilteredOut ? 0 : 1.0
407
417
} ) ;
408
418
409
419
// UPDATE text in each node for all nodes
@@ -420,7 +430,10 @@ class D3NetGraph {
420
430
if ( d . selected ) return 'bold' ;
421
431
return undefined ; // don't set font weight
422
432
} )
423
- . text ( ( d ) => { return d . label } ) ; // in case text is updated
433
+ . text ( ( d ) => { return d . label } ) // in case text is updated
434
+ . style ( "opacity" , d => {
435
+ return d . isFilteredOut ? 0 : 1.0
436
+ } ) ;
424
437
425
438
nodeElements . merge ( nodeElements )
426
439
. selectAll ( "title" ) // node tooltip
@@ -446,12 +459,18 @@ class D3NetGraph {
446
459
// if (DBG) console.log('clicked on',d.label,d.id)
447
460
// this.edgeClickFn( d )
448
461
// })
462
+ . style ( "opacity" , d => {
463
+ return d . isFilteredOut ? 0 : 1.0
464
+ } ) ;
449
465
450
466
// .merge() updates the visuals whenever the data is updated.
451
467
linkElements . merge ( linkElements )
452
468
. classed ( "selected" , ( d ) => { return d . selected } )
453
469
. style ( 'stroke' , this . _UpdateLinkStrokeColor )
454
470
. style ( 'stroke-width' , this . _UpdateLinkStrokeWidth )
471
+ . style ( "opacity" , d => {
472
+ return d . isFilteredOut ? 0 : 1.0
473
+ } ) ;
455
474
456
475
linkElements . exit ( ) . remove ( )
457
476
0 commit comments