Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'release'

  • Loading branch information...
commit 9523f9499866f3d249402140962a2e0b2e669c4f 2 parents 2df8c62 + 9c92666
Mike Bostock authored
1  Makefile
@@ -53,6 +53,7 @@ d3.core.js: \
53 53
 	src/core/number.js \
54 54
 	src/core/sum.js \
55 55
 	src/core/quantile.js \
  56
+	src/core/transpose.js \
56 57
 	src/core/zip.js \
57 58
 	src/core/bisect.js \
58 59
 	src/core/first.js \
208  d3.js
@@ -10,7 +10,7 @@ try {
10 10
     d3_style_setProperty.call(this, name, value + "", priority);
11 11
   };
12 12
 }
13  
-d3 = {version: "2.5.2"}; // semver
  13
+d3 = {version: "2.6.0"}; // semver
14 14
 var d3_array = d3_arraySlice; // conversion for NodeLists
15 15
 
16 16
 function d3_arrayCopy(pseudoarray) {
@@ -175,6 +175,9 @@ d3.quantile = function(values, p) {
175 175
       e = H - h;
176 176
   return e ? v + e * (values[h] - v) : v;
177 177
 };
  178
+d3.transpose = function(matrix) {
  179
+  return d3.zip.apply(d3, matrix);
  180
+};
178 181
 d3.zip = function() {
179 182
   if (!(n = arguments.length)) return [];
180 183
   for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m;) {
@@ -464,24 +467,22 @@ d3.xml = function(url, mime, callback) {
464 467
   }
465 468
   d3.xhr(url, mime, ready);
466 469
 };
467  
-d3.ns = {
468  
-
469  
-  prefix: {
470  
-    svg: "http://www.w3.org/2000/svg",
471  
-    xhtml: "http://www.w3.org/1999/xhtml",
472  
-    xlink: "http://www.w3.org/1999/xlink",
473  
-    xml: "http://www.w3.org/XML/1998/namespace",
474  
-    xmlns: "http://www.w3.org/2000/xmlns/"
475  
-  },
  470
+var d3_nsPrefix = {
  471
+  svg: "http://www.w3.org/2000/svg",
  472
+  xhtml: "http://www.w3.org/1999/xhtml",
  473
+  xlink: "http://www.w3.org/1999/xlink",
  474
+  xml: "http://www.w3.org/XML/1998/namespace",
  475
+  xmlns: "http://www.w3.org/2000/xmlns/"
  476
+};
476 477
 
  478
+d3.ns = {
  479
+  prefix: d3_nsPrefix,
477 480
   qualify: function(name) {
478 481
     var i = name.indexOf(":");
479  
-    return i < 0 ? name : {
480  
-      space: d3.ns.prefix[name.substring(0, i)],
481  
-      local: name.substring(i + 1)
482  
-    };
  482
+    return i < 0 ? (name in d3_nsPrefix
  483
+      ? {space: d3_nsPrefix[name], local: name} : name)
  484
+      : {space: d3_nsPrefix[name.substring(0, i)], local: name.substring(i + 1)};
483 485
   }
484  
-
485 486
 };
486 487
 d3.dispatch = function() {
487 488
   var dispatch = new d3_dispatch(),
@@ -1586,7 +1587,7 @@ d3_selectionPrototype.append = function(name) {
1586 1587
   name = d3.ns.qualify(name);
1587 1588
 
1588 1589
   function append() {
1589  
-    return this.appendChild(document.createElement(name));
  1590
+    return this.appendChild(document.createElementNS(this.namespaceURI, name));
1590 1591
   }
1591 1592
 
1592 1593
   function appendNS() {
@@ -1603,7 +1604,7 @@ d3_selectionPrototype.insert = function(name, before) {
1603 1604
 
1604 1605
   function insert() {
1605 1606
     return this.insertBefore(
1606  
-        document.createElement(name),
  1607
+        document.createElementNS(this.namespaceURI, name),
1607 1608
         d3_select(before, this));
1608 1609
   }
1609 1610
 
@@ -2325,6 +2326,10 @@ function d3_scaleExtent(domain) {
2325 2326
   var start = domain[0], stop = domain[domain.length - 1];
2326 2327
   return start < stop ? [start, stop] : [stop, start];
2327 2328
 }
  2329
+
  2330
+function d3_scaleRange(scale) {
  2331
+  return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());
  2332
+}
2328 2333
 function d3_scale_nice(domain, nice) {
2329 2334
   var i0 = 0,
2330 2335
       i1 = domain.length - 1,
@@ -2696,6 +2701,10 @@ function d3_scale_ordinal(domain, ranger) {
2696 2701
     return rangeBand;
2697 2702
   };
2698 2703
 
  2704
+  scale.rangeExtent = function() {
  2705
+    return ranger.x;
  2706
+  };
  2707
+
2699 2708
   scale.copy = function() {
2700 2709
     return d3_scale_ordinal(domain, ranger);
2701 2710
   };
@@ -3791,9 +3800,9 @@ d3.svg.axis = function() {
3791 3800
         }
3792 3801
       } : Object;
3793 3802
 
3794  
-      // Ticks.
3795  
-      var ticks = scale.ticks.apply(scale, tickArguments_),
3796  
-          tickFormat = tickFormat_ == null ? scale.tickFormat.apply(scale, tickArguments_) : tickFormat_;
  3803
+      // Ticks, or domain values for ordinal scales.
  3804
+      var ticks = scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain(),
  3805
+          tickFormat = tickFormat_ == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : String) : tickFormat_;
3797 3806
 
3798 3807
       // Minor ticks.
3799 3808
       var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide),
@@ -3810,14 +3819,15 @@ d3.svg.axis = function() {
3810 3819
           tickTransform;
3811 3820
 
3812 3821
       // Domain.
3813  
-      var range = d3_scaleExtent(scale.range()),
  3822
+      var range = d3_scaleRange(scale),
3814 3823
           path = g.selectAll(".domain").data([0]),
3815 3824
           pathEnter = path.enter().append("svg:path").attr("class", "domain"),
3816 3825
           pathUpdate = transition(path);
3817 3826
 
3818  
-      // Stash the new scale and grab the old scale.
3819  
-      var scale0 = this.__chart__ || scale;
3820  
-      this.__chart__ = scale.copy();
  3827
+      // Stash a snapshot of the new scale, and retrieve the old snapshot.
  3828
+      var scale1 = scale.copy(),
  3829
+          scale0 = this.__chart__ || scale1;
  3830
+      this.__chart__ = scale1;
3821 3831
 
3822 3832
       tickEnter.append("svg:line").attr("class", "tick");
3823 3833
       tickEnter.append("svg:text");
@@ -3858,13 +3868,27 @@ d3.svg.axis = function() {
3858 3868
         }
3859 3869
       }
3860 3870
 
3861  
-      tickEnter.call(tickTransform, scale0);
3862  
-      tickUpdate.call(tickTransform, scale);
3863  
-      tickExit.call(tickTransform, scale);
  3871
+      // For quantitative scales:
  3872
+      // - enter new ticks from the old scale
  3873
+      // - exit old ticks to the new scale
  3874
+      if (scale.ticks) {
  3875
+        tickEnter.call(tickTransform, scale0);
  3876
+        tickUpdate.call(tickTransform, scale1);
  3877
+        tickExit.call(tickTransform, scale1);
  3878
+        subtickEnter.call(tickTransform, scale0);
  3879
+        subtickUpdate.call(tickTransform, scale1);
  3880
+        subtickExit.call(tickTransform, scale1);
  3881
+      }
3864 3882
 
3865  
-      subtickEnter.call(tickTransform, scale0);
3866  
-      subtickUpdate.call(tickTransform, scale);
3867  
-      subtickExit.call(tickTransform, scale);
  3883
+      // For ordinal scales:
  3884
+      // - any entering ticks are undefined in the old scale
  3885
+      // - any exiting ticks are undefined in the new scale
  3886
+      // Therefore, we only need to transition updating ticks.
  3887
+      else {
  3888
+        var dx = scale1.rangeBand() / 2, x = function(d) { return scale1(d) + dx; };
  3889
+        tickEnter.call(tickTransform, x);
  3890
+        tickUpdate.call(tickTransform, x);
  3891
+      }
3868 3892
     });
3869 3893
   }
