MCPcopy Create free account
hub / github.com/idank/explainshell / cluster

Function cluster

explainshell/web/static/js/d3.v3.js:6105–6124  ·  view source on GitHub ↗
(d, i)

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 6

d3_layout_treeVisitAfterFunction · 0.85
d3_layout_clusterXFunction · 0.85
d3_layout_clusterYFunction · 0.85
d3_layout_clusterLeftFunction · 0.85
d3_layout_clusterRightFunction · 0.85
callMethod · 0.45

Tested by

no test coverage detected