summaryrefslogtreecommitdiff
path: root/media/d3.layout.min.js
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-02-28 21:36:38 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-02-28 21:36:38 -0500
commit94cb6df76692cea50e2989e58512947debbe70e4 (patch)
treebcd0518d318deffd12b7f2999aa43e040e5d50f3 /media/d3.layout.min.js
parent9e90f1968802d350157bcbeef0cebd7d96eb1ada (diff)
parent9c6fd09153b4bac9f6b95e2584a3776a0d91ba42 (diff)
Merge commit '9c6fd0' from archweb: upgrade to d3-2.6.1
Conflicts: media/d3.layout.min.js media/d3.min.js This brought out a few bugs in the Makefile, fix them.
Diffstat (limited to 'media/d3.layout.min.js')
-rw-r--r--media/d3.layout.min.js73
1 files changed, 37 insertions, 36 deletions
diff --git a/media/d3.layout.min.js b/media/d3.layout.min.js
index 1e9195f5..d899e1b3 100644
--- a/media/d3.layout.min.js
+++ b/media/d3.layout.min.js
@@ -1,25 +1,25 @@
/* d3.layout.js - Data Driven Documents
- * Version: 2.4.3
+ * Version: 2.6.1
* Homepage: http://mbostock.github.com/d3/
* Copyright: 2010, Michael Bostock
* Licence: 3-Clause BSD
*
* Copyright (c) 2010, Michael Bostock
* All rights reserved.
-
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
-
+ *
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
-
+ *
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
-
+ *
* * The name Michael Bostock may not be used to endorse or promote products
* derived from this software without specific prior written permission.
-
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -146,16 +146,19 @@ d3.layout.chord = function() {
k = (2 * Math.PI - padding * n) / k;
// Compute the start and end angle for each group and subgroup.
+ // Note: Opera has a bug reordering object literal properties!
x = 0, i = -1; while (++i < n) {
x0 = x, j = -1; while (++j < n) {
var di = groupIndex[i],
- dj = subgroupIndex[i][j],
- v = matrix[di][dj];
+ dj = subgroupIndex[di][j],
+ v = matrix[di][dj],
+ a0 = x,
+ a1 = x += v * k;
subgroups[di + "-" + dj] = {
index: di,
subindex: dj,
- startAngle: x,
- endAngle: x += v * k,
+ startAngle: a0,
+ endAngle: a1,
value: v
};
}
@@ -186,7 +189,9 @@ d3.layout.chord = function() {
function resort() {
chords.sort(function(a, b) {
- return sortChords(a.target.value, b.target.value);
+ return sortChords(
+ (a.source.value + a.target.value) / 2,
+ (b.source.value + b.target.value) / 2);
});
}
@@ -346,17 +351,12 @@ d3.layout.force = function() {
}
}
- event.tick.dispatch({type: "tick", alpha: alpha});
+ event.tick({type: "tick", alpha: alpha});
// simulated annealing, basically
return (alpha *= .99) < .005;
}
- force.on = function(type, listener) {
- event[type].add(listener);
- return force;
- };
-
force.nodes = function(x) {
if (!arguments.length) return nodes;
nodes = x;
@@ -503,6 +503,7 @@ d3.layout.force = function() {
// use `node.call(force.drag)` to make nodes draggable
force.drag = function() {
if (!drag) drag = d3.behavior.drag()
+ .origin(Object)
.on("dragstart", dragstart)
.on("drag", d3_layout_forceDrag)
.on("dragend", d3_layout_forceDragEnd);
@@ -517,7 +518,7 @@ d3.layout.force = function() {
d3_layout_forceDragForce = force;
}
- return force;
+ return d3.rebind(force, event, "on");
};
var d3_layout_forceDragForce,
@@ -538,8 +539,8 @@ function d3_layout_forceDragEnd() {
}
function d3_layout_forceDrag() {
- d3_layout_forceDragNode.px += d3.event.dx;
- d3_layout_forceDragNode.py += d3.event.dy;
+ d3_layout_forceDragNode.px = d3.event.x;
+ d3_layout_forceDragNode.py = d3.event.y;
d3_layout_forceDragForce.resume(); // restart annealing
}
@@ -633,33 +634,31 @@ d3.layout.partition = function() {
};
d3.layout.pie = function() {
var value = Number,
- sort = null,
+ sort = d3_layout_pieSortByValue,
startAngle = 0,
endAngle = 2 * Math.PI;
function pie(data, i) {
+ // Compute the numeric values for each data element.
+ var values = data.map(function(d, i) { return +value.call(pie, d, i); });
+
// Compute the start angle.
var a = +(typeof startAngle === "function"
? startAngle.apply(this, arguments)
: startAngle);
- // Compute the angular range (end - start).
- var k = (typeof endAngle === "function"
+ // Compute the angular scale factor: from value to radians.
+ var k = ((typeof endAngle === "function"
? endAngle.apply(this, arguments)
- : endAngle) - startAngle;
+ : endAngle) - startAngle)
+ / d3.sum(values);
// Optionally sort the data.
var index = d3.range(data.length);
- if (sort != null) index.sort(function(i, j) {
- return sort(data[i], data[j]);
- });
-
- // Compute the numeric values for each data element.
- var values = data.map(value);
-
- // Convert k into a scale factor from value to angle, using the sum.
- k /= values.reduce(function(p, d) { return p + d; }, 0);
+ if (sort != null) index.sort(sort === d3_layout_pieSortByValue
+ ? function(i, j) { return values[j] - values[i]; }
+ : function(i, j) { return sort(data[i], data[j]); });
// Compute the arcs!
var arcs = index.map(function(i) {
@@ -726,6 +725,8 @@ d3.layout.pie = function() {
return pie;
};
+
+var d3_layout_pieSortByValue = {};
// data is two-dimensional array of x,y; we populate y0
d3.layout.stack = function() {
var values = Object,
@@ -1148,10 +1149,10 @@ d3.layout.hierarchy = function() {
// A method assignment helper for hierarchy subclasses.
function d3_layout_hierarchyRebind(object, hierarchy) {
- object.sort = d3.rebind(object, hierarchy.sort);
- object.children = d3.rebind(object, hierarchy.children);
+ d3.rebind(object, hierarchy, "sort", "children", "value");
+
+ // Add an alias for links, for convenience.
object.links = d3_layout_hierarchyLinks;
- object.value = d3.rebind(object, hierarchy.value);
// If the new API is used, enabling inlining.
object.nodes = function(d) {