d3-rails 3.4.4 → 3.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf7a62496e32ed2626849bd502e7bf4068822828
4
- data.tar.gz: 6ee0a0b582a1cf5a40e1c50bcfb301e48e31dba8
3
+ metadata.gz: da6ac0888f02c6736f79a6d444d3155ada9b5380
4
+ data.tar.gz: 0b2943921830c14b72a1c39f9805115313cd0d6b
5
5
  SHA512:
6
- metadata.gz: 6b594a8af29f6428c7b4e73b700e8308fd341a5b1355e76b36b8b4cc6558d9973bec5f6f4fa2e04d63e397fd817134f8feeb1b4ce1f1d09a6239b4913dd05266
7
- data.tar.gz: f3ac661ab30160f21c0aebbea2610e01e33434870fb1966ef732ea6a16685f6cf06027ff6736bb5905e48b2dcd87d050ca0565ea9b541fd01ee0af5fbbbadc39
6
+ metadata.gz: 2adca8ab210f31901da1a8abab150baf10a40c7450d7bdf486f5bd18cc6ad1209e6a65867e22c848c1407d1a84628f2127a4b043cb7be7f166715944fe5ea41b
7
+ data.tar.gz: da1baf3fe57ebbc604b016425623a8db72053d6ea5997d533c2fd6e03f5bc4065402485fdd14441e48961ef9858ad5e5311c84b7905de5f0d776f65c59034323
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ imports/*
8
8
  .*.swp
9
9
  .*.swo
10
10
  Gemfile.lock
11
+ .project
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 3.4.11 (12 September 2014)
2
+
3
+ * Upgrade D3 to 3.4.11
4
+
1
5
  ## 3.4.4 (2 April 2014)
2
6
 
3
7
  * Upgrade D3 to 3.4.4
data/README.md CHANGED
@@ -6,7 +6,7 @@ d3-rails provides D3 for Rails 3.1 and higher.
6
6
 
7
7
  ## Version
8
8
 
9
- d3-rails comes with version 3.4.4 of D3.js. and will track the always
9
+ d3-rails comes with version 3.4.11 of D3.js. and will track the always
10
10
  mirror the version of D3 it comes with.
11
11
 
12
12
 
@@ -1,6 +1,6 @@
1
1
  !function() {
2
2
  var d3 = {
3
- version: "3.4.4"
3
+ version: "3.4.11"
4
4
  };
5
5
  if (!Date.now) Date.now = function() {
6
6
  return +new Date();
@@ -91,13 +91,13 @@
91
91
  return x != null && !isNaN(x);
92
92
  }
93
93
  d3.mean = function(array, f) {
94
- var n = array.length, a, m = 0, i = -1, j = 0;
94
+ var s = 0, n = array.length, a, i = -1, j = n;
95
95
  if (arguments.length === 1) {
96
- while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j;
96
+ while (++i < n) if (d3_number(a = array[i])) s += a; else --j;
97
97
  } else {
98
- while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j;
98
+ while (++i < n) if (d3_number(a = f.call(array, array[i], i))) s += a; else --j;
99
99
  }
100
- return j ? m : undefined;
100
+ return j ? s / j : undefined;
101
101
  };
102
102
  d3.quantile = function(values, p) {
103
103
  var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;
@@ -492,7 +492,7 @@
492
492
  return n.querySelector(s);
493
493
  }, d3_selectAll = function(s, n) {
494
494
  return n.querySelectorAll(s);
495
- }, d3_selectMatcher = d3_documentElement[d3_vendorSymbol(d3_documentElement, "matchesSelector")], d3_selectMatches = function(n, s) {
495
+ }, d3_selectMatcher = d3_documentElement.matches || d3_documentElement[d3_vendorSymbol(d3_documentElement, "matchesSelector")], d3_selectMatches = function(n, s) {
496
496
  return d3_selectMatcher.call(n, s);
497
497
  };
498
498
  if (typeof Sizzle === "function") {
@@ -627,7 +627,7 @@
627
627
  return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g");
628
628
  }
629
629
  function d3_selection_classes(name) {
630
- return name.trim().split(/^|\s+/);
630
+ return (name + "").trim().split(/^|\s+/);
631
631
  }
632
632
  function d3_selection_classed(name, value) {
633
633
  name = d3_selection_classes(name).map(d3_selection_classedName);
@@ -1089,12 +1089,27 @@
1089
1089
  d3.mouse = function(container) {
1090
1090
  return d3_mousePoint(container, d3_eventSource());
1091
1091
  };
1092
+ var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0;
1092
1093
  function d3_mousePoint(container, e) {
1093
1094
  if (e.changedTouches) e = e.changedTouches[0];
1094
1095
  var svg = container.ownerSVGElement || container;
1095
1096
  if (svg.createSVGPoint) {
1096
1097
  var point = svg.createSVGPoint();
1097
- point.x = e.clientX, point.y = e.clientY;
1098
+ if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) {
1099
+ svg = d3.select("body").append("svg").style({
1100
+ position: "absolute",
1101
+ top: 0,
1102
+ left: 0,
1103
+ margin: 0,
1104
+ padding: 0,
1105
+ border: "none"
1106
+ }, "important");
1107
+ var ctm = svg[0][0].getScreenCTM();
1108
+ d3_mouse_bug44083 = !(ctm.f || ctm.e);
1109
+ svg.remove();
1110
+ }
1111
+ if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX,
1112
+ point.y = e.clientY;
1098
1113
  point = point.matrixTransform(container.getScreenCTM().inverse());
1099
1114
  return [ point.x, point.y ];
1100
1115
  }
@@ -1212,9 +1227,9 @@
1212
1227
  x: 0,
1213
1228
  y: 0,
1214
1229
  k: 1
1215
- }, translate0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1;
1230
+ }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1;
1216
1231
  function zoom(g) {
1217
- g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on(mousemove, mousewheelreset).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1232
+ g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1218
1233
  }
1219
1234
  zoom.event = function(g) {
1220
1235
  g.each(function() {
@@ -1356,13 +1371,13 @@
1356
1371
  zoomed(dispatch);
1357
1372
  }
1358
1373
  function ended() {
1359
- subject.on(mousemove, d3_window === that ? mousewheelreset : null).on(mouseup, null);
1374
+ subject.on(mousemove, null).on(mouseup, null);
1360
1375
  dragRestore(dragged && d3.event.target === target);
1361
1376
  zoomended(dispatch);
1362
1377
  }
1363
1378
  }
1364
1379
  function touchstarted() {
1365
- var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, target = d3.select(d3.event.target).on(touchmove, moved).on(touchend, ended), subject = d3.select(that).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress();
1380
+ var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress();
1366
1381
  d3_selection_interrupt.call(that);
1367
1382
  started();
1368
1383
  zoomstarted(dispatch);
@@ -1375,6 +1390,9 @@
1375
1390
  return touches;
1376
1391
  }
1377
1392
  function started() {
1393
+ var target = d3.event.target;
1394
+ d3.select(target).on(touchmove, moved).on(touchend, ended);
1395
+ targets.push(target);
1378
1396
  var changed = d3.event.changedTouches;
1379
1397
  for (var i = 0, n = changed.length; i < n; ++i) {
1380
1398
  locations0[changed[i].identifier] = null;
@@ -1423,7 +1441,7 @@
1423
1441
  return void relocate();
1424
1442
  }
1425
1443
  }
1426
- target.on(zoomName, null);
1444
+ d3.selectAll(targets).on(zoomName, null);
1427
1445
  subject.on(mousedown, mousedowned).on(touchstart, touchstarted);
1428
1446
  dragRestore();
1429
1447
  zoomended(dispatch);
@@ -1431,22 +1449,17 @@
1431
1449
  }
1432
1450
  function mousewheeled() {
1433
1451
  var dispatch = event.of(this, arguments);
1434
- if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this),
1435
- zoomstarted(dispatch);
1452
+ if (mousewheelTimer) clearTimeout(mousewheelTimer); else translate0 = location(center0 = center || d3.mouse(this)),
1453
+ d3_selection_interrupt.call(this), zoomstarted(dispatch);
1436
1454
  mousewheelTimer = setTimeout(function() {
1437
1455
  mousewheelTimer = null;
1438
1456
  zoomended(dispatch);
1439
1457
  }, 50);
1440
1458
  d3_eventPreventDefault();
1441
- var point = center || d3.mouse(this);
1442
- if (!translate0) translate0 = location(point);
1443
1459
  scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k);
1444
- translateTo(point, translate0);
1460
+ translateTo(center0, translate0);
1445
1461
  zoomed(dispatch);
1446
1462
  }
1447
- function mousewheelreset() {
1448
- translate0 = null;
1449
- }
1450
1463
  function dblclicked() {
1451
1464
  var dispatch = event.of(this, arguments), p = d3.mouse(this), l = location(p), k = Math.log(view.k) / Math.LN2;
1452
1465
  zoomstarted(dispatch);
@@ -1465,29 +1478,23 @@
1465
1478
  }, "mousewheel") : (d3_behavior_zoomDelta = function() {
1466
1479
  return -d3.event.detail;
1467
1480
  }, "MozMousePixelScroll");
1468
- function d3_Color() {}
1469
- d3_Color.prototype.toString = function() {
1481
+ d3.color = d3_color;
1482
+ function d3_color() {}
1483
+ d3_color.prototype.toString = function() {
1470
1484
  return this.rgb() + "";
1471
1485
  };
1472
- d3.hsl = function(h, s, l) {
1473
- return arguments.length === 1 ? h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : d3_hsl(+h, +s, +l);
1474
- };
1486
+ d3.hsl = d3_hsl;
1475
1487
  function d3_hsl(h, s, l) {
1476
- return new d3_Hsl(h, s, l);
1488
+ return this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) : arguments.length < 2 ? h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : new d3_hsl(h, s, l);
1477
1489
  }
1478
- function d3_Hsl(h, s, l) {
1479
- this.h = h;
1480
- this.s = s;
1481
- this.l = l;
1482
- }
1483
- var d3_hslPrototype = d3_Hsl.prototype = new d3_Color();
1490
+ var d3_hslPrototype = d3_hsl.prototype = new d3_color();
1484
1491
  d3_hslPrototype.brighter = function(k) {
1485
1492
  k = Math.pow(.7, arguments.length ? k : 1);
1486
- return d3_hsl(this.h, this.s, this.l / k);
1493
+ return new d3_hsl(this.h, this.s, this.l / k);
1487
1494
  };
1488
1495
  d3_hslPrototype.darker = function(k) {
1489
1496
  k = Math.pow(.7, arguments.length ? k : 1);
1490
- return d3_hsl(this.h, this.s, k * this.l);
1497
+ return new d3_hsl(this.h, this.s, k * this.l);
1491
1498
  };
1492
1499
  d3_hslPrototype.rgb = function() {
1493
1500
  return d3_hsl_rgb(this.h, this.s, this.l);
@@ -1509,25 +1516,18 @@
1509
1516
  function vv(h) {
1510
1517
  return Math.round(v(h) * 255);
1511
1518
  }
1512
- return d3_rgb(vv(h + 120), vv(h), vv(h - 120));
1519
+ return new d3_rgb(vv(h + 120), vv(h), vv(h - 120));
1513
1520
  }
1514
- d3.hcl = function(h, c, l) {
1515
- return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l);
1516
- };
1521
+ d3.hcl = d3_hcl;
1517
1522
  function d3_hcl(h, c, l) {
1518
- return new d3_Hcl(h, c, l);
1519
- }
1520
- function d3_Hcl(h, c, l) {
1521
- this.h = h;
1522
- this.c = c;
1523
- this.l = l;
1523
+ return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) : arguments.length < 2 ? h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) : h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : new d3_hcl(h, c, l);
1524
1524
  }
1525
- var d3_hclPrototype = d3_Hcl.prototype = new d3_Color();
1525
+ var d3_hclPrototype = d3_hcl.prototype = new d3_color();
1526
1526
  d3_hclPrototype.brighter = function(k) {
1527
- return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));
1527
+ return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));
1528
1528
  };
1529
1529
  d3_hclPrototype.darker = function(k) {
1530
- return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));
1530
+ return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));
1531
1531
  };
1532
1532
  d3_hclPrototype.rgb = function() {
1533
1533
  return d3_hcl_lab(this.h, this.c, this.l).rgb();
@@ -1535,27 +1535,20 @@
1535
1535
  function d3_hcl_lab(h, c, l) {
1536
1536
  if (isNaN(h)) h = 0;
1537
1537
  if (isNaN(c)) c = 0;
1538
- return d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);
1538
+ return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);
1539
1539
  }
1540
- d3.lab = function(l, a, b) {
1541
- return arguments.length === 1 ? l instanceof d3_Lab ? d3_lab(l.l, l.a, l.b) : l instanceof d3_Hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3.rgb(l)).r, l.g, l.b) : d3_lab(+l, +a, +b);
1542
- };
1540
+ d3.lab = d3_lab;
1543
1541
  function d3_lab(l, a, b) {
1544
- return new d3_Lab(l, a, b);
1545
- }
1546
- function d3_Lab(l, a, b) {
1547
- this.l = l;
1548
- this.a = a;
1549
- this.b = b;
1542
+ return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b);
1550
1543
  }
1551
1544
  var d3_lab_K = 18;
1552
1545
  var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;
1553
- var d3_labPrototype = d3_Lab.prototype = new d3_Color();
1546
+ var d3_labPrototype = d3_lab.prototype = new d3_color();
1554
1547
  d3_labPrototype.brighter = function(k) {
1555
- return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1548
+ return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1556
1549
  };
1557
1550
  d3_labPrototype.darker = function(k) {
1558
- return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1551
+ return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1559
1552
  };
1560
1553
  d3_labPrototype.rgb = function() {
1561
1554
  return d3_lab_rgb(this.l, this.a, this.b);
@@ -1565,10 +1558,10 @@
1565
1558
  x = d3_lab_xyz(x) * d3_lab_X;
1566
1559
  y = d3_lab_xyz(y) * d3_lab_Y;
1567
1560
  z = d3_lab_xyz(z) * d3_lab_Z;
1568
- return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z));
1561
+ return new d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z));
1569
1562
  }
1570
1563
  function d3_lab_hcl(l, a, b) {
1571
- return l > 0 ? d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : d3_hcl(NaN, NaN, l);
1564
+ return l > 0 ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : new d3_hcl(NaN, NaN, l);
1572
1565
  }
1573
1566
  function d3_lab_xyz(x) {
1574
1567
  return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;
@@ -1579,36 +1572,29 @@
1579
1572
  function d3_xyz_rgb(r) {
1580
1573
  return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055));
1581
1574
  }
1582
- d3.rgb = function(r, g, b) {
1583
- return arguments.length === 1 ? r instanceof d3_Rgb ? d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : d3_rgb(~~r, ~~g, ~~b);
1584
- };
1575
+ d3.rgb = d3_rgb;
1576
+ function d3_rgb(r, g, b) {
1577
+ return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) : arguments.length < 2 ? r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : new d3_rgb(r, g, b);
1578
+ }
1585
1579
  function d3_rgbNumber(value) {
1586
- return d3_rgb(value >> 16, value >> 8 & 255, value & 255);
1580
+ return new d3_rgb(value >> 16, value >> 8 & 255, value & 255);
1587
1581
  }
1588
1582
  function d3_rgbString(value) {
1589
1583
  return d3_rgbNumber(value) + "";
1590
1584
  }
1591
- function d3_rgb(r, g, b) {
1592
- return new d3_Rgb(r, g, b);
1593
- }
1594
- function d3_Rgb(r, g, b) {
1595
- this.r = r;
1596
- this.g = g;
1597
- this.b = b;
1598
- }
1599
- var d3_rgbPrototype = d3_Rgb.prototype = new d3_Color();
1585
+ var d3_rgbPrototype = d3_rgb.prototype = new d3_color();
1600
1586
  d3_rgbPrototype.brighter = function(k) {
1601
1587
  k = Math.pow(.7, arguments.length ? k : 1);
1602
1588
  var r = this.r, g = this.g, b = this.b, i = 30;
1603
- if (!r && !g && !b) return d3_rgb(i, i, i);
1589
+ if (!r && !g && !b) return new d3_rgb(i, i, i);
1604
1590
  if (r && r < i) r = i;
1605
1591
  if (g && g < i) g = i;
1606
1592
  if (b && b < i) b = i;
1607
- return d3_rgb(Math.min(255, ~~(r / k)), Math.min(255, ~~(g / k)), Math.min(255, ~~(b / k)));
1593
+ return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k));
1608
1594
  };
1609
1595
  d3_rgbPrototype.darker = function(k) {
1610
1596
  k = Math.pow(.7, arguments.length ? k : 1);
1611
- return d3_rgb(~~(k * this.r), ~~(k * this.g), ~~(k * this.b));
1597
+ return new d3_rgb(k * this.r, k * this.g, k * this.b);
1612
1598
  };
1613
1599
  d3_rgbPrototype.hsl = function() {
1614
1600
  return d3_rgb_hsl(this.r, this.g, this.b);
@@ -1663,7 +1649,7 @@
1663
1649
  h = NaN;
1664
1650
  s = l > 0 && l < 1 ? 0 : h;
1665
1651
  }
1666
- return d3_hsl(h, s, l);
1652
+ return new d3_hsl(h, s, l);
1667
1653
  }
1668
1654
  function d3_rgb_lab(r, g, b) {
1669
1655
  r = d3_rgb_xyz(r);
@@ -1843,7 +1829,7 @@
1843
1829
  d3.xhr = d3_xhrType(d3_identity);
1844
1830
  function d3_xhrType(response) {
1845
1831
  return function(url, mimeType, callback) {
1846
- if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType,
1832
+ if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType,
1847
1833
  mimeType = null;
1848
1834
  return d3_xhr(url, mimeType, response, callback);
1849
1835
  };
@@ -2031,7 +2017,7 @@
2031
2017
  return dsv;
2032
2018
  };
2033
2019
  d3.csv = d3.dsv(",", "text/csv");
2034
- d3.tsv = d3.dsv(" ", "text/tab-separated-values");
2020
+ d3.tsv = d3.dsv(" ", "text/tab-separated-values");
2035
2021
  d3.touch = function(container, touches, identifier) {
2036
2022
  if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches;
2037
2023
  if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) {
@@ -2675,7 +2661,7 @@
2675
2661
  return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;
2676
2662
  }
2677
2663
  function d3_time_parseZone(date, string, i) {
2678
- return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5)) ? (date.Z = +string,
2664
+ return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5)) ? (date.Z = -string,
2679
2665
  i + 5) : -1;
2680
2666
  }
2681
2667
  function d3_time_expandYear(d) {
@@ -2868,7 +2854,7 @@
2868
2854
  var λ00, φ00, λ0, cosφ0, sinφ0;
2869
2855
  d3_geo_area.point = function(λ, φ) {
2870
2856
  d3_geo_area.point = nextPoint;
2871
- λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4),
2857
+ λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4),
2872
2858
  sinφ0 = Math.sin(φ);
2873
2859
  };
2874
2860
  function nextPoint(λ, φ) {
@@ -3224,7 +3210,6 @@
3224
3210
  clip.lineEnd = ringEnd;
3225
3211
  segments = [];
3226
3212
  polygon = [];
3227
- listener.polygonStart();
3228
3213
  },
3229
3214
  polygonEnd: function() {
3230
3215
  clip.point = point;
@@ -3233,13 +3218,15 @@
3233
3218
  segments = d3.merge(segments);
3234
3219
  var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon);
3235
3220
  if (segments.length) {
3221
+ if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3236
3222
  d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener);
3237
3223
  } else if (clipStartInside) {
3224
+ if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3238
3225
  listener.lineStart();
3239
3226
  interpolate(null, null, 1, listener);
3240
3227
  listener.lineEnd();
3241
3228
  }
3242
- listener.polygonEnd();
3229
+ if (polygonStarted) listener.polygonEnd(), polygonStarted = false;
3243
3230
  segments = polygon = null;
3244
3231
  },
3245
3232
  sphere: function() {
@@ -3267,7 +3254,7 @@
3267
3254
  line.lineEnd();
3268
3255
  }
3269
3256
  var segments;
3270
- var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygon, ring;
3257
+ var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring;
3271
3258
  function pointRing(λ, φ) {
3272
3259
  ring.push([ λ, φ ]);
3273
3260
  var point = rotate(λ, φ);
@@ -3288,9 +3275,12 @@
3288
3275
  if (clean & 1) {
3289
3276
  segment = ringSegments[0];
3290
3277
  var n = segment.length - 1, i = -1, point;
3291
- listener.lineStart();
3292
- while (++i < n) listener.point((point = segment[i])[0], point[1]);
3293
- listener.lineEnd();
3278
+ if (n > 0) {
3279
+ if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3280
+ listener.lineStart();
3281
+ while (++i < n) listener.point((point = segment[i])[0], point[1]);
3282
+ listener.lineEnd();
3283
+ }
3294
3284
  return;
3295
3285
  }
3296
3286
  if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
@@ -4690,13 +4680,13 @@
4690
4680
  (d3.geo.transverseMercator = function() {
4691
4681
  var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate;
4692
4682
  projection.center = function(_) {
4693
- return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ -_[1], _[0] ]);
4683
+ return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]);
4694
4684
  };
4695
4685
  projection.rotate = function(_) {
4696
- return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(),
4686
+ return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(),
4697
4687
  [ _[0], _[1], _[2] - 90 ]);
4698
4688
  };
4699
- return projection.rotate([ 0, 0 ]);
4689
+ return rotate([ 0, 0, 90 ]);
4700
4690
  }).raw = d3_geo_transverseMercator;
4701
4691
  d3.geom = {};
4702
4692
  function d3_geom_pointX(d) {
@@ -5544,7 +5534,7 @@
5544
5534
  };
5545
5535
  quadtree.extent = function(_) {
5546
5536
  if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ];
5547
- if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0],
5537
+ if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0],
5548
5538
  y2 = +_[1][1];
5549
5539
  return quadtree;
5550
5540
  };
@@ -5617,71 +5607,38 @@
5617
5607
  }
5618
5608
  d3.interpolateString = d3_interpolateString;
5619
5609
  function d3_interpolateString(a, b) {
5620
- var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o;
5610
+ var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = [];
5621
5611
  a = a + "", b = b + "";
5622
- d3_interpolate_number.lastIndex = 0;
5623
- for (i = 0; m = d3_interpolate_number.exec(b); ++i) {
5624
- if (m.index) s.push(b.substring(s0, s1 = m.index));
5625
- q.push({
5626
- i: s.length,
5627
- x: m[0]
5628
- });
5629
- s.push(null);
5630
- s0 = d3_interpolate_number.lastIndex;
5631
- }
5632
- if (s0 < b.length) s.push(b.substring(s0));
5633
- for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) {
5634
- o = q[i];
5635
- if (o.x == m[0]) {
5636
- if (o.i) {
5637
- if (s[o.i + 1] == null) {
5638
- s[o.i - 1] += o.x;
5639
- s.splice(o.i, 1);
5640
- for (j = i + 1; j < n; ++j) q[j].i--;
5641
- } else {
5642
- s[o.i - 1] += o.x + s[o.i + 1];
5643
- s.splice(o.i, 2);
5644
- for (j = i + 1; j < n; ++j) q[j].i -= 2;
5645
- }
5646
- } else {
5647
- if (s[o.i + 1] == null) {
5648
- s[o.i] = o.x;
5649
- } else {
5650
- s[o.i] = o.x + s[o.i + 1];
5651
- s.splice(o.i + 1, 1);
5652
- for (j = i + 1; j < n; ++j) q[j].i--;
5653
- }
5654
- }
5655
- q.splice(i, 1);
5656
- n--;
5657
- i--;
5658
- } else {
5659
- o.x = d3_interpolateNumber(parseFloat(m[0]), parseFloat(o.x));
5612
+ while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) {
5613
+ if ((bs = bm.index) > bi) {
5614
+ bs = b.substring(bi, bs);
5615
+ if (s[i]) s[i] += bs; else s[++i] = bs;
5660
5616
  }
5661
- }
5662
- while (i < n) {
5663
- o = q.pop();
5664
- if (s[o.i + 1] == null) {
5665
- s[o.i] = o.x;
5617
+ if ((am = am[0]) === (bm = bm[0])) {
5618
+ if (s[i]) s[i] += bm; else s[++i] = bm;
5666
5619
  } else {
5667
- s[o.i] = o.x + s[o.i + 1];
5668
- s.splice(o.i + 1, 1);
5620
+ s[++i] = null;
5621
+ q.push({
5622
+ i: i,
5623
+ x: d3_interpolateNumber(am, bm)
5624
+ });
5669
5625
  }
5670
- n--;
5626
+ bi = d3_interpolate_numberB.lastIndex;
5671
5627
  }
5672
- if (s.length === 1) {
5673
- return s[0] == null ? (o = q[0].x, function(t) {
5674
- return o(t) + "";
5675
- }) : function() {
5676
- return b;
5677
- };
5628
+ if (bi < b.length) {
5629
+ bs = b.substring(bi);
5630
+ if (s[i]) s[i] += bs; else s[++i] = bs;
5678
5631
  }
5679
- return function(t) {
5680
- for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t);
5632
+ return s.length < 2 ? q[0] ? (b = q[0].x, function(t) {
5633
+ return b(t) + "";
5634
+ }) : function() {
5635
+ return b;
5636
+ } : (b = q.length, function(t) {
5637
+ for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
5681
5638
  return s.join("");
5682
- };
5639
+ });
5683
5640
  }
5684
- var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
5641
+ var d3_interpolate_numberA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, "g");
5685
5642
  d3.interpolate = d3_interpolate;
5686
5643
  function d3_interpolate(a, b) {
5687
5644
  var i = d3.interpolators.length, f;
@@ -5690,7 +5647,7 @@
5690
5647
  }
5691
5648
  d3.interpolators = [ function(a, b) {
5692
5649
  var t = typeof b;
5693
- return (t === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_Color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === "object" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b);
5650
+ return (t === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === "object" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b);
5694
5651
  } ];
5695
5652
  d3.interpolateArray = d3_interpolateArray;
5696
5653
  function d3_interpolateArray(a, b) {
@@ -6361,41 +6318,30 @@
6361
6318
  var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity;
6362
6319
  d3.layout.hierarchy = function() {
6363
6320
  var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue;
6364
- function recurse(node, depth, nodes) {
6365
- var childs = children.call(hierarchy, node, depth);
6366
- node.depth = depth;
6367
- nodes.push(node);
6368
- if (childs && (n = childs.length)) {
6369
- var i = -1, n, c = node.children = new Array(n), v = 0, j = depth + 1, d;
6370
- while (++i < n) {
6371
- d = c[i] = recurse(childs[i], j, nodes);
6372
- d.parent = node;
6373
- v += d.value;
6374
- }
6375
- if (sort) c.sort(sort);
6376
- if (value) node.value = v;
6377
- } else {
6378
- delete node.children;
6379
- if (value) {
6380
- node.value = +value.call(hierarchy, node, depth) || 0;
6321
+ function hierarchy(root) {
6322
+ var stack = [ root ], nodes = [], node;
6323
+ root.depth = 0;
6324
+ while ((node = stack.pop()) != null) {
6325
+ nodes.push(node);
6326
+ if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) {
6327
+ var n, childs, child;
6328
+ while (--n >= 0) {
6329
+ stack.push(child = childs[n]);
6330
+ child.parent = node;
6331
+ child.depth = node.depth + 1;
6332
+ }
6333
+ if (value) node.value = 0;
6334
+ node.children = childs;
6335
+ } else {
6336
+ if (value) node.value = +value.call(hierarchy, node, node.depth) || 0;
6337
+ delete node.children;
6381
6338
  }
6382
6339
  }
6383
- return node;
6384
- }
6385
- function revalue(node, depth) {
6386
- var children = node.children, v = 0;
6387
- if (children && (n = children.length)) {
6388
- var i = -1, n, j = depth + 1;
6389
- while (++i < n) v += revalue(children[i], j);
6390
- } else if (value) {
6391
- v = +value.call(hierarchy, node, depth) || 0;
6392
- }
6393
- if (value) node.value = v;
6394
- return v;
6395
- }
6396
- function hierarchy(d) {
6397
- var nodes = [];
6398
- recurse(d, 0, nodes);
6340
+ d3_layout_hierarchyVisitAfter(root, function(node) {
6341
+ var childs, parent;
6342
+ if (sort && (childs = node.children)) childs.sort(sort);
6343
+ if (value && (parent = node.parent)) parent.value += node.value;
6344
+ });
6399
6345
  return nodes;
6400
6346
  }
6401
6347
  hierarchy.sort = function(x) {
@@ -6414,7 +6360,16 @@
6414
6360
  return hierarchy;
6415
6361
  };
6416
6362
  hierarchy.revalue = function(root) {
6417
- revalue(root, 0);
6363
+ if (value) {
6364
+ d3_layout_hierarchyVisitBefore(root, function(node) {
6365
+ if (node.children) node.value = 0;
6366
+ });
6367
+ d3_layout_hierarchyVisitAfter(root, function(node) {
6368
+ var parent;
6369
+ if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;
6370
+ if (parent = node.parent) parent.value += node.value;
6371
+ });
6372
+ }
6418
6373
  return root;
6419
6374
  };
6420
6375
  return hierarchy;
@@ -6425,6 +6380,29 @@
6425
6380
  object.links = d3_layout_hierarchyLinks;
6426
6381
  return object;
6427
6382
  }
6383
+ function d3_layout_hierarchyVisitBefore(node, callback) {
6384
+ var nodes = [ node ];
6385
+ while ((node = nodes.pop()) != null) {
6386
+ callback(node);
6387
+ if ((children = node.children) && (n = children.length)) {
6388
+ var n, children;
6389
+ while (--n >= 0) nodes.push(children[n]);
6390
+ }
6391
+ }
6392
+ }
6393
+ function d3_layout_hierarchyVisitAfter(node, callback) {
6394
+ var nodes = [ node ], nodes2 = [];
6395
+ while ((node = nodes.pop()) != null) {
6396
+ nodes2.push(node);
6397
+ if ((children = node.children) && (n = children.length)) {
6398
+ var i = -1, n, children;
6399
+ while (++i < n) nodes.push(children[i]);
6400
+ }
6401
+ }
6402
+ while ((node = nodes2.pop()) != null) {
6403
+ callback(node);
6404
+ }
6405
+ }
6428
6406
  function d3_layout_hierarchyChildren(d) {
6429
6407
  return d.children;
6430
6408
  }
@@ -6740,185 +6718,6 @@
6740
6718
  function d3_layout_histogramRange(values) {
6741
6719
  return [ d3.min(values), d3.max(values) ];
6742
6720
  }
6743
- d3.layout.tree = function() {
6744
- var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;
6745
- function tree(d, i) {
6746
- var nodes = hierarchy.call(this, d, i), root = nodes[0];
6747
- function firstWalk(node, previousSibling) {
6748
- var children = node.children, layout = node._tree;
6749
- if (children && (n = children.length)) {
6750
- var n, firstChild = children[0], previousChild, ancestor = firstChild, child, i = -1;
6751
- while (++i < n) {
6752
- child = children[i];
6753
- firstWalk(child, previousChild);
6754
- ancestor = apportion(child, previousChild, ancestor);
6755
- previousChild = child;
6756
- }
6757
- d3_layout_treeShift(node);
6758
- var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim);
6759
- if (previousSibling) {
6760
- layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
6761
- layout.mod = layout.prelim - midpoint;
6762
- } else {
6763
- layout.prelim = midpoint;
6764
- }
6765
- } else {
6766
- if (previousSibling) {
6767
- layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
6768
- }
6769
- }
6770
- }
6771
- function secondWalk(node, x) {
6772
- node.x = node._tree.prelim + x;
6773
- var children = node.children;
6774
- if (children && (n = children.length)) {
6775
- var i = -1, n;
6776
- x += node._tree.mod;
6777
- while (++i < n) {
6778
- secondWalk(children[i], x);
6779
- }
6780
- }
6781
- }
6782
- function apportion(node, previousSibling, ancestor) {
6783
- if (previousSibling) {
6784
- var vip = node, vop = node, vim = previousSibling, vom = node.parent.children[0], sip = vip._tree.mod, sop = vop._tree.mod, sim = vim._tree.mod, som = vom._tree.mod, shift;
6785
- while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
6786
- vom = d3_layout_treeLeft(vom);
6787
- vop = d3_layout_treeRight(vop);
6788
- vop._tree.ancestor = node;
6789
- shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip);
6790
- if (shift > 0) {
6791
- d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift);
6792
- sip += shift;
6793
- sop += shift;
6794
- }
6795
- sim += vim._tree.mod;
6796
- sip += vip._tree.mod;
6797
- som += vom._tree.mod;
6798
- sop += vop._tree.mod;
6799
- }
6800
- if (vim && !d3_layout_treeRight(vop)) {
6801
- vop._tree.thread = vim;
6802
- vop._tree.mod += sim - sop;
6803
- }
6804
- if (vip && !d3_layout_treeLeft(vom)) {
6805
- vom._tree.thread = vip;
6806
- vom._tree.mod += sip - som;
6807
- ancestor = node;
6808
- }
6809
- }
6810
- return ancestor;
6811
- }
6812
- d3_layout_treeVisitAfter(root, function(node, previousSibling) {
6813
- node._tree = {
6814
- ancestor: node,
6815
- prelim: 0,
6816
- mod: 0,
6817
- change: 0,
6818
- shift: 0,
6819
- number: previousSibling ? previousSibling._tree.number + 1 : 0
6820
- };
6821
- });
6822
- firstWalk(root);
6823
- secondWalk(root, -root._tree.prelim);
6824
- var left = d3_layout_treeSearch(root, d3_layout_treeLeftmost), right = d3_layout_treeSearch(root, d3_layout_treeRightmost), deep = d3_layout_treeSearch(root, d3_layout_treeDeepest), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2, y1 = deep.depth || 1;
6825
- d3_layout_treeVisitAfter(root, nodeSize ? function(node) {
6826
- node.x *= size[0];
6827
- node.y = node.depth * size[1];
6828
- delete node._tree;
6829
- } : function(node) {
6830
- node.x = (node.x - x0) / (x1 - x0) * size[0];
6831
- node.y = node.depth / y1 * size[1];
6832
- delete node._tree;
6833
- });
6834
- return nodes;
6835
- }
6836
- tree.separation = function(x) {
6837
- if (!arguments.length) return separation;
6838
- separation = x;
6839
- return tree;
6840
- };
6841
- tree.size = function(x) {
6842
- if (!arguments.length) return nodeSize ? null : size;
6843
- nodeSize = (size = x) == null;
6844
- return tree;
6845
- };
6846
- tree.nodeSize = function(x) {
6847
- if (!arguments.length) return nodeSize ? size : null;
6848
- nodeSize = (size = x) != null;
6849
- return tree;
6850
- };
6851
- return d3_layout_hierarchyRebind(tree, hierarchy);
6852
- };
6853
- function d3_layout_treeSeparation(a, b) {
6854
- return a.parent == b.parent ? 1 : 2;
6855
- }
6856
- function d3_layout_treeLeft(node) {
6857
- var children = node.children;
6858
- return children && children.length ? children[0] : node._tree.thread;
6859
- }
6860
- function d3_layout_treeRight(node) {
6861
- var children = node.children, n;
6862
- return children && (n = children.length) ? children[n - 1] : node._tree.thread;
6863
- }
6864
- function d3_layout_treeSearch(node, compare) {
6865
- var children = node.children;
6866
- if (children && (n = children.length)) {
6867
- var child, n, i = -1;
6868
- while (++i < n) {
6869
- if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) {
6870
- node = child;
6871
- }
6872
- }
6873
- }
6874
- return node;
6875
- }
6876
- function d3_layout_treeRightmost(a, b) {
6877
- return a.x - b.x;
6878
- }
6879
- function d3_layout_treeLeftmost(a, b) {
6880
- return b.x - a.x;
6881
- }
6882
- function d3_layout_treeDeepest(a, b) {
6883
- return a.depth - b.depth;
6884
- }
6885
- function d3_layout_treeVisitAfter(node, callback) {
6886
- function visit(node, previousSibling) {
6887
- var children = node.children;
6888
- if (children && (n = children.length)) {
6889
- var child, previousChild = null, i = -1, n;
6890
- while (++i < n) {
6891
- child = children[i];
6892
- visit(child, previousChild);
6893
- previousChild = child;
6894
- }
6895
- }
6896
- callback(node, previousSibling);
6897
- }
6898
- visit(node, null);
6899
- }
6900
- function d3_layout_treeShift(node) {
6901
- var shift = 0, change = 0, children = node.children, i = children.length, child;
6902
- while (--i >= 0) {
6903
- child = children[i]._tree;
6904
- child.prelim += shift;
6905
- child.mod += shift;
6906
- shift += child.shift + (change += child.change);
6907
- }
6908
- }
6909
- function d3_layout_treeMove(ancestor, node, shift) {
6910
- ancestor = ancestor._tree;
6911
- node = node._tree;
6912
- var change = shift / (node.number - ancestor.number);
6913
- ancestor.change += change;
6914
- node.change -= change;
6915
- node.shift += shift;
6916
- node.prelim += shift;
6917
- node.mod += shift;
6918
- }
6919
- function d3_layout_treeAncestor(vim, node, ancestor) {
6920
- return vim._tree.ancestor.parent == node.parent ? vim._tree.ancestor : ancestor;
6921
- }
6922
6721
  d3.layout.pack = function() {
6923
6722
  var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius;
6924
6723
  function pack(d, i) {
@@ -6926,17 +6725,17 @@
6926
6725
  return radius;
6927
6726
  };
6928
6727
  root.x = root.y = 0;
6929
- d3_layout_treeVisitAfter(root, function(d) {
6728
+ d3_layout_hierarchyVisitAfter(root, function(d) {
6930
6729
  d.r = +r(d.value);
6931
6730
  });
6932
- d3_layout_treeVisitAfter(root, d3_layout_packSiblings);
6731
+ d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
6933
6732
  if (padding) {
6934
6733
  var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2;
6935
- d3_layout_treeVisitAfter(root, function(d) {
6734
+ d3_layout_hierarchyVisitAfter(root, function(d) {
6936
6735
  d.r += dr;
6937
6736
  });
6938
- d3_layout_treeVisitAfter(root, d3_layout_packSiblings);
6939
- d3_layout_treeVisitAfter(root, function(d) {
6737
+ d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
6738
+ d3_layout_hierarchyVisitAfter(root, function(d) {
6940
6739
  d.r -= dr;
6941
6740
  });
6942
6741
  }
@@ -7073,11 +6872,158 @@
7073
6872
  c.y = a.y;
7074
6873
  }
7075
6874
  }
6875
+ d3.layout.tree = function() {
6876
+ var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null;
6877
+ function tree(d, i) {
6878
+ var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0);
6879
+ d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z;
6880
+ d3_layout_hierarchyVisitBefore(root1, secondWalk);
6881
+ if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else {
6882
+ var left = root0, right = root0, bottom = root0;
6883
+ d3_layout_hierarchyVisitBefore(root0, function(node) {
6884
+ if (node.x < left.x) left = node;
6885
+ if (node.x > right.x) right = node;
6886
+ if (node.depth > bottom.depth) bottom = node;
6887
+ });
6888
+ var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1);
6889
+ d3_layout_hierarchyVisitBefore(root0, function(node) {
6890
+ node.x = (node.x + tx) * kx;
6891
+ node.y = node.depth * ky;
6892
+ });
6893
+ }
6894
+ return nodes;
6895
+ }
6896
+ function wrapTree(root0) {
6897
+ var root1 = {
6898
+ A: null,
6899
+ children: [ root0 ]
6900
+ }, queue = [ root1 ], node1;
6901
+ while ((node1 = queue.pop()) != null) {
6902
+ for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) {
6903
+ queue.push((children[i] = child = {
6904
+ _: children[i],
6905
+ parent: node1,
6906
+ children: (child = children[i].children) && child.slice() || [],
6907
+ A: null,
6908
+ a: null,
6909
+ z: 0,
6910
+ m: 0,
6911
+ c: 0,
6912
+ s: 0,
6913
+ t: null,
6914
+ i: i
6915
+ }).a = child);
6916
+ }
6917
+ }
6918
+ return root1.children[0];
6919
+ }
6920
+ function firstWalk(v) {
6921
+ var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;
6922
+ if (children.length) {
6923
+ d3_layout_treeShift(v);
6924
+ var midpoint = (children[0].z + children[children.length - 1].z) / 2;
6925
+ if (w) {
6926
+ v.z = w.z + separation(v._, w._);
6927
+ v.m = v.z - midpoint;
6928
+ } else {
6929
+ v.z = midpoint;
6930
+ }
6931
+ } else if (w) {
6932
+ v.z = w.z + separation(v._, w._);
6933
+ }
6934
+ v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
6935
+ }
6936
+ function secondWalk(v) {
6937
+ v._.x = v.z + v.parent.m;
6938
+ v.m += v.parent.m;
6939
+ }
6940
+ function apportion(v, w, ancestor) {
6941
+ if (w) {
6942
+ var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift;
6943
+ while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
6944
+ vom = d3_layout_treeLeft(vom);
6945
+ vop = d3_layout_treeRight(vop);
6946
+ vop.a = v;
6947
+ shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
6948
+ if (shift > 0) {
6949
+ d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift);
6950
+ sip += shift;
6951
+ sop += shift;
6952
+ }
6953
+ sim += vim.m;
6954
+ sip += vip.m;
6955
+ som += vom.m;
6956
+ sop += vop.m;
6957
+ }
6958
+ if (vim && !d3_layout_treeRight(vop)) {
6959
+ vop.t = vim;
6960
+ vop.m += sim - sop;
6961
+ }
6962
+ if (vip && !d3_layout_treeLeft(vom)) {
6963
+ vom.t = vip;
6964
+ vom.m += sip - som;
6965
+ ancestor = v;
6966
+ }
6967
+ }
6968
+ return ancestor;
6969
+ }
6970
+ function sizeNode(node) {
6971
+ node.x *= size[0];
6972
+ node.y = node.depth * size[1];
6973
+ }
6974
+ tree.separation = function(x) {
6975
+ if (!arguments.length) return separation;
6976
+ separation = x;
6977
+ return tree;
6978
+ };
6979
+ tree.size = function(x) {
6980
+ if (!arguments.length) return nodeSize ? null : size;
6981
+ nodeSize = (size = x) == null ? sizeNode : null;
6982
+ return tree;
6983
+ };
6984
+ tree.nodeSize = function(x) {
6985
+ if (!arguments.length) return nodeSize ? size : null;
6986
+ nodeSize = (size = x) == null ? null : sizeNode;
6987
+ return tree;
6988
+ };
6989
+ return d3_layout_hierarchyRebind(tree, hierarchy);
6990
+ };
6991
+ function d3_layout_treeSeparation(a, b) {
6992
+ return a.parent == b.parent ? 1 : 2;
6993
+ }
6994
+ function d3_layout_treeLeft(v) {
6995
+ var children = v.children;
6996
+ return children.length ? children[0] : v.t;
6997
+ }
6998
+ function d3_layout_treeRight(v) {
6999
+ var children = v.children, n;
7000
+ return (n = children.length) ? children[n - 1] : v.t;
7001
+ }
7002
+ function d3_layout_treeMove(wm, wp, shift) {
7003
+ var change = shift / (wp.i - wm.i);
7004
+ wp.c -= change;
7005
+ wp.s += shift;
7006
+ wm.c += change;
7007
+ wp.z += shift;
7008
+ wp.m += shift;
7009
+ }
7010
+ function d3_layout_treeShift(v) {
7011
+ var shift = 0, change = 0, children = v.children, i = children.length, w;
7012
+ while (--i >= 0) {
7013
+ w = children[i];
7014
+ w.z += shift;
7015
+ w.m += shift;
7016
+ shift += w.s + (change += w.c);
7017
+ }
7018
+ }
7019
+ function d3_layout_treeAncestor(vim, v, ancestor) {
7020
+ return vim.a.parent === v.parent ? vim.a : ancestor;
7021
+ }
7076
7022
  d3.layout.cluster = function() {
7077
7023
  var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;
7078
7024
  function cluster(d, i) {
7079
7025
  var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0;
7080
- d3_layout_treeVisitAfter(root, function(node) {
7026
+ d3_layout_hierarchyVisitAfter(root, function(node) {
7081
7027
  var children = node.children;
7082
7028
  if (children && children.length) {
7083
7029
  node.x = d3_layout_clusterX(children);
@@ -7089,7 +7035,7 @@
7089
7035
  }
7090
7036
  });
7091
7037
  var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2;
7092
- d3_layout_treeVisitAfter(root, nodeSize ? function(node) {
7038
+ d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) {
7093
7039
  node.x = (node.x - root.x) * size[0];
7094
7040
  node.y = (root.y - node.y) * size[1];
7095
7041
  } : function(node) {
@@ -7254,7 +7200,7 @@
7254
7200
  return d3_layout_treemapPad(node, x);
7255
7201
  }
7256
7202
  var type;
7257
- pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ],
7203
+ pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ],
7258
7204
  padConstant) : padConstant;
7259
7205
  return treemap;
7260
7206
  };
@@ -7554,7 +7500,7 @@
7554
7500
  scale.tickFormat = function(n, format) {
7555
7501
  if (!arguments.length) return d3_scale_logFormat;
7556
7502
  if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format);
7557
- var k = Math.max(.1, n / scale.ticks().length), f = positive ? (e = 1e-12, Math.ceil) : (e = -1e-12,
7503
+ var k = Math.max(.1, n / scale.ticks().length), f = positive ? (e = 1e-12, Math.ceil) : (e = -1e-12,
7558
7504
  Math.floor), e;
7559
7505
  return function(d) {
7560
7506
  return d / pow(f(log(d) + e)) <= k ? format(d) : "";
@@ -7732,9 +7678,7 @@
7732
7678
  }
7733
7679
  scale.domain = function(x) {
7734
7680
  if (!arguments.length) return domain;
7735
- domain = x.filter(function(d) {
7736
- return !isNaN(d);
7737
- }).sort(d3_ascending);
7681
+ domain = x.filter(d3_number).sort(d3_ascending);
7738
7682
  return rescale();
7739
7683
  };
7740
7684
  scale.range = function(x) {
@@ -7842,7 +7786,7 @@
7842
7786
  d3.svg.arc = function() {
7843
7787
  var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;
7844
7788
  function arc() {
7845
- var r0 = innerRadius.apply(this, arguments), r1 = outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset, a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset, da = (a1 < a0 && (da = a0,
7789
+ var r0 = innerRadius.apply(this, arguments), r1 = outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset, a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset, da = (a1 < a0 && (da = a0,
7846
7790
  a0 = a1, a1 = da), a1 - a0), df = da < π ? "0" : "1", c0 = Math.cos(a0), s0 = Math.sin(a0), c1 = Math.cos(a1), s1 = Math.sin(a1);
7847
7791
  return da >= d3_svg_arcMax ? r0 ? "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "M0," + r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + -r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + r0 + "Z" : "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "Z" : r0 ? "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L" + r0 * c1 + "," + r0 * s1 + "A" + r0 + "," + r0 + " 0 " + df + ",0 " + r0 * c0 + "," + r0 * s0 + "Z" : "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L0,0" + "Z";
7848
7792
  }
@@ -7978,7 +7922,7 @@
7978
7922
  return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), d3_svg_lineCardinalTangents(points, tension));
7979
7923
  }
7980
7924
  function d3_svg_lineCardinalClosed(points, tension) {
7981
- return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]),
7925
+ return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]),
7982
7926
  points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));
7983
7927
  }
7984
7928
  function d3_svg_lineCardinal(points, tension) {
@@ -8684,7 +8628,7 @@
8684
8628
  var g = d3.select(this);
8685
8629
  var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy();
8686
8630
  var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickTransform;
8687
- var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"),
8631
+ var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"),
8688
8632
  d3.transition(path));
8689
8633
  tickEnter.append("line");
8690
8634
  tickEnter.append("text");
@@ -9284,11 +9228,6 @@
9284
9228
  d3.xml = d3_xhrType(function(request) {
9285
9229
  return request.responseXML;
9286
9230
  });
9287
- if (typeof define === "function" && define.amd) {
9288
- define(d3);
9289
- } else if (typeof module === "object" && module.exports) {
9290
- module.exports = d3;
9291
- } else {
9292
- this.d3 = d3;
9293
- }
9231
+ if (typeof define === "function" && define.amd) define(d3); else if (typeof module === "object" && module.exports) module.exports = d3;
9232
+ this.d3 = d3;
9294
9233
  }();