summaryrefslogtreecommitdiff
path: root/visualize/static/d3.layout.js
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-01-21 13:35:52 -0600
committerDan McGee <dan@archlinux.org>2012-01-21 13:35:52 -0600
commit32633d45583000949ba3e14ae1c27d82ee24404d (patch)
treeb0f0bc8d2fe3857bce894ebac976a77160424b8e /visualize/static/d3.layout.js
parent1a6554dab794b5eb9153c4eb9dd60e6d359a0ab9 (diff)
Update D3 JS resources
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'visualize/static/d3.layout.js')
-rw-r--r--visualize/static/d3.layout.js34
1 files changed, 12 insertions, 22 deletions
diff --git a/visualize/static/d3.layout.js b/visualize/static/d3.layout.js
index 30ba7918..d93fbe5c 100644
--- a/visualize/static/d3.layout.js
+++ b/visualize/static/d3.layout.js
@@ -628,19 +628,17 @@ d3.layout.pie = function() {
: function(i, j) { return sort(data[i], data[j]); });
// Compute the arcs!
- var arcs = index.map(function(i) {
- return {
+ // They are stored in the original data's order.
+ var arcs = [];
+ index.forEach(function(i) {
+ arcs[i] = {
data: data[i],
value: d = values[i],
startAngle: a,
endAngle: a += d * k
};
});
-
- // Return the arcs in the original data's order.
- return data.map(function(d, i) {
- return arcs[index[i]];
- });
+ return arcs;
}
/**
@@ -1205,7 +1203,7 @@ function d3_layout_packIntersects(a, b) {
var dx = b.x - a.x,
dy = b.y - a.y,
dr = a.r + b.r;
- return (dr * dr - dx * dx - dy * dy) > .001; // within epsilon
+ return dr * dr - dx * dx - dy * dy > .001; // within epsilon
}
function d3_layout_packCircle(nodes) {
@@ -1264,28 +1262,20 @@ function d3_layout_packCircle(nodes) {
if (isect == 1) {
for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {
if (d3_layout_packIntersects(k, c)) {
- if (s2 < s1) {
- isect = -1;
- j = k;
- }
break;
}
}
}
// Update node chain.
- if (isect == 0) {
+ if (isect) {
+ if (s1 < s2 || (s1 == s2 && b.r < a.r)) d3_layout_packSplice(a, b = j);
+ else d3_layout_packSplice(a = k, b);
+ i--;
+ } else {
d3_layout_packInsert(a, c);
b = c;
bound(c);
- } else if (isect > 0) {
- d3_layout_packSplice(a, j);
- b = j;
- i--;
- } else { // isect < 0
- d3_layout_packSplice(j, b);
- a = j;
- i--;
}
}
}
@@ -1392,7 +1382,7 @@ d3.layout.cluster = function() {
// Second walk, normalizing x & y to the desired size.
d3_layout_treeVisitAfter(root, function(node) {
node.x = (node.x - x0) / (x1 - x0) * size[0];
- node.y = (1 - node.y / root.y) * size[1];
+ node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];
});
return nodes;