Skip to content

Commit

Permalink
bug hierarchical layout
Browse files Browse the repository at this point in the history
  • Loading branch information
marion-clemence committed Feb 20, 2018
1 parent 201e0f4 commit c0d7cf4
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions dist/layout.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
var layout_physical_active=true;
var layout_hierarchical_active=false;

var temp;
var allNodesTemp;

function layout_physical(){

if(layout_physical_active != true){
Expand All @@ -18,9 +21,22 @@ function layout_physical(){

function layout_hierarchical(){

console.log(JSON.stringify(allNodes));
//allNodes=nodesDataset.get({returnType:"Object"});

var updateArray = [];
for (var nodeId in allNodes) {
if (allNodes.hasOwnProperty(nodeId)) {
updateArray.push(allNodes[nodeId]);
}
}
temp= new vis.DataSet(updateArray);

console.log(JSON.stringify(temp));


if(layout_hierarchical_active==false){
//var tempNodeDataset=nodesDataset;
//console.log(nodesDataset);

document.getElementById("text_scenario").innerHTML="";

// Create a new directed graph
Expand Down Expand Up @@ -458,16 +474,35 @@ options = {
listener();
//console.log(tempNodeDataset);

//nodesDataset=tempNodeDataset;
layout_physical_active=false;
layout_hierarchical_active=true;



}

else if($("#text_scenario")[0].innerHTML.includes("You are already on the") == false) {
document.getElementById("text_scenario").innerHTML+="<br>" + "You are already on the hierarchical layout !";
}

allNodes=temp.get({returnType:"Object"});


var updateArray = [];
for (var nodeId in allNodes) {
if (allNodes.hasOwnProperty(nodeId)) {
updateArray.push(allNodes[nodeId]);
}
}
nodesDataset.update(updateArray);

data.nodes.update(data.nodes.get().map(function(item) {
item.x = undefined;
item.y = undefined;
return item;
}));


console.log(JSON.stringify(allNodes));
console.log(JSON.stringify(temp));
console.log(JSON.stringify(nodesDataset));

}

0 comments on commit c0d7cf4

Please sign in to comment.