3870 3894
 
@@ -3993,12 +4017,12 @@ d3.svg.brush = function() {
3993 4017
       // Initialize the background to fill the defined range.
3994 4018
       // If the range isn't defined, you can post-process.
3995 4019
       if (x) {
3996  
-        e = d3_scaleExtent(x.range());
  4020
+        e = d3_scaleRange(x);
3997 4021
         bg.attr("x", e[0]).attr("width", e[1] - e[0]);
3998 4022
         d3_svg_brushRedrawX(g, extent);
3999 4023
       }
4000 4024
       if (y) {
4001  
-        e = d3_scaleExtent(y.range());
  4025
+        e = d3_scaleRange(y);
4002 4026
         bg.attr("y", e[0]).attr("height", e[1] - e[0]);
4003 4027
         d3_svg_brushRedrawY(g, extent);
4004 4028
       }
@@ -4075,11 +4099,13 @@ d3.svg.brush = function() {
4075 4099
     // Invert the pixel extent to data-space.
4076 4100
     if (!arguments.length) {
4077 4101
       if (x) {
4078  
-        x0 = x.invert(extent[0][0]), x1 = x.invert(extent[1][0]);
  4102
+        x0 = extent[0][0], x1 = extent[1][0];
  4103
+        if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);
4079 4104
         if (x1 < x0) t = x0, x0 = x1, x1 = t;
4080 4105
       }
4081 4106
       if (y) {
4082  
-        y0 = y.invert(extent[0][1]), y1 = y.invert(extent[1][1]);
  4107
+        y0 = extent[0][1], y1 = extent[1][1];
  4108
+        if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);
4083 4109
         if (y1 < y0) t = y0, y0 = y1, y1 = t;
4084 4110
       }
4085 4111
       return x && y ? [[x0, y0], [x1, y1]] : x ? [x0, x1] : y && [y0, y1];
@@ -4089,14 +4115,14 @@ d3.svg.brush = function() {
4089 4115
     if (x) {
4090 4116
       x0 = z[0], x1 = z[1];
4091 4117
       if (y) x0 = x0[0], x1 = x1[0];
4092  
-      x0 = x(x0), x1 = x(x1);
  4118
+      if (x.invert) x0 = x(x0), x1 = x(x1);
4093 4119
       if (x1 < x0) t = x0, x0 = x1, x1 = t;
4094 4120
       extent[0][0] = x0, extent[1][0] = x1;
4095 4121
     }
4096 4122
     if (y) {
4097 4123
       y0 = z[0], y1 = z[1];
4098 4124
       if (x) y0 = y0[1], y1 = y1[1];
4099  
-      y0 = y(y0), y1 = y(y1);
  4125
+      if (y.invert) y0 = y(y0), y1 = y(y1);
4100 4126
       if (y1 < y0) t = y0, y0 = y1, y1 = t;
4101 4127
       extent[0][1] = y0, extent[1][1] = y1;
4102 4128
     }
@@ -4211,7 +4237,9 @@ function d3_svg_brushMove() {
4211 4237
 }
4212 4238
 
4213 4239
 function d3_svg_brushMove1(mouse, scale, i) {
4214  
-  var range = d3_scaleExtent(scale.range()),
  4240
+  var range = d3_scaleRange(scale),
  4241
+      r0 = range[0],
  4242
+      r1 = range[1],
4215 4243
       offset = d3_svg_brushOffset[i],
4216 4244
       size = d3_svg_brushExtent[1][i] - d3_svg_brushExtent[0][i],
4217 4245
       min,
@@ -4219,12 +4247,12 @@ function d3_svg_brushMove1(mouse, scale, i) {
4219 4247
 
4220 4248
   // When dragging, reduce the range by the extent size and offset.
4221 4249
   if (d3_svg_brushDrag) {
4222  
-    range[0] -= offset;
4223  
-    range[1] -= size + offset;
  4250
+    r0 -= offset;
  4251
+    r1 -= size + offset;
4224 4252
   }
4225 4253
 
4226 4254
   // Clamp the mouse so that the extent fits within the range extent.
4227  
-  min = Math.max(range[0], Math.min(range[1], mouse[i]));
  4255
+  min = Math.max(r0, Math.min(r1, mouse[i]));
4228 4256
 
4229 4257
   // Compute the new extent bounds.
4230 4258
   if (d3_svg_brushDrag) {
@@ -4232,7 +4260,7 @@ function d3_svg_brushMove1(mouse, scale, i) {
4232 4260
   } else {
4233 4261
 
4234 4262
     // If the ALT key is pressed, then preserve the center of the extent.
4235  
-    if (d3_svg_brushCenter) offset = Math.max(range[0], Math.min(range[1], 2 * d3_svg_brushCenter[i] - min));
  4263
+    if (d3_svg_brushCenter) offset = Math.max(r0, Math.min(r1, 2 * d3_svg_brushCenter[i] - min));
4236 4264
 
4237 4265
     // Compute the min and max of the offset and mouse.
4238 4266
     if (offset < min) {
@@ -4278,8 +4306,11 @@ var d3_svg_brushCursor = {
4278 4306
   sw: "nesw-resize"
4279 4307
 };
4280 4308
 d3.behavior = {};
  4309
+// TODO Track touch points by identifier.
  4310
+
4281 4311
 d3.behavior.drag = function() {
4282  
-  var event = d3.dispatch("drag", "dragstart", "dragend");
  4312
+  var event = d3.dispatch("drag", "dragstart", "dragend"),
  4313
+      origin = null;
4283 4314
 
4284 4315
   function drag() {
4285 4316
     this
@@ -4298,9 +4329,16 @@ d3.behavior.drag = function() {
4298 4329
   function start() {
4299 4330
     d3_behavior_dragEvent = event;
4300 4331
     d3_behavior_dragEventTarget = d3.event.target;
4301  
-    d3_behavior_dragOffset = d3_behavior_dragPoint((d3_behavior_dragTarget = this).parentNode);
4302  
-    d3_behavior_dragMoved = 0;
  4332
+    d3_behavior_dragTarget = this;
4303 4333
     d3_behavior_dragArguments = arguments;
  4334
+    d3_behavior_dragOrigin = d3_behavior_dragPoint();
  4335
+    if (origin) {
  4336
+      d3_behavior_dragOffset = origin.apply(d3_behavior_dragTarget, d3_behavior_dragArguments);
  4337
+      d3_behavior_dragOffset = [d3_behavior_dragOffset.x - d3_behavior_dragOrigin[0], d3_behavior_dragOffset.y - d3_behavior_dragOrigin[1]];
  4338
+    } else {
  4339
+      d3_behavior_dragOffset = [0, 0];
  4340
+    }
  4341
+    d3_behavior_dragMoved = 0;
4304 4342
   }
4305 4343
 
4306 4344
   function mousedown() {
@@ -4308,6 +4346,12 @@ d3.behavior.drag = function() {
4308 4346
     d3_behavior_dragDispatch("dragstart");
4309 4347
   }
4310 4348
 
  4349
+  drag.origin = function(x) {
  4350
+    if (!arguments.length) return origin;
  4351
+    origin = x;
  4352
+    return drag;
  4353
+  };
  4354
+
4311 4355
   return d3.rebind(drag, event, "on");
4312 4356
 };
4313 4357
 
@@ -4316,34 +4360,39 @@ var d3_behavior_dragEvent,
4316 4360
     d3_behavior_dragTarget,
4317 4361
     d3_behavior_dragArguments,
4318 4362
     d3_behavior_dragOffset,
4319  
-    d3_behavior_dragMoved,
4320  
-    d3_behavior_dragStopClick;
  4363
+    d3_behavior_dragOrigin,
  4364
+    d3_behavior_dragMoved;
4321 4365
 
4322 4366
 function d3_behavior_dragDispatch(type) {
4323  
-  var o = d3.event, p = d3_behavior_dragTarget.parentNode, dx = 0, dy = 0;
  4367
+  var p = d3_behavior_dragPoint(),
  4368
+      o = d3.event,
  4369
+      e = d3.event = {type: type};
4324 4370
 
4325 4371
   if (p) {
4326  
-    p = d3_behavior_dragPoint(p);
4327  
-    dx = p[0] - d3_behavior_dragOffset[0];
4328  
-    dy = p[1] - d3_behavior_dragOffset[1];
4329  
-    d3_behavior_dragOffset = p;
4330  
-    d3_behavior_dragMoved |= dx | dy;
  4372
+    e.x = p[0] + d3_behavior_dragOffset[0];
  4373
+    e.y = p[1] + d3_behavior_dragOffset[1];
  4374
+    e.dx = p[0] - d3_behavior_dragOrigin[0];
  4375
+    e.dy = p[1] - d3_behavior_dragOrigin[1];
  4376
+    d3_behavior_dragMoved |= e.dx | e.dy;
  4377
+    d3_behavior_dragOrigin = p;
4331 4378
   }
4332 4379
 
4333 4380
   try {
4334  
-    d3.event = {dx: dx, dy: dy};
4335 4381
     d3_behavior_dragEvent[type].apply(d3_behavior_dragTarget, d3_behavior_dragArguments);
4336 4382
   } finally {
4337 4383
     d3.event = o;
4338 4384
   }
4339 4385
 
  4386
+  o.stopPropagation();
4340 4387
   o.preventDefault();
4341 4388
 }
4342 4389
 
4343  
-function d3_behavior_dragPoint(container, type) {
4344  
-  // TODO Track touch points by identifier.
4345  
-  var t = d3.event.changedTouches;
4346  
-  return t ? d3.svg.touches(container, t)[0] : d3.svg.mouse(container);
  4390
+function d3_behavior_dragPoint() {
  4391
+  var p = d3_behavior_dragTarget.parentNode,
  4392
+      t = d3.event.changedTouches;
  4393
+  return p && (t
  4394
+      ? d3.svg.touches(p, t)[0]
  4395
+      : d3.svg.mouse(p));
4347 4396
 }
4348 4397
 
4349 4398
 function d3_behavior_dragMove() {
@@ -4360,21 +4409,26 @@ function d3_behavior_dragMove() {
4360 4409
 function d3_behavior_dragUp() {
4361 4410
   if (!d3_behavior_dragTarget) return;
4362 4411
   d3_behavior_dragDispatch("dragend");
4363  
-  d3_behavior_dragTarget = null;
4364 4412
 
4365 4413
   // If the node was moved, prevent the mouseup from propagating.
4366 4414
   // Also prevent the subsequent click from propagating (e.g., for anchors).
4367  
-  if (d3_behavior_dragMoved && d3_behavior_dragEventTarget === d3.event.target) {
4368  
-    d3_behavior_dragStopClick = true;
  4415
+  if (d3_behavior_dragMoved) {
4369 4416
     d3_eventCancel();
  4417
+    d3_behavior_dragMoved = d3.event.target === d3_behavior_dragEventTarget;
4370 4418
   }
  4419
+
  4420
+  d3_behavior_dragEvent =
  4421
+  d3_behavior_dragEventTarget =
  4422
+  d3_behavior_dragTarget =
  4423
+  d3_behavior_dragArguments =
  4424
+  d3_behavior_dragOffset =
  4425
+  d3_behavior_dragOrigin = null;
4371 4426
 }
4372 4427
 
4373 4428
 function d3_behavior_dragClick() {
4374  
-  if (d3_behavior_dragStopClick && d3_behavior_dragEventTarget === d3.event.target) {
  4429
+  if (d3_behavior_dragMoved) {
4375 4430
     d3_eventCancel();
4376  
-    d3_behavior_dragStopClick = false;
4377  
-    d3_behavior_dragEventTarget = null;
  4431
+    d3_behavior_dragMoved = 0;
4378 4432
   }
4379 4433
 }
4380 4434
 // TODO unbind zoom behavior?
@@ -4412,7 +4466,7 @@ d3.behavior.zoom = function() {
4412 4466
   function mousedown() {
4413 4467
     start.apply(this, arguments);
4414 4468
     d3_behavior_zoomPanning = d3_behavior_zoomLocation(d3.svg.mouse(d3_behavior_zoomTarget));
4415  
-    d3_behavior_zoomMoved = false;
  4469
+    d3_behavior_zoomMoved = 0;
4416 4470
     d3.event.preventDefault();
4417 4471
     window.focus();
4418 4472
   }
@@ -4462,8 +4516,7 @@ var d3_behavior_zoomDiv,
4462 4516
     d3_behavior_zoomEventTarget,
4463 4517
     d3_behavior_zoomTarget,
4464 4518
     d3_behavior_zoomArguments,
4465  
-    d3_behavior_zoomMoved,
4466  
-    d3_behavior_zoomStopClick;
  4519
+    d3_behavior_zoomMoved;
4467 4520
 
4468 4521
 function d3_behavior_zoomLocation(point) {
4469 4522
   return [
@@ -4543,27 +4596,32 @@ function d3_behavior_zoomTouchmove() {
4543 4596
 function d3_behavior_zoomMousemove() {
4544 4597
   d3_behavior_zoomZooming = null;
4545 4598
   if (d3_behavior_zoomPanning) {
4546  
-    d3_behavior_zoomMoved = true;
  4599
+    d3_behavior_zoomMoved = 1;
4547 4600
     d3_behavior_zoomTo(d3_behavior_zoomXyz[2], d3.svg.mouse(d3_behavior_zoomTarget), d3_behavior_zoomPanning);
4548 4601
   }
4549 4602
 }
4550 4603
 
4551 4604
 function d3_behavior_zoomMouseup() {
4552 4605
   if (d3_behavior_zoomPanning) {
4553  
-    if (d3_behavior_zoomMoved && d3_behavior_zoomEventTarget === d3.event.target) {
4554  
-      d3_behavior_zoomStopClick = true;
  4606
+    if (d3_behavior_zoomMoved) {
  4607
+      d3_eventCancel();
  4608
+      d3_behavior_zoomMoved = d3_behavior_zoomEventTarget === d3.event.target;
4555 4609
     }
4556  
-    d3_behavior_zoomMousemove();
  4610
+
  4611
+    d3_behavior_zoomXyz =
  4612
+    d3_behavior_zoomExtent =
  4613
+    d3_behavior_zoomDispatch =
  4614
+    d3_behavior_zoomEventTarget =
  4615
+    d3_behavior_zoomTarget =
  4616
+    d3_behavior_zoomArguments =
4557 4617
     d3_behavior_zoomPanning = null;
4558 4618
   }
4559 4619
 }
4560 4620
 
4561 4621
 function d3_behavior_zoomClick() {
4562  
-  if (d3_behavior_zoomStopClick && d3_behavior_zoomEventTarget === d3.event.target) {
4563  
-    d3.event.stopPropagation();
4564  
-    d3.event.preventDefault();
4565  
-    d3_behavior_zoomStopClick = false;
4566  
-    d3_behavior_zoomEventTarget = null;
  4622
+  if (d3_behavior_zoomMoved) {
  4623
+    d3_eventCancel();
  4624
+    d3_behavior_zoomMoved = 0;
4567 4625
   }
4568 4626
 }
4569 4627
 
5  d3.layout.js
@@ -470,6 +470,7 @@ d3.layout.force = function() {
470 470
   // use `node.call(force.drag)` to make nodes draggable
471 471
   force.drag = function() {
472 472
     if (!drag) drag = d3.behavior.drag()
  473
+        .origin(Object)
473 474
         .on("dragstart", dragstart)
474 475
         .on("drag", d3_layout_forceDrag)
475 476
         .on("dragend", d3_layout_forceDragEnd);
@@ -505,8 +506,8 @@ function d3_layout_forceDragEnd() {
505 506
 }
506 507
 
507 508
 function d3_layout_forceDrag() {
508  
-  d3_layout_forceDragNode.px += d3.event.dx;
509  
-  d3_layout_forceDragNode.py += d3.event.dy;
  509
+  d3_layout_forceDragNode.px = d3.event.x;
  510
+  d3_layout_forceDragNode.py = d3.event.y;
510 511
   d3_layout_forceDragForce.resume(); // restart annealing
511 512
 }
512 513
 
2  d3.layout.min.js
... ...
@@ -1 +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 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 d3.rebind(a,b,"sort","children","value"),a.links=D,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.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)},d3.rebind(a,b,"on")};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)}})();
  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.x,f.py=d3.event.y,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 d3.rebind(a,b,"sort","children","value"),a.links=D,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.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().origin(Object).on("dragstart",C).on("drag",j).on("dragend",i)),this.on("mouseover.force",g).on("mouseout.force",h).call(d)},d3.rebind(a,b,"on")};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)}})();
4  d3.min.js
2 additions, 2 deletions not shown
142  examples/bar/bar.html
@@ -3,90 +3,98 @@
3 3
   <head>
4 4
     <title>Bar Chart</title>
5 5
     <script type="text/javascript" src="../../d3.js"></script>
  6
+    <script type="text/javascript" src="../../d3.csv.js"></script>
6 7
     <style type="text/css">
7 8
 
8 9
 body {
9 10
   font: 10px sans-serif;
10 11
 }
11 12
 
12  
-svg {
  13
+.bar rect {
  14
+  fill: steelblue;
  15
+}
  16
+
  17
+.bar text.value {
  18
+  fill: white;
  19
+}
  20
+
  21
+.axis {
13 22
   shape-rendering: crispEdges;
14 23
 }
15 24
 
  25
+.axis path {
  26
+  fill: none;
  27
+}
  28
+
  29
+.x.axis line {
  30
+  stroke: #fff;
  31
+  stroke-opacity: .8;
  32
+}
  33
+
  34
+.y.axis path {
  35
+  stroke: black;
  36
+}
  37
+
16 38
     </style>
17 39
   </head>
18 40
   <body>
19 41
     <script type="text/javascript">
20 42
 
21  
-var data = d3.range(10).map(Math.random);
  43
+var m = [30, 10, 10, 30],
  44
+    w = 960 - m[1] - m[3],
  45
+    h = 930 - m[0] - m[2];
  46
+
  47
+var format = d3.format(",.0f");
  48
+
  49
+var x = d3.scale.linear().range([0, w]),
  50
+    y = d3.scale.ordinal().rangeRoundBands([0, h], .1);
22 51
 
23  
-var w = 430,
24  
-    h = 230,
25  
-    x = d3.scale.linear().domain([0, 1]).range([0, w]),
26  
-    y = d3.scale.ordinal().domain(d3.range(data.length)).rangeBands([0, h], .2);
  52
+var xAxis = d3.svg.axis().scale(x).orient("top").tickSize(-h),
  53
+    yAxis = d3.svg.axis().scale(y).orient("left").tickSize(0);
27 54
 
28  
-var vis = d3.select("body")
29  
-  .append("svg:svg")
30  
-    .attr("width", w + 40)
31  
-    .attr("height", h + 20)
  55
+var svg = d3.select("body").append("svg:svg")
  56
+    .attr("width", w + m[1] + m[3])
  57
+    .attr("height", h + m[0] + m[2])
32 58
   .append("svg:g")
33  
-    .attr("transform", "translate(20,0)");
34  
-
35  
-var bars = vis.selectAll("g.bar")
36  
-    .data(data)
37  
-  .enter().append("svg:g")
38  
-    .attr("class", "bar")
39  
-    .attr("transform", function(d, i) { return "translate(0," + y(i) + ")"; });
40  
-
41  
-bars.append("svg:rect")
42  
-    .attr("fill", "steelblue")
43  
-    .attr("width", x)
44  
-    .attr("height", y.rangeBand());
45  
-
46  
-bars.append("svg:text")
47  
-    .attr("x", x)
48  
-    .attr("y", y.rangeBand() / 2)
49  
-    .attr("dx", -6)
50  
-    .attr("dy", ".35em")
51  
-    .attr("fill", "white")
52  
-    .attr("text-anchor", "end")
53  
-    .text(x.tickFormat(100));
54  
-
55  
-bars.append("svg:text")
56  
-    .attr("x", 0)
57  
-    .attr("y", y.rangeBand() / 2)
58  
-    .attr("dx", -6)
59  
-    .attr("dy", ".35em")
60  
-    .attr("text-anchor", "end")
61  
-    .text(function(d, i) { return String.fromCharCode(65 + i); });
62  
-
63  
-var rules = vis.selectAll("g.rule")
64  
-    .data(x.ticks(10))
65  
-  .enter().append("svg:g")
66  
-    .attr("class", "rule")
67  
-    .attr("transform", function(d) { return "translate(" + x(d) + ",0)"; });
68  
-
69  
-rules.append("svg:line")
70  
-    .attr("y1", h)
71  
-    .attr("y2", h + 6)
72  
-    .attr("stroke", "black");
73  
-
74  
-rules.append("svg:line")
75  
-    .attr("y1", 0)
76  
-    .attr("y2", h)
77  
-    .attr("stroke", "white")
78  
-    .attr("stroke-opacity", .3);
79  
-
80  
-rules.append("svg:text")
81  
-    .attr("y", h + 9)
82  
-    .attr("dy", ".71em")
83  
-    .attr("text-anchor", "middle")
84  
-    .text(x.tickFormat(10));
85  
-
86  
-vis.append("svg:line")
87  
-    .attr("y1", 0)
88  
-    .attr("y2", h)
89  
-    .attr("stroke", "black");
  59
+    .attr("transform", "translate(" + m[3] + "," + m[0] + ")");
  60
+
  61
+d3.csv("sample-data.csv", function(data) {
  62
+
  63
+  // Parse numbers, and sort by value.
  64
+  data.forEach(function(d) { d.value = +d.value; });
  65
+  data.sort(function(a, b) { return b.value - a.value; });
  66
+
  67
+  // Set the scale domain.
  68
+  x.domain([0, d3.max(data, function(d) { return d.value; })]);
  69
+  y.domain(data.map(function(d) { return d.name; }));
  70
+
  71
+  var bar = svg.selectAll("g.bar")
  72
+      .data(data)
  73
+    .enter().append("svg:g")
  74
+      .attr("class", "bar")
  75
+      .attr("transform", function(d) { return "translate(0," + y(d.name) + ")"; });
  76
+
  77
+  bar.append("svg:rect")
  78
+      .attr("width", function(d) { return x(d.value); })
  79
+      .attr("height", y.rangeBand());
  80
+
  81
+  bar.append("svg:text")
  82
+      .attr("class", "value")
  83
+      .attr("x", function(d) { return x(d.value); })
  84
+      .attr("y", y.rangeBand() / 2)
  85
+      .attr("dx", -3)
  86
+      .attr("dy", ".35em")
  87
+      .attr("text-anchor", "end")
  88
+      .text(function(d) { return format(d.value); });
  89
+
  90
+  svg.append("svg:g")
  91
+      .attr("class", "x axis")
  92
+      .call(xAxis);
  93
+
  94
+  svg.append("svg:g")
  95
+      .attr("class", "y axis")
  96
+      .call(yAxis);
  97
+});
90 98
 
91 99
     </script>
92 100
   </body>
53  examples/bar/sample-data.csv
... ...
@@ -0,0 +1,53 @@
  1
+name,value
  2
+AL,4708708
  3
+AK,698473
  4
+AZ,6595778
  5
+AR,2889450
  6
+CA,36961664
  7
+CO,5024748
  8
+CT,3518288
  9
+DE,885122
  10
+DC,599657
  11
+FL,18537969
  12
+GA,9829211
  13
+HI,1295178
  14
+ID,1545801
  15
+IL,12910409
  16
+IN,6423113
  17
+IA,3007856
  18
+KS,2818747
  19
+KY,4314113
  20
+LA,4492076
  21
+ME,1318301
  22
+MD,5699478
  23
+MA,6593587
  24
+MI,9969727
  25
+MN,5266214
  26
+MS,2951996
  27
+MO,5987580
  28
+MT,974989
  29
+NE,1796619
  30
+NV,2643085
  31
+NH,1324575
  32
+NJ,8707739
  33
+NM,2009671
  34
+NY,19541453
  35
+NC,9380884
  36
+ND,646844
  37
+OH,11542645
  38
+OK,3687050
  39
+OR,3825657
  40
+PA,12604767
  41
+RI,1053209
  42
+SC,4561242
  43
+SD,812383
  44
+TN,6296254
  45
+TX,24782302
  46
+UT,2784572
  47
+VT,621760
  48
+VA,7882590
  49
+WA,6664195
  50
+WV,1819777
  51
+WI,5654774
  52
+WY,544270
  53
+PR,3967288
92  examples/brush/brush-ordinal.html
... ...
@@ -0,0 +1,92 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+  <head>
  4
+    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  5
+    <title>Brush</title>
  6
+    <script type="text/javascript" src="../../d3.js"></script>
  7
+    <style type="text/css">
  8
+
  9
+svg {
  10
+  font: 10px sans-serif;
  11
+}
  12
+
  13
+path {
  14
+  -webkit-transition: fill-opacity 250ms linear;
  15
+}
  16
+
  17
+.selecting path {
  18
+  fill-opacity: .2;
  19
+}
  20
+
  21
+.selecting path.selected {
  22
+  stroke: #f00;
  23
+  stroke-width: 2px;
  24
+}
  25
+
  26
+.axis path, .axis line {
  27
+  fill: none;
  28
+  stroke: #000;
  29
+  shape-rendering: crispEdges;
  30
+}
  31
+
  32
+.brush .extent {
  33
+  stroke: #fff;
  34
+  fill-opacity: .125;
  35
+  shape-rendering: crispEdges;
  36
+}
  37
+
  38
+    </style>
  39
+  </head>
  40
+  <body>
  41
+    <script type="text/javascript">
  42
+
  43
+var data = d3.svg.symbolTypes;
  44
+
  45
+var m = [10, 10, 20, 10],
  46
+    w = 960 - m[1] - m[3],
  47
+    h = 100 - m[0] - m[2];
  48
+
  49
+var x = d3.scale.ordinal().domain(data).rangePoints([0, w], 1);
  50
+
  51
+var svg = d3.select("body").append("svg:svg")
  52
+    .attr("width", w + m[1] + m[3])
  53
+    .attr("height", h + m[0] + m[2])
  54
+  .append("svg:g")
  55
+    .attr("transform", "translate(" + m[3] + "," + m[0] + ")");
  56
+
  57
+svg.append("svg:g")
  58
+    .attr("class", "x axis")
  59
+    .attr("transform", "translate(0," + h + ")")
  60
+    .call(d3.svg.axis().scale(x).orient("bottom"));
  61
+
  62
+var symbol = svg.append("svg:g").selectAll("path")
  63
+    .data(data)
  64
+  .enter().append("svg:path")
  65
+    .attr("transform", function(d) { return "translate(" + x(d) + "," + (h / 2) + ")"; })
  66
+    .attr("d", d3.svg.symbol().type(String).size(200));
  67
+
  68
+svg.append("svg:g")
  69
+    .attr("class", "brush")
  70
+    .call(d3.svg.brush().x(x)
  71
+    .on("brushstart", brushstart)
  72
+    .on("brush", brush)
  73
+    .on("brushend", brushend))
  74
+  .selectAll("rect")
  75
+    .attr("height", h);
  76
+
  77
+function brushstart() {
  78
+  svg.classed("selecting", true);
  79
+}
  80
+
  81
+function brush() {
  82
+  var s = d3.event.target.extent();
  83
+  symbol.classed("selected", function(d) { return s[0] <= (d = x(d)) && d <= s[1]; });
  84
+}
  85
+
  86
+function brushend() {
  87
+  svg.classed("selecting", !d3.event.target.empty());
  88
+}
  89
+
  90
+    </script>
  91
+  </body>
  92
+</html>
44  examples/drag/drag.html
... ...
@@ -0,0 +1,44 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+  <head>
  4
+    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  5
+    <style type="text/css">
  6
+
  7
+svg {
  8
+  border: solid 1px #aaa;
  9
+}
  10
+
  11
+    </style>
  12
+  </head>
  13
+  <body>
  14
+    <script type="text/javascript" src="../../d3.js"></script>
  15
+    <script type="text/javascript">
  16
+
  17
+var w = 960,
  18
+    h = 500,
  19
+    r = 120;
  20
+
  21
+var drag = d3.behavior.drag()
  22
+    .origin(Object)
  23
+    .on("drag", dragmove);
  24
+
  25
+var svg = d3.select("body").append("svg:svg")
  26
+    .attr("width", w)
  27
+    .attr("height", h)
  28
+
  29
+var circle = svg.append("svg:circle")
  30
+    .data([{x: w / 2, y: h / 2}])
  31
+    .attr("r", r)
  32
+    .attr("cx", function(d) { return d.x; })
  33
+    .attr("cy", function(d) { return d.y; })
  34
+    .call(drag);
  35
+
  36
+function dragmove(d) {
  37
+  circle
  38
+      .attr("cx", d.x = Math.max(r, Math.min(w - r, d3.event.x)))
  39
+      .attr("cy", d.y = Math.max(r, Math.min(h - r, d3.event.y)));
  40
+}
  41
+
  42
+    </script>
  43
+  </body>
  44
+</html>
2  package.json
... ...
@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "d3",
3  
-  "version": "2.5.2",
  3
+  "version": "2.6.0",
4 4
   "description": "A small, free JavaScript library for manipulating documents based on data.",
5 5
   "keywords": [
6 6
     "dom",
70  src/behavior/drag.js
... ...
@@ -1,5 +1,8 @@
  1
+// TODO Track touch points by identifier.
  2
+
1 3
 d3.behavior.drag = function() {
2  
-  var event = d3.dispatch("drag", "dragstart", "dragend");
  4
+  var event = d3.dispatch("drag", "dragstart", "dragend"),
  5
+      origin = null;
3 6
 
4 7
   function drag() {
5 8
     this
@@ -18,9 +21,16 @@ d3.behavior.drag = function() {
18 21
   function start() {
19 22
     d3_behavior_dragEvent = event;
20 23
     d3_behavior_dragEventTarget = d3.event.target;
21  
-    d3_behavior_dragOffset = d3_behavior_dragPoint((d3_behavior_dragTarget = this).parentNode);
22  
-    d3_behavior_dragMoved = 0;
  24
+    d3_behavior_dragTarget = this;
23 25
     d3_behavior_dragArguments = arguments;
  26
+    d3_behavior_dragOrigin = d3_behavior_dragPoint();
  27
+    if (origin) {
  28
+      d3_behavior_dragOffset = origin.apply(d3_behavior_dragTarget, d3_behavior_dragArguments);
  29
+      d3_behavior_dragOffset = [d3_behavior_dragOffset.x - d3_behavior_dragOrigin[0], d3_behavior_dragOffset.y - d3_behavior_dragOrigin[1]];
  30
+    } else {
  31
+      d3_behavior_dragOffset = [0, 0];
  32
+    }
  33
+    d3_behavior_dragMoved = 0;
24 34
   }
25 35
 
26 36
   function mousedown() {
@@ -28,6 +38,12 @@ d3.behavior.drag = function() {
28 38
     d3_behavior_dragDispatch("dragstart");
29 39
   }
30 40
 
  41
+  drag.origin = function(x) {
  42
+    if (!arguments.length) return origin;
  43
+    origin = x;
  44
+    return drag;
  45
+  };
  46
+
31 47
   return d3.rebind(drag, event, "on");
32 48
 };
33 49
 
@@ -36,34 +52,39 @@ var d3_behavior_dragEvent,
36 52
     d3_behavior_dragTarget,
37 53
     d3_behavior_dragArguments,
38 54
     d3_behavior_dragOffset,
39  
-    d3_behavior_dragMoved,
40  
-    d3_behavior_dragStopClick;
  55
+    d3_behavior_dragOrigin,
  56
+    d3_behavior_dragMoved;
41 57
 
42 58
 function d3_behavior_dragDispatch(type) {
43  
-  var o = d3.event, p = d3_behavior_dragTarget.parentNode, dx = 0, dy = 0;
  59
+  var p = d3_behavior_dragPoint(),
  60
+      o = d3.event,
  61
+      e = d3.event = {type: type};
44 62
 
45 63
   if (p) {
46  
-    p = d3_behavior_dragPoint(p);
47  
-    dx = p[0] - d3_behavior_dragOffset[0];
48  
-    dy = p[1] - d3_behavior_dragOffset[1];
49  
-    d3_behavior_dragOffset = p;
50  
-    d3_behavior_dragMoved |= dx | dy;
  64
+    e.x = p[0] + d3_behavior_dragOffset[0];
  65
+    e.y = p[1] + d3_behavior_dragOffset[1];
  66
+    e.dx = p[0] - d3_behavior_dragOrigin[0];
  67
+    e.dy = p[1] - d3_behavior_dragOrigin[1];
  68
+    d3_behavior_dragMoved |= e.dx | e.dy;
  69
+    d3_behavior_dragOrigin = p;
51 70
   }
52 71
 
53 72
   try {
54  
-    d3.event = {dx: dx, dy: dy};
55 73
     d3_behavior_dragEvent[type].apply(d3_behavior_dragTarget, d3_behavior_dragArguments);
56 74
   } finally {
57 75
     d3.event = o;
58 76
   }
59 77
 
  78
+  o.stopPropagation();
60 79
   o.preventDefault();
61 80
 }
62 81
 
63  
-function d3_behavior_dragPoint(container, type) {
64  
-  // TODO Track touch points by identifier.
65  
-  var t = d3.event.changedTouches;
66  
-  return t ? d3.svg.touches(container, t)[0] : d3.svg.mouse(container);
  82
+function d3_behavior_dragPoint() {
  83
+  var p = d3_behavior_dragTarget.parentNode,
  84
+      t = d3.event.changedTouches;
  85
+  return p && (t
  86
+      ? d3.svg.touches(p, t)[0]
  87
+      : d3.svg.mouse(p));
67 88
 }
68 89
 
69 90
 function d3_behavior_dragMove() {
@@ -80,20 +101,25 @@ function d3_behavior_dragMove() {
80 101
 function d3_behavior_dragUp() {
81 102
   if (!d3_behavior_dragTarget) return;
82 103
   d3_behavior_dragDispatch("dragend");
83  
-  d3_behavior_dragTarget = null;
84 104
 
85 105
   // If the node was moved, prevent the mouseup from propagating.
86 106
   // Also prevent the subsequent click from propagating (e.g., for anchors).
87  
-  if (d3_behavior_dragMoved && d3_behavior_dragEventTarget === d3.event.target) {
88  
-    d3_behavior_dragStopClick = true;
  107
+  if (d3_behavior_dragMoved) {
89 108
     d3_eventCancel();
  109
+    d3_behavior_dragMoved = d3.event.target === d3_behavior_dragEventTarget;
90 110
   }
  111
+
  112
+  d3_behavior_dragEvent =
  113
+  d3_behavior_dragEventTarget =
  114
+  d3_behavior_dragTarget =
  115
+  d3_behavior_dragArguments =
  116
+  d3_behavior_dragOffset =
  117
+  d3_behavior_dragOrigin = null;
91 118
 }
92 119
 
93 120
 function d3_behavior_dragClick() {
94  
-  if (d3_behavior_dragStopClick && d3_behavior_dragEventTarget === d3.event.target) {
  121
+  if (d3_behavior_dragMoved) {
95 122
     d3_eventCancel();
96  
-    d3_behavior_dragStopClick = false;
97  
-    d3_behavior_dragEventTarget = null;
  123
+    d3_behavior_dragMoved = 0;
98 124
   }
99 125
 }
28  src/behavior/zoom.js
@@ -33,7 +33,7 @@ d3.behavior.zoom = function() {
33 33
   function mousedown() {
34 34
     start.apply(this, arguments);
35 35
     d3_behavior_zoomPanning = d3_behavior_zoomLocation(d3.svg.mouse(d3_behavior_zoomTarget));
36  
-    d3_behavior_zoomMoved = false;
  36
+    d3_behavior_zoomMoved = 0;
37 37
     d3.event.preventDefault();
38 38
     window.focus();
39 39
   }
@@ -83,8 +83,7 @@ var d3_behavior_zoomDiv,
83 83
     d3_behavior_zoomEventTarget,
84 84
     d3_behavior_zoomTarget,
85 85
     d3_behavior_zoomArguments,
86  
-    d3_behavior_zoomMoved,
87  
-    d3_behavior_zoomStopClick;
  86
+    d3_behavior_zoomMoved;
88 87
 
89 88
 function d3_behavior_zoomLocation(point) {
90 89
   return [
@@ -164,27 +163,32 @@ function d3_behavior_zoomTouchmove() {
164 163
 function d3_behavior_zoomMousemove() {
165 164
   d3_behavior_zoomZooming = null;
166 165
   if (d3_behavior_zoomPanning) {
167  
-    d3_behavior_zoomMoved = true;
  166
+    d3_behavior_zoomMoved = 1;
168 167
     d3_behavior_zoomTo(d3_behavior_zoomXyz[2], d3.svg.mouse(d3_behavior_zoomTarget), d3_behavior_zoomPanning);
169 168
   }
170 169
 }
171 170
 
172 171
 function d3_behavior_zoomMouseup() {
173 172
   if (d3_behavior_zoomPanning) {
174  
-    if (d3_behavior_zoomMoved && d3_behavior_zoomEventTarget === d3.event.target) {
175  
-      d3_behavior_zoomStopClick = true;
  173
+    if (d3_behavior_zoomMoved) {
  174
+      d3_eventCancel();
  175
+      d3_behavior_zoomMoved = d3_behavior_zoomEventTarget === d3.event.target;
176 176
     }
177  
-    d3_behavior_zoomMousemove();
  177
+
  178
+    d3_behavior_zoomXyz =
  179
+    d3_behavior_zoomExtent =
  180
+    d3_behavior_zoomDispatch =
  181
+    d3_behavior_zoomEventTarget =
  182
+    d3_behavior_zoomTarget =
  183
+    d3_behavior_zoomArguments =
178 184
     d3_behavior_zoomPanning = null;
179 185
   }
180 186
 }
181 187
 
182 188
 function d3_behavior_zoomClick() {
183  
-  if (d3_behavior_zoomStopClick && d3_behavior_zoomEventTarget === d3.event.target) {
184  
-    d3.event.stopPropagation();
185  
-    d3.event.preventDefault();
186  
-    d3_behavior_zoomStopClick = false;
187  
-    d3_behavior_zoomEventTarget = null;
  189
+  if (d3_behavior_zoomMoved) {
  190
+    d3_eventCancel();
  191
+    d3_behavior_zoomMoved = 0;
188 192
   }
189 193
 }
190 194
 
2  src/core/core.js
... ...
@@ -1 +1 @@
1  
-d3 = {version: "2.5.2"}; // semver
  1
+d3 = {version: "2.6.0"}; // semver
26  src/core/ns.js
... ...
@@ -1,19 +1,17 @@
1  
-d3.ns = {
2  
-
3  
-  prefix: {
4  
-    svg: "http://www.w3.org/2000/svg",
5  
-    xhtml: "http://www.w3.org/1999/xhtml",
6  
-    xlink: "http://www.w3.org/1999/xlink",
7  
-    xml: "http://www.w3.org/XML/1998/namespace",
8  
-    xmlns: "http://www.w3.org/2000/xmlns/"
9  
-  },
  1
+var d3_nsPrefix = {
  2
+  svg: "http://www.w3.org/2000/svg",
  3
+  xhtml: "http://www.w3.org/1999/xhtml",
  4
+  xlink: "http://www.w3.org/1999/xlink",
  5
+  xml: "http://www.w3.org/XML/1998/namespace",
  6
+  xmlns: "http://www.w3.org/2000/xmlns/"
  7
+};
10 8
 
  9
+d3.ns = {
  10
+  prefix: d3_nsPrefix,
11 11
   qualify: function(name) {
12 12
     var i = name.indexOf(":");
13  
-    return i < 0 ? name : {
14  
-      space: d3.ns.prefix[name.substring(0, i)],
15  
-      local: name.substring(i + 1)
16  
-    };
  13
+    return i < 0 ? (name in d3_nsPrefix
  14
+      ? {space: d3_nsPrefix[name], local: name} : name)
  15
+      : {space: d3_nsPrefix[name.substring(0, i)], local: name.substring(i + 1)};
17 16
   }
18  
-
19 17
 };
2  src/core/selection-append.js
@@ -4,7 +4,7 @@ d3_selectionPrototype.append = function(name) {
4 4
   name = d3.ns.qualify(name);
5 5
 
6 6
   function append() {
7  
-    return this.appendChild(document.createElement(name));
  7
+    return this.appendChild(document.createElementNS(this.namespaceURI, name));
8 8
   }
9 9
 
10 10
   function appendNS() {
2  src/core/selection-insert.js
@@ -6,7 +6,7 @@ d3_selectionPrototype.insert = function(name, before) {
6 6
 
7 7
   function insert() {
8 8
     return this.insertBefore(
9  
-        document.createElement(name),
  9
+        document.createElementNS(this.namespaceURI, name),
10 10
         d3_select(before, this));
11 11
   }
12 12
 
3  src/core/transpose.js
... ...
@@ -0,0 +1,3 @@
  1
+d3.transpose = function(matrix) {
  2
+  return d3.zip.apply(d3, matrix);
  3
+};
5  src/layout/force.js
@@ -259,6 +259,7 @@ d3.layout.force = function() {
259 259
   // use `node.call(force.drag)` to make nodes draggable
260 260
   force.drag = function() {
261 261
     if (!drag) drag = d3.behavior.drag()
  262
+        .origin(Object)
262 263
         .on("dragstart", dragstart)
263 264
         .on("drag", d3_layout_forceDrag)
264 265
         .on("dragend", d3_layout_forceDragEnd);
@@ -294,8 +295,8 @@ function d3_layout_forceDragEnd() {
294 295
 }
295 296
 
296 297
 function d3_layout_forceDrag() {
297  
-  d3_layout_forceDragNode.px += d3.event.dx;
298  
-  d3_layout_forceDragNode.py += d3.event.dy;
  298
+  d3_layout_forceDragNode.px = d3.event.x;
  299
+  d3_layout_forceDragNode.py = d3.event.y;
299 300
   d3_layout_forceDragForce.resume(); // restart annealing
300 301
 }
301 302
 
4  src/scale/ordinal.js
@@ -69,6 +69,10 @@ function d3_scale_ordinal(domain, ranger) {
69 69
     return rangeBand;
70 70
   };
71 71
 
  72
+  scale.rangeExtent = function() {
  73
+    return ranger.x;
  74
+  };
  75
+
72 76
   scale.copy = function() {
73 77
     return d3_scale_ordinal(domain, ranger);
74 78
   };
4  src/scale/scale.js
@@ -4,3 +4,7 @@ function d3_scaleExtent(domain) {
4