From 2950ba6d09ee287bafe83e6eac4a47e808c69ae9 Mon Sep 17 00:00:00 2001 From: Junghyun Kim Date: Thu, 26 Jan 2017 11:24:25 +0900 Subject: [PATCH] [make_dep_graph] enhance the highlight feature highlight only edges connected directly to the selected Node. Change-Id: If9668a009c9ef4c3b31c1947877719086f56bb30 Signed-off-by: Junghyun Kim --- dep_graph/dep_graph_common.js | 47 +++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/dep_graph/dep_graph_common.js b/dep_graph/dep_graph_common.js index 3ee4f4b..1510924 100644 --- a/dep_graph/dep_graph_common.js +++ b/dep_graph/dep_graph_common.js @@ -4,7 +4,7 @@ var allEdges; var highlightActive = false; var foundNodes; -var nodesDataset; +var nodesDataset; var edgesDataset = edges; var show_network=0; var network_max_level=1; @@ -94,7 +94,7 @@ function redrawAll() { } nodesDataset = new vis.DataSet(nodes); - var data = {nodes:nodesDataset, edges:edgesDataset} + var data = {nodes:nodesDataset, edges:edgesDataset} network = new vis.Network(container, data, options); @@ -143,7 +143,7 @@ function AddPackagesIntoTable(level_packages) { count=count+1; } package_string+=last_string; - + header_td.appendChild(document.createTextNode('Level'+i+' Packages ('+count+')')); tr.appendChild(header_td); @@ -172,7 +172,7 @@ function neighbourhoodHighlight(params) { highlightNode(params.nodes); } -function highlightNode(nodes) +function highlightNode(nodes) { // if something is selected: if (nodes.length > 0) { @@ -199,15 +199,21 @@ function highlightNode(nodes) allNodes[nodeId].label = undefined; } } + + // mark all edges as hard to read. + for (var edgeId in allEdges) { + allEdges[edgeId].color = 'rgba(200,200,200,0.2)'; + } var connectedNodes = network.getConnectedNodes(selectedNode); - var allConnectedNodes = []; + var connectedEdges = network.getConnectedEdges(selectedNode); + //var allConnectedNodes = []; // get the second degree nodes - for (i = 1; i < degrees; i++) { - for (j = 0; j < connectedNodes.length; j++) { - allConnectedNodes = allConnectedNodes.concat(network.getConnectedNodes(connectedNodes[j])); - } - } + //for (i = 1; i < degrees; i++) { + //for (j = 0; j < connectedNodes.length; j++) { + //allConnectedNodes = allConnectedNodes.concat(network.getConnectedNodes(connectedNodes[j])); + //} + //} // all second degree nodes get a different color and their label back // for (i = 0; i < allConnectedNodes.length; i++) { @@ -249,11 +255,17 @@ function highlightNode(nodes) allNodes[selectedNode].color = undefined; else allNodes[selectedNode].color = allNodes[selectedNode].set_color; + if (allNodes[selectedNode].hiddenLabel !== undefined) { allNodes[selectedNode].label = allNodes[selectedNode].hiddenLabel; allNodes[selectedNode].hiddenLabel = undefined; } + // all first degree edges get their own color and their label back + for (i = 0; i < connectedEdges.length; i++) { + allEdges[connectedEdges[i]].color = {inherit: 'from'}; + } + if( document.getElementById("build_triggers") ) { // set table contents. document.getElementById("build_triggers").innerHTML="Packages build-triggers "+ @@ -263,7 +275,6 @@ function highlightNode(nodes) allNodes[selectedNode].label+"("+packages_build_triggered_count+")"; document.getElementById("packages_build_triggered").innerHTML=packages_build_triggered; } - } else if (highlightActive === true) { // reset all nodes @@ -277,11 +288,25 @@ function highlightNode(nodes) allNodes[nodeId].hiddenLabel = undefined; } } + + // reset all edges + for (var edgeId in allEdges) { + allEdges[edgeId].color = {inherit: 'from'}; + } highlightActive = false; } // transform the object into an array var updateArray = []; + for (var edgeId in allEdges) { + if (allEdges.hasOwnProperty(edgeId)) { + updateArray.push(allEdges[edgeId]); + } + } + edgesDataset.update(updateArray); + + // transform the object into an array + var updateArray = []; for (nodeId in allNodes) { if (allNodes.hasOwnProperty(nodeId)) { updateArray.push(allNodes[nodeId]); -- 2.7.4