Last active
April 11, 2019 10:36
-
-
Save MaximPiessen/f5cbfa899e7094f3dd6c0b07c43b5acc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// only show edges related to node on click | |
allEdges = $('.edge'); | |
allNodes = $('.node') | |
node.on("click", function(d) { | |
var id = d.id.toString(); | |
allEdges.removeClass('hidden'); | |
allNodes.removeClass('hidden'); | |
nonRelevantEdges = $('.edge:not(.' + id + ')'); | |
nonRelevantEdges.toggleClass('hidden'); | |
relevantNodes = ($('.'+id).map(function(){return $(this).attr("source");}).get()).concat($('.'+id).map(function(){return $(this).attr("target");}).get()); | |
relevantNodes[0] = '#' + relevantNodes[0]; | |
nodeIdList = relevantNodes.join(", #"); | |
allNodes.toggleClass('hidden') | |
$(nodeIdList).removeClass('hidden'); | |
}) | |
// show all edges again when clicking on white space | |
$('rect').on("click", function(d) { | |
allEdges.removeClass('hidden'); | |
allNodes.removeClass('hidden'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment