MCPcopy Index your code
hub / github.com/jipegit/OSXAuditor / tree

Function tree

d3-3.2.8/d3.js:6100–6190  ·  view source on GitHub ↗
(d, i)

Source from the content-addressed store, hash-verified

6098 d3.layout.tree = function() {
6099 var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;
6100 function tree(d, i) {
6101 var nodes = hierarchy.call(this, d, i), root = nodes[0];
6102 function firstWalk(node, previousSibling) {
6103 var children = node.children, layout = node._tree;
6104 if (children && (n = children.length)) {
6105 var n, firstChild = children[0], previousChild, ancestor = firstChild, child, i = -1;
6106 while (++i < n) {
6107 child = children[i];
6108 firstWalk(child, previousChild);
6109 ancestor = apportion(child, previousChild, ancestor);
6110 previousChild = child;
6111 }
6112 d3_layout_treeShift(node);
6113 var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim);
6114 if (previousSibling) {
6115 layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
6116 layout.mod = layout.prelim - midpoint;
6117 } else {
6118 layout.prelim = midpoint;
6119 }
6120 } else {
6121 if (previousSibling) {
6122 layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
6123 }
6124 }
6125 }
6126 function secondWalk(node, x) {
6127 node.x = node._tree.prelim + x;
6128 var children = node.children;
6129 if (children && (n = children.length)) {
6130 var i = -1, n;
6131 x += node._tree.mod;
6132 while (++i < n) {
6133 secondWalk(children[i], x);
6134 }
6135 }
6136 }
6137 function apportion(node, previousSibling, ancestor) {
6138 if (previousSibling) {
6139 var vip = node, vop = node, vim = previousSibling, vom = node.parent.children[0], sip = vip._tree.mod, sop = vop._tree.mod, sim = vim._tree.mod, som = vom._tree.mod, shift;
6140 while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
6141 vom = d3_layout_treeLeft(vom);
6142 vop = d3_layout_treeRight(vop);
6143 vop._tree.ancestor = node;
6144 shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip);
6145 if (shift > 0) {
6146 d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift);
6147 sip += shift;
6148 sop += shift;
6149 }
6150 sim += vim._tree.mod;
6151 sip += vip._tree.mod;
6152 som += vom._tree.mod;
6153 sop += vop._tree.mod;
6154 }
6155 if (vim && !d3_layout_treeRight(vop)) {
6156 vop._tree.thread = vim;
6157 vop._tree.mod += sim - sop;

Callers 1

tree-test.jsFile · 0.85

Calls 4

d3_layout_treeVisitAfterFunction · 0.85
firstWalkFunction · 0.85
secondWalkFunction · 0.85
d3_layout_treeSearchFunction · 0.85

Tested by

no test coverage detected