Renderer.prototype.layout = function()

in src/core/renderer.js [92:138]


Renderer.prototype.layout = function(nodes){
  var options = this.options;

  var gap = options.layerGap + options.nodeHeight;

  switch(options.direction){
    case 'left':
      nodes.forEach(function(node){
        var pos = node.getLayerIndex() * gap + options.layerGap;
        node.x = -pos - options.nodeHeight;
        node.y = node.currentPos;
        node.dx = options.nodeHeight;
        node.dy = node.width;
      });
      break;
    case 'right':
      nodes.forEach(function(node){
        var pos = node.getLayerIndex() * gap + options.layerGap;
        node.x = pos;
        node.y = node.currentPos;
        node.dx = options.nodeHeight;
        node.dy = node.width;
      });
      break;
    case 'up':
      nodes.forEach(function(node){
        var pos = node.getLayerIndex() * gap + options.layerGap;
        node.x = node.currentPos;
        node.y = -pos - options.nodeHeight;
        node.dx = node.width;
        node.dy = options.nodeHeight;
      });
      break;
    default:
    case 'down':
      nodes.forEach(function(node){
        var pos = node.getLayerIndex() * gap + options.layerGap;
        node.x = node.currentPos;
        node.y = pos;
        node.dx = node.width;
        node.dy = options.nodeHeight;
      });
      break;
  }

  return nodes;
};