Commit e3b5dd51 authored by Clement Frainay's avatar Clement Frainay

hide isolated nodes after univist & collapse.

todo : keep seeds visible
parent f400345c
......@@ -295,6 +295,7 @@ Ext.define('metExploreViz.view.panel.viz.VizController', {
iconCls: "neighboursCollapse",
handler: function () {
theNode.hide();
metExploreD3.GraphNetwork.hideIsolatedNodes("viz");
metExploreD3.GraphNetwork.updateNetwork("viz", _metExploreViz.getSessionById("viz"));
}
}, {
......
......@@ -3204,6 +3204,51 @@ metExploreD3.GraphNetwork = {
});
},
hideIsolatedNodes : function(panel){
var session = _metExploreViz.getSessionById(panel);
var networkData = session.getD3Data();
// Get visible links
var visibleLinks = networkData.getLinks()
.filter(function (link) {
var target, source;
target = link.getTarget();
source = link.getSource();
return !source.isHidden() && !target.isHidden();
});
// Get visible nodes
var visibleNodes = networkData.getNodes()
.filter(function (node) {
return !node.isHidden();
});
//get isolated nodes from visible ones
var isolatedNodes = visibleNodes
.filter(function (node){
//get links connected to the visible nodes
var visibleAdjLink = networkData.getLinks()
.filter(function (link) {
return link.getSource()===node || link.getTarget()===node;
})
.filter(function (link) {
//keep the links present in the visible set
return visibleLinks.indexOf(link) >= 0;
});
//keep nodes without links in the visible links set
return (typeof visibleAdjLink === 'undefined' || visibleAdjLink.length === 0);
});
//hide isolated nodes
isolatedNodes.forEach(function(node) {
node.hide();
});
},
/*******************************************
* Remove node which is Isolated
* @param {} panel : The panel
......
......@@ -238,6 +238,7 @@ metExploreD3.GraphNode = {
};
});
//update display
metExploreD3.GraphNetwork.hideIsolatedNodes("viz");
metExploreD3.GraphNetwork.updateNetwork("viz", _metExploreViz.getSessionById("viz"));
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment