So I managed to solve my hiding unselected groups issue:
Hide all but selected connected nodes in D3 (v4) force graph
But I now have another problem:
Opening the following Plunker in Chrome gives incorrect behaviour: http://plnkr.co/edit/TiKKmvydqXNipe103juL?p=preview
When a link is clicked on it hides all of the nodes & text, not just the unselected ones, leaving only the selected links visible.
I really don't understand this, the lines of code that deal with the show/hide are based on the IDs 'group' and 'nodeGroup':
.attr("group",function(d) {return d.group; })
.on("click", function(d) {
// This is to toggle visibility - need to do it on the nodes and links
d3.selectAll("line:not([group='"+d.group+"'])")
.style("opacity", function() {
currentDisplay = d3.select(this).style("opacity");
currentDisplay = currentDisplay == "1" ? "0.1" : "1";
return currentDisplay;
});
d3.selectAll("circle:not([nodeGroup='"+d.group+"'])")
.style("opacity",function() {
currentDisplay = d3.select(this).style("opacity");
currentDisplay = currentDisplay == "1" ? "0.1" : "1";
return currentDisplay;
});
d3.selectAll("text:not([nodeGroup='"+d.group+"'])")
.style("opacity",function() {
currentDisplay = d3.select(this).style("opacity");
currentDisplay = currentDisplay == "1" ? "0.1" : "1";
return currentDisplay;
});
})
If I step through this in the Chrome debugger then it appears to get called and run correctly, but then it looks like "circle" and "text" being included in the selection for hiding and not excluded as per the :not pseudo-class. (using onclick("mousedown".... makes no difference, nor does altering the order)
I have look around and can only find issues people have had with Chrome not interpreting pseudo-classes in the same way as IE, but this can't be the same problem as it half-works?
Any clues would be greatly appreciated.