From 32633d45583000949ba3e14ae1c27d82ee24404d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 21 Jan 2012 13:35:52 -0600 Subject: Update D3 JS resources Signed-off-by: Dan McGee --- visualize/static/d3.layout.js | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'visualize/static/d3.layout.js') diff --git a/visualize/static/d3.layout.js b/visualize/static/d3.layout.js index 30ba791..d93fbe5 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; -- cgit v1.2.3-24-g4f1b