d3_rails 3.4.6 → 3.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/d3.js +215 -223
- data/app/assets/javascripts/d3.min.js +5 -5
- data/lib/d3_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d2a54fe1febbdf9ab3b2e5c589b51415ac6276e
|
4
|
+
data.tar.gz: a957911b3ae00169214d49365f8d492f2db8b8cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd06b68dffbe57d6904fb4ced7beb2ff978efc8d1309bff992459993deaddc259e736b26be02640c968e7300eace26cde0f70036144a8db619a28a7b39afc5f1
|
7
|
+
data.tar.gz: 579cfd101fcb0df75a7e41bbd682a908fb52f7f2dd8dca5c6cdd9e6fad914b36fc286663682eb9e6c7ce7de06dca177b95295921f59513d5bd3a273cf4c7f7e9
|
@@ -1,6 +1,6 @@
|
|
1
1
|
!function() {
|
2
2
|
var d3 = {
|
3
|
-
version: "3.4.
|
3
|
+
version: "3.4.8"
|
4
4
|
};
|
5
5
|
if (!Date.now) Date.now = function() {
|
6
6
|
return +new Date();
|
@@ -1362,7 +1362,7 @@
|
|
1362
1362
|
}
|
1363
1363
|
}
|
1364
1364
|
function touchstarted() {
|
1365
|
-
var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName,
|
1365
|
+
var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress();
|
1366
1366
|
d3_selection_interrupt.call(that);
|
1367
1367
|
started();
|
1368
1368
|
zoomstarted(dispatch);
|
@@ -1375,6 +1375,9 @@
|
|
1375
1375
|
return touches;
|
1376
1376
|
}
|
1377
1377
|
function started() {
|
1378
|
+
var target = d3.event.target;
|
1379
|
+
d3.select(target).on(touchmove, moved).on(touchend, ended);
|
1380
|
+
targets.push(target);
|
1378
1381
|
var changed = d3.event.changedTouches;
|
1379
1382
|
for (var i = 0, n = changed.length; i < n; ++i) {
|
1380
1383
|
locations0[changed[i].identifier] = null;
|
@@ -1423,7 +1426,7 @@
|
|
1423
1426
|
return void relocate();
|
1424
1427
|
}
|
1425
1428
|
}
|
1426
|
-
|
1429
|
+
d3.selectAll(targets).on(zoomName, null);
|
1427
1430
|
subject.on(mousedown, mousedowned).on(touchstart, touchstarted);
|
1428
1431
|
dragRestore();
|
1429
1432
|
zoomended(dispatch);
|
@@ -6332,41 +6335,30 @@
|
|
6332
6335
|
var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity;
|
6333
6336
|
d3.layout.hierarchy = function() {
|
6334
6337
|
var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue;
|
6335
|
-
function
|
6336
|
-
var
|
6337
|
-
|
6338
|
-
|
6339
|
-
|
6340
|
-
|
6341
|
-
|
6342
|
-
|
6343
|
-
|
6344
|
-
|
6345
|
-
|
6346
|
-
|
6347
|
-
|
6348
|
-
|
6349
|
-
|
6350
|
-
|
6351
|
-
node.
|
6338
|
+
function hierarchy(root) {
|
6339
|
+
var stack = [ root ], nodes = [], node;
|
6340
|
+
root.depth = 0;
|
6341
|
+
while ((node = stack.pop()) != null) {
|
6342
|
+
nodes.push(node);
|
6343
|
+
if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) {
|
6344
|
+
var n, childs, child;
|
6345
|
+
while (--n >= 0) {
|
6346
|
+
stack.push(child = childs[n]);
|
6347
|
+
child.parent = node;
|
6348
|
+
child.depth = node.depth + 1;
|
6349
|
+
}
|
6350
|
+
if (value) node.value = 0;
|
6351
|
+
node.children = childs;
|
6352
|
+
} else {
|
6353
|
+
if (value) node.value = +value.call(hierarchy, node, node.depth) || 0;
|
6354
|
+
delete node.children;
|
6352
6355
|
}
|
6353
6356
|
}
|
6354
|
-
|
6355
|
-
|
6356
|
-
|
6357
|
-
|
6358
|
-
|
6359
|
-
var i = -1, n, j = depth + 1;
|
6360
|
-
while (++i < n) v += revalue(children[i], j);
|
6361
|
-
} else if (value) {
|
6362
|
-
v = +value.call(hierarchy, node, depth) || 0;
|
6363
|
-
}
|
6364
|
-
if (value) node.value = v;
|
6365
|
-
return v;
|
6366
|
-
}
|
6367
|
-
function hierarchy(d) {
|
6368
|
-
var nodes = [];
|
6369
|
-
recurse(d, 0, nodes);
|
6357
|
+
d3_layout_hierarchyVisitAfter(root, function(node) {
|
6358
|
+
var childs, parent;
|
6359
|
+
if (sort && (childs = node.children)) childs.sort(sort);
|
6360
|
+
if (value && (parent = node.parent)) parent.value += node.value;
|
6361
|
+
});
|
6370
6362
|
return nodes;
|
6371
6363
|
}
|
6372
6364
|
hierarchy.sort = function(x) {
|
@@ -6385,7 +6377,16 @@
|
|
6385
6377
|
return hierarchy;
|
6386
6378
|
};
|
6387
6379
|
hierarchy.revalue = function(root) {
|
6388
|
-
|
6380
|
+
if (value) {
|
6381
|
+
d3_layout_hierarchyVisitBefore(root, function(node) {
|
6382
|
+
if (node.children) node.value = 0;
|
6383
|
+
});
|
6384
|
+
d3_layout_hierarchyVisitAfter(root, function(node) {
|
6385
|
+
var parent;
|
6386
|
+
if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;
|
6387
|
+
if (parent = node.parent) parent.value += node.value;
|
6388
|
+
});
|
6389
|
+
}
|
6389
6390
|
return root;
|
6390
6391
|
};
|
6391
6392
|
return hierarchy;
|
@@ -6396,6 +6397,29 @@
|
|
6396
6397
|
object.links = d3_layout_hierarchyLinks;
|
6397
6398
|
return object;
|
6398
6399
|
}
|
6400
|
+
function d3_layout_hierarchyVisitBefore(node, callback) {
|
6401
|
+
var nodes = [ node ];
|
6402
|
+
while ((node = nodes.pop()) != null) {
|
6403
|
+
callback(node);
|
6404
|
+
if ((children = node.children) && (n = children.length)) {
|
6405
|
+
var n, children;
|
6406
|
+
while (--n >= 0) nodes.push(children[n]);
|
6407
|
+
}
|
6408
|
+
}
|
6409
|
+
}
|
6410
|
+
function d3_layout_hierarchyVisitAfter(node, callback) {
|
6411
|
+
var nodes = [ node ], nodes2 = [];
|
6412
|
+
while ((node = nodes.pop()) != null) {
|
6413
|
+
nodes2.push(node);
|
6414
|
+
if ((children = node.children) && (n = children.length)) {
|
6415
|
+
var i = -1, n, children;
|
6416
|
+
while (++i < n) nodes.push(children[i]);
|
6417
|
+
}
|
6418
|
+
}
|
6419
|
+
while ((node = nodes2.pop()) != null) {
|
6420
|
+
callback(node);
|
6421
|
+
}
|
6422
|
+
}
|
6399
6423
|
function d3_layout_hierarchyChildren(d) {
|
6400
6424
|
return d.children;
|
6401
6425
|
}
|
@@ -6711,185 +6735,6 @@
|
|
6711
6735
|
function d3_layout_histogramRange(values) {
|
6712
6736
|
return [ d3.min(values), d3.max(values) ];
|
6713
6737
|
}
|
6714
|
-
d3.layout.tree = function() {
|
6715
|
-
var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;
|
6716
|
-
function tree(d, i) {
|
6717
|
-
var nodes = hierarchy.call(this, d, i), root = nodes[0];
|
6718
|
-
function firstWalk(node, previousSibling) {
|
6719
|
-
var children = node.children, layout = node._tree;
|
6720
|
-
if (children && (n = children.length)) {
|
6721
|
-
var n, firstChild = children[0], previousChild, ancestor = firstChild, child, i = -1;
|
6722
|
-
while (++i < n) {
|
6723
|
-
child = children[i];
|
6724
|
-
firstWalk(child, previousChild);
|
6725
|
-
ancestor = apportion(child, previousChild, ancestor);
|
6726
|
-
previousChild = child;
|
6727
|
-
}
|
6728
|
-
d3_layout_treeShift(node);
|
6729
|
-
var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim);
|
6730
|
-
if (previousSibling) {
|
6731
|
-
layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
|
6732
|
-
layout.mod = layout.prelim - midpoint;
|
6733
|
-
} else {
|
6734
|
-
layout.prelim = midpoint;
|
6735
|
-
}
|
6736
|
-
} else {
|
6737
|
-
if (previousSibling) {
|
6738
|
-
layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
|
6739
|
-
}
|
6740
|
-
}
|
6741
|
-
}
|
6742
|
-
function secondWalk(node, x) {
|
6743
|
-
node.x = node._tree.prelim + x;
|
6744
|
-
var children = node.children;
|
6745
|
-
if (children && (n = children.length)) {
|
6746
|
-
var i = -1, n;
|
6747
|
-
x += node._tree.mod;
|
6748
|
-
while (++i < n) {
|
6749
|
-
secondWalk(children[i], x);
|
6750
|
-
}
|
6751
|
-
}
|
6752
|
-
}
|
6753
|
-
function apportion(node, previousSibling, ancestor) {
|
6754
|
-
if (previousSibling) {
|
6755
|
-
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;
|
6756
|
-
while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
|
6757
|
-
vom = d3_layout_treeLeft(vom);
|
6758
|
-
vop = d3_layout_treeRight(vop);
|
6759
|
-
vop._tree.ancestor = node;
|
6760
|
-
shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip);
|
6761
|
-
if (shift > 0) {
|
6762
|
-
d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift);
|
6763
|
-
sip += shift;
|
6764
|
-
sop += shift;
|
6765
|
-
}
|
6766
|
-
sim += vim._tree.mod;
|
6767
|
-
sip += vip._tree.mod;
|
6768
|
-
som += vom._tree.mod;
|
6769
|
-
sop += vop._tree.mod;
|
6770
|
-
}
|
6771
|
-
if (vim && !d3_layout_treeRight(vop)) {
|
6772
|
-
vop._tree.thread = vim;
|
6773
|
-
vop._tree.mod += sim - sop;
|
6774
|
-
}
|
6775
|
-
if (vip && !d3_layout_treeLeft(vom)) {
|
6776
|
-
vom._tree.thread = vip;
|
6777
|
-
vom._tree.mod += sip - som;
|
6778
|
-
ancestor = node;
|
6779
|
-
}
|
6780
|
-
}
|
6781
|
-
return ancestor;
|
6782
|
-
}
|
6783
|
-
d3_layout_treeVisitAfter(root, function(node, previousSibling) {
|
6784
|
-
node._tree = {
|
6785
|
-
ancestor: node,
|
6786
|
-
prelim: 0,
|
6787
|
-
mod: 0,
|
6788
|
-
change: 0,
|
6789
|
-
shift: 0,
|
6790
|
-
number: previousSibling ? previousSibling._tree.number + 1 : 0
|
6791
|
-
};
|
6792
|
-
});
|
6793
|
-
firstWalk(root);
|
6794
|
-
secondWalk(root, -root._tree.prelim);
|
6795
|
-
var left = d3_layout_treeSearch(root, d3_layout_treeLeftmost), right = d3_layout_treeSearch(root, d3_layout_treeRightmost), deep = d3_layout_treeSearch(root, d3_layout_treeDeepest), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2, y1 = deep.depth || 1;
|
6796
|
-
d3_layout_treeVisitAfter(root, nodeSize ? function(node) {
|
6797
|
-
node.x *= size[0];
|
6798
|
-
node.y = node.depth * size[1];
|
6799
|
-
delete node._tree;
|
6800
|
-
} : function(node) {
|
6801
|
-
node.x = (node.x - x0) / (x1 - x0) * size[0];
|
6802
|
-
node.y = node.depth / y1 * size[1];
|
6803
|
-
delete node._tree;
|
6804
|
-
});
|
6805
|
-
return nodes;
|
6806
|
-
}
|
6807
|
-
tree.separation = function(x) {
|
6808
|
-
if (!arguments.length) return separation;
|
6809
|
-
separation = x;
|
6810
|
-
return tree;
|
6811
|
-
};
|
6812
|
-
tree.size = function(x) {
|
6813
|
-
if (!arguments.length) return nodeSize ? null : size;
|
6814
|
-
nodeSize = (size = x) == null;
|
6815
|
-
return tree;
|
6816
|
-
};
|
6817
|
-
tree.nodeSize = function(x) {
|
6818
|
-
if (!arguments.length) return nodeSize ? size : null;
|
6819
|
-
nodeSize = (size = x) != null;
|
6820
|
-
return tree;
|
6821
|
-
};
|
6822
|
-
return d3_layout_hierarchyRebind(tree, hierarchy);
|
6823
|
-
};
|
6824
|
-
function d3_layout_treeSeparation(a, b) {
|
6825
|
-
return a.parent == b.parent ? 1 : 2;
|
6826
|
-
}
|
6827
|
-
function d3_layout_treeLeft(node) {
|
6828
|
-
var children = node.children;
|
6829
|
-
return children && children.length ? children[0] : node._tree.thread;
|
6830
|
-
}
|
6831
|
-
function d3_layout_treeRight(node) {
|
6832
|
-
var children = node.children, n;
|
6833
|
-
return children && (n = children.length) ? children[n - 1] : node._tree.thread;
|
6834
|
-
}
|
6835
|
-
function d3_layout_treeSearch(node, compare) {
|
6836
|
-
var children = node.children;
|
6837
|
-
if (children && (n = children.length)) {
|
6838
|
-
var child, n, i = -1;
|
6839
|
-
while (++i < n) {
|
6840
|
-
if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) {
|
6841
|
-
node = child;
|
6842
|
-
}
|
6843
|
-
}
|
6844
|
-
}
|
6845
|
-
return node;
|
6846
|
-
}
|
6847
|
-
function d3_layout_treeRightmost(a, b) {
|
6848
|
-
return a.x - b.x;
|
6849
|
-
}
|
6850
|
-
function d3_layout_treeLeftmost(a, b) {
|
6851
|
-
return b.x - a.x;
|
6852
|
-
}
|
6853
|
-
function d3_layout_treeDeepest(a, b) {
|
6854
|
-
return a.depth - b.depth;
|
6855
|
-
}
|
6856
|
-
function d3_layout_treeVisitAfter(node, callback) {
|
6857
|
-
function visit(node, previousSibling) {
|
6858
|
-
var children = node.children;
|
6859
|
-
if (children && (n = children.length)) {
|
6860
|
-
var child, previousChild = null, i = -1, n;
|
6861
|
-
while (++i < n) {
|
6862
|
-
child = children[i];
|
6863
|
-
visit(child, previousChild);
|
6864
|
-
previousChild = child;
|
6865
|
-
}
|
6866
|
-
}
|
6867
|
-
callback(node, previousSibling);
|
6868
|
-
}
|
6869
|
-
visit(node, null);
|
6870
|
-
}
|
6871
|
-
function d3_layout_treeShift(node) {
|
6872
|
-
var shift = 0, change = 0, children = node.children, i = children.length, child;
|
6873
|
-
while (--i >= 0) {
|
6874
|
-
child = children[i]._tree;
|
6875
|
-
child.prelim += shift;
|
6876
|
-
child.mod += shift;
|
6877
|
-
shift += child.shift + (change += child.change);
|
6878
|
-
}
|
6879
|
-
}
|
6880
|
-
function d3_layout_treeMove(ancestor, node, shift) {
|
6881
|
-
ancestor = ancestor._tree;
|
6882
|
-
node = node._tree;
|
6883
|
-
var change = shift / (node.number - ancestor.number);
|
6884
|
-
ancestor.change += change;
|
6885
|
-
node.change -= change;
|
6886
|
-
node.shift += shift;
|
6887
|
-
node.prelim += shift;
|
6888
|
-
node.mod += shift;
|
6889
|
-
}
|
6890
|
-
function d3_layout_treeAncestor(vim, node, ancestor) {
|
6891
|
-
return vim._tree.ancestor.parent == node.parent ? vim._tree.ancestor : ancestor;
|
6892
|
-
}
|
6893
6738
|
d3.layout.pack = function() {
|
6894
6739
|
var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius;
|
6895
6740
|
function pack(d, i) {
|
@@ -6897,17 +6742,17 @@
|
|
6897
6742
|
return radius;
|
6898
6743
|
};
|
6899
6744
|
root.x = root.y = 0;
|
6900
|
-
|
6745
|
+
d3_layout_hierarchyVisitAfter(root, function(d) {
|
6901
6746
|
d.r = +r(d.value);
|
6902
6747
|
});
|
6903
|
-
|
6748
|
+
d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
|
6904
6749
|
if (padding) {
|
6905
6750
|
var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2;
|
6906
|
-
|
6751
|
+
d3_layout_hierarchyVisitAfter(root, function(d) {
|
6907
6752
|
d.r += dr;
|
6908
6753
|
});
|
6909
|
-
|
6910
|
-
|
6754
|
+
d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
|
6755
|
+
d3_layout_hierarchyVisitAfter(root, function(d) {
|
6911
6756
|
d.r -= dr;
|
6912
6757
|
});
|
6913
6758
|
}
|
@@ -7044,11 +6889,158 @@
|
|
7044
6889
|
c.y = a.y;
|
7045
6890
|
}
|
7046
6891
|
}
|
6892
|
+
d3.layout.tree = function() {
|
6893
|
+
var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null;
|
6894
|
+
function tree(d, i) {
|
6895
|
+
var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0);
|
6896
|
+
d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z;
|
6897
|
+
d3_layout_hierarchyVisitBefore(root1, secondWalk);
|
6898
|
+
if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else {
|
6899
|
+
var left = root0, right = root0, bottom = root0;
|
6900
|
+
d3_layout_hierarchyVisitBefore(root0, function(node) {
|
6901
|
+
if (node.x < left.x) left = node;
|
6902
|
+
if (node.x > right.x) right = node;
|
6903
|
+
if (node.depth > bottom.depth) bottom = node;
|
6904
|
+
});
|
6905
|
+
var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1);
|
6906
|
+
d3_layout_hierarchyVisitBefore(root0, function(node) {
|
6907
|
+
node.x = (node.x + tx) * kx;
|
6908
|
+
node.y = node.depth * ky;
|
6909
|
+
});
|
6910
|
+
}
|
6911
|
+
return nodes;
|
6912
|
+
}
|
6913
|
+
function wrapTree(root0) {
|
6914
|
+
var root1 = {
|
6915
|
+
A: null,
|
6916
|
+
children: [ root0 ]
|
6917
|
+
}, queue = [ root1 ], node1;
|
6918
|
+
while ((node1 = queue.pop()) != null) {
|
6919
|
+
for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) {
|
6920
|
+
queue.push((children[i] = child = {
|
6921
|
+
_: children[i],
|
6922
|
+
parent: node1,
|
6923
|
+
children: (child = children[i].children) && child.slice() || [],
|
6924
|
+
A: null,
|
6925
|
+
a: null,
|
6926
|
+
z: 0,
|
6927
|
+
m: 0,
|
6928
|
+
c: 0,
|
6929
|
+
s: 0,
|
6930
|
+
t: null,
|
6931
|
+
i: i
|
6932
|
+
}).a = child);
|
6933
|
+
}
|
6934
|
+
}
|
6935
|
+
return root1.children[0];
|
6936
|
+
}
|
6937
|
+
function firstWalk(v) {
|
6938
|
+
var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;
|
6939
|
+
if (children.length) {
|
6940
|
+
d3_layout_treeShift(v);
|
6941
|
+
var midpoint = (children[0].z + children[children.length - 1].z) / 2;
|
6942
|
+
if (w) {
|
6943
|
+
v.z = w.z + separation(v._, w._);
|
6944
|
+
v.m = v.z - midpoint;
|
6945
|
+
} else {
|
6946
|
+
v.z = midpoint;
|
6947
|
+
}
|
6948
|
+
} else if (w) {
|
6949
|
+
v.z = w.z + separation(v._, w._);
|
6950
|
+
}
|
6951
|
+
v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
|
6952
|
+
}
|
6953
|
+
function secondWalk(v) {
|
6954
|
+
v._.x = v.z + v.parent.m;
|
6955
|
+
v.m += v.parent.m;
|
6956
|
+
}
|
6957
|
+
function apportion(v, w, ancestor) {
|
6958
|
+
if (w) {
|
6959
|
+
var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift;
|
6960
|
+
while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
|
6961
|
+
vom = d3_layout_treeLeft(vom);
|
6962
|
+
vop = d3_layout_treeRight(vop);
|
6963
|
+
vop.a = v;
|
6964
|
+
shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
|
6965
|
+
if (shift > 0) {
|
6966
|
+
d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift);
|
6967
|
+
sip += shift;
|
6968
|
+
sop += shift;
|
6969
|
+
}
|
6970
|
+
sim += vim.m;
|
6971
|
+
sip += vip.m;
|
6972
|
+
som += vom.m;
|
6973
|
+
sop += vop.m;
|
6974
|
+
}
|
6975
|
+
if (vim && !d3_layout_treeRight(vop)) {
|
6976
|
+
vop.t = vim;
|
6977
|
+
vop.m += sim - sop;
|
6978
|
+
}
|
6979
|
+
if (vip && !d3_layout_treeLeft(vom)) {
|
6980
|
+
vom.t = vip;
|
6981
|
+
vom.m += sip - som;
|
6982
|
+
ancestor = v;
|
6983
|
+
}
|
6984
|
+
}
|
6985
|
+
return ancestor;
|
6986
|
+
}
|
6987
|
+
function sizeNode(node) {
|
6988
|
+
node.x *= size[0];
|
6989
|
+
node.y = node.depth * size[1];
|
6990
|
+
}
|
6991
|
+
tree.separation = function(x) {
|
6992
|
+
if (!arguments.length) return separation;
|
6993
|
+
separation = x;
|
6994
|
+
return tree;
|
6995
|
+
};
|
6996
|
+
tree.size = function(x) {
|
6997
|
+
if (!arguments.length) return nodeSize ? null : size;
|
6998
|
+
nodeSize = (size = x) == null ? sizeNode : null;
|
6999
|
+
return tree;
|
7000
|
+
};
|
7001
|
+
tree.nodeSize = function(x) {
|
7002
|
+
if (!arguments.length) return nodeSize ? size : null;
|
7003
|
+
nodeSize = (size = x) == null ? null : sizeNode;
|
7004
|
+
return tree;
|
7005
|
+
};
|
7006
|
+
return d3_layout_hierarchyRebind(tree, hierarchy);
|
7007
|
+
};
|
7008
|
+
function d3_layout_treeSeparation(a, b) {
|
7009
|
+
return a.parent == b.parent ? 1 : 2;
|
7010
|
+
}
|
7011
|
+
function d3_layout_treeLeft(v) {
|
7012
|
+
var children = v.children;
|
7013
|
+
return children.length ? children[0] : v.t;
|
7014
|
+
}
|
7015
|
+
function d3_layout_treeRight(v) {
|
7016
|
+
var children = v.children, n;
|
7017
|
+
return (n = children.length) ? children[n - 1] : v.t;
|
7018
|
+
}
|
7019
|
+
function d3_layout_treeMove(wm, wp, shift) {
|
7020
|
+
var change = shift / (wp.i - wm.i);
|
7021
|
+
wp.c -= change;
|
7022
|
+
wp.s += shift;
|
7023
|
+
wm.c += change;
|
7024
|
+
wp.z += shift;
|
7025
|
+
wp.m += shift;
|
7026
|
+
}
|
7027
|
+
function d3_layout_treeShift(v) {
|
7028
|
+
var shift = 0, change = 0, children = v.children, i = children.length, w;
|
7029
|
+
while (--i >= 0) {
|
7030
|
+
w = children[i];
|
7031
|
+
w.z += shift;
|
7032
|
+
w.m += shift;
|
7033
|
+
shift += w.s + (change += w.c);
|
7034
|
+
}
|
7035
|
+
}
|
7036
|
+
function d3_layout_treeAncestor(vim, v, ancestor) {
|
7037
|
+
return vim.a.parent === v.parent ? vim.a : ancestor;
|
7038
|
+
}
|
7047
7039
|
d3.layout.cluster = function() {
|
7048
7040
|
var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;
|
7049
7041
|
function cluster(d, i) {
|
7050
7042
|
var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0;
|
7051
|
-
|
7043
|
+
d3_layout_hierarchyVisitAfter(root, function(node) {
|
7052
7044
|
var children = node.children;
|
7053
7045
|
if (children && children.length) {
|
7054
7046
|
node.x = d3_layout_clusterX(children);
|
@@ -7060,7 +7052,7 @@
|
|
7060
7052
|
}
|
7061
7053
|
});
|
7062
7054
|
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;
|
7063
|
-
|
7055
|
+
d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) {
|
7064
7056
|
node.x = (node.x - root.x) * size[0];
|
7065
7057
|
node.y = (root.y - node.y) * size[1];
|
7066
7058
|
} : function(node) {
|