Skip to content
Browse files

Merge branch '2.5.0'

  • Loading branch information...
2 parents 98da365 + 7ae28f1 commit 8cba1d7e1ca1c0e1b6529bb494f209243a271762 @mbostock mbostock committed Nov 4, 2011
Showing with 2,310 additions and 411 deletions.
  1. +1 −0 .gitignore
  2. +5 −1 Makefile
  3. +11 −1 d3.geom.js
  4. +549 −84 d3.js
  5. +21 −18 d3.layout.js
  6. +1 −1 d3.layout.min.js
  7. +2 −2 d3.min.js
  8. +92 −0 examples/brush/brush-x.html
  9. +91 −0 examples/brush/brush-y.html
  10. +98 −0 examples/brush/brush.html
  11. +1 −1 examples/calendar/dji.js
  12. +1 −2 examples/calendar/vix.js
  13. +1 −1 examples/donut/donut.html
  14. +1 −7 examples/force/force.js
  15. +407 −0 examples/parallel/cars.csv
  16. +134 −0 examples/parallel/parallel.html
  17. +3 −4 examples/pie/pie-transition.html
  18. +1 −1 examples/pie/pie.html
  19. +0 −7 examples/splom/cross.js
  20. +45 −4 examples/splom/splom.css
  21. +0 −1 examples/splom/splom.html
  22. +96 −126 examples/splom/splom.js
  23. +60 −0 examples/transform/transform.html
  24. +3 −2 examples/zoom-pan/zoom-pan-transform.html
  25. +3 −2 examples/zoom-pan/zoom-pan.html
  26. +2 −1 package.json
  27. +9 −14 src/behavior/drag.js
  28. +41 −15 src/behavior/zoom.js
  29. +1 −1 src/core/core.js
  30. +45 −33 src/core/dispatch.js
  31. +5 −0 src/core/event.js
  32. +21 −0 src/core/extent.js
  33. +9 −6 src/core/interpolate.js
  34. +15 −0 src/core/random.js
  35. +48 −0 src/core/transform.js
  36. +1 −1 src/core/transition-attr.js
  37. +1 −1 src/core/transition-style.js
  38. +7 −6 src/core/transition.js
  39. +11 −1 src/geom/voronoi.js
  40. +6 −3 src/layout/chord.js
  41. +2 −2 src/layout/force.js
  42. +13 −13 src/layout/pie.js
  43. +1 −0 src/package.js
  44. +8 −5 src/scale/ordinal.js
  45. +335 −0 src/svg/brush.js
  46. +3 −2 src/svg/touches.js
  47. +39 −40 test/core/dispatch-test.js
  48. +51 −0 test/core/extent-test.js
  49. +4 −0 test/core/interpolate-test.js
  50. +2 −2 test/core/transition-test-each.js
  51. +3 −0 test/scale/ordinal-test.js
