|
|
@ -94,26 +94,31 @@ exports._placeNodesByHierarchy = function(distribution) { |
|
|
|
var nodeId, node; |
|
|
|
|
|
|
|
// start placing all the level 0 nodes first. Then recursively position their branches.
|
|
|
|
for (nodeId in distribution[0].nodes) { |
|
|
|
if (distribution[0].nodes.hasOwnProperty(nodeId)) { |
|
|
|
node = distribution[0].nodes[nodeId]; |
|
|
|
if (this.constants.hierarchicalLayout.direction == "UD" || this.constants.hierarchicalLayout.direction == "DU") { |
|
|
|
if (node.xFixed) { |
|
|
|
node.x = distribution[0].minPos; |
|
|
|
node.xFixed = false; |
|
|
|
|
|
|
|
distribution[0].minPos += distribution[0].nodeSpacing; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
if (node.yFixed) { |
|
|
|
node.y = distribution[0].minPos; |
|
|
|
node.yFixed = false; |
|
|
|
for (var level in distribution) { |
|
|
|
if (distribution.hasOwnProperty(level)) { |
|
|
|
|
|
|
|
distribution[0].minPos += distribution[0].nodeSpacing; |
|
|
|
for (nodeId in distribution[level].nodes) { |
|
|
|
if (distribution[level].nodes.hasOwnProperty(nodeId)) { |
|
|
|
node = distribution[level].nodes[nodeId]; |
|
|
|
if (this.constants.hierarchicalLayout.direction == "UD" || this.constants.hierarchicalLayout.direction == "DU") { |
|
|
|
if (node.xFixed) { |
|
|
|
node.x = distribution[level].minPos; |
|
|
|
node.xFixed = false; |
|
|
|
|
|
|
|
distribution[level].minPos += distribution[level].nodeSpacing; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
if (node.yFixed) { |
|
|
|
node.y = distribution[level].minPos; |
|
|
|
node.yFixed = false; |
|
|
|
|
|
|
|
distribution[level].minPos += distribution[level].nodeSpacing; |
|
|
|
} |
|
|
|
} |
|
|
|
this._placeBranchNodes(node.edges,node.id,distribution,node.level); |
|
|
|
} |
|
|
|
} |
|
|
|
this._placeBranchNodes(node.edges,node.id,distribution,node.level); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -145,11 +150,11 @@ exports._getDistribution = function() { |
|
|
|
else { |
|
|
|
node.x = this.constants.hierarchicalLayout.levelSeparation*node.level; |
|
|
|
} |
|
|
|
if (!distribution.hasOwnProperty(node.level)) { |
|
|
|
if (distribution[node.level] === undefined) { |
|
|
|
distribution[node.level] = {amount: 0, nodes: {}, minPos:0, nodeSpacing:0}; |
|
|
|
} |
|
|
|
distribution[node.level].amount += 1; |
|
|
|
distribution[node.level].nodes[node.id] = node; |
|
|
|
distribution[node.level].nodes[nodeId] = node; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|