(d, i)
| 6103 | d3.layout.cluster = function() { |
| 6104 | var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ]; |
| 6105 | function cluster(d, i) { |
| 6106 | var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0; |
| 6107 | d3_layout_treeVisitAfter(root, function(node) { |
| 6108 | var children = node.children; |
| 6109 | if (children && children.length) { |
| 6110 | node.x = d3_layout_clusterX(children); |
| 6111 | node.y = d3_layout_clusterY(children); |
| 6112 | } else { |
| 6113 | node.x = previousNode ? x += separation(node, previousNode) : 0; |
| 6114 | node.y = 0; |
| 6115 | previousNode = node; |
| 6116 | } |
| 6117 | }); |
| 6118 | var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2; |
| 6119 | d3_layout_treeVisitAfter(root, function(node) { |
| 6120 | node.x = (node.x - x0) / (x1 - x0) * size[0]; |
| 6121 | node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1]; |
| 6122 | }); |
| 6123 | return nodes; |
| 6124 | } |
| 6125 | cluster.separation = function(x) { |
| 6126 | if (!arguments.length) return separation; |
| 6127 | separation = x; |
nothing calls this directly
no test coverage detected