View
1 .gitignore
@@ -1,2 +1,3 @@
_site
node_modules
+.DS_Store
View
6 Makefile
@@ -48,6 +48,8 @@ d3.core.js: \
src/core/median.js \
src/core/min.js \
src/core/max.js \
+ src/core/extent.js \
+ src/core/random.js \
src/core/number.js \
src/core/sum.js \
src/core/quantile.js \
@@ -118,6 +120,7 @@ d3.core.js: \
src/core/transition-each.js \
src/core/transition-transition.js \
src/core/timer.js \
+ src/core/transform.js \
src/core/noop.js
d3.scale.js: \
@@ -147,7 +150,8 @@ d3.svg.js: \
src/svg/mouse.js \
src/svg/touches.js \
src/svg/symbol.js \
- src/svg/axis.js
+ src/svg/axis.js \
+ src/svg/brush.js
d3.behavior.js: \
src/behavior/behavior.js \
View
12 d3.geom.js
@@ -268,14 +268,24 @@ function d3_geom_polygonIntersect(c, d, a, b) {
// http://blog.thejit.org/assets/voronoijs/voronoi.js
// See lib/jit/LICENSE for details.
+// Notes:
+//
+// This implementation does not clip the returned polygons, so if you want to
+// clip them to a particular shape you will need to do that either in SVG or by
+// post-processing with d3.geom.polygon's clip method.
+//
+// If any vertices are coincident or have NaN positions, the behavior of this
+// method is undefined. Most likely invalid polygons will be returned. You
+// should filter invalid points, and consolidate coincident points, before
+// computing the tessellation.
+
/**
* @param vertices [[x1, y1], [x2, y2], …]
* @returns polygons [[[x1, y1], [x2, y2], …], …]
*/
d3.geom.voronoi = function(vertices) {
var polygons = vertices.map(function() { return []; });
- // Note: we expect the caller to clip the polygons, if needed.
d3_voronoi_tessellate(vertices, function(e) {
var s1,
s2,
View
633 d3.js
@@ -10,7 +10,7 @@ try {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
-d3 = {version: "2.4.6"}; // semver
+d3 = {version: "2.5.0"}; // semver
var d3_array = d3_arraySlice; // conversion for NodeLists
function d3_arrayCopy(pseudoarray) {
@@ -105,6 +105,42 @@ d3.max = function(array, f) {
}
return a;
};
+d3.extent = function(array, f) {
+ var i = -1,
+ n = array.length,
+ a,
+ b,
+ c;
+ if (arguments.length === 1) {
+ while (++i < n && ((a = c = array[i]) == null || a != a)) a = c = undefined;
+ while (++i < n) if ((b = array[i]) != null) {
+ if (a > b) a = b;
+ if (c < b) c = b;
+ }
+ } else {
+ while (++i < n && ((a = c = f.call(array, array[i], i)) == null || a != a)) a = undefined;
+ while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
+ if (a > b) a = b;
+ if (c < b) c = b;
+ }
+ }
+ return [a, c];
+};
+d3.random = {
+ normal: function(mean, deviation) {
+ if (arguments.length < 2) deviation = 1;
+ if (arguments.length < 1) mean = 0;
+ return function() {
+ var x, y, r;
+ do {
+ x = Math.random() * 2 - 1;
+ y = Math.random() * 2 - 1;
+ r = x * x + y * y;
+ } while (!r || r > 1);
+ return mean + deviation * x * Math.sqrt(-2 * Math.log(r) / r);
+ };
+ }
+};
function d3_number(x) {
return x != null && !isNaN(x);
}
@@ -438,47 +474,59 @@ d3.ns = {
}
};
-/** @param {...string} types */
-d3.dispatch = function(types) {
- var dispatch = {},
- type;
- for (var i = 0, n = arguments.length; i < n; i++) {
- type = arguments[i];
- dispatch[type] = d3_dispatch(type);
- }
+d3.dispatch = function() {
+ var dispatch = new d3_dispatch(),
+ i = -1,
+ n = arguments.length;
+ while (++i < n) dispatch[arguments[i]] = d3_dispatch_event();
return dispatch;
};
-function d3_dispatch(type) {
- var dispatch = {},
- listeners = [];
+function d3_dispatch() {}
- dispatch.add = function(listener) {
- for (var i = 0; i < listeners.length; i++) {
- if (listeners[i].listener == listener) return dispatch; // already registered
- }
- listeners.push({listener: listener, on: true});
- return dispatch;
- };
+d3_dispatch.prototype.on = function(type, listener) {
+ var i = type.indexOf("."),
+ name = "";
- dispatch.remove = function(listener) {
- for (var i = 0; i < listeners.length; i++) {
- var l = listeners[i];
- if (l.listener == listener) {
- l.on = false;
- listeners = listeners.slice(0, i).concat(listeners.slice(i + 1));
- break;
- }
+ // Extract optional namespace, e.g., "click.foo"
+ if (i > 0) {
+ name = type.substring(i + 1);
+ type = type.substring(0, i);
+ }
+
+ this[type].on(name, listener);
+};
+
+function d3_dispatch_event() {
+ var listeners = [],
+ listenerByName = {};
+
+ function dispatch() {
+ var z = listeners, // defensive reference
+ i = -1,
+ n = z.length,
+ l;
+ while (++i < n) if ((l = z[i])._on) l.apply(this, arguments);
+ }
+
+ dispatch.on = function(name, listener) {
+ var l, i;
+
+ // remove the old listener, if any
+ if (l = listenerByName[name]) {
+ l._on = false;
+ listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));
+ delete listenerByName[name];
}
- return dispatch;
- };
- dispatch.dispatch = function() {
- var ls = listeners; // defensive reference
- for (var i = 0, n = ls.length; i < n; i++) {
- var l = ls[i];
- if (l.on) l.listener.apply(this, arguments);
+ // add the new listener, if any
+ if (listener) {
+ listener._on = true;
+ listeners.push(listener);
+ listenerByName[name] = listener;
}
+
+ return dispatch;
};
return dispatch;
@@ -732,6 +780,11 @@ function d3_ease_bounce(t) {
: 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
}
d3.event = null;
+
+function d3_eventCancel() {
+ d3.event.stopPropagation();
+ d3.event.preventDefault();
+}
d3.interpolate = function(a, b) {
var i = d3.interpolators.length, f;
while (--i >= 0 && !(f = d3.interpolators[i](a, b)));
@@ -826,6 +879,10 @@ d3.interpolateString = function(a, b) {
};
};
+d3.interpolateTransform = function(a, b) {
+ return d3.interpolateString(d3.transform(a) + "", d3.transform(b) + "");
+};
+
d3.interpolateRgb = function(a, b) {
a = d3.rgb(a);
b = d3.rgb(b);
@@ -896,20 +953,19 @@ d3.interpolateObject = function(a, b) {
};
}
-var d3_interpolate_number = /[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,
- d3_interpolate_rgb = {background: 1, fill: 1, stroke: 1};
+var d3_interpolate_number = /[-+]?(?:\d*\.?\d+)(?:[eE][-+]?\d+)?/g;
function d3_interpolateByName(n) {
- return n in d3_interpolate_rgb || /\bcolor\b/.test(n)
- ? d3.interpolateRgb
+ return n == "transform"
+ ? d3.interpolateTransform
: d3.interpolate;
}
d3.interpolators = [
d3.interpolateObject,
function(a, b) { return (b instanceof Array) && d3.interpolateArray(a, b); },
- function(a, b) { return (typeof b === "string") && d3.interpolateString(String(a), b); },
- function(a, b) { return (typeof b === "string" ? b in d3_rgb_names || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Rgb || b instanceof d3_Hsl) && d3.interpolateRgb(String(a), b); },
+ function(a, b) { return (typeof b === "string") && d3.interpolateString(a + "", b); },
+ function(a, b) { return (typeof b === "string" ? b in d3_rgb_names || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Rgb || b instanceof d3_Hsl) && d3.interpolateRgb(a + "", b); },
function(a, b) { return (typeof b === "number") && d3.interpolateNumber(+a, b); }
];
function d3_uninterpolateNumber(a, b) {
@@ -1871,7 +1927,7 @@ function d3_transition(groups, id, time) {
groups.each = function(type, listener) {
if (arguments.length < 2) return d3_transition_each.call(groups, type);
- event[type].add(listener);
+ event.on(type, listener);
return groups;
};
@@ -1897,7 +1953,7 @@ function d3_transition(groups, id, time) {
}
}
- event.start.dispatch.call(node, d, i);
+ event.start.call(node, d, i);
if (!tick(elapsed)) d3.timer(tick, 0, time);
return 1;
}
@@ -1916,7 +1972,7 @@ function d3_transition(groups, id, time) {
if (t >= 1) {
stop();
d3_transitionInheritId = id;
- event.end.dispatch.call(node, d, i);
+ event.end.call(node, d, i);
d3_transitionInheritId = 0;
return 1;
}
@@ -1939,17 +1995,18 @@ function d3_transitionNull(d, i, a) {
return a != "" && d3_transitionRemove;
}
-function d3_transitionTween(b) {
+function d3_transitionTween(name, b) {
+ var interpolate = d3_interpolateByName(name);
function transitionFunction(d, i, a) {
var v = b.call(this, d, i);
return v == null
? a != "" && d3_transitionRemove
- : a != v && d3.interpolate(a, v);
+ : a != v && interpolate(a, v);
}
function transitionString(d, i, a) {
- return a != b && d3.interpolate(a, b);
+ return a != b && interpolate(a, b);
}
return typeof b === "function" ? transitionFunction
@@ -2014,7 +2071,7 @@ d3_transitionPrototype.selectAll = function(selector) {
return d3_transition(subgroups, this.id, this.time).ease(this.ease());
};
d3_transitionPrototype.attr = function(name, value) {
- return this.attrTween(name, d3_transitionTween(value));
+ return this.attrTween(name, d3_transitionTween(name, value));
};
d3_transitionPrototype.attrTween = function(nameNS, tween) {
@@ -2038,7 +2095,7 @@ d3_transitionPrototype.attrTween = function(nameNS, tween) {
};
d3_transitionPrototype.style = function(name, value, priority) {
if (arguments.length < 3) priority = "";
- return this.styleTween(name, d3_transitionTween(value), priority);
+ return this.styleTween(name, d3_transitionTween(name, value), priority);
};
d3_transitionPrototype.styleTween = function(name, tween, priority) {
@@ -2191,6 +2248,54 @@ var d3_timer_frame = window.requestAnimationFrame
|| window.oRequestAnimationFrame
|| window.msRequestAnimationFrame
|| function(callback) { setTimeout(callback, 17); };
+d3.transform = function(string) {
+ d3_transformG.setAttribute("transform", string);
+ return new d3_transform(d3_transformG.transform.baseVal.consolidate().matrix);
+};
+
+// Compute x-scale and normalize the first row.
+// Compute shear and make second row orthogonal to first.
+// Compute y-scale and normalize the second row.
+// Finally, compute the rotation.
+function d3_transform(m) {
+ var r0 = [m.a, m.b],
+ r1 = [m.c, m.d],
+ kx = d3_transformNormalize(r0),
+ kz = d3_transformDot(r0, r1),
+ ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz));
+ this.translate = [m.e, m.f];
+ this.rotate = Math.atan2(m.b, m.a) * d3_transformDegrees;
+ this.scale = [kx, ky || 0];
+ this.skew = ky ? kz / ky * d3_transformDegrees : 0;
+};
+
+d3_transform.prototype.toString = function() {
+ return "translate(" + this.translate
+ + ")rotate(" + this.rotate
+ + ")skewX(" + this.skew
+ + ")scale(" + this.scale
+ + ")";
+};
+
+function d3_transformDot(a, b) {
+ return a[0] * b[0] + a[1] * b[1];
+}
+
+function d3_transformNormalize(a) {
+ var k = Math.sqrt(d3_transformDot(a, a));
+ a[0] /= k;
+ a[1] /= k;
+ return k;
+}
+
+function d3_transformCombine(a, b, k) {
+ a[0] += k * b[0];
+ a[1] += k * b[1];
+ return a;
+}
+
+var d3_transformG = document.createElementNS(d3.ns.prefix.svg, "g"),
+ d3_transformDegrees = 180 / Math.PI;
function d3_noop() {}
d3.scale = {};
@@ -2515,6 +2620,10 @@ function d3_scale_ordinal(domain, ranger) {
return range[((index[x] || (index[x] = domain.push(x))) - 1) % range.length];
}
+ function steps(start, step) {
+ return d3.range(domain.length).map(function(i) { return start + step * i; });
+ }
+
scale.domain = function(x) {
if (!arguments.length) return domain;
domain = [];
@@ -2537,7 +2646,7 @@ function d3_scale_ordinal(domain, ranger) {
var start = x[0],
stop = x[1],
step = (stop - start) / (domain.length - 1 + padding);
- range = domain.length < 2 ? [(start + stop) / 2] : d3.range(start + step * padding / 2, stop + step / 2, step);
+ range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step);
rangeBand = 0;
ranger = {t: "rangePoints", x: x, p: padding};
return scale;
@@ -2548,7 +2657,7 @@ function d3_scale_ordinal(domain, ranger) {
var start = x[0],
stop = x[1],
step = (stop - start) / (domain.length + padding);
- range = d3.range(start + step * padding, stop, step);
+ range = steps(start + step * padding, step);
rangeBand = step * (1 - padding);
ranger = {t: "rangeBands", x: x, p: padding};
return scale;
@@ -2558,9 +2667,8 @@ function d3_scale_ordinal(domain, ranger) {
if (arguments.length < 2) padding = 0;
var start = x[0],
stop = x[1],
- step = Math.floor((stop - start) / (domain.length + padding)),
- err = stop - start - (domain.length - padding) * step;
- range = d3.range(start + Math.round(err / 2), stop, step);
+ step = Math.floor((stop - start) / (domain.length + padding));
+ range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step);
rangeBand = Math.round(step * (1 - padding));
ranger = {t: "rangeRoundBands", x: x, p: padding};
return scale;
@@ -3529,8 +3637,9 @@ function d3_svg_mousePoint(container, e) {
point = point.matrixTransform(container.getScreenCTM().inverse());
return [point.x, point.y];
};
-d3.svg.touches = function(container) {
- var touches = d3.event.touches;
+d3.svg.touches = function(container, touches) {
+ if (arguments.length < 2) touches = d3.event.touches;
+
return touches ? d3_array(touches).map(function(touch) {
var point = d3_svg_mousePoint(container, touch);
point.identifier = touch.identifier;
@@ -3820,6 +3929,341 @@ function d3_svg_axisSubdivide(scale, ticks, m) {
}
return subticks;
}
+d3.svg.brush = function() {
+ var event = d3.dispatch("brushstart", "brush", "brushend"),
+ x, // x-scale, optional
+ y, // y-scale, optional
+ extent = [[0, 0], [0, 0]]; // [x0, y0], [x1, y1]
+
+ function brush(g) {
+ var resizes = x && y ? ["n", "e", "s", "w", "nw", "ne", "se", "sw"]
+ : x ? ["e", "w"]
+ : y ? ["n", "s"]
+ : [];
+
+ g.each(function() {
+ var g = d3.select(this).on("mousedown.brush", down),
+ bg = g.selectAll(".background").data([,]),
+ fg = g.selectAll(".extent").data([,]),
+ tz = g.selectAll(".resize").data(resizes, String),
+ e;
+
+ // An invisible, mouseable area for starting a new brush.
+ bg.enter().append("svg:rect")
+ .attr("class", "background")
+ .style("visibility", "hidden")
+ .style("pointer-events", "all")
+ .style("cursor", "crosshair");
+
+ // The visible brush extent; style this as you like!
+ fg.enter().append("svg:rect")
+ .attr("class", "extent")
+ .style("cursor", "move");
+
+ // More invisible rects for resizing the extent.
+ tz.enter().append("svg:rect")
+ .attr("class", function(d) { return "resize " + d; })
+ .attr("width", 6)
+ .attr("height", 6)
+ .style("visibility", "hidden")
+ .style("pointer-events", brush.empty() ? "none" : "all")
+ .style("cursor", function(d) { return d3_svg_brushCursor[d]; });
+
+ // Remove any superfluous resizers.
+ tz.exit().remove();
+
+ // Initialize the background to fill the defined range.
+ // If the range isn't defined, you can post-process.
+ if (x) {
+ e = d3_scaleExtent(x.range());
+ bg.attr("x", e[0]).attr("width", e[1] - e[0]);
+ d3_svg_brushRedrawX(g, extent);
+ }
+ if (y) {
+ e = d3_scaleExtent(y.range());
+ bg.attr("y", e[0]).attr("height", e[1] - e[0]);
+ d3_svg_brushRedrawY(g, extent);
+ }
+ });
+ }
+
+ function down() {
+ var target = d3.select(d3.event.target);
+
+ // Store some global state for the duration of the brush gesture.
+ d3_svg_brush = brush;
+ d3_svg_brushTarget = this;
+ d3_svg_brushExtent = extent;
+ d3_svg_brushOffset = d3.svg.mouse(d3_svg_brushTarget);
+
+ // If the extent was clicked on, drag rather than brush;
+ // store the offset between the mouse and extent origin instead.
+ if (d3_svg_brushDrag = target.classed("extent")) {
+ d3_svg_brushOffset[0] = extent[0][0] - d3_svg_brushOffset[0];
+ d3_svg_brushOffset[1] = extent[0][1] - d3_svg_brushOffset[1];
+ }
+
+ // If a resizer was clicked on, record which side is to be resized.
+ // Also, set the offset to the opposite side.
+ else if (target.classed("resize")) {
+ d3_svg_brushResize = d3.event.target.__data__;
+ d3_svg_brushOffset[0] = extent[+/w$/.test(d3_svg_brushResize)][0];
+ d3_svg_brushOffset[1] = extent[+/^n/.test(d3_svg_brushResize)][1];
+ }
+
+ // If the ALT key is down when starting a brush, the center is at the mouse.
+ else if (d3.event.altKey) {
+ d3_svg_brushCenter = d3_svg_brushOffset.slice();
+ }
+
+ // Restrict which dimensions are resized.
+ d3_svg_brushX = !/^(n|s)$/.test(d3_svg_brushResize) && x;
+ d3_svg_brushY = !/^(e|w)$/.test(d3_svg_brushResize) && y;
+
+ // Notify listeners.
+ d3_svg_brushDispatch = dispatcher(this, arguments);
+ d3_svg_brushDispatch("brushstart");
+ d3_svg_brushMove();
+ d3_eventCancel();
+ }
+
+ function dispatcher(that, argumentz) {
+ return function(type) {
+ var e = d3.event;
+ try {
+ d3.event = {type: type, target: brush};
+ event[type].apply(that, argumentz);
+ } finally {
+ d3.event = e;
+ }
+ };
+ }
+
+ brush.x = function(z) {
+ if (!arguments.length) return x;
+ x = z;
+ return brush;
+ };
+
+ brush.y = function(z) {
+ if (!arguments.length) return y;
+ y = z;
+ return brush;
+ };
+
+ brush.extent = function(z) {
+ var x0, x1, y0, y1, t;
+
+ // Invert the pixel extent to data-space.
+ if (!arguments.length) {
+ if (x) {
+ x0 = x.invert(extent[0][0]), x1 = x.invert(extent[1][0]);
+ if (x1 < x0) t = x0, x0 = x1, x1 = t;
+ }
+ if (y) {
+ y0 = y.invert(extent[0][1]), y1 = y.invert(extent[1][1]);
+ if (y1 < y0) t = y0, y0 = y1, y1 = t;
+ }
+ return x && y ? [[x0, y0], [x1, y1]] : x ? [x0, x1] : y && [y0, y1];
+ }
+
+ // Scale the data-space extent to pixels.
+ if (x) {
+ x0 = z[0], x1 = z[1];
+ if (y) x0 = x0[0], x1 = x1[0];
+ x0 = x(x0), x1 = x(x1);
+ if (x1 < x0) t = x0, x0 = x1, x1 = t;
+ extent[0][0] = x0, extent[1][0] = x1;
+ }
+ if (y) {
+ y0 = z[0], y1 = z[1];
+ if (x) y0 = y0[1], y1 = y1[1];
+ y0 = y(y0), y1 = y(y1);
+ if (y1 < y0) t = y0, y0 = y1, y1 = t;
+ extent[0][1] = y0, extent[1][1] = y1;
+ }
+
+ return brush;
+ };
+
+ brush.clear = function() {
+ extent[0][0] =
+ extent[0][1] =
+ extent[1][0] =
+ extent[1][1] = 0;
+ return brush;
+ };
+
+ brush.empty = function() {
+ return (x && extent[0][0] === extent[1][0])
+ || (y && extent[0][1] === extent[1][1]);
+ };
+
+ brush.on = function(type, listener) {
+ event.on(type, listener);
+ return brush;
+ };
+
+ d3.select(window)
+ .on("mousemove.brush", d3_svg_brushMove)
+ .on("mouseup.brush", d3_svg_brushUp)
+ .on("keydown.brush", d3_svg_brushKeydown)
+ .on("keyup.brush", d3_svg_brushKeyup);
+
+ return brush;
+};
+
+var d3_svg_brush,
+ d3_svg_brushDispatch,
+ d3_svg_brushTarget,
+ d3_svg_brushX,
+ d3_svg_brushY,
+ d3_svg_brushExtent,
+ d3_svg_brushDrag,
+ d3_svg_brushResize,
+ d3_svg_brushCenter,
+ d3_svg_brushOffset;
+
+function d3_svg_brushRedrawX(g, extent) {
+ g.select(".extent").attr("x", extent[0][0]);
+ g.selectAll(".n,.s,.w,.nw,.sw").attr("x", extent[0][0] - 2);
+ g.selectAll(".e,.ne,.se").attr("x", extent[1][0] - 3);
+ g.selectAll(".extent,.n,.s").attr("width", extent[1][0] - extent[0][0]);
+}
+
+function d3_svg_brushRedrawY(g, extent) {
+ g.select(".extent").attr("y", extent[0][1]);
+ g.selectAll(".n,.e,.w,.nw,.ne").attr("y", extent[0][1] - 3);
+ g.selectAll(".s,.se,.sw").attr("y", extent[1][1] - 4);
+ g.selectAll(".extent,.e,.w").attr("height", extent[1][1] - extent[0][1]);
+}
+
+function d3_svg_brushKeydown() {
+ if (d3.event.keyCode == 32 && d3_svg_brushTarget && !d3_svg_brushDrag) {
+ d3_svg_brushCenter = null;
+ d3_svg_brushOffset[0] -= d3_svg_brushExtent[1][0];
+ d3_svg_brushOffset[1] -= d3_svg_brushExtent[1][1];
+ d3_svg_brushDrag = 2;
+ d3_eventCancel();
+ }
+}
+
+function d3_svg_brushKeyup() {
+ if (d3.event.keyCode == 32 && d3_svg_brushDrag == 2) {
+ d3_svg_brushOffset[0] += d3_svg_brushExtent[1][0];
+ d3_svg_brushOffset[1] += d3_svg_brushExtent[1][1];
+ d3_svg_brushDrag = 0;
+ d3_eventCancel();
+ }
+}
+
+function d3_svg_brushMove() {
+ if (d3_svg_brushOffset) {
+ var mouse = d3.svg.mouse(d3_svg_brushTarget),
+ g = d3.select(d3_svg_brushTarget);
+
+ if (!d3_svg_brushDrag) {
+
+ // If needed, determine the center from the current extent.
+ if (d3.event.altKey) {
+ if (!d3_svg_brushCenter) {
+ d3_svg_brushCenter = [
+ (d3_svg_brushExtent[0][0] + d3_svg_brushExtent[1][0]) / 2,
+ (d3_svg_brushExtent[0][1] + d3_svg_brushExtent[1][1]) / 2
+ ];
+ }
+
+ // Update the offset, for when the ALT key is released.
+ d3_svg_brushOffset[0] = d3_svg_brushExtent[+(mouse[0] < d3_svg_brushCenter[0])][0];
+ d3_svg_brushOffset[1] = d3_svg_brushExtent[+(mouse[1] < d3_svg_brushCenter[1])][1];
+ }
+
+ // When the ALT key is released, we clear the center.
+ else d3_svg_brushCenter = null;
+ }
+
+ // Update the brush extent for each dimension.
+ if (d3_svg_brushX) {
+ d3_svg_brushMove1(mouse, d3_svg_brushX, 0);
+ d3_svg_brushRedrawX(g, d3_svg_brushExtent);
+ }
+ if (d3_svg_brushY) {
+ d3_svg_brushMove1(mouse, d3_svg_brushY, 1);
+ d3_svg_brushRedrawY(g, d3_svg_brushExtent);
+ }
+
+ // Notify listeners.
+ d3_svg_brushDispatch("brush");
+ }
+}
+
+function d3_svg_brushMove1(mouse, scale, i) {
+ var range = d3_scaleExtent(scale.range()),
+ offset = d3_svg_brushOffset[i],
+ size = d3_svg_brushExtent[1][i] - d3_svg_brushExtent[0][i],
+ min,
+ max;
+
+ // When dragging, reduce the range by the extent size and offset.
+ if (d3_svg_brushDrag) {
+ range[0] -= offset;
+ range[1] -= size + offset;
+ }
+
+ // Clamp the mouse so that the extent fits within the range extent.
+ min = Math.max(range[0], Math.min(range[1], mouse[i]));
+
+ // Compute the new extent bounds.
+ if (d3_svg_brushDrag) {
+ max = (min += offset) + size;
+ } else {
+
+ // If the ALT key is pressed, then preserve the center of the extent.
+ if (d3_svg_brushCenter) offset = Math.max(range[0], Math.min(range[1], 2 * d3_svg_brushCenter[i] - min));
+
+ // Compute the min and max of the offset and mouse.
+ if (offset < min) {
+ max = min;
+ min = offset;
+ } else {
+ max = offset;
+ }
+ }
+
+ // Update the stored bounds.
+ d3_svg_brushExtent[0][i] = min;
+ d3_svg_brushExtent[1][i] = max;
+}
+
+function d3_svg_brushUp() {
+ if (d3_svg_brushOffset) {
+ d3_svg_brushMove();
+ d3.select(d3_svg_brushTarget).selectAll(".resize").style("pointer-events", d3_svg_brush.empty() ? "none" : "all");
+ d3_svg_brushDispatch("brushend");
+ d3_svg_brush =
+ d3_svg_brushDispatch =
+ d3_svg_brushTarget =
+ d3_svg_brushX =
+ d3_svg_brushY =
+ d3_svg_brushExtent =
+ d3_svg_brushDrag =
+ d3_svg_brushResize =
+ d3_svg_brushCenter =
+ d3_svg_brushOffset = null;
+ d3_eventCancel();
+ }
+}
+
+var d3_svg_brushCursor = {
+ n: "ns-resize",
+ e: "ew-resize",
+ s: "ns-resize",
+ w: "ew-resize",
+ nw: "nwse-resize",
+ ne: "nesw-resize",
+ se: "nwse-resize",
+ sw: "nesw-resize"
+};
d3.behavior = {};
d3.behavior.drag = function() {
var event = d3.dispatch("drag", "dragstart", "dragend");
@@ -3852,7 +4296,7 @@ d3.behavior.drag = function() {
}
drag.on = function(type, listener) {
- event[type].add(listener);
+ event.on(type, listener);
return drag;
};
@@ -3880,18 +4324,18 @@ function d3_behavior_dragDispatch(type) {
try {
d3.event = {dx: dx, dy: dy};
- d3_behavior_dragEvent[type].dispatch.apply(d3_behavior_dragTarget, d3_behavior_dragArguments);
+ d3_behavior_dragEvent[type].apply(d3_behavior_dragTarget, d3_behavior_dragArguments);
} finally {
d3.event = o;
}
o.preventDefault();
}
-function d3_behavior_dragPoint(container) {
- return d3.event.touches
- ? d3.svg.touches(container)[0]
- : d3.svg.mouse(container);
+function d3_behavior_dragPoint(container, type) {
+ // TODO Track touch points by identifier.
+ var t = d3.event.changedTouches;
+ return t ? d3.svg.touches(container, t)[0] : d3.svg.mouse(container);
}
function d3_behavior_dragMove() {
@@ -3902,7 +4346,7 @@ function d3_behavior_dragMove() {
if (!parent) return d3_behavior_dragUp();
d3_behavior_dragDispatch("drag");
- d3_behavior_dragCancel();
+ d3_eventCancel();
}
function d3_behavior_dragUp() {
@@ -3914,27 +4358,22 @@ function d3_behavior_dragUp() {
// Also prevent the subsequent click from propagating (e.g., for anchors).
if (d3_behavior_dragMoved && d3_behavior_dragEventTarget === d3.event.target) {
d3_behavior_dragStopClick = true;
- d3_behavior_dragCancel();
+ d3_eventCancel();
}
}
function d3_behavior_dragClick() {
if (d3_behavior_dragStopClick && d3_behavior_dragEventTarget === d3.event.target) {
- d3_behavior_dragCancel();
+ d3_eventCancel();
d3_behavior_dragStopClick = false;
d3_behavior_dragEventTarget = null;
}
}
-
-function d3_behavior_dragCancel() {
- d3.event.stopPropagation();
- d3.event.preventDefault();
-}
// TODO unbind zoom behavior?
-// TODO unbind listener?
d3.behavior.zoom = function() {
var xyz = [0, 0, 0],
- event = d3.dispatch("zoom");
+ event = d3.dispatch("zoom"),
+ extent = d3_behavior_zoomInfiniteExtent;
function zoom() {
this
@@ -3955,7 +4394,8 @@ d3.behavior.zoom = function() {
// snapshot the local context for subsequent dispatch
function start() {
d3_behavior_zoomXyz = xyz;
- d3_behavior_zoomDispatch = event.zoom.dispatch;
+ d3_behavior_zoomExtent = extent;
+ d3_behavior_zoomDispatch = event.zoom;
d3_behavior_zoomEventTarget = d3.event.target;
d3_behavior_zoomTarget = this;
d3_behavior_zoomArguments = arguments;
@@ -3994,8 +4434,14 @@ d3.behavior.zoom = function() {
d3_behavior_zoomLast = now;
}
+ zoom.extent = function(x) {
+ if (!arguments.length) return extent;
+ extent = x == null ? d3_behavior_zoomInfiniteExtent : x;
+ return zoom;
+ };
+
zoom.on = function(type, listener) {
- event[type].add(listener);
+ event.on(type, listener);
return zoom;
};
@@ -4008,6 +4454,7 @@ var d3_behavior_zoomDiv,
d3_behavior_zoomLocations = {}, // identifier -> location
d3_behavior_zoomLast = 0,
d3_behavior_zoomXyz,
+ d3_behavior_zoomExtent,
d3_behavior_zoomDispatch,
d3_behavior_zoomEventTarget,
d3_behavior_zoomTarget,
@@ -4118,25 +4565,27 @@ function d3_behavior_zoomClick() {
}
function d3_behavior_zoomTo(z, x0, x1) {
- var K = Math.pow(2, (d3_behavior_zoomXyz[2] = z) - x1[2]),
- x = d3_behavior_zoomXyz[0] = x0[0] - K * x1[0],
- y = d3_behavior_zoomXyz[1] = x0[1] - K * x1[1],
- o = d3.event, // Events can be reentrant (e.g., focus).
- k = Math.pow(2, z);
+ z = d3_behavior_zoomExtentClamp(z, 2);
+ var j = Math.pow(2, d3_behavior_zoomXyz[2]),
+ k = Math.pow(2, z),
+ K = Math.pow(2, (d3_behavior_zoomXyz[2] = z) - x1[2]),
+ x_ = d3_behavior_zoomXyz[0],
+ y_ = d3_behavior_zoomXyz[1],
+ x = d3_behavior_zoomXyz[0] = d3_behavior_zoomExtentClamp((x0[0] - x1[0] * K), 0, k),
+ y = d3_behavior_zoomXyz[1] = d3_behavior_zoomExtentClamp((x0[1] - x1[1] * K), 1, k),
+ o = d3.event; // Events can be reentrant (e.g., focus).
d3.event = {
scale: k,
translate: [x, y],
transform: function(sx, sy) {
- if (sx) transform(sx, x);
- if (sy) transform(sy, y);
+ if (sx) transform(sx, x_, x);
+ if (sy) transform(sy, y_, y);
}
};
- function transform(scale, o) {
- var domain = scale.__domain || (scale.__domain = scale.domain()),
- range = scale.range().map(function(v) { return (v - o) / k; });
- scale.domain(domain).domain(range.map(scale.invert));
+ function transform(scale, a, b) {
+ scale.domain(scale.range().map(function(v) { return scale.invert(((v - b) * j) / k + a); }));
}
try {
@@ -4147,4 +4596,20 @@ function d3_behavior_zoomTo(z, x0, x1) {
o.preventDefault();
}
+
+var d3_behavior_zoomInfiniteExtent = [
+ [-Infinity, Infinity],
+ [-Infinity, Infinity],
+ [-Infinity, Infinity]
+];
+
+function d3_behavior_zoomExtentClamp(x, i, k) {
+ var range = d3_behavior_zoomExtent[i],
+ r0 = range[0],
+ r1 = range[1];
+ return arguments.length === 3
+ ? Math.max(r1 * (r1 === Infinity ? -Infinity : 1 / k - 1),
+ Math.min(r0 === -Infinity ? Infinity : r0, x / k)) * k
+ : Math.max(r0, Math.min(r1, x));
+}
})();
View
39 d3.layout.js
@@ -113,16 +113,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[di][j],
- v = matrix[di][dj];
+ 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
};
}
@@ -315,14 +318,14 @@ 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);
+ event.on(type, listener);
return force;
};
@@ -602,33 +605,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) {
@@ -695,6 +696,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,
View
2 d3.layout.min.js
@@ -1 +1 @@
-(function(){function a(a){var b=a.source,d=a.target,e=c(b,d),f=[b];while(b!==e)b=b.parent,f.push(b);var g=f.length;while(d!==e)f.splice(g,0,d),d=d.parent;return f}function b(a){var b=[],c=a.parent;while(c!=null)b.push(a),a=c,c=c.parent;return b.push(a),b}function c(a,c){if(a===c)return a;var d=b(a),e=b(c),f=d.pop(),g=e.pop(),h=null;while(f===g)h=f,f=d.pop(),g=e.pop();return h}function g(a){a.fixed|=2}function h(a){a!==f&&(a.fixed&=1)}function i(){j(),f.fixed&=1,e=f=null}function j(){f.px+=d3.event.dx,f.py+=d3.event.dy,e.resume()}function k(a,b,c){var d=0,e=0;a.charge=0;if(!a.leaf){var f=a.nodes,g=f.length,h=-1,i;while(++h<g){i=f[h];if(i==null)continue;k(i,b,c),a.charge+=i.charge,d+=i.charge*i.cx,e+=i.charge*i.cy}}if(a.point){a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5);var j=b*c[a.point.index];a.charge+=a.pointCharge=j,d+=j*a.point.x,e+=j*a.point.y}a.cx=d/a.charge,a.cy=e/a.charge}function l(a){return 20}function m(a){return 1}function n(a){return a.x}function o(a){return a.y}function p(a,b,c){a.y0=b,a.y=c}function s(a){var b=1,c=0,d=a[0][1],e,f=a.length;for(;b<f;++b)(e=a[b][1])>d&&(c=b,d=e);return c}function t(a){return a.reduce(u,0)}function u(a,b){return a+b[1]}function v(a,b){return w(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function w(a,b){var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];while(++c<=b)f[c]=e*c+d;return f}function x(a){return[d3.min(a),d3.max(a)]}function y(a,b){return a.sort=d3.rebind(a,b.sort),a.children=d3.rebind(a,b.children),a.links=C,a.value=d3.rebind(a,b.value),a.nodes=function(b){return D=!0,(a.nodes=a)(b)},a}function z(a){return a.children}function A(a){return a.value}function B(a,b){return b.value-a.value}function C(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function E(a,b){return a.value-b.value}function F(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function G(a,b){a._pack_next=b,b._pack_prev=a}function H(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function I(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(J),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],N(g,h,i),l(i),F(g,i),g._pack_prev=i,F(i,h),h=g._pack_next;for(var m=3;m<f;m++){N(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!==h;j=j._pack_next,o++)if(H(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!==j._pack_prev;k=k._pack_prev,p++)if(H(k,i)){p<o&&(n=-1,j=k);break}n==0?(F(g,i),h=i,l(i)):n>0?(G(g,j),h=j,m--):(G(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}return a.forEach(K),s}function J(a){a._pack_next=a._pack_prev=a}function K(a){delete a._pack_next,delete a._pack_prev}function L(a){var b=a.children;b&&b.length?(b.forEach(L),a.r=I(b)):a.r=Math.sqrt(a.value)}function M(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)M(e[f],b,c,d)}}function N(a,b,c){var d=a.r+c.r,e=b.x-a.x,f=b.y-a.y;if(d&&(e||f)){var g=b.r+c.r,h=Math.sqrt(e*e+f*f),i=Math.max(-1,Math.min(1,(d*d+h*h-g*g)/(2*d*h))),j=Math.acos(i),k=i*(d/=h),l=Math.sin(j)*d;c.x=a.x+k*e+l*f,c.y=a.y+k*f-l*e}else c.x=a.x+d,c.y=a.y}function O(a){return 1+d3.max(a,function(a){return a.y})}function P(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function Q(a){var b=a.children;return b&&b.length?Q(b[0]):a}function R(a){var b=a.children,c;return b&&(c=b.length)?R(b[c-1]):a}function S(a,b){return a.parent==b.parent?1:2}function T(a){var b=a.children;return b&&b.length?b[0]:a._tree.thread}function U(a){var b=a.children,c;return b&&(c=b.length)?b[c-1]:a._tree.thread}function V(a,b){var c=a.children;if(c&&(e=c.length)){var d,e,f=-1;while(++f<e)b(d=V(c[f],b),a)>0&&(a=d)}return a}function W(a,b){return a.x-b.x}function X(a,b){return b.x-a.x}function Y(a,b){return a.depth-b.depth}function Z(a,b){function c(a,d){var e=a.children;if(e&&(i=e.length)){var f,g=null,h=-1,i;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function $(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function _(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function ba(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function bb(a){return{x:a.x,y:a.y,dx:a.dx,dy:a.dy}}function bc(a,b){var c=a.x+b[3],d=a.y+b[0],e=a.dx-b[1]-b[3],f=a.dy-b[0]-b[2];return e<0&&(c+=e/2,e=0),f<0&&(d+=f/2,f=0),{x:c,y:d,dx:e,dy:f}}d3.layout={},d3.layout.bundle=function(){return function(b){var c=[],d=-1,e=b.length;while(++d<e)c.push(a(b[d]));return c}},d3.layout.chord=function(){function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[s][r],u=d[s][t];a[s+"-"+t]={index:s,subindex:t,startAngle:o,endAngle:o+=u*n,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var v=a[q+"-"+r],w=a[r+"-"+q];(v.value||w.value)&&b.push(v.value<w.value?{source:w,target:v}:{source:v,target:w})}}i&&k()}function k(){b.sort(function(a,b){return i((a.source.value+a.target.value)/2,(b.source.value+b.target.value)/2)})}var a={},b,c,d,e,f=0,g,h,i;return a.matrix=function(f){return arguments.length?(e=(d=f)&&d.length,b=c=null,a):d},a.padding=function(d){return arguments.length?(f=d,b=c=null,a):f},a.sortGroups=function(d){return arguments.length?(g=d,b=c=null,a):g},a.sortSubgroups=function(c){return arguments.length?(h=c,b=null,a):h},a.sortChords=function(c){return arguments.length?(i=c,b&&k(),a):i},a.chords=function(){return b||j(),b},a.groups=function(){return c||j(),c},a},d3.layout.force=function(){function A(a){return function(b,c,d,e,f){if(b.point!==a){var g=b.cx-a.x,h=b.cy-a.y,i=1/Math.sqrt(g*g+h*h);if((e-c)*i<t){var j=b.charge*i*i;return a.px-=g*j,a.py-=h*j,!0}if(b.point&&isFinite(i)){var j=b.pointCharge*i*i;a.px-=g*j,a.py-=h*j}}return!b.charge}}function B(){var a=v.length,d=w.length,e,f,g,h,i,j,l,m,p;for(f=0;f<d;++f){g=w[f],h=g.source,i=g.target,m=i.x-h.x,p=i.y-h.y;if(j=m*m+p*p)j=n*y[f]*((j=Math.sqrt(j))-x[f])/j,m*=j,p*=j,i.x-=m*(l=h.weight/(i.weight+h.weight)),i.y-=p*l,h.x+=m*(l=1-l),h.y+=p*l}if(l=n*s){m=c[0]/2,p=c[1]/2,f=-1;if(l)while(++f<a)g=v[f],g.x+=(m-g.x)*l,g.y+=(p-g.y)*l}if(r){k(e=d3.geom.quadtree(v),n,z),f=-1;while(++f<a)(g=v[f]).fixed||e.visit(A(g))}f=-1;while(++f<a)g=v[f],g.fixed?(g.x=g.px,g.y=g.py):(g.x-=(g.px-(g.px=g.x))*o,g.y-=(g.py-(g.py=g.y))*o);return b.tick.dispatch({type:"tick",alpha:n}),(n*=.99)<.005}function C(b){g(f=b),e=a}var a={},b=d3.dispatch("tick"),c=[1,1],d,n,o=.9,p=l,q=m,r=-30,s=.1,t=.8,u,v=[],w=[],x,y,z;return a.on=function(c,d){return b[c].add(d),a},a.nodes=function(b){return arguments.length?(v=b,a):v},a.links=function(b){return arguments.length?(w=b,a):w},a.size=function(b){return arguments.length?(c=b,a):c},a.linkDistance=function(b){return arguments.length?(p=d3.functor(b),a):p},a.distance=a.linkDistance,a.linkStrength=function(b){return arguments.length?(q=d3.functor(b),a):q},a.friction=function(b){return arguments.length?(o=b,a):o},a.charge=function(b){return arguments.length?(r=typeof b=="function"?b:+b,a):r},a.gravity=function(b){return arguments.length?(s=b,a):s},a.theta=function(b){return arguments.length?(t=b,a):t},a.start=function(){function k(a,c){var d=l(b),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][a]))return g;return Math.random()*c}function l(){if(!i){i=[];for(d=0;d<e;++d)i[d]=[];for(d=0;d<f;++d){var a=w[d];i[a.source.index].push(a.target),i[a.target.index].push(a.source)}}return i[b]}var b,d,e=v.length,f=w.length,g=c[0],h=c[1],i,j;for(b=0;b<e;++b)(j=v[b]).index=b,j.weight=0;x=[],y=[];for(b=0;b<f;++b)j=w[b],typeof j.source=="number"&&(j.source=v[j.source]),typeof j.target=="number"&&(j.target=v[j.target]),x[b]=p.call(this,j,b),y[b]=q.call(this,j,b),++j.source.weight,++j.target.weight;for(b=0;b<e;++b)j=v[b],isNaN(j.x)&&(j.x=k("x",g)),isNaN(j.y)&&(j.y=k("y",h)),isNaN(j.px)&&(j.px=j.x),isNaN(j.py)&&(j.py=j.y);z=[];if(typeof r=="function")for(b=0;b<e;++b)z[b]=+r.call(this,v[b],b);else for(b=0;b<e;++b)z[b]=r;return a.resume()},a.resume=function(){return n=.1,d3.timer(B),a},a.stop=function(){return n=0,a},a.drag=function(){d||(d=d3.behavior.drag().on("dragstart",C).on("drag",j).on("dragend",i)),this.on("mouseover.force",g).on("mouseout.force",h).call(d)},a};var e,f;d3.layout.partition=function(){function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f&&(h=f.length)){var g=-1,h,i,j;d=a.value?d/a.value:0;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}function d(a){var b=a.children,c=0;if(b&&(f=b.length)){var e=-1,f;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function e(e,f){var g=a.call(this,e,f);return c(g[0],0,b[0],b[1]/d(g[0])),g}var a=d3.layout.hierarchy(),b=[1,1];return e.size=function(a){return arguments.length?(b=a,e):b},y(e,a)},d3.layout.pie=function(){function f(f,g){var h=+(typeof c=="function"?c.apply(this,arguments):c),i=(typeof e=="function"?e.apply(this,arguments):e)-c,j=d3.range(f.length);b!=null&&j.sort(function(a,c){return b(f[a],f[c])});var k=f.map(a);i/=k.reduce(function(a,b){return a+b},0);var l=j.map(function(a){return{data:f[a],value:d=k[a],startAngle:h,endAngle:h+=d*i}});return f.map(function(a,b){return l[j[b]]})}var a=Number,b=null,c=0,e=2*Math.PI;return f.value=function(b){return arguments.length?(a=b,f):a},f.sort=function(a){return arguments.length?(b=a,f):b},f.startAngle=function(a){return arguments.length?(c=a,f):c},f.endAngle=function(a){return arguments.length?(e=a,f):e},f},d3.layout.stack=function(){function g(h,i){var j=h.map(function(b,c){return a.call(g,b,c)}),k=j.map(function(a,b){return a.map(function(a,b){return[e.call(g,a,b),f.call(g,a,b)]})}),l=b.call(g,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m=c.call(g,k,i),n=j.length,o=j[0].length,p,q,r;for(q=0;q<o;++q){d.call(g,j[0][q],r=m[q],k[0][q][1]);for(p=1;p<n;++p)d.call(g,j[p][q],r+=k[p-1][q][1],k[p][q][1])}return h}var a=Object,b=q["default"],c=r.zero,d=p,e=n,f=o;return g.values=function(b){return arguments.length?(a=b,g):a},g.order=function(a){return arguments.length?(b=typeof a=="function"?a:q[a],g):b},g.offset=function(a){return arguments.length?(c=typeof a=="function"?a:r[a],g):c},g.x=function(a){return arguments.length?(e=a,g):e},g.y=function(a){return arguments.length?(f=a,g):f},g.out=function(a){return arguments.length?(d=a,g):d},g};var q={"inside-out":function(a){var b=a.length,c,d,e=a.map(s),f=a.map(t),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;++c)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},r={silhouette:function(a){var b=a.length,c=a[0].length,d=[],e=0,f,g,h,i=[];for(g=0;g<c;++g){for(f=0,h=0;f<b;f++)h+=a[f][g][1];h>e&&(e=h),d.push(h)}for(g=0;g<c;++g)i[g]=(e-d[g])/2;return i},wiggle:function(a){var b=a.length,c=a[0],d=c.length,e=0,f,g,h,i,j,k,l,m,n,o=[];o[0]=m=n=0;for(g=1;g<d;++g){for(f=0,i=0;f<b;++f)i+=a[f][g][1];for(f=0,j=0,l=c[g][0]-c[g-1][0];f<b;++f){for(h=0,k=(a[f][g][1]-a[f][g-1][1])/(2*l);h<f;++h)k+=(a[h][g][1]-a[h][g-1][1])/l;j+=k*a[f][g][1]}o[g]=m-=i?j/i*l:0,m<n&&(n=m)}for(g=0;g<d;++g)o[g]-=n;return o},expand:function(a){var b=a.length,c=a[0].length,d=1/b,e,f,g,h=[];for(f=0;f<c;++f){for(e=0,g=0;e<b;e++)g+=a[e][f][1];if(g)for(e=0;e<b;e++)a[e][f][1]/=g;else for(e=0;e<b;e++)a[e][f][1]=d}for(f=0;f<c;++f)h[f]=0;return h},zero:function(a){var b=-1,c=a[0].length,d=[];while(++b<c)d[b]=0;return d}};d3.layout.histogram=function(){function e(e,f){var g=[],h=e.map(b,this),i=c.call(this,h,f),j=d.call(this,i,h,f),k,f=-1,l=h.length,m=j.length-1,n=a?1:1/l,o;while(++f<m)k=g[f]=[],k.dx=j[f+1]-(k.x=j[f]),k.y=0;f=-1;while(++f<l)o=h[f],o>=i[0]&&o<=i[1]&&(k=g[d3.bisect(j,o,1,m)-1],k.y+=n,k.push(e[f]));return g}var a=!0,b=Number,c=x,d=v;return e.value=function(a){return arguments.length?(b=a,e):b},e.range=function(a){return arguments.length?(c=d3.functor(a),e):c},e.bins=function(a){return arguments.length?(d=typeof a=="number"?function(b){return w(b,a)}:d3.functor(a),e):d},e.frequency=function(b){return arguments.length?(a=!!b,e):a},e},d3.layout.hierarchy=function(){function e(f,h,i){var j=b.call(g,f,h),k=D?f:{data:f};k.depth=h,i.push(k);if(j&&(m=j.length)){var l=-1,m,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=+c.call(g,f,h)||0);return k}function f(a,b){var d=a.children,e=0;if(d&&(i=d.length)){var h=-1,i,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=+c.call(g,D?a:a.data,b)||0);return c&&(a.value=e),e}function g(a){var b=[];return e(a,0,b),b}var a=B,b=z,c=A;return g.sort=function(b){return arguments.length?(a=b,g):a},g.children=function(a){return arguments.length?(b=a,g):b},g.value=function(a){return arguments.length?(c=a,g):c},g.revalue=function(a){return f(a,0),a},g};var D=!1;d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,L(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);return M(f,g/2,h/2,i),e}var a=d3.layout.hierarchy().sort(E),b=[1,1];return c.size=function(a){return arguments.length?(b=a,c):b},y(c,a)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;Z(g,function(a){var c=a.children;c&&c.length?(a.x=P(c),a.y=O(c)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=Q(g),m=R(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;return Z(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-a.y/g.y)*c[1]}),f}var a=d3.layout.hierarchy().sort(null).value(null),b=S,c=[1,1];return d.separation=function(a){return arguments.length?(b=a,d):b},d.size=function(a){return arguments.length?(c=a,d):c},y(d,a)},d3.layout.tree=function(){function d(d,e){function h(a,c){var d=a.children,e=a._tree;if(d&&(f=d.length)){var f,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;$(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c&&(e=c.length)){var d=-1,e;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=U(g),e=T(e),g&&e)h=T(h),f=U(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(_(ba(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!U(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!T(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}var f=a.call(this,d,e),g=f[0];Z(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=V(g,X),l=V(g,W),m=V(g,Y),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth||1;return Z(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree}),f}var a=d3.layout.hierarchy().sort(null).value(null),b=S,c=[1,1];return d.separation=function(a){return arguments.length?(b=a,d):b},d.size=function(a){return arguments.length?(c=a,d):c},y(d,a)},d3.layout.treemap=function(){function i(a,b){var c=-1,d=a.length,e,f;while(++c<d)f=(e=a[c]).value*(b<0?0:b),e.area=isNaN(f)||f<=0?0:f}function j(a){var b=a.children;if(b&&b.length){var c=e(a),d=[],f=b.slice(),g,h=Infinity,k,n=Math.min(c.dx,c.dy),o;i(f,c.dx*c.dy/a.value),d.area=0;while((o=f.length)>0)d.push(g=f[o-1]),d.area+=g.area,(k=l(d,n))<=h?(f.pop(),h=k):(d.area-=d.pop().area,m(d,n,c,!1),n=Math.min(c.dx,c.dy),d.length=d.area=0,h=Infinity);d.length&&(m(d,n,c,!0),d.length=d.area=0),b.forEach(j)}}function k(a){var b=a.children;if(b&&b.length){var c=e(a),d=b.slice(),f,g=[];i(d,c.dx*c.dy/a.value),g.area=0;while(f=d.pop())g.push(f),g.area+=f.area,f.z!=null&&(m(g,f.z?c.dx:c.dy,c,!d.length),g.length=g.area=0);b.forEach(k)}}function l(a,b){var c=a.area,d,e=0,f=Infinity,g=-1,i=a.length;while(++g<i){if(!(d=a[g].area))continue;d<f&&(f=d),d>e&&(e=d)}return c*=c,b*=b,c?Math.max(b*e*h/c,c/(b*f*h)):Infinity}function m(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=j?d.dy:0;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=j?b(k.area/j):0;k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=j?d.dx:0;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=j?b(k.area/j):0;k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function n(b){var d=g||a(b),e=d[0];return e.x=0,e.y=0,e.dx=c[0],e.dy=c[1],g&&a.revalue(e),i([e],e.dx*e.dy/e.value),(g?k:j)(e),f&&(g=d),d}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=null,e=bb,f=!1,g,h=.5*(1+Math.sqrt(5));return n.size=function(a){return arguments.length?(c=a,n):c},n.padding=function(a){function b(b){var c=a.call(n,b,b.depth);return c==null?bb(b):bc(b,typeof c=="number"?[c,c,c,c]:c)}function c(b){return bc(b,a)}if(!arguments.length)return d;var f;return e=(d=a)==null?bb:(f=typeof a)==="function"?b:f==="number"?(a=[a,a,a,a],c):c,n},n.round=function(a){return arguments.length?(b=a?Math.round:Number,n):b!=Number},n.sticky=function(a){return arguments.length?(f=a,g=null,n):f},n.ratio=function(a){return arguments.length?(h=a,n):h},y(n,a)}})();
+(function(){function a(a){var b=a.source,d=a.target,e=c(b,d),f=[b];while(b!==e)b=b.parent,f.push(b);var g=f.length;while(d!==e)f.splice(g,0,d),d=d.parent;return f}function b(a){var b=[],c=a.parent;while(c!=null)b.push(a),a=c,c=c.parent;return b.push(a),b}function c(a,c){if(a===c)return a;var d=b(a),e=b(c),f=d.pop(),g=e.pop(),h=null;while(f===g)h=f,f=d.pop(),g=e.pop();return h}function g(a){a.fixed|=2}function h(a){a!==f&&(a.fixed&=1)}function i(){j(),f.fixed&=1,e=f=null}function j(){f.px+=d3.event.dx,f.py+=d3.event.dy,e.resume()}function k(a,b,c){var d=0,e=0;a.charge=0;if(!a.leaf){var f=a.nodes,g=f.length,h=-1,i;while(++h<g){i=f[h];if(i==null)continue;k(i,b,c),a.charge+=i.charge,d+=i.charge*i.cx,e+=i.charge*i.cy}}if(a.point){a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5);var j=b*c[a.point.index];a.charge+=a.pointCharge=j,d+=j*a.point.x,e+=j*a.point.y}a.cx=d/a.charge,a.cy=e/a.charge}function l(a){return 20}function m(a){return 1}function o(a){return a.x}function p(a){return a.y}function q(a,b,c){a.y0=b,a.y=c}function t(a){var b=1,c=0,d=a[0][1],e,f=a.length;for(;b<f;++b)(e=a[b][1])>d&&(c=b,d=e);return c}function u(a){return a.reduce(v,0)}function v(a,b){return a+b[1]}function w(a,b){return x(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function x(a,b){var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];while(++c<=b)f[c]=e*c+d;return f}function y(a){return[d3.min(a),d3.max(a)]}function z(a,b){return a.sort=d3.rebind(a,b.sort),a.children=d3.rebind(a,b.children),a.links=D,a.value=d3.rebind(a,b.value),a.nodes=function(b){return E=!0,(a.nodes=a)(b)},a}function A(a){return a.children}function B(a){return a.value}function C(a,b){return b.value-a.value}function D(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function F(a,b){return a.value-b.value}function G(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function H(a,b){a._pack_next=b,b._pack_prev=a}function I(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function J(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(K),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],O(g,h,i),l(i),G(g,i),g._pack_prev=i,G(i,h),h=g._pack_next;for(var m=3;m<f;m++){O(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!==h;j=j._pack_next,o++)if(I(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!==j._pack_prev;k=k._pack_prev,p++)if(I(k,i)){p<o&&(n=-1,j=k);break}n==0?(G(g,i),h=i,l(i)):n>0?(H(g,j),h=j,m--):(H(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}return a.forEach(L),s}function K(a){a._pack_next=a._pack_prev=a}function L(a){delete a._pack_next,delete a._pack_prev}function M(a){var b=a.children;b&&b.length?(b.forEach(M),a.r=J(b)):a.r=Math.sqrt(a.value)}function N(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)N(e[f],b,c,d)}}function O(a,b,c){var d=a.r+c.r,e=b.x-a.x,f=b.y-a.y;if(d&&(e||f)){var g=b.r+c.r,h=Math.sqrt(e*e+f*f),i=Math.max(-1,Math.min(1,(d*d+h*h-g*g)/(2*d*h))),j=Math.acos(i),k=i*(d/=h),l=Math.sin(j)*d;c.x=a.x+k*e+l*f,c.y=a.y+k*f-l*e}else c.x=a.x+d,c.y=a.y}function P(a){return 1+d3.max(a,function(a){return a.y})}function Q(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function R(a){var b=a.children;return b&&b.length?R(b[0]):a}function S(a){var b=a.children,c;return b&&(c=b.length)?S(b[c-1]):a}function T(a,b){return a.parent==b.parent?1:2}function U(a){var b=a.children;return b&&b.length?b[0]:a._tree.thread}function V(a){var b=a.children,c;return b&&(c=b.length)?b[c-1]:a._tree.thread}function W(a,b){var c=a.children;if(c&&(e=c.length)){var d,e,f=-1;while(++f<e)b(d=W(c[f],b),a)>0&&(a=d)}return a}function X(a,b){return a.x-b.x}function Y(a,b){return b.x-a.x}function Z(a,b){return a.depth-b.depth}function $(a,b){function c(a,d){var e=a.children;if(e&&(i=e.length)){var f,g=null,h=-1,i;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function _(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function ba(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function bb(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function bc(a){return{x:a.x,y:a.y,dx:a.dx,dy:a.dy}}function bd(a,b){var c=a.x+b[3],d=a.y+b[0],e=a.dx-b[1]-b[3],f=a.dy-b[0]-b[2];return e<0&&(c+=e/2,e=0),f<0&&(d+=f/2,f=0),{x:c,y:d,dx:e,dy:f}}d3.layout={},d3.layout.bundle=function(){return function(b){var c=[],d=-1,e=b.length;while(++d<e)c.push(a(b[d]));return c}},d3.layout.chord=function(){function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[s][r],u=d[s][t],v=o,w=o+=u*n;a[s+"-"+t]={index:s,subindex:t,startAngle:v,endAngle:w,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var x=a[q+"-"+r],y=a[r+"-"+q];(x.value||y.value)&&b.push(x.value<y.value?{source:y,target:x}:{source:x,target:y})}}i&&k()}function k(){b.sort(function(a,b){return i((a.source.value+a.target.value)/2,(b.source.value+b.target.value)/2)})}var a={},b,c,d,e,f=0,g,h,i;return a.matrix=function(f){return arguments.length?(e=(d=f)&&d.length,b=c=null,a):d},a.padding=function(d){return arguments.length?(f=d,b=c=null,a):f},a.sortGroups=function(d){return arguments.length?(g=d,b=c=null,a):g},a.sortSubgroups=function(c){return arguments.length?(h=c,b=null,a):h},a.sortChords=function(c){return arguments.length?(i=c,b&&k(),a):i},a.chords=function(){return b||j(),b},a.groups=function(){return c||j(),c},a},d3.layout.force=function(){function A(a){return function(b,c,d,e,f){if(b.point!==a){var g=b.cx-a.x,h=b.cy-a.y,i=1/Math.sqrt(g*g+h*h);if((e-c)*i<t){var j=b.charge*i*i;return a.px-=g*j,a.py-=h*j,!0}if(b.point&&isFinite(i)){var j=b.pointCharge*i*i;a.px-=g*j,a.py-=h*j}}return!b.charge}}function B(){var a=v.length,d=w.length,e,f,g,h,i,j,l,m,p;for(f=0;f<d;++f){g=w[f],h=g.source,i=g.target,m=i.x-h.x,p=i.y-h.y;if(j=m*m+p*p)j=n*y[f]*((j=Math.sqrt(j))-x[f])/j,m*=j,p*=j,i.x-=m*(l=h.weight/(i.weight+h.weight)),i.y-=p*l,h.x+=m*(l=1-l),h.y+=p*l}if(l=n*s){m=c[0]/2,p=c[1]/2,f=-1;if(l)while(++f<a)g=v[f],g.x+=(m-g.x)*l,g.y+=(p-g.y)*l}if(r){k(e=d3.geom.quadtree(v),n,z),f=-1;while(++f<a)(g=v[f]).fixed||e.visit(A(g))}f=-1;while(++f<a)g=v[f],g.fixed?(g.x=g.px,g.y=g.py):(g.x-=(g.px-(g.px=g.x))*o,g.y-=(g.py-(g.py=g.y))*o);return b.tick({type:"tick",alpha:n}),(n*=.99)<.005}function C(b){g(f=b),e=a}var a={},b=d3.dispatch("tick"),c=[1,1],d,n,o=.9,p=l,q=m,r=-30,s=.1,t=.8,u,v=[],w=[],x,y,z;return a.on=function(c,d){return b.on(c,d),a},a.nodes=function(b){return arguments.length?(v=b,a):v},a.links=function(b){return arguments.length?(w=b,a):w},a.size=function(b){return arguments.length?(c=b,a):c},a.linkDistance=function(b){return arguments.length?(p=d3.functor(b),a):p},a.distance=a.linkDistance,a.linkStrength=function(b){return arguments.length?(q=d3.functor(b),a):q},a.friction=function(b){return arguments.length?(o=b,a):o},a.charge=function(b){return arguments.length?(r=typeof b=="function"?b:+b,a):r},a.gravity=function(b){return arguments.length?(s=b,a):s},a.theta=function(b){return arguments.length?(t=b,a):t},a.start=function(){function k(a,c){var d=l(b),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][a]))return g;return Math.random()*c}function l(){if(!i){i=[];for(d=0;d<e;++d)i[d]=[];for(d=0;d<f;++d){var a=w[d];i[a.source.index].push(a.target),i[a.target.index].push(a.source)}}return i[b]}var b,d,e=v.length,f=w.length,g=c[0],h=c[1],i,j;for(b=0;b<e;++b)(j=v[b]).index=b,j.weight=0;x=[],y=[];for(b=0;b<f;++b)j=w[b],typeof j.source=="number"&&(j.source=v[j.source]),typeof j.target=="number"&&(j.target=v[j.target]),x[b]=p.call(this,j,b),y[b]=q.call(this,j,b),++j.source.weight,++j.target.weight;for(b=0;b<e;++b)j=v[b],isNaN(j.x)&&(j.x=k("x",g)),isNaN(j.y)&&(j.y=k("y",h)),isNaN(j.px)&&(j.px=j.x),isNaN(j.py)&&(j.py=j.y);z=[];if(typeof r=="function")for(b=0;b<e;++b)z[b]=+r.call(this,v[b],b);else for(b=0;b<e;++b)z[b]=r;return a.resume()},a.resume=function(){return n=.1,d3.timer(B),a},a.stop=function(){return n=0,a},a.drag=function(){d||(d=d3.behavior.drag().on("dragstart",C).on("drag",j).on("dragend",i)),this.on("mouseover.force",g).on("mouseout.force",h).call(d)},a};var e,f;d3.layout.partition=function(){function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f&&(h=f.length)){var g=-1,h,i,j;d=a.value?d/a.value:0;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}function d(a){var b=a.children,c=0;if(b&&(f=b.length)){var e=-1,f;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function e(e,f){var g=a.call(this,e,f);return c(g[0],0,b[0],b[1]/d(g[0])),g}var a=d3.layout.hierarchy(),b=[1,1];return e.size=function(a){return arguments.length?(b=a,e):b},z(e,a)},d3.layout.pie=function(){function f(g,h){var i=g.map(function(b,c){return+a.call(f,b,c)}),j=+(typeof c=="function"?c.apply(this,arguments):c),k=((typeof e=="function"?e.apply(this,arguments):e)-c)/d3.sum(i),l=d3.range(g.length);b!=null&&l.sort(b===n?function(a,b){return i[b]-i[a]}:function(a,c){return b(g[a],g[c])});var m=l.map(function(a){return{data:g[a],value:d=i[a],startAngle:j,endAngle:j+=d*k}});return g.map(function(a,b){return m[l[b]]})}var a=Number,b=n,c=0,e=2*Math.PI;return f.value=function(b){return arguments.length?(a=b,f):a},f.sort=function(a){return arguments.length?(b=a,f):b},f.startAngle=function(a){return arguments.length?(c=a,f):c},f.endAngle=function(a){return arguments.length?(e=a,f):e},f};var n={};d3.layout.stack=function(){function g(h,i){var j=h.map(function(b,c){return a.call(g,b,c)}),k=j.map(function(a,b){return a.map(function(a,b){return[e.call(g,a,b),f.call(g,a,b)]})}),l=b.call(g,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m=c.call(g,k,i),n=j.length,o=j[0].length,p,q,r;for(q=0;q<o;++q){d.call(g,j[0][q],r=m[q],k[0][q][1]);for(p=1;p<n;++p)d.call(g,j[p][q],r+=k[p-1][q][1],k[p][q][1])}return h}var a=Object,b=r["default"],c=s.zero,d=q,e=o,f=p;return g.values=function(b){return arguments.length?(a=b,g):a},g.order=function(a){return arguments.length?(b=typeof a=="function"?a:r[a],g):b},g.offset=function(a){return arguments.length?(c=typeof a=="function"?a:s[a],g):c},g.x=function(a){return arguments.length?(e=a,g):e},g.y=function(a){return arguments.length?(f=a,g):f},g.out=function(a){return arguments.length?(d=a,g):d},g};var r={"inside-out":function(a){var b=a.length,c,d,e=a.map(t),f=a.map(u),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;++c)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},s={silhouette:function(a){var b=a.length,c=a[0].length,d=[],e=0,f,g,h,i=[];for(g=0;g<c;++g){for(f=0,h=0;f<b;f++)h+=a[f][g][1];h>e&&(e=h),d.push(h)}for(g=0;g<c;++g)i[g]=(e-d[g])/2;return i},wiggle:function(a){var b=a.length,c=a[0],d=c.length,e=0,f,g,h,i,j,k,l,m,n,o=[];o[0]=m=n=0;for(g=1;g<d;++g){for(f=0,i=0;f<b;++f)i+=a[f][g][1];for(f=0,j=0,l=c[g][0]-c[g-1][0];f<b;++f){for(h=0,k=(a[f][g][1]-a[f][g-1][1])/(2*l);h<f;++h)k+=(a[h][g][1]-a[h][g-1][1])/l;j+=k*a[f][g][1]}o[g]=m-=i?j/i*l:0,m<n&&(n=m)}for(g=0;g<d;++g)o[g]-=n;return o},expand:function(a){var b=a.length,c=a[0].length,d=1/b,e,f,g,h=[];for(f=0;f<c;++f){for(e=0,g=0;e<b;e++)g+=a[e][f][1];if(g)for(e=0;e<b;e++)a[e][f][1]/=g;else for(e=0;e<b;e++)a[e][f][1]=d}for(f=0;f<c;++f)h[f]=0;return h},zero:function(a){var b=-1,c=a[0].length,d=[];while(++b<c)d[b]=0;return d}};d3.layout.histogram=function(){function e(e,f){var g=[],h=e.map(b,this),i=c.call(this,h,f),j=d.call(this,i,h,f),k,f=-1,l=h.length,m=j.length-1,n=a?1:1/l,o;while(++f<m)k=g[f]=[],k.dx=j[f+1]-(k.x=j[f]),k.y=0;f=-1;while(++f<l)o=h[f],o>=i[0]&&o<=i[1]&&(k=g[d3.bisect(j,o,1,m)-1],k.y+=n,k.push(e[f]));return g}var a=!0,b=Number,c=y,d=w;return e.value=function(a){return arguments.length?(b=a,e):b},e.range=function(a){return arguments.length?(c=d3.functor(a),e):c},e.bins=function(a){return arguments.length?(d=typeof a=="number"?function(b){return x(b,a)}:d3.functor(a),e):d},e.frequency=function(b){return arguments.length?(a=!!b,e):a},e},d3.layout.hierarchy=function(){function e(f,h,i){var j=b.call(g,f,h),k=E?f:{data:f};k.depth=h,i.push(k);if(j&&(m=j.length)){var l=-1,m,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=+c.call(g,f,h)||0);return k}function f(a,b){var d=a.children,e=0;if(d&&(i=d.length)){var h=-1,i,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=+c.call(g,E?a:a.data,b)||0);return c&&(a.value=e),e}function g(a){var b=[];return e(a,0,b),b}var a=C,b=A,c=B;return g.sort=function(b){return arguments.length?(a=b,g):a},g.children=function(a){return arguments.length?(b=a,g):b},g.value=function(a){return arguments.length?(c=a,g):c},g.revalue=function(a){return f(a,0),a},g};var E=!1;d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,M(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);return N(f,g/2,h/2,i),e}var a=d3.layout.hierarchy().sort(F),b=[1,1];return c.size=function(a){return arguments.length?(b=a,c):b},z(c,a)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;$(g,function(a){var c=a.children;c&&c.length?(a.x=Q(c),a.y=P(c)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=R(g),m=S(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;return $(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-a.y/g.y)*c[1]}),f}var a=d3.layout.hierarchy().sort(null).value(null),b=T,c=[1,1];return d.separation=function(a){return arguments.length?(b=a,d):b},d.size=function(a){return arguments.length?(c=a,d):c},z(d,a)},d3.layout.tree=function(){function d(d,e){function h(a,c){var d=a.children,e=a._tree;if(d&&(f=d.length)){var f,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;_(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c&&(e=c.length)){var d=-1,e;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=V(g),e=U(e),g&&e)h=U(h),f=V(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(ba(bb(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!V(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!U(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}var f=a.call(this,d,e),g=f[0];$(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=W(g,Y),l=W(g,X),m=W(g,Z),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth||1;return $(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree}),f}var a=d3.layout.hierarchy().sort(null).value(null),b=T,c=[1,1];return d.separation=function(a){return arguments.length?(b=a,d):b},d.size=function(a){return arguments.length?(c=a,d):c},z(d,a)},d3.layout.treemap=function(){function i(a,b){var c=-1,d=a.length,e,f;while(++c<d)f=(e=a[c]).value*(b<0?0:b),e.area=isNaN(f)||f<=0?0:f}function j(a){var b=a.children;if(b&&b.length){var c=e(a),d=[],f=b.slice(),g,h=Infinity,k,n=Math.min(c.dx,c.dy),o;i(f,c.dx*c.dy/a.value),d.area=0;while((o=f.length)>0)d.push(g=f[o-1]),d.area+=g.area,(k=l(d,n))<=h?(f.pop(),h=k):(d.area-=d.pop().area,m(d,n,c,!1),n=Math.min(c.dx,c.dy),d.length=d.area=0,h=Infinity);d.length&&(m(d,n,c,!0),d.length=d.area=0),b.forEach(j)}}function k(a){var b=a.children;if(b&&b.length){var c=e(a),d=b.slice(),f,g=[];i(d,c.dx*c.dy/a.value),g.area=0;while(f=d.pop())g.push(f),g.area+=f.area,f.z!=null&&(m(g,f.z?c.dx:c.dy,c,!d.length),g.length=g.area=0);b.forEach(k)}}function l(a,b){var c=a.area,d,e=0,f=Infinity,g=-1,i=a.length;while(++g<i){if(!(d=a[g].area))continue;d<f&&(f=d),d>e&&(e=d)}return c*=c,b*=b,c?Math.max(b*e*h/c,c/(b*f*h)):Infinity}function m(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=j?d.dy:0;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=j?b(k.area/j):0;k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=j?d.dx:0;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=j?b(k.area/j):0;k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function n(b){var d=g||a(b),e=d[0];return e.x=0,e.y=0,e.dx=c[0],e.dy=c[1],g&&a.revalue(e),i([e],e.dx*e.dy/e.value),(g?k:j)(e),f&&(g=d),d}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=null,e=bc,f=!1,g,h=.5*(1+Math.sqrt(5));return n.size=function(a){return arguments.length?(c=a,n):c},n.padding=function(a){function b(b){var c=a.call(n,b,b.depth);return c==null?bc(b):bd(b,typeof c=="number"?[c,c,c,c]:c)}function c(b){return bd(b,a)}if(!arguments.length)return d;var f;return e=(d=a)==null?bc:(f=typeof a)==="function"?b:f==="number"?(a=[a,a,a,a],c):c,n},n.round=function(a){return arguments.length?(b=a?Math.round:Number,n):b!=Number},n.sticky=function(a){return arguments.length?(f=a,g=null,n):f},n.ratio=function(a){return arguments.length?(h=a,n):h},z(n,a)}})();
View
4 d3.min.js
2 additions, 2 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
92 examples/brush/brush-x.html
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+ <title>Brush</title>
+ <script type="text/javascript" src="../../d3.js"></script>
+ <style type="text/css">
+
+svg {
+ font: 10px sans-serif;
+}
+
+circle {
+ -webkit-transition: fill-opacity 250ms linear;
+}
+
+.selecting circle {
+ fill-opacity: .2;
+}
+
+.selecting circle.selected {
+ stroke: #f00;
+}
+
+.axis path, .axis line {
+ fill: none;
+ stroke: #000;
+ shape-rendering: crispEdges;
+}
+
+.brush .extent {
+ stroke: #fff;
+ fill-opacity: .125;
+ shape-rendering: crispEdges;
+}
+
+ </style>
+ </head>
+ <body>
+ <script type="text/javascript">
+
+var data = d3.range(800).map(Math.random);
+
+var m = [10, 10, 20, 10],
+ w = 960 - m[1] - m[3],
+ h = 100 - m[0] - m[2];
+
+var x = d3.scale.linear().range([0, w]),
+ y = d3.random.normal(h / 2, h / 8);
+
+var svg = d3.select("body").append("svg:svg")
+ .attr("width", w + m[1] + m[3])
+ .attr("height", h + m[0] + m[2])
+ .append("svg:g")
+ .attr("transform", "translate(" + m[3] + "," + m[0] + ")");
+
+svg.append("svg:g")
+ .attr("class", "x axis")
+ .attr("transform", "translate(0," + h + ")")
+ .call(d3.svg.axis().scale(x).orient("bottom"));
+
+var circle = svg.selectAll("circle")
+ .data(data)
+ .enter().append("svg:circle")
+ .attr("transform", function(d) { return "translate(" + x(d) + "," + y() + ")"; })
+ .attr("r", 3.5);
+
+svg.append("svg:g")
+ .attr("class", "brush")
+ .call(d3.svg.brush().x(x)
+ .on("brushstart", brushstart)
+ .on("brush", brush)
+ .on("brushend", brushend))
+ .selectAll("rect")
+ .attr("height", h);
+
+function brushstart() {
+ svg.classed("selecting", true);
+}
+
+function brush() {
+ var s = d3.event.target.extent();
+ circle.classed("selected", function(d) { return s[0] <= d && d < s[1]; });
+}
+
+function brushend() {
+ svg.classed("selecting", !d3.event.target.empty());
+}
+
+ </script>
+ </body>
+</html>
View
91 examples/brush/brush-y.html
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+ <title>Brush</title>
+ <script type="text/javascript" src="../../d3.js"></script>
+ <style type="text/css">
+
+svg {
+ font: 10px sans-serif;
+}
+
+circle {
+ -webkit-transition: fill-opacity 250ms linear;
+}
+
+.selecting circle {
+ fill-opacity: .2;
+}
+
+.selecting circle.selected {
+ stroke: #f00;
+}
+
+.axis path, .axis line {
+ fill: none;
+ stroke: #000;
+ shape-rendering: crispEdges;
+}
+
+.brush .extent {
+ stroke: #fff;
+ fill-opacity: .125;
+ shape-rendering: crispEdges;
+}
+
+ </style>
+ </head>
+ <body>
+ <script type="text/javascript">
+
+var data = d3.range(800).map(Math.random);
+
+var m = [10, 10, 10, 40],
+ w = 120 - m[1] - m[3],
+ h = 960 - m[0] - m[2];
+
+var x = d3.random.normal(w / 2, w / 8),
+ y = d3.scale.linear().range([h, 0]);
+
+var svg = d3.select("body").append("svg:svg")
+ .attr("width", w + m[1] + m[3])
+ .attr("height", h + m[0] + m[2])
+ .append("svg:g")
+ .attr("transform", "translate(" + m[3] + "," + m[0] + ")");
+
+svg.append("svg:g")
+ .attr("class", "y axis")
+ .call(d3.svg.axis().scale(y).orient("left"));
+
+var circle = svg.selectAll("circle")
+ .data(data)
+ .enter().append("svg:circle")
+ .attr("transform", function(d) { return "translate(" + x() + "," + y(d) + ")"; })
+ .attr("r", 3.5);
+
+svg.append("svg:g")
+ .attr("class", "brush")
+ .call(d3.svg.brush().y(y)
+ .on("brushstart", brushstart)
+ .on("brush", brush)
+ .on("brushend", brushend))
+ .selectAll("rect")
+ .attr("width", w);
+
+function brushstart() {
+ svg.classed("selecting", true);
+}
+
+function brush() {
+ var e = d3.event.target.extent();
+ circle.classed("selected", function(d) { return e[0] <= d && d < e[1]; });
+}
+
+function brushend() {
+ svg.classed("selecting", !d3.event.target.empty());
+}
+
+ </script>
+ </body>
+</html>
View
98 examples/brush/brush.html
@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+ <title>Brush</title>
+ <script type="text/javascript" src="../../d3.js"></script>
+ <style type="text/css">
+
+svg {
+ font: 10px sans-serif;
+}
+
+circle {
+ -webkit-transition: fill-opacity 250ms linear;
+}
+
+.selecting circle {
+ fill-opacity: .2;
+}
+
+.selecting circle.selected {
+ stroke: #f00;
+}
+
+.axis path, .axis line {
+ fill: none;
+ stroke: #000;
+ shape-rendering: crispEdges;
+}
+
+.brush .extent {
+ stroke: #fff;
+ fill-opacity: .125;
+ shape-rendering: crispEdges;
+}
+
+ </style>
+ </head>
+ <body>
+ <script type="text/javascript">
+
+var random = d3.random.normal(.5, .1),
+ data = d3.range(800).map(function() { return [random(), random()]; });
+
+var m = [10, 10, 20, 40],
+ w = 960 - m[1] - m[3],
+ h = 500 - m[0] - m[2];
+
+var x = d3.scale.linear().range([0, w]),
+ y = d3.scale.linear().range([h, 0]);
+
+var svg = d3.select("body").append("svg:svg")
+ .attr("width", w + m[1] + m[3])
+ .attr("height", h + m[0] + m[2])
+ .append("svg:g")
+ .attr("transform", "translate(" + m[3] + "," + m[0] + ")");
+
+svg.append("svg:g")
+ .attr("class", "x axis")
+ .attr("transform", "translate(0," + h + ")")
+ .call(d3.svg.axis().scale(x).orient("bottom"));
+
+svg.append("svg:g")
+ .attr("class", "y axis")
+ .call(d3.svg.axis().scale(y).orient("left"));
+
+var circle = svg.selectAll("circle")
+ .data(data)
+ .enter().append("svg:circle")
+ .attr("transform", function(d) { return "translate(" + x(d[0]) + "," + y(d[1]) + ")"; })
+ .attr("r", 3.5);
+
+svg.append("svg:g")
+ .attr("class", "brush")
+ .call(d3.svg.brush().x(x).y(y)
+ .on("brushstart", brushstart)
+ .on("brush", brush)
+ .on("brushend", brushend));
+
+function brushstart() {
+ svg.classed("selecting", true);
+}
+
+function brush() {
+ var e = d3.event.target.extent();
+ circle.classed("selected", function(d) {
+ return e[0][0] <= d[0] && d[0] < e[1][0]
+ && e[0][1] <= d[1] && d[1] < e[1][1];
+ });
+}
+
+function brushend() {
+ svg.classed("selecting", !d3.event.target.empty());
+}
+
+ </script>
+ </body>
+</html>
View
2 examples/calendar/dji.js
@@ -50,7 +50,7 @@ d3.csv("dji.csv", function(csv) {
rect
.attr("class", function(d) { return "day q" + color(data[format(d)]) + "-9"; })
.append("svg:title")
- .text(function(d) { return format(d) + ": " + percent(data[format(d)]); });
+ .text(function(d) { return (d = format(d)) + (d in data ? ": " + percent(data[d]) : ""); });
});
function monthPath(t0) {
View
3 examples/calendar/vix.js
@@ -5,7 +5,6 @@ var m = [19, 20, 20, 19], // top right bottom left margin
var day = d3.time.format("%w"),
week = d3.time.format("%U"),
- percent = d3.format(".1%"),
format = d3.time.format("%Y-%m-%d");
var color = d3.scale.quantile()
@@ -51,7 +50,7 @@ d3.csv("vix.csv", function(csv) {
rect
.attr("class", function(d) { return "day q" + color(data[format(d)]) + "-9"; })
.append("svg:title")
- .text(function(d) { return format(d) + ": " + data[format(d)]; });
+ .text(function(d) { return (d = format(d)) + (d in data ? ": " + data[d] : ""); });
});
function monthPath(t0) {
View
2 examples/donut/donut.html
@@ -26,7 +26,7 @@
data,
color = d3.scale.category20(),
arc = d3.svg.arc(),
- donut = d3.layout.pie();
+ donut = d3.layout.pie().sort(null);
var vis = d3.select("body")
.append("svg:svg")
View
8 examples/force/force.js
@@ -2,8 +2,7 @@ var w = 960,
h = 500,
fill = d3.scale.category20();
-var vis = d3.select("#chart")
- .append("svg:svg")
+var vis = d3.select("#chart").append("svg:svg")
.attr("width", w)
.attr("height", h);
@@ -39,11 +38,6 @@ d3.json("miserables.json", function(json) {
node.append("svg:title")
.text(function(d) { return d.name; });
- vis.style("opacity", 1e-6)
- .transition()
- .duration(1000)
- .style("opacity", 1);
-
force.on("tick", function() {
link.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
View
407 examples/parallel/cars.csv
@@ -0,0 +1,407 @@
+name,economy (mpg),cylinders,displacement (cc),power (hp),weight (lb),0-60 mph (s),year
+AMC Ambassador Brougham,13,8,360,175,3821,11,73
+AMC Ambassador DPL,15,8,390,190,3850,8.5,70
+AMC Ambassador SST,17,8,304,150,3672,11.5,72
+AMC Concord DL 6,20.2,6,232,90,3265,18.2,79
+AMC Concord DL,18.1,6,258,120,3410,15.1,78
+AMC Concord DL,23,4,151,,3035,20.5,82
+AMC Concord,19.4,6,232,90,3210,17.2,78
+AMC Concord,24.3,4,151,90,3003,20.1,80
+AMC Gremlin,18,6,232,100,2789,15,73
+AMC Gremlin,19,6,232,100,2634,13,71
+AMC Gremlin,20,6,232,100,2914,16,75
+AMC Gremlin,21,6,199,90,2648,15,70
+AMC Hornet Sportabout (Wagon),18,6,258,110,2962,13.5,71
+AMC Hornet,18,6,199,97,2774,15.5,70
+AMC Hornet,18,6,232,100,2945,16,73
+AMC Hornet,19,6,232,100,2901,16,74
+AMC Hornet,22.5,6,232,90,3085,17.6,76
+AMC Matador (Wagon),14,8,304,150,4257,15.5,74
+AMC Matador (Wagon),15,8,304,150,3892,12.5,72
+AMC Matador,14,8,304,150,3672,11.5,73
+AMC Matador,15,6,258,110,3730,19,75
+AMC Matador,15.5,8,304,120,3962,13.9,76
+AMC Matador,16,6,258,110,3632,18,74
+AMC Matador,18,6,232,100,3288,15.5,71
+AMC Pacer D/L,17.5,6,258,95,3193,17.8,76
+AMC Pacer,19,6,232,90,3211,17,75
+AMC Rebel SST (Wagon),,8,360,175,3850,11,70
+AMC Rebel SST,16,8,304,150,3433,12,70
+AMC Spirit DL,27.4,4,121,80,2670,15,79
+Audi 100 LS,20,4,114,91,2582,14,73
+Audi 100 LS,23,4,115,95,2694,15,75
+Audi 100 LS,24,4,107,90,2430,14.5,70
+Audi 4000,34.3,4,97,78,2188,15.8,80
+Audi 5000,20.3,5,131,103,2830,15.9,78
+Audi 5000S (Diesel),36.4,5,121,67,2950,19.9,80
+Audi Fox,29,4,98,83,2219,16.5,74
+BMW 2002,26,4,121,113,2234,12.5,70
+BMW 320i,21.5,4,121,110,2600,12.8,77
+Buick Century 350,13,8,350,175,4100,13,73
+Buick Century Limited,25,6,181,110,2945,16.4,82
+Buick Century Luxus (Wagon),13,8,350,150,4699,14.5,74
+Buick Century Special,20.6,6,231,105,3380,15.8,78
+Buick Century,17,6,231,110,3907,21,75
+Buick Century,22.4,6,231,110,3415,15.8,81
+Buick Electra 225 Custom,12,8,455,225,4951,11,73
+Buick Estate Wagon (Wagon),14,8,455,225,3086,10,70
+Buick Estate Wagon (Wagon),16.9,8,350,155,4360,14.9,79
+Buick Lesabre Custom,13,8,350,155,4502,13.5,72
+Buick Opel Isuzu Deluxe,30,4,111,80,2155,14.8,77
+Buick Regal Sport Coupe (Turbo),17.7,6,231,165,3445,13.4,78
+Buick Skyhawk,21,6,231,110,3039,15,75
+Buick Skylark 320,15,8,350,165,3693,11.5,70
+Buick Skylark Limited,28.4,4,151,90,2670,16,79
+Buick Skylark,20.5,6,231,105,3425,16.9,77
+Buick Skylark,26.6,4,151,84,2635,16.4,81
+Cadillac Eldorado,23,8,350,125,3900,17.4,79
+Cadillac Seville,16.5,8,350,180,4380,12.1,76
+Chevroelt Chevelle Malibu,16,6,250,105,3897,18.5,75
+Chevrolet Bel Air,15,8,350,145,4440,14,75
+Chevrolet Camaro,27,4,151,90,2950,17.3,82
+Chevrolet Caprice Classic,13,8,400,150,4464,12,73
+Chevrolet Caprice Classic,17,8,305,130,3840,15.4,79
+Chevrolet Caprice Classic,17.5,8,305,145,3880,12.5,77
+Chevrolet Cavalier 2-Door,34,4,112,88,2395,18,82
+Chevrolet Cavalier Wagon,27,4,112,88,2640,18.6,82
+Chevrolet Cavalier,28,4,112,88,2605,19.6,82
+Chevrolet Chevelle Concours (Wagon),,8,350,165,4142,11.5,70
+Chevrolet Chevelle Concours (Wagon),13,8,307,130,4098,14,72
+Chevrolet Chevelle Malibu Classic,16,6,250,100,3781,17,74
+Chevrolet Chevelle Malibu Classic,17.5,8,305,140,4215,13,76
+Chevrolet Chevelle Malibu,17,6,250,100,3329,15.5,71
+Chevrolet Chevelle Malibu,18,8,307,130,3504,12,70
+Chevrolet Chevette,29,4,85,52,2035,22.2,76
+Chevrolet Chevette,30,4,98,68,2155,16.5,78
+Chevrolet Chevette,30.5,4,98,63,2051,17,77
+Chevrolet Chevette,32.1,4,98,70,2120,15.5,80
+Chevrolet Citation,23.5,6,173,110,2725,12.6,81
+Chevrolet Citation,28,4,151,90,2678,16.5,80
+Chevrolet Citation,28.8,6,173,115,2595,11.3,79
+Chevrolet Concours,17.5,6,250,110,3520,16.4,77
+Chevrolet Impala,11,8,400,150,4997,14,73
+Chevrolet Impala,13,8,350,165,4274,12,72
+Chevrolet Impala,14,8,350,165,4209,12,71
+Chevrolet Impala,14,8,454,220,4354,9,70
+Chevrolet Malibu Classic (Wagon),19.2,8,267,125,3605,15,79
+Chevrolet Malibu,13,8,350,145,3988,13,73
+Chevrolet Malibu,20.5,6,200,95,3155,18.2,78
+Chevrolet Monte Carlo Landau,15.5,8,350,170,4165,11.4,77
+Chevrolet Monte Carlo Landau,19.2,8,305,145,3425,13.2,78
+Chevrolet Monte Carlo S,15,8,350,145,4082,13,73
+Chevrolet Monte Carlo,15,8,400,150,3761,9.5,70
+Chevrolet Monza 2+2,20,8,262,110,3221,13.5,75
+Chevrolet Nova Custom,16,6,250,100,3278,18,73
+Chevrolet Nova,15,6,250,100,3336,17,74
+Chevrolet Nova,18,6,250,105,3459,16,75
+Chevrolet Nova,22,6,250,105,3353,14.5,76
+Chevrolet Vega (Wagon),22,4,140,72,2408,19,71
+Chevrolet Vega 2300,28,4,140,90,2264,15.5,71
+Chevrolet Vega,20,4,140,90,2408,19.5,72
+Chevrolet Vega,21,4,140,72,2401,19.5,73
+Chevrolet Vega,25,4,140,75,2542,17,74
+Chevrolet Woody,24.5,4,98,60,2164,22.1,76
+Chevy C10,13,8,350,145,4055,12,76
+Chevy C20,10,8,307,200,4376,15,70
+Chevy S-10,31,4,119,82,2720,19.4,82
+Chrysler Cordoba,15.5,8,400,190,4325,12.2,77
+Chrysler Lebaron Medallion,26,4,156,92,2585,14.5,82
+Chrysler Lebaron Salon,17.6,6,225,85,3465,16.6,81
+Chrysler Lebaron Town & Country (Wagon),18.5,8,360,150,3940,13,79
+Chrysler New Yorker Brougham,13,8,440,215,4735,11,73
+Chrysler Newport Royal,13,8,400,190,4422,12.5,72
+Citroen DS-21 Pallas,,4,133,115,3090,17.5,70
+Datsun 1200,35,4,72,69,1613,18,71
+Datsun 200SX,23.9,4,119,97,2405,14.9,78
+Datsun 200SX,32.9,4,119,100,2615,14.8,81
+Datsun 210,31.8,4,85,65,2020,19.2,79
+Datsun 210,37,4,85,65,1975,19.4,81
+Datsun 210,40.8,4,85,65,2110,19.2,80
+Datsun 280ZX,32.7,6,168,132,2910,11.4,80
+Datsun 310 GX,38,4,91,67,1995,16.2,82
+Datsun 310,37.2,4,86,65,2019,16.4,80
+Datsun 510 (Wagon),28,4,97,92,2288,17,72
+Datsun 510 Hatchback,37,4,119,92,2434,15,80
+Datsun 510,27.2,4,119,97,2300,14.7,78
+Datsun 610,22,4,108,94,2379,16.5,73
+Datsun 710,24,4,119,97,2545,17,75
+Datsun 710,32,4,83,61,2003,19,74
+Datsun 810 Maxima,24.2,6,146,120,2930,13.8,81
+Datsun 810,22,6,146,97,2815,14.5,77
+Datsun B-210,32,4,85,70,1990,17,76
+Datsun B210 GX,39.4,4,85,70,2070,18.6,78
+Datsun B210,31,4,79,67,1950,19,74
+Datsun F-10 Hatchback,33.5,4,85,70,1945,16.8,77
+Datsun PL510,27,4,97,88,2130,14.5,70
+Datsun PL510,27,4,97,88,2130,14.5,71
+Dodge Aries SE,29,4,135,84,2525,16,82
+Dodge Aries Wagon (Wagon),25.8,4,156,92,2620,14.4,81
+Dodge Aspen 6,20.6,6,225,110,3360,16.6,79
+Dodge Aspen SE,20,6,225,100,3651,17.7,76
+Dodge Aspen,18.6,6,225,110,3620,18.7,78
+Dodge Aspen,19.1,6,225,90,3381,18.7,80
+Dodge Challenger SE,15,8,383,170,3563,10,70
+Dodge Charger 2.2,36,4,135,84,2370,13,82
+Dodge Colt (Wagon),28,4,98,80,2164,15,72
+Dodge Colt Hardtop,25,4,97.5,80,2126,17,72
+Dodge Colt Hatchback Custom,35.7,4,98,80,1915,14.4,79
+Dodge Colt M/M,33.5,4,98,83,2075,15.9,77
+Dodge Colt,26,4,98,79,2255,17.7,76
+Dodge Colt,27.9,4,156,105,2800,14.4,80
+Dodge Colt,28,4,90,75,2125,14.5,74
+Dodge Coronet Brougham,16,8,318,150,4190,13,76
+Dodge Coronet Custom (Wagon),14,8,318,150,4457,13.5,74
+Dodge Coronet Custom,15,8,318,150,3777,12.5,73
+Dodge D100,13,8,318,150,3755,14,76
+Dodge D200,11,8,318,210,4382,13.5,70
+Dodge Dart Custom,15,8,318,150,3399,11,73
+Dodge Diplomat,19.4,8,318,140,3735,13.2,78
+Dodge Magnum XE,17.5,8,318,140,4080,13.7,78
+Dodge Monaco (Wagon),12,8,383,180,4955,11.5,71
+Dodge Monaco Brougham,15.5,8,318,145,4140,13.7,77
+Dodge Omni,30.9,4,105,75,2230,14.5,78
+Dodge Rampage,32,4,135,84,2295,11.6,82
+Dodge St. Regis,18.2,8,318,135,3830,15.2,79
+Fiat 124 Sport Coupe,26,4,98,90,2265,15.5,73
+Fiat 124 TC,26,4,116,75,2246,14,74
+Fiat 124B,30,4,88,76,2065,14.5,71
+Fiat 128,24,4,90,75,2108,15.5,74
+Fiat 128,29,4,68,49,1867,19.5,73
+Fiat 131,28,4,107,86,2464,15.5,76
+Fiat Strada Custom,37.3,4,91,69,2130,14.7,79
+Fiat X1.9,31,4,79,67,2000,16,74
+Ford Capri II,25,4,140,92,2572,14.9,76
+Ford Country Squire (Wagon),13,8,400,170,4746,12,71
+Ford Country Squire (Wagon),15.5,8,351,142,4054,14.3,79
+Ford Country,12,8,400,167,4906,12.5,73
+Ford Escort 2H,29.9,4,98,65,2380,20.7,81
+Ford Escort 4W,34.4,4,98,65,2045,16.2,81
+Ford F108,13,8,302,130,3870,15,76
+Ford F250,10,8,360,215,4615,14,70
+Ford Fairmont (Auto),20.2,6,200,85,2965,15.8,78
+Ford Fairmont (Man),25.1,4,140,88,2720,15.4,78
+Ford Fairmont 4,22.3,4,140,88,2890,17.3,79
+Ford Fairmont Futura,24,4,140,92,2865,16.4,82
+Ford Fairmont,26.4,4,140,88,2870,18.1,80
+Ford Fiesta,36.1,4,98,66,1800,14.4,78
+Ford Futura,18.1,8,302,139,3205,11.2,78
+Ford Galaxie 500,14,8,351,153,4129,13,72
+Ford Galaxie 500,14,8,351,153,4154,13.5,71
+Ford Galaxie 500,15,8,429,198,4341,10,70
+Ford Gran Torino (Wagon),13,8,302,140,4294,16,72
+Ford Gran Torino (Wagon),14,8,302,140,4638,16,74
+Ford Gran Torino,14,8,302,137,4042,14.5,73
+Ford Gran Torino,14.5,8,351,152,4215,12.8,76
+Ford Gran Torino,16,8,302,140,4141,14,74
+Ford Granada Ghia,18,6,250,78,3574,21,76
+Ford Granada GL,20.2,6,200,88,3060,17.1,81
+Ford Granada L,22,6,232,112,2835,14.7,82
+Ford Granada,18.5,6,250,98,3525,19,77
+Ford LTD Landau,17.6,8,302,129,3725,13.4,79
+Ford LTD,13,8,351,158,4363,13,73
+Ford LTD,14,8,351,148,4657,13.5,75
+Ford Maverick,15,6,250,72,3158,19.5,75
+Ford Maverick,18,6,250,88,3021,16.5,73
+Ford Maverick,21,6,200,,2875,17,74
+Ford Maverick,21,6,200,85,2587,16,70
+Ford Maverick,24,6,200,81,3012,17.6,76
+Ford Mustang Boss 302,,8,302,140,3353,8,70
+Ford Mustang Cobra,23.6,4,140,,2905,14.3,80
+Ford Mustang GL,27,4,140,86,2790,15.6,82
+Ford Mustang II 2+2,25.5,4,140,89,2755,15.8,77
+Ford Mustang II,13,8,302,129,3169,12,75
+Ford Mustang,18,6,250,88,3139,14.5,71
+Ford Pinto (Wagon),22,4,122,86,2395,16,72
+Ford Pinto Runabout,21,4,122,86,2226,16.5,72
+Ford Pinto,18,6,171,97,2984,14.5,75
+Ford Pinto,19,4,122,85,2310,18.5,73
+Ford Pinto,23,4,140,83,2639,17,75
+Ford Pinto,25,4,98,,2046,19,71
+Ford Pinto,26,4,122,80,2451,16.5,74
+Ford Pinto,26.5,4,140,72,2565,13.6,76
+Ford Ranger,28,4,120,79,2625,18.6,82
+Ford Thunderbird,16,8,351,149,4335,14.5,77
+Ford Torino (Wagon),,8,351,153,4034,11,70
+Ford Torino 500,19,6,250,88,3302,15.5,71
+Ford Torino,17,8,302,140,3449,10.5,70
+Hi 1200D,9,8,304,193,4732,18.5,70
+Honda Accord CVCC,31.5,4,98,68,2045,18.5,77
+Honda Accord LX,29.5,4,98,68,2135,16.6,78
+Honda Accord,32.4,4,107,72,2290,17,80
+Honda Accord,36,4,107,75,2205,14.5,82
+Honda Civic (Auto),32,4,91,67,1965,15.7,82
+Honda Civic 1300,35.1,4,81,60,1760,16.1,81
+Honda Civic 1500 GL,44.6,4,91,67,1850,13.8,80
+Honda Civic CVCC,33,4,91,53,1795,17.5,75
+Honda Civic CVCC,36.1,4,91,60,1800,16.4,78
+Honda Civic,24,4,120,97,2489,15,74
+Honda Civic,33,4,91,53,1795,17.4,76
+Honda Civic,38,4,91,67,1965,15,82
+Honda Prelude,33.7,4,107,75,2210,14.4,81
+Maxda GLC Deluxe,34.1,4,86,65,1975,15.2,79
+Maxda RX-3,18,3,70,90,2124,13.5,73
+Mazda 626,31.3,4,120,75,2542,17.5,80
+Mazda 626,31.6,4,120,74,2635,18.3,81
+Mazda GLC 4,34.1,4,91,68,1985,16,81
+Mazda GLC Custom L,37,4,91,68,2025,18.2,82
+Mazda GLC Custom,31,4,91,68,1970,17.6,82
+Mazda GLC Deluxe,32.8,4,78,52,1985,19.4,78
+Mazda GLC,46.6,4,86,65,2110,17.9,80
+Mazda RX-2 Coupe,19,3,70,97,2330,13.5,72
+Mazda RX-4,21.5,3,80,110,2720,13.5,77
+Mazda RX-7 Gs,23.7,3,70,100,2420,12.5,80
+Mercedes-Benz 240D,30,4,146,67,3250,21.8,80
+Mercedes-Benz 280S,16.5,6,168,120,3820,16.7,76
+Mercedes-Benz 300D,25.4,5,183,77,3530,20.1,79
+Mercury Capri 2000,23,4,122,86,2220,14,71
+Mercury Capri V6,21,6,155,107,2472,14,73
+Mercury Cougar Brougham,15,8,302,130,4295,14.9,77
+Mercury Grand Marquis,16.5,8,351,138,3955,13.2,79
+Mercury Lynx L,36,4,98,70,2125,17.3,82
+Mercury Marquis Brougham,12,8,429,198,4952,11.5,73
+Mercury Marquis,11,8,429,208,4633,11,72
+Mercury Monarch Ghia,20.2,8,302,139,3570,12.8,78
+Mercury Monarch,15,6,250,72,3432,21,75
+Mercury Zephyr 6,19.8,6,200,85,2990,18.2,79
+Mercury Zephyr,20.8,6,200,85,3070,16.7,78
+Nissan Stanza XE,36,4,120,88,2160,14.5,82
+Oldsmobile Cutlass Ciera (Diesel),38,6,262,85,3015,17,82
+Oldsmobile Cutlass LS,26.6,8,350,105,3725,19,81
+Oldsmobile Cutlass Salon Brougham,19.9,8,260,110,3365,15.5,78
+Oldsmobile Cutlass Salon Brougham,23.9,8,260,90,3420,22.2,79
+Oldsmobile Cutlass Supreme,17,8,260,110,4060,19,77
+Oldsmobile Delta 88 Royale,12,8,350,160,4456,13.5,72
+Oldsmobile Omega Brougham,26.8,6,173,115,2700,12.9,79
+Oldsmobile Omega,11,8,350,180,3664,11,73
+Oldsmobile Starfire SX,23.8,4,151,85,2855,17.6,78
+Oldsmobile Vista Cruiser,12,8,350,180,4499,12.5,73
+Opel 1900,25,4,116,81,2220,16.9,76
+Opel 1900,28,4,116,90,2123,14,71
+Opel Manta,24,4,116,75,2158,15.5,73
+Opel Manta,26,4,97,78,2300,14.5,74
+Peugeot 304,30,4,79,70,2074,19.5,71
+Peugeot 504 (Wagon),21,4,120,87,2979,19.5,72
+Peugeot 504,19,4,120,88,3270,21.9,76
+Peugeot 504,23,4,120,88,2957,17,75
+Peugeot 504,25,4,110,87,2672,17.5,70
+Peugeot 504,27.2,4,141,71,3190,24.8,79
+Peugeot 505S Turbo Diesel,28.1,4,141,80,3230,20.4,81
+Peugeot 604SL,16.2,6,163,133,3410,15.8,78
+Plymouth Arrow GS,25.5,4,122,96,2300,15.5,77
+Plymouth Barracuda 340,14,8,340,160,3609,8,70
+Plymouth Champ,39,4,86,64,1875,16.4,81
+Plymouth Cricket,26,4,91,70,1955,20.5,71
+Plymouth Custom Suburb,13,8,360,170,4654,13,73
+Plymouth Duster,20,6,198,95,3102,16.5,74
+Plymouth Duster,22,6,198,95,2833,15.5,70
+Plymouth Duster,23,6,198,95,2904,16,73
+Plymouth Fury Gran Sedan,14,8,318,150,4237,14.5,73
+Plymouth Fury III,14,8,318,150,4096,13,71
+Plymouth Fury III,14,8,440,215,4312,8.5,70
+Plymouth Fury III,15,8,318,150,4135,13.5,72
+Plymouth Fury,18,6,225,95,3785,19,75
+Plymouth Grand Fury,16,8,318,150,4498,14.5,75
+Plymouth Horizon 4,34.7,4,105,63,2215,14.9,81
+Plymouth Horizon Miser,38,4,105,63,2125,14.7,82
+Plymouth Horizon TC3,34.5,4,105,70,2150,14.9,79
+Plymouth Horizon,34.2,4,105,70,2200,13.2,79
+Plymouth Reliant,27.2,4,135,84,2490,15.7,81
+Plymouth Reliant,30,4,135,84,2385,12.9,81
+Plymouth Sapporo,23.2,4,156,105,2745,16.7,78
+Plymouth Satellite (Wagon),,8,383,175,4166,10.5,70
+Plymouth Satellite Custom (Wagon),14,8,318,150,4077,14,72
+Plymouth Satellite Custom,16,6,225,105,3439,15.5,71
+Plymouth Satellite Sebring,18,6,225,105,3613,16.5,74
+Plymouth Satellite,18,8,318,150,3436,11,70
+Plymouth Valiant Custom,19,6,225,95,3264,16,75
+Plymouth Valiant,18,6,225,105,3121,16.5,73
+Plymouth Valiant,22,6,225,100,3233,15.4,76
+Plymouth Volare Custom,19,6,225,100,3630,17.7,77
+Plymouth Volare Premier V8,13,8,318,150,3940,13.2,76
+Plymouth Volare,20.5,6,225,100,3430,17.2,78
+Pontiac Astro,23,4,140,78,2592,18.5,75
+Pontiac Catalina Brougham,14,8,400,175,4464,11.5,71
+Pontiac Catalina,14,8,400,175,4385,12,72
+Pontiac Catalina,14,8,455,225,4425,10,70
+Pontiac Catalina,16,8,400,170,4668,11.5,75
+Pontiac Firebird,19,6,250,100,3282,15,71
+Pontiac Grand Prix Lj,16,8,400,180,4220,11.1,77
+Pontiac Grand Prix,16,8,400,230,4278,9.5,73
+Pontiac J2000 Se Hatchback,31,4,112,85,2575,16.2,82
+Pontiac Lemans V6,21.5,6,231,115,3245,15.4,79
+Pontiac Phoenix LJ,19.2,6,231,105,3535,19.2,78
+Pontiac Phoenix,27,4,151,90,2735,18,82
+Pontiac Phoenix,33.5,4,151,90,2556,13.2,79
+Pontiac Safari (Wagon),13,8,400,175,5140,12,71
+Pontiac Sunbird Coupe,24.5,4,151,88,2740,16,77
+Pontiac Ventura Sj,18.5,6,250,110,3645,16.2,76
+Renault 12 (Wagon),26,4,96,69,2189,18,72
+Renault 12TL,27,4,101,83,2202,15.3,76
+Renault 18I,34.5,4,100,,2320,15.8,81
+Renault 5 Gtl,36,4,79,58,1825,18.6,77
+Renault Lecar Deluxe,40.9,4,85,,1835,17.3,80
+Saab 900S,,4,121,110,2800,15.4,81
+Saab 99E,25,4,104,95,2375,17.5,70
+Saab 99GLE,21.6,4,121,115,2795,15.7,78
+Saab 99LE,24,4,121,110,2660,14,73
+Saab 99LE,25,4,121,115,2671,13.5,75
+Subaru DL,30,4,97,67,1985,16.4,77
+Subaru DL,33.8,4,97,67,2145,18,80
+Subaru,26,4,108,93,2391,15.5,74
+Subaru,32.3,4,97,67,2065,17.8,81
+Toyota Carina,20,4,97,88,2279,19,73
+Toyota Celica GT Liftback,21.1,4,134,95,2515,14.8,78
+Toyota Celica GT,32,4,144,96,2665,13.9,82
+Toyota Corolla 1200,31,4,71,65,1773,19,71
+Toyota Corolla 1200,32,4,71,65,1836,21,74
+Toyota Corolla 1600 (Wagon),27,4,97,88,2100,16.5,72
+Toyota Corolla Liftback,26,4,97,75,2265,18.2,77
+Toyota Corolla Tercel,38.1,4,89,60,1968,18.8,80
+Toyota Corolla,28,4,97,75,2155,16.4,76
+Toyota Corolla,29,4,97,75,2171,16,75
+Toyota Corolla,32.2,4,108,75,2265,15.2,80
+Toyota Corolla,32.4,4,108,75,2350,16.8,81
+Toyota Corolla,34,4,108,70,2245,16.9,82
+Toyota Corona Hardtop,24,4,113,95,2278,15.5,72
+Toyota Corona Liftback,29.8,4,134,90,2711,15.5,80
+Toyota Corona Mark II,24,4,113,95,2372,15,70
+Toyota Corona,24,4,134,96,2702,13.5,75
+Toyota Corona,25,4,113,95,2228,14,71
+Toyota Corona,27.5,4,134,95,2560,14.2,78
+Toyota Corona,31,4,76,52,1649,16.5,74
+Toyota Cressida,25.4,6,168,116,2900,12.6,81
+Toyota Mark II,19,6,156,108,2930,15.5,76
+Toyota Mark II,20,6,156,122,2807,13.5,73
+Toyota Starlet,39.1,4,79,58,1755,16.9,81
+Toyota Tercel,37.7,4,89,62,2050,17.3,81
+Toyouta Corona Mark II (Wagon),23,4,120,97,2506,14.5,72
+Triumph TR7 Coupe,35,4,122,88,2500,15.1,80
+Vokswagen Rabbit,29.8,4,89,62,1845,15.3,80
+Volkswagen 1131 Deluxe Sedan,26,4,97,46,1835,20.5,70
+Volkswagen 411 (Wagon),22,4,121,76,2511,18,72
+Volkswagen Dasher (Diesel),43.4,4,90,48,2335,23.7,80
+Volkswagen Dasher,25,4,90,71,2223,16.5,75
+Volkswagen Dasher,26,4,79,67,1963,15.5,74
+Volkswagen Dasher,30.5,4,97,78,2190,14.1,77
+Volkswagen Jetta,33,4,105,74,2190,14.2,81
+Volkswagen Model 111,27,4,97,60,1834,19,71
+Volkswagen Pickup,44,4,97,52,2130,24.6,82
+Volkswagen Rabbit C (Diesel),44.3,4,90,48,2085,21.7,80
+Volkswagen Rabbit Custom Diesel,43.1,4,90,48,1985,21.5,78
+Volkswagen Rabbit Custom,29,4,97,78,1940,14.5,77
+Volkswagen Rabbit Custom,31.9,4,89,71,1925,14,79
+Volkswagen Rabbit L,36,4,105,74,1980,15.3,82
+Volkswagen Rabbit,29,4,90,70,1937,14,75
+Volkswagen Rabbit,29,4,90,70,1937,14.2,76
+Volkswagen Rabbit,29.5,4,97,71,1825,12.2,76
+Volkswagen Rabbit,41.5,4,98,76,2144,14.7,80
+Volkswagen Scirocco,31.5,4,89,71,1990,14.9,78
+Volkswagen Super Beetle 117,,4,97,48,1978,20,71
+Volkswagen Super Beetle,26,4,97,46,1950,21,73
+Volkswagen Type 3,23,4,97,54,2254,23.5,72
+Volvo 144EA,19,4,121,112,2868,15.5,73
+Volvo 145E (Wagon),18,4,121,112,2933,14.5,72
+Volvo 244DL,22,4,121,98,2945,14.5,75
+Volvo 245,20,4,130,102,3150,15.7,76
+Volvo 264GL,17,6,163,125,3140,13.6,78
+Volvo Diesel,30.7,6,145,76,3160,19.6,81
View
134 examples/parallel/parallel.html
@@ -0,0 +1,134 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+ <title>Parallel Coordinates</title>
+ <style type="text/css">
+
+svg {
+ font: 10px sans-serif;
+}
+
+.background path {
+ fill: none;
+ stroke: #ccc;
+ stroke-opacity: .4;
+ shape-rendering: crispEdges;
+}
+
+.foreground path {
+ fill: none;
+ stroke: steelblue;
+ stroke-opacity: .7;
+}
+
+.brush .extent {
+ fill-opacity: .3;
+ stroke: #fff;
+ shape-rendering: crispEdges;
+}
+
+.axis line, .axis path {
+ fill: none;
+ stroke: #000;
+ shape-rendering: crispEdges;
+}
+
+.axis text {
+ text-shadow: 0 1px 0 #fff;
+}
+
+ </style>
+ </head>
+ <body>
+ <script type="text/javascript" src="../../d3.js"></script>
+ <script type="text/javascript" src="../../d3.csv.js"></script>
+ <script type="text/javascript">
+
+var m = [30, 10, 10, 10],
+ w = 960 - m[1] - m[3],
+ h = 500 - m[0] - m[2];
+
+var x = d3.scale.ordinal().rangePoints([0, w], 1),
+ y = {};
+
+var line = d3.svg.line(),
+ axis = d3.svg.axis().orient("left"),
+ background,
+ foreground;
+
+var svg = d3.select("body").append("svg:svg")
+ .attr("width", w + m[1] + m[3])
+ .attr("height", h + m[0] + m[2])
+ .append("svg:g")
+ .attr("transform", "translate(" + m[3] + "," + m[0] + ")");
+
+d3.csv("cars.csv", function(cars) {
+
+ // Extract the list of dimensions and create a scale for each.
+ x.domain(dimensions = d3.keys(cars[0]).filter(function(d) {
+ return d != "name" && (y[d] = d3.scale.linear()
+ .domain(d3.extent(cars, function(p) { return +p[d]; }))
+ .range([h, 0]));
+ }));
+
+ // Add grey background lines for context.
+ background = svg.append("svg:g")
+ .attr("class", "background")
+ .selectAll("path")
+ .data(cars)
+ .enter().append("svg:path")
+ .attr("d", path);
+
+ // Add blue foreground lines for focus.
+ foreground = svg.append("svg:g")
+ .attr("class", "foreground")
+ .selectAll("path")
+ .data(cars)
+ .enter().append("svg:path")
+ .attr("d", path);
+
+ // Add a group element for each dimension.
+ var g = svg.selectAll(".dimension")
+ .data(dimensions)
+ .enter().append("svg:g")
+ .attr("class", "dimension")
+ .attr("transform", function(d) { return "translate(" + x(d) + ")"; });
+
+ // Add an axis and title.
+ g.append("svg:g")
+ .attr("class", "axis")
+ .each(function(d) { d3.select(this).call(axis.scale(y[d])); })
+ .append("svg:text")
+ .attr("text-anchor", "middle")
+ .attr("y", -9)
+ .text(String);
+
+ // Add and store a brush for each axis.
+ g.append("svg:g")
+ .attr("class", "brush")
+ .each(function(d) { d3.select(this).call(y[d].brush = d3.svg.brush().y(y[d]).on("brush", brush)); })
+ .selectAll("rect")
+ .attr("x", -8)
+ .attr("width", 16);
+});
+
+// Returns the path for a given data point.
+function path(d) {
+ return line(dimensions.map(function(p) { return [x(p), y[p](d[p])]; }));
+}
+
+// Handles a brush event, toggling the display of foreground lines.
+function brush() {
+ var actives = dimensions.filter(function(p) { return !y[p].brush.empty(); }),
+ extents = actives.map(function(p) { return y[p].brush.extent(); });
+ foreground.style("display", function(d) {
+ return actives.every(function(p, i) {
+ return extents[i][0] <= d[p] && d[p] <= extents[i][1];
+ }) ? null : "none";
+ });
+}
+
+ </script>
+ </body>
+</html>
View
7 examples/pie/pie-transition.html
@@ -18,14 +18,13 @@
var w = 400,
h = 400,
r = Math.min(w, h) / 2,
- data = d3.range(10).map(Math.random),
+ data = d3.range(10).map(Math.random).sort(d3.descending),
color = d3.scale.category20(),
arc = d3.svg.arc().outerRadius(r),
donut = d3.layout.pie();
-var vis = d3.select("body")
- .append("svg:svg")
- .data([data.sort(d3.descending)])
+var vis = d3.select("body").append("svg:svg")
+ .data([data])
.attr("width", w)
.attr("height", h);
View
2 examples/pie/pie.html
@@ -20,7 +20,7 @@
r = Math.min(w, h) / 2,