Skip to content

Commit bdb4ab7

Browse files
committed
config-ip-filter: d3 set opacity to 0 if isFilteredOut
1 parent de4de00 commit bdb4ab7

File tree

1 file changed

+42
-23
lines changed

1 file changed

+42
-23
lines changed

build/app/view/netcreate/components/d3-simplenetgraph.js

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -303,27 +303,30 @@ class D3NetGraph {
303303
// enter node: also append 'circle' element of a calculated size
304304
elementG
305305
.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+
});
327330

328331
// enter node: also append 'text' element
329332
elementG
@@ -332,7 +335,10 @@ class D3NetGraph {
332335
.attr("font-size", 10)
333336
.attr("dx", (d=>{return this.defaultSize + 5})) // 8)
334337
.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+
});
336342

337343
// enter node: also append a 'title' tag
338344
// we should move this to our tooltip functions, but it works for now
@@ -404,6 +410,10 @@ class D3NetGraph {
404410
d.weight = radius
405411
d.size = radius // save the calculated size
406412
return this.defaultSize + (this.defaultSize * d.weight / 2)
413+
})
414+
.style("opacity", d => {
415+
// console.log(d);
416+
return d.isFilteredOut ? 0 : 1.0
407417
});
408418

409419
// UPDATE text in each node for all nodes
@@ -420,7 +430,10 @@ class D3NetGraph {
420430
if (d.selected) return 'bold';
421431
return undefined; // don't set font weight
422432
})
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+
});
424437

425438
nodeElements.merge(nodeElements)
426439
.selectAll("title") // node tooltip
@@ -446,12 +459,18 @@ class D3NetGraph {
446459
// if (DBG) console.log('clicked on',d.label,d.id)
447460
// this.edgeClickFn( d )
448461
// })
462+
.style("opacity", d => {
463+
return d.isFilteredOut ? 0 : 1.0
464+
});
449465

450466
// .merge() updates the visuals whenever the data is updated.
451467
linkElements.merge(linkElements)
452468
.classed("selected", (d) => { return d.selected })
453469
.style('stroke', this._UpdateLinkStrokeColor)
454470
.style('stroke-width', this._UpdateLinkStrokeWidth)
471+
.style("opacity", d => {
472+
return d.isFilteredOut ? 0 : 1.0
473+
});
455474

456475
linkElements.exit().remove()
457476

0 commit comments

Comments
 (0)