d3_rails 3.4.13 → 3.5.0

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: 9d37fd1b298532d28388dc70dcbb683601833dd4
4
- data.tar.gz: 6d741120dd5ae4616e53ac4e073bddfd7f04aac3
3
+ metadata.gz: a3c1b5612085cc931ddb1a304812dca6b03ab907
4
+ data.tar.gz: 24def8bb3a67b29435e956781aa8141b39d4632a
5
5
  SHA512:
6
- metadata.gz: 9abc200f85d156050e5f9d978c29d9f73767ec2a1aad4830a2c0b429d98385a3d2f5c905764a6334b426982ad9e1dfb4aaa5c89acbf2e1c286c1384869eccab4
7
- data.tar.gz: a26d3cff8f3dac03d478d9b53a7963b771728d5709583a735897303bbe7aea5c5ab8d6fe533318738b8fa6ddf146019991a29a5bc1eebfe7e91be16534307f44
6
+ metadata.gz: ad5e60edf6504a84bf5135e3344599b5b4ab49dd2fae46cd992706f0d9f9d7646116b6857e2ddef30e749451d6bf880c8080f9a15a5bb87ce92d1fe7728b616d
7
+ data.tar.gz: 96203f6f6167d24980683526f6efaa141fa568d8351ec350b1a2c30bd740b612b42130b0aec9e4d26232b5c588c7dfa8a69d174287b7c6ebf607a0df3687480a
@@ -1,6 +1,6 @@
1
1
  !function() {
2
2
  var d3 = {
3
- version: "3.4.13"
3
+ version: "3.5.0"
4
4
  };
5
5
  if (!Date.now) Date.now = function() {
6
6
  return +new Date();
@@ -42,10 +42,16 @@
42
42
  d3.min = function(array, f) {
43
43
  var i = -1, n = array.length, a, b;
44
44
  if (arguments.length === 1) {
45
- while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined;
45
+ while (++i < n) if ((b = array[i]) != null && b >= b) {
46
+ a = b;
47
+ break;
48
+ }
46
49
  while (++i < n) if ((b = array[i]) != null && a > b) a = b;
47
50
  } else {
48
- while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
51
+ while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
52
+ a = b;
53
+ break;
54
+ }
49
55
  while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
50
56
  }
51
57
  return a;
@@ -53,10 +59,16 @@
53
59
  d3.max = function(array, f) {
54
60
  var i = -1, n = array.length, a, b;
55
61
  if (arguments.length === 1) {
56
- while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined;
62
+ while (++i < n) if ((b = array[i]) != null && b >= b) {
63
+ a = b;
64
+ break;
65
+ }
57
66
  while (++i < n) if ((b = array[i]) != null && b > a) a = b;
58
67
  } else {
59
- while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
68
+ while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
69
+ a = b;
70
+ break;
71
+ }
60
72
  while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
61
73
  }
62
74
  return a;
@@ -64,13 +76,19 @@
64
76
  d3.extent = function(array, f) {
65
77
  var i = -1, n = array.length, a, b, c;
66
78
  if (arguments.length === 1) {
67
- while (++i < n && !((a = c = array[i]) != null && a <= a)) a = c = undefined;
79
+ while (++i < n) if ((b = array[i]) != null && b >= b) {
80
+ a = c = b;
81
+ break;
82
+ }
68
83
  while (++i < n) if ((b = array[i]) != null) {
69
84
  if (a > b) a = b;
70
85
  if (c < b) c = b;
71
86
  }
72
87
  } else {
73
- while (++i < n && !((a = c = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
88
+ while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
89
+ a = c = b;
90
+ break;
91
+ }
74
92
  while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
75
93
  if (a > b) a = b;
76
94
  if (c < b) c = b;
@@ -100,7 +118,7 @@
100
118
  } else {
101
119
  while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j;
102
120
  }
103
- return j ? s / j : undefined;
121
+ if (j) return s / j;
104
122
  };
105
123
  d3.quantile = function(values, p) {
106
124
  var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;
@@ -113,7 +131,7 @@
113
131
  } else {
114
132
  while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a);
115
133
  }
116
- return numbers.length ? d3.quantile(numbers.sort(d3_ascending), .5) : undefined;
134
+ if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5);
117
135
  };
118
136
  function d3_bisector(compare) {
119
137
  return {
@@ -145,11 +163,15 @@
145
163
  return d3_ascending(f(d), x);
146
164
  } : f);
147
165
  };
148
- d3.shuffle = function(array) {
149
- var m = array.length, t, i;
166
+ d3.shuffle = function(array, i0, i1) {
167
+ if ((m = arguments.length) < 3) {
168
+ i1 = array.length;
169
+ if (m < 2) i0 = 0;
170
+ }
171
+ var m = i1 - i0, t, i;
150
172
  while (m) {
151
173
  i = Math.random() * m-- | 0;
152
- t = array[m], array[m] = array[i], array[i] = t;
174
+ t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t;
153
175
  }
154
176
  return array;
155
177
  };
@@ -237,11 +259,18 @@
237
259
  });
238
260
  }
239
261
  }
240
- d3.map = function(object) {
262
+ d3.map = function(object, f) {
241
263
  var map = new d3_Map();
242
- if (object instanceof d3_Map) object.forEach(function(key, value) {
243
- map.set(key, value);
244
- }); else for (var key in object) map.set(key, object[key]);
264
+ if (object instanceof d3_Map) {
265
+ object.forEach(function(key, value) {
266
+ map.set(key, value);
267
+ });
268
+ } else if (Array.isArray(object)) {
269
+ var i = -1, n = object.length, o;
270
+ if (arguments.length === 1) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f.call(object, o = object[i], i), o);
271
+ } else {
272
+ for (var key in object) map.set(key, object[key]);
273
+ }
245
274
  return map;
246
275
  };
247
276
  function d3_Map() {
@@ -746,11 +775,12 @@
746
775
  });
747
776
  };
748
777
  d3_selectionPrototype.remove = function() {
749
- return this.each(function() {
750
- var parent = this.parentNode;
751
- if (parent) parent.removeChild(this);
752
- });
778
+ return this.each(d3_selectionRemove);
753
779
  };
780
+ function d3_selectionRemove() {
781
+ var parent = this.parentNode;
782
+ if (parent) parent.removeChild(this);
783
+ }
754
784
  d3_selectionPrototype.data = function(value, key) {
755
785
  var i = -1, n = this.length, group, node;
756
786
  if (!arguments.length) {
@@ -959,8 +989,8 @@
959
989
  return node;
960
990
  };
961
991
  }
962
- d3_selectionPrototype.transition = function() {
963
- var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = d3_transitionInherit || {
992
+ d3_selectionPrototype.transition = function(name) {
993
+ var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || {
964
994
  time: Date.now(),
965
995
  ease: d3_ease_cubicInOut,
966
996
  delay: 0,
@@ -969,17 +999,21 @@
969
999
  for (var j = -1, m = this.length; ++j < m; ) {
970
1000
  subgroups.push(subgroup = []);
971
1001
  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
972
- if (node = group[i]) d3_transitionNode(node, i, id, transition);
1002
+ if (node = group[i]) d3_transitionNode(node, i, ns, id, transition);
973
1003
  subgroup.push(node);
974
1004
  }
975
1005
  }
976
- return d3_transition(subgroups, id);
1006
+ return d3_transition(subgroups, ns, id);
977
1007
  };
978
- d3_selectionPrototype.interrupt = function() {
979
- return this.each(d3_selection_interrupt);
1008
+ d3_selectionPrototype.interrupt = function(name) {
1009
+ var ns = d3_transitionNamespace(name);
1010
+ return this.each(function() {
1011
+ var lock = this[ns];
1012
+ if (lock) ++lock.active;
1013
+ });
980
1014
  };
981
- function d3_selection_interrupt() {
982
- var lock = this.__transition__;
1015
+ function d3_selection_interrupt(that) {
1016
+ var lock = that.__transition__;
983
1017
  if (lock) ++lock.active;
984
1018
  }
985
1019
  d3.select = function(node) {
@@ -1075,9 +1109,9 @@
1075
1109
  w.on(name, null);
1076
1110
  if (d3_event_dragSelect) style[d3_event_dragSelect] = select;
1077
1111
  if (suppressClick) {
1078
- function off() {
1112
+ var off = function() {
1079
1113
  w.on(click, null);
1080
- }
1114
+ };
1081
1115
  w.on(click, function() {
1082
1116
  d3_eventPreventDefault();
1083
1117
  off();
@@ -1190,7 +1224,7 @@
1190
1224
  return point;
1191
1225
  }) : [];
1192
1226
  };
1193
- var π = Math.PI, τ = 2 * π, halfπ = π / 2, ε = 1e-6, ε2 = ε * ε, d3_radians = π / 180, d3_degrees = 180 / π;
1227
+ var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
1194
1228
  function d3_sgn(x) {
1195
1229
  return x > 0 ? 1 : x < 0 ? -1 : 0;
1196
1230
  }
@@ -1235,7 +1269,7 @@
1235
1269
  x: 0,
1236
1270
  y: 0,
1237
1271
  k: 1
1238
- }, 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;
1272
+ }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, duration = 250, zooming = 0, 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;
1239
1273
  function zoom(g) {
1240
1274
  g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1241
1275
  }
@@ -1251,7 +1285,7 @@
1251
1285
  };
1252
1286
  zoomstarted(dispatch);
1253
1287
  }).tween("zoom:zoom", function() {
1254
- var dx = size[0], dy = size[1], cx = dx / 2, cy = dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]);
1288
+ var dx = size[0], dy = size[1], cx = center0 ? center0[0] : dx / 2, cy = center0 ? center0[1] : dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]);
1255
1289
  return function(t) {
1256
1290
  var l = i(t), k = dx / l[2];
1257
1291
  this.__chart__ = view = {
@@ -1261,6 +1295,8 @@
1261
1295
  };
1262
1296
  zoomed(dispatch);
1263
1297
  };
1298
+ }).each("interrupt.zoom", function() {
1299
+ zoomended(dispatch);
1264
1300
  }).each("end.zoom", function() {
1265
1301
  zoomended(dispatch);
1266
1302
  });
@@ -1307,6 +1343,11 @@
1307
1343
  size = _ && [ +_[0], +_[1] ];
1308
1344
  return zoom;
1309
1345
  };
1346
+ zoom.duration = function(_) {
1347
+ if (!arguments.length) return duration;
1348
+ duration = +_;
1349
+ return zoom;
1350
+ };
1310
1351
  zoom.x = function(z) {
1311
1352
  if (!arguments.length) return x1;
1312
1353
  x1 = z;
@@ -1343,6 +1384,18 @@
1343
1384
  view.x += p[0] - l[0];
1344
1385
  view.y += p[1] - l[1];
1345
1386
  }
1387
+ function zoomTo(that, p, l, k) {
1388
+ that.__chart__ = {
1389
+ x: view.x,
1390
+ y: view.y,
1391
+ k: view.k
1392
+ };
1393
+ scaleTo(Math.pow(2, k));
1394
+ translateTo(center0 = p, l);
1395
+ that = d3.select(that);
1396
+ if (duration > 0) that = that.transition().duration(duration);
1397
+ that.call(zoom.event);
1398
+ }
1346
1399
  function rescale() {
1347
1400
  if (x1) x1.domain(x0.range().map(function(x) {
1348
1401
  return (x - view.x) / view.k;
@@ -1352,7 +1405,7 @@
1352
1405
  }).map(y0.invert));
1353
1406
  }
1354
1407
  function zoomstarted(dispatch) {
1355
- dispatch({
1408
+ if (!zooming++) dispatch({
1356
1409
  type: "zoomstart"
1357
1410
  });
1358
1411
  }
@@ -1365,13 +1418,14 @@
1365
1418
  });
1366
1419
  }
1367
1420
  function zoomended(dispatch) {
1368
- dispatch({
1421
+ if (!--zooming) dispatch({
1369
1422
  type: "zoomend"
1370
1423
  });
1424
+ center0 = null;
1371
1425
  }
1372
1426
  function mousedowned() {
1373
1427
  var that = this, target = d3.event.target, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress();
1374
- d3_selection_interrupt.call(that);
1428
+ d3_selection_interrupt(that);
1375
1429
  zoomstarted(dispatch);
1376
1430
  function moved() {
1377
1431
  dragged = 1;
@@ -1386,7 +1440,6 @@
1386
1440
  }
1387
1441
  function touchstarted() {
1388
1442
  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), dragRestore = d3_event_dragSuppress();
1389
- d3_selection_interrupt.call(that);
1390
1443
  started();
1391
1444
  zoomstarted(dispatch);
1392
1445
  subject.on(mousedown, null).on(touchstart, started);
@@ -1409,11 +1462,9 @@
1409
1462
  var touches = relocate(), now = Date.now();
1410
1463
  if (touches.length === 1) {
1411
1464
  if (now - touchtime < 500) {
1412
- var p = touches[0], l = locations0[p.identifier];
1413
- scaleTo(view.k * 2);
1414
- translateTo(p, l);
1465
+ var p = touches[0];
1466
+ zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1);
1415
1467
  d3_eventPreventDefault();
1416
- zoomed(dispatch);
1417
1468
  }
1418
1469
  touchtime = now;
1419
1470
  } else if (touches.length > 1) {
@@ -1423,6 +1474,7 @@
1423
1474
  }
1424
1475
  function moved() {
1425
1476
  var touches = d3.touches(that), p0, l0, p1, l1;
1477
+ d3_selection_interrupt(that);
1426
1478
  for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {
1427
1479
  p1 = touches[i];
1428
1480
  if (l1 = locations0[p1.identifier]) {
@@ -1459,7 +1511,7 @@
1459
1511
  function mousewheeled() {
1460
1512
  var dispatch = event.of(this, arguments);
1461
1513
  if (mousewheelTimer) clearTimeout(mousewheelTimer); else translate0 = location(center0 = center || d3.mouse(this)),
1462
- d3_selection_interrupt.call(this), zoomstarted(dispatch);
1514
+ d3_selection_interrupt(this), zoomstarted(dispatch);
1463
1515
  mousewheelTimer = setTimeout(function() {
1464
1516
  mousewheelTimer = null;
1465
1517
  zoomended(dispatch);
@@ -1470,12 +1522,8 @@
1470
1522
  zoomed(dispatch);
1471
1523
  }
1472
1524
  function dblclicked() {
1473
- var dispatch = event.of(this, arguments), p = d3.mouse(this), l = location(p), k = Math.log(view.k) / Math.LN2;
1474
- zoomstarted(dispatch);
1475
- scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1));
1476
- translateTo(p, l);
1477
- zoomed(dispatch);
1478
- zoomended(dispatch);
1525
+ var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2;
1526
+ zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1);
1479
1527
  }
1480
1528
  return d3.rebind(zoom, event, "on");
1481
1529
  };
@@ -3131,6 +3179,15 @@
3131
3179
  d3_geo_centroidPointXYZ(x0, y0, z0);
3132
3180
  }
3133
3181
  }
3182
+ function d3_geo_compose(a, b) {
3183
+ function compose(x, y) {
3184
+ return x = a(x, y), b(x[0], x[1]);
3185
+ }
3186
+ if (a.invert && b.invert) compose.invert = function(x, y) {
3187
+ return x = b.invert(x, y), x && a.invert(x[0], x[1]);
3188
+ };
3189
+ return compose;
3190
+ }
3134
3191
  function d3_true() {
3135
3192
  return true;
3136
3193
  }
@@ -3729,15 +3786,6 @@
3729
3786
  return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0];
3730
3787
  }
3731
3788
  }
3732
- function d3_geo_compose(a, b) {
3733
- function compose(x, y) {
3734
- return x = a(x, y), b(x[0], x[1]);
3735
- }
3736
- if (a.invert && b.invert) compose.invert = function(x, y) {
3737
- return x = b.invert(x, y), x && a.invert(x[0], x[1]);
3738
- };
3739
- return compose;
3740
- }
3741
3789
  function d3_geo_conic(projectAt) {
3742
3790
  var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1);
3743
3791
  p.parallels = function(_) {
@@ -4009,7 +4057,7 @@
4009
4057
  result: d3_noop
4010
4058
  };
4011
4059
  function point(x, y) {
4012
- context.moveTo(x, y);
4060
+ context.moveTo(x + pointRadius, y);
4013
4061
  context.arc(x, y, pointRadius, 0, τ);
4014
4062
  }
4015
4063
  function pointLineStart(x, y) {
@@ -5517,11 +5565,11 @@
5517
5565
  }
5518
5566
  }
5519
5567
  function insertChild(n, d, x, y, x1, y1, x2, y2) {
5520
- var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, right = x >= sx, bottom = y >= sy, i = (bottom << 1) + right;
5568
+ var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right;
5521
5569
  n.leaf = false;
5522
5570
  n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());
5523
- if (right) x1 = sx; else x2 = sx;
5524
- if (bottom) y1 = sy; else y2 = sy;
5571
+ if (right) x1 = xm; else x2 = xm;
5572
+ if (below) y1 = ym; else y2 = ym;
5525
5573
  insert(n, d, x, y, x1, y1, x2, y2);
5526
5574
  }
5527
5575
  var root = d3_geom_quadtreeNode();
@@ -5531,6 +5579,9 @@
5531
5579
  root.visit = function(f) {
5532
5580
  d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_);
5533
5581
  };
5582
+ root.find = function(point) {
5583
+ return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_);
5584
+ };
5534
5585
  i = -1;
5535
5586
  if (x1 == null) {
5536
5587
  while (++i < n) {
@@ -5584,6 +5635,42 @@
5584
5635
  if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
5585
5636
  }
5586
5637
  }
5638
+ function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) {
5639
+ var minDistance2 = Infinity, closestPoint;
5640
+ (function find(node, x1, y1, x2, y2) {
5641
+ if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return;
5642
+ if (point = node.point) {
5643
+ var point, dx = x - point[0], dy = y - point[1], distance2 = dx * dx + dy * dy;
5644
+ if (distance2 < minDistance2) {
5645
+ var distance = Math.sqrt(minDistance2 = distance2);
5646
+ x0 = x - distance, y0 = y - distance;
5647
+ x3 = x + distance, y3 = y + distance;
5648
+ closestPoint = point;
5649
+ }
5650
+ }
5651
+ var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym;
5652
+ for (var i = below << 1 | right, j = i + 4; i < j; ++i) {
5653
+ if (node = children[i & 3]) switch (i & 3) {
5654
+ case 0:
5655
+ find(node, x1, y1, xm, ym);
5656
+ break;
5657
+
5658
+ case 1:
5659
+ find(node, xm, y1, x2, ym);
5660
+ break;
5661
+
5662
+ case 2:
5663
+ find(node, x1, ym, xm, y2);
5664
+ break;
5665
+
5666
+ case 3:
5667
+ find(node, xm, ym, x2, y2);
5668
+ break;
5669
+ }
5670
+ }
5671
+ })(root, x0, y0, x3, y3);
5672
+ return closestPoint;
5673
+ }
5587
5674
  d3.interpolateRgb = d3_interpolateRgb;
5588
5675
  function d3_interpolateRgb(a, b) {
5589
5676
  a = d3.rgb(a);
@@ -6475,49 +6562,50 @@
6475
6562
  return d3_layout_hierarchyRebind(partition, hierarchy);
6476
6563
  };
6477
6564
  d3.layout.pie = function() {
6478
- var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ;
6565
+ var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0;
6479
6566
  function pie(data) {
6480
- var values = data.map(function(d, i) {
6567
+ var n = data.length, values = data.map(function(d, i) {
6481
6568
  return +value.call(pie, d, i);
6482
- });
6483
- var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle);
6484
- var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a) / d3.sum(values);
6485
- var index = d3.range(data.length);
6569
+ }), a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === "function" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), k = (da - n * pa) / d3.sum(values), index = d3.range(n), arcs = [], v;
6486
6570
  if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {
6487
6571
  return values[j] - values[i];
6488
6572
  } : function(i, j) {
6489
6573
  return sort(data[i], data[j]);
6490
6574
  });
6491
- var arcs = [];
6492
6575
  index.forEach(function(i) {
6493
- var d;
6494
6576
  arcs[i] = {
6495
6577
  data: data[i],
6496
- value: d = values[i],
6578
+ value: v = values[i],
6497
6579
  startAngle: a,
6498
- endAngle: a += d * k
6580
+ endAngle: a += v * k + pa,
6581
+ padAngle: p
6499
6582
  };
6500
6583
  });
6501
6584
  return arcs;
6502
6585
  }
6503
- pie.value = function(x) {
6586
+ pie.value = function(_) {
6504
6587
  if (!arguments.length) return value;
6505
- value = x;
6588
+ value = _;
6506
6589
  return pie;
6507
6590
  };
6508
- pie.sort = function(x) {
6591
+ pie.sort = function(_) {
6509
6592
  if (!arguments.length) return sort;
6510
- sort = x;
6593
+ sort = _;
6511
6594
  return pie;
6512
6595
  };
6513
- pie.startAngle = function(x) {
6596
+ pie.startAngle = function(_) {
6514
6597
  if (!arguments.length) return startAngle;
6515
- startAngle = x;
6598
+ startAngle = _;
6516
6599
  return pie;
6517
6600
  };
6518
- pie.endAngle = function(x) {
6601
+ pie.endAngle = function(_) {
6519
6602
  if (!arguments.length) return endAngle;
6520
- endAngle = x;
6603
+ endAngle = _;
6604
+ return pie;
6605
+ };
6606
+ pie.padAngle = function(_) {
6607
+ if (!arguments.length) return padAngle;
6608
+ padAngle = _;
6521
6609
  return pie;
6522
6610
  };
6523
6611
  return pie;
@@ -7616,8 +7704,9 @@
7616
7704
  };
7617
7705
  scale.rangePoints = function(x, padding) {
7618
7706
  if (arguments.length < 2) padding = 0;
7619
- var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding);
7620
- range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step);
7707
+ var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2,
7708
+ 0) : (stop - start) / (domain.length - 1 + padding);
7709
+ range = steps(start + step * padding / 2, step);
7621
7710
  rangeBand = 0;
7622
7711
  ranger = {
7623
7712
  t: "rangePoints",
@@ -7625,6 +7714,18 @@
7625
7714
  };
7626
7715
  return scale;
7627
7716
  };
7717
+ scale.rangeRoundPoints = function(x, padding) {
7718
+ if (arguments.length < 2) padding = 0;
7719
+ var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2),
7720
+ 0) : (stop - start) / (domain.length - 1 + padding) | 0;
7721
+ range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step);
7722
+ rangeBand = 0;
7723
+ ranger = {
7724
+ t: "rangeRoundPoints",
7725
+ a: arguments
7726
+ };
7727
+ return scale;
7728
+ };
7628
7729
  scale.rangeBands = function(x, padding, outerPadding) {
7629
7730
  if (arguments.length < 2) padding = 0;
7630
7731
  if (arguments.length < 3) outerPadding = padding;
@@ -7641,8 +7742,8 @@
7641
7742
  scale.rangeRoundBands = function(x, padding, outerPadding) {
7642
7743
  if (arguments.length < 2) padding = 0;
7643
7744
  if (arguments.length < 3) outerPadding = padding;
7644
- var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)), error = stop - start - (domain.length - padding) * step;
7645
- range = steps(start + Math.round(error / 2), step);
7745
+ var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding));
7746
+ range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step);
7646
7747
  if (reverse) range.reverse();
7647
7748
  rangeBand = Math.round(step * (1 - padding));
7648
7749
  ranger = {
@@ -7799,12 +7900,86 @@
7799
7900
  return identity;
7800
7901
  }
7801
7902
  d3.svg = {};
7903
+ function d3_zero() {
7904
+ return 0;
7905
+ }
7802
7906
  d3.svg.arc = function() {
7803
- var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;
7907
+ var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, cornerRadius = d3_zero, padRadius = d3_svg_arcAuto, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle, padAngle = d3_svg_arcPadAngle;
7804
7908
  function arc() {
7805
- 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,
7806
- 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);
7807
- 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";
7909
+ var r0 = Math.max(0, +innerRadius.apply(this, arguments)), r1 = Math.max(0, +outerRadius.apply(this, arguments)), a0 = startAngle.apply(this, arguments) - halfπ, a1 = endAngle.apply(this, arguments) - halfπ, da = Math.abs(a1 - a0), cw = a0 > a1 ? 0 : 1;
7910
+ if (r1 < r0) rc = r1, r1 = r0, r0 = rc;
7911
+ if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : "") + "Z";
7912
+ var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = [];
7913
+ if (ap = (+padAngle.apply(this, arguments) || 0) / 2) {
7914
+ rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments);
7915
+ if (!cw) p1 *= -1;
7916
+ if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap));
7917
+ if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap));
7918
+ }
7919
+ if (r1) {
7920
+ x0 = r1 * Math.cos(a0 + p1);
7921
+ y0 = r1 * Math.sin(a0 + p1);
7922
+ x1 = r1 * Math.cos(a1 - p1);
7923
+ y1 = r1 * Math.sin(a1 - p1);
7924
+ var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1;
7925
+ if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) {
7926
+ var h1 = (a0 + a1) / 2;
7927
+ x0 = r1 * Math.cos(h1);
7928
+ y0 = r1 * Math.sin(h1);
7929
+ x1 = y1 = null;
7930
+ }
7931
+ } else {
7932
+ x0 = y0 = 0;
7933
+ }
7934
+ if (r0) {
7935
+ x2 = r0 * Math.cos(a1 - p0);
7936
+ y2 = r0 * Math.sin(a1 - p0);
7937
+ x3 = r0 * Math.cos(a0 + p0);
7938
+ y3 = r0 * Math.sin(a0 + p0);
7939
+ var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1;
7940
+ if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) {
7941
+ var h0 = (a0 + a1) / 2;
7942
+ x2 = r0 * Math.cos(h0);
7943
+ y2 = r0 * Math.sin(h0);
7944
+ x3 = y3 = null;
7945
+ }
7946
+ } else {
7947
+ x2 = y2 = 0;
7948
+ }
7949
+ if ((rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) {
7950
+ cr = r0 < r1 ^ cw ? 0 : 1;
7951
+ var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
7952
+ if (x1 != null) {
7953
+ var rc1 = Math.min(rc, (r1 - lc) / (kc + 1)), t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw);
7954
+ if (rc === rc1) {
7955
+ path.push("M", t30[0], "A", rc1, ",", rc1, " 0 0,", cr, " ", t30[1], "A", r1, ",", r1, " 0 ", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), ",", cw, " ", t12[1], "A", rc1, ",", rc1, " 0 0,", cr, " ", t12[0]);
7956
+ } else {
7957
+ path.push("M", t30[0], "A", rc1, ",", rc1, " 0 1,", cr, " ", t12[0]);
7958
+ }
7959
+ } else {
7960
+ path.push("M", x0, ",", y0);
7961
+ }
7962
+ if (x3 != null) {
7963
+ var rc0 = Math.min(rc, (r0 - lc) / (kc - 1)), t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw);
7964
+ if (rc === rc0) {
7965
+ path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t21[1], "A", r0, ",", r0, " 0 ", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), ",", 1 - cw, " ", t03[1], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]);
7966
+ } else {
7967
+ path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]);
7968
+ }
7969
+ } else {
7970
+ path.push("L", x2, ",", y2);
7971
+ }
7972
+ } else {
7973
+ path.push("M", x0, ",", y0);
7974
+ if (x1 != null) path.push("A", r1, ",", r1, " 0 ", l1, ",", cw, " ", x1, ",", y1);
7975
+ path.push("L", x2, ",", y2);
7976
+ if (x3 != null) path.push("A", r0, ",", r0, " 0 ", l0, ",", 1 - cw, " ", x3, ",", y3);
7977
+ }
7978
+ path.push("Z");
7979
+ return path.join("");
7980
+ }
7981
+ function circleSegment(r1, cw) {
7982
+ return "M0," + r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + -r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + r1;
7808
7983
  }
7809
7984
  arc.innerRadius = function(v) {
7810
7985
  if (!arguments.length) return innerRadius;
@@ -7816,6 +7991,16 @@
7816
7991
  outerRadius = d3_functor(v);
7817
7992
  return arc;
7818
7993
  };
7994
+ arc.cornerRadius = function(v) {
7995
+ if (!arguments.length) return cornerRadius;
7996
+ cornerRadius = d3_functor(v);
7997
+ return arc;
7998
+ };
7999
+ arc.padRadius = function(v) {
8000
+ if (!arguments.length) return padRadius;
8001
+ padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v);
8002
+ return arc;
8003
+ };
7819
8004
  arc.startAngle = function(v) {
7820
8005
  if (!arguments.length) return startAngle;
7821
8006
  startAngle = d3_functor(v);
@@ -7826,13 +8011,18 @@
7826
8011
  endAngle = d3_functor(v);
7827
8012
  return arc;
7828
8013
  };
8014
+ arc.padAngle = function(v) {
8015
+ if (!arguments.length) return padAngle;
8016
+ padAngle = d3_functor(v);
8017
+ return arc;
8018
+ };
7829
8019
  arc.centroid = function() {
7830
- var r = (innerRadius.apply(this, arguments) + outerRadius.apply(this, arguments)) / 2, a = (startAngle.apply(this, arguments) + endAngle.apply(this, arguments)) / 2 + d3_svg_arcOffset;
8020
+ var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - halfπ;
7831
8021
  return [ Math.cos(a) * r, Math.sin(a) * r ];
7832
8022
  };
7833
8023
  return arc;
7834
8024
  };
7835
- var d3_svg_arcOffset = -halfπ, d3_svg_arcMax = τ - ε;
8025
+ var d3_svg_arcAuto = "auto";
7836
8026
  function d3_svg_arcInnerRadius(d) {
7837
8027
  return d.innerRadius;
7838
8028
  }
@@ -7845,6 +8035,17 @@
7845
8035
  function d3_svg_arcEndAngle(d) {
7846
8036
  return d.endAngle;
7847
8037
  }
8038
+ function d3_svg_arcPadAngle(d) {
8039
+ return d && d.padAngle;
8040
+ }
8041
+ function d3_svg_arcSweep(x0, y0, x1, y1) {
8042
+ return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1;
8043
+ }
8044
+ function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) {
8045
+ var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(r * r * d2 - D * D), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3;
8046
+ if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
8047
+ return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ];
8048
+ }
7848
8049
  function d3_svg_line(projection) {
7849
8050
  var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;
7850
8051
  function line(data) {
@@ -7935,7 +8136,7 @@
7935
8136
  return path.join("");
7936
8137
  }
7937
8138
  function d3_svg_lineCardinalOpen(points, tension) {
7938
- return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), d3_svg_lineCardinalTangents(points, tension));
8139
+ return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));
7939
8140
  }
7940
8141
  function d3_svg_lineCardinalClosed(points, tension) {
7941
8142
  return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]),
@@ -8105,7 +8306,7 @@
8105
8306
  while (++i < n) {
8106
8307
  point = points[i];
8107
8308
  r = point[0];
8108
- a = point[1] + d3_svg_arcOffset;
8309
+ a = point[1] - halfπ;
8109
8310
  point[0] = r * Math.cos(a);
8110
8311
  point[1] = r * Math.sin(a);
8111
8312
  }
@@ -8206,7 +8407,7 @@
8206
8407
  return "M" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + "Z";
8207
8408
  }
8208
8409
  function subgroup(self, f, d, i) {
8209
- var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) + d3_svg_arcOffset, a1 = endAngle.call(self, subgroup, i) + d3_svg_arcOffset;
8410
+ var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) - halfπ, a1 = endAngle.call(self, subgroup, i) - halfπ;
8210
8411
  return {
8211
8412
  r: r,
8212
8413
  a0: a0,
@@ -8296,7 +8497,7 @@
8296
8497
  };
8297
8498
  function d3_svg_diagonalRadialProjection(projection) {
8298
8499
  return function() {
8299
- var d = projection.apply(this, arguments), r = d[0], a = d[1] + d3_svg_arcOffset;
8500
+ var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ;
8300
8501
  return [ r * Math.cos(a), r * Math.sin(a) ];
8301
8502
  };
8302
8503
  }
@@ -8352,8 +8553,9 @@
8352
8553
  });
8353
8554
  d3.svg.symbolTypes = d3_svg_symbols.keys();
8354
8555
  var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);
8355
- function d3_transition(groups, id) {
8556
+ function d3_transition(groups, namespace, id) {
8356
8557
  d3_subclass(groups, d3_transitionPrototype);
8558
+ groups.namespace = namespace;
8357
8559
  groups.id = id;
8358
8560
  return groups;
8359
8561
  }
@@ -8367,39 +8569,39 @@
8367
8569
  };
8368
8570
  d3.transition.prototype = d3_transitionPrototype;
8369
8571
  d3_transitionPrototype.select = function(selector) {
8370
- var id = this.id, subgroups = [], subgroup, subnode, node;
8572
+ var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node;
8371
8573
  selector = d3_selection_selector(selector);
8372
8574
  for (var j = -1, m = this.length; ++j < m; ) {
8373
8575
  subgroups.push(subgroup = []);
8374
8576
  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8375
8577
  if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) {
8376
8578
  if ("__data__" in node) subnode.__data__ = node.__data__;
8377
- d3_transitionNode(subnode, i, id, node.__transition__[id]);
8579
+ d3_transitionNode(subnode, i, ns, id, node[ns][id]);
8378
8580
  subgroup.push(subnode);
8379
8581
  } else {
8380
8582
  subgroup.push(null);
8381
8583
  }
8382
8584
  }
8383
8585
  }
8384
- return d3_transition(subgroups, id);
8586
+ return d3_transition(subgroups, ns, id);
8385
8587
  };
8386
8588
  d3_transitionPrototype.selectAll = function(selector) {
8387
- var id = this.id, subgroups = [], subgroup, subnodes, node, subnode, transition;
8589
+ var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition;
8388
8590
  selector = d3_selection_selectorAll(selector);
8389
8591
  for (var j = -1, m = this.length; ++j < m; ) {
8390
8592
  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8391
8593
  if (node = group[i]) {
8392
- transition = node.__transition__[id];
8594
+ transition = node[ns][id];
8393
8595
  subnodes = selector.call(node, node.__data__, i, j);
8394
8596
  subgroups.push(subgroup = []);
8395
8597
  for (var k = -1, o = subnodes.length; ++k < o; ) {
8396
- if (subnode = subnodes[k]) d3_transitionNode(subnode, k, id, transition);
8598
+ if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition);
8397
8599
  subgroup.push(subnode);
8398
8600
  }
8399
8601
  }
8400
8602
  }
8401
8603
  }
8402
- return d3_transition(subgroups, id);
8604
+ return d3_transition(subgroups, ns, id);
8403
8605
  };
8404
8606
  d3_transitionPrototype.filter = function(filter) {
8405
8607
  var subgroups = [], subgroup, group, node;
@@ -8412,23 +8614,23 @@
8412
8614
  }
8413
8615
  }
8414
8616
  }
8415
- return d3_transition(subgroups, this.id);
8617
+ return d3_transition(subgroups, this.namespace, this.id);
8416
8618
  };
8417
8619
  d3_transitionPrototype.tween = function(name, tween) {
8418
- var id = this.id;
8419
- if (arguments.length < 2) return this.node().__transition__[id].tween.get(name);
8620
+ var id = this.id, ns = this.namespace;
8621
+ if (arguments.length < 2) return this.node()[ns][id].tween.get(name);
8420
8622
  return d3_selection_each(this, tween == null ? function(node) {
8421
- node.__transition__[id].tween.remove(name);
8623
+ node[ns][id].tween.remove(name);
8422
8624
  } : function(node) {
8423
- node.__transition__[id].tween.set(name, tween);
8625
+ node[ns][id].tween.set(name, tween);
8424
8626
  });
8425
8627
  };
8426
8628
  function d3_transition_tween(groups, name, value, tween) {
8427
- var id = groups.id;
8629
+ var id = groups.id, ns = groups.namespace;
8428
8630
  return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) {
8429
- node.__transition__[id].tween.set(name, tween(value.call(node, node.__data__, i, j)));
8631
+ node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j)));
8430
8632
  } : (value = tween(value), function(node) {
8431
- node.__transition__[id].tween.set(name, value);
8633
+ node[ns][id].tween.set(name, value);
8432
8634
  }));
8433
8635
  }
8434
8636
  d3_transitionPrototype.attr = function(nameNS, value) {
@@ -8520,73 +8722,81 @@
8520
8722
  };
8521
8723
  }
8522
8724
  d3_transitionPrototype.remove = function() {
8725
+ var ns = this.namespace;
8523
8726
  return this.each("end.transition", function() {
8524
8727
  var p;
8525
- if (this.__transition__.count < 2 && (p = this.parentNode)) p.removeChild(this);
8728
+ if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this);
8526
8729
  });
8527
8730
  };
8528
8731
  d3_transitionPrototype.ease = function(value) {
8529
- var id = this.id;
8530
- if (arguments.length < 1) return this.node().__transition__[id].ease;
8732
+ var id = this.id, ns = this.namespace;
8733
+ if (arguments.length < 1) return this.node()[ns][id].ease;
8531
8734
  if (typeof value !== "function") value = d3.ease.apply(d3, arguments);
8532
8735
  return d3_selection_each(this, function(node) {
8533
- node.__transition__[id].ease = value;
8736
+ node[ns][id].ease = value;
8534
8737
  });
8535
8738
  };
8536
8739
  d3_transitionPrototype.delay = function(value) {
8537
- var id = this.id;
8538
- if (arguments.length < 1) return this.node().__transition__[id].delay;
8740
+ var id = this.id, ns = this.namespace;
8741
+ if (arguments.length < 1) return this.node()[ns][id].delay;
8539
8742
  return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8540
- node.__transition__[id].delay = +value.call(node, node.__data__, i, j);
8743
+ node[ns][id].delay = +value.call(node, node.__data__, i, j);
8541
8744
  } : (value = +value, function(node) {
8542
- node.__transition__[id].delay = value;
8745
+ node[ns][id].delay = value;
8543
8746
  }));
8544
8747
  };
8545
8748
  d3_transitionPrototype.duration = function(value) {
8546
- var id = this.id;
8547
- if (arguments.length < 1) return this.node().__transition__[id].duration;
8749
+ var id = this.id, ns = this.namespace;
8750
+ if (arguments.length < 1) return this.node()[ns][id].duration;
8548
8751
  return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8549
- node.__transition__[id].duration = Math.max(1, value.call(node, node.__data__, i, j));
8752
+ node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j));
8550
8753
  } : (value = Math.max(1, value), function(node) {
8551
- node.__transition__[id].duration = value;
8754
+ node[ns][id].duration = value;
8552
8755
  }));
8553
8756
  };
8554
8757
  d3_transitionPrototype.each = function(type, listener) {
8555
- var id = this.id;
8758
+ var id = this.id, ns = this.namespace;
8556
8759
  if (arguments.length < 2) {
8557
8760
  var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;
8558
8761
  d3_transitionInheritId = id;
8559
8762
  d3_selection_each(this, function(node, i, j) {
8560
- d3_transitionInherit = node.__transition__[id];
8763
+ d3_transitionInherit = node[ns][id];
8561
8764
  type.call(node, node.__data__, i, j);
8562
8765
  });
8563
8766
  d3_transitionInherit = inherit;
8564
8767
  d3_transitionInheritId = inheritId;
8565
8768
  } else {
8566
8769
  d3_selection_each(this, function(node) {
8567
- var transition = node.__transition__[id];
8568
- (transition.event || (transition.event = d3.dispatch("start", "end"))).on(type, listener);
8770
+ var transition = node[ns][id];
8771
+ (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener);
8569
8772
  });
8570
8773
  }
8571
8774
  return this;
8572
8775
  };
8573
8776
  d3_transitionPrototype.transition = function() {
8574
- var id0 = this.id, id1 = ++d3_transitionId, subgroups = [], subgroup, group, node, transition;
8777
+ var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition;
8575
8778
  for (var j = 0, m = this.length; j < m; j++) {
8576
8779
  subgroups.push(subgroup = []);
8577
8780
  for (var group = this[j], i = 0, n = group.length; i < n; i++) {
8578
8781
  if (node = group[i]) {
8579
- transition = Object.create(node.__transition__[id0]);
8580
- transition.delay += transition.duration;
8581
- d3_transitionNode(node, i, id1, transition);
8782
+ transition = node[ns][id0];
8783
+ d3_transitionNode(node, i, ns, id1, {
8784
+ time: transition.time,
8785
+ ease: transition.ease,
8786
+ delay: transition.delay + transition.duration,
8787
+ duration: transition.duration
8788
+ });
8582
8789
  }
8583
8790
  subgroup.push(node);
8584
8791
  }
8585
8792
  }
8586
- return d3_transition(subgroups, id1);
8793
+ return d3_transition(subgroups, ns, id1);
8587
8794
  };
8588
- function d3_transitionNode(node, i, id, inherit) {
8589
- var lock = node.__transition__ || (node.__transition__ = {
8795
+ function d3_transitionNamespace(name) {
8796
+ return name == null ? "__transition__" : "__transition_" + name + "__";
8797
+ }
8798
+ function d3_transitionNode(node, i, namespace, id, inherit) {
8799
+ var lock = node[namespace] || (node[namespace] = {
8590
8800
  active: 0,
8591
8801
  count: 0
8592
8802
  }), transition = lock[id];
@@ -8595,18 +8805,19 @@
8595
8805
  transition = lock[id] = {
8596
8806
  tween: new d3_Map(),
8597
8807
  time: time,
8598
- ease: inherit.ease,
8599
8808
  delay: inherit.delay,
8600
- duration: inherit.duration
8809
+ duration: inherit.duration,
8810
+ ease: inherit.ease
8601
8811
  };
8812
+ inherit = null;
8602
8813
  ++lock.count;
8603
8814
  d3.timer(function(elapsed) {
8604
- var d = node.__data__, ease = transition.ease, delay = transition.delay, duration = transition.duration, timer = d3_timer_active, tweened = [];
8815
+ var d = node.__data__, delay = transition.delay, duration, ease, timer = d3_timer_active, tweened = [];
8605
8816
  timer.t = delay + time;
8606
8817
  if (delay <= elapsed) return start(elapsed - delay);
8607
8818
  timer.c = start;
8608
8819
  function start(elapsed) {
8609
- if (lock.active > id) return stop();
8820
+ if (lock.active > id) return stop(false);
8610
8821
  lock.active = id;
8611
8822
  transition.event && transition.event.start.call(node, d, i);
8612
8823
  transition.tween.forEach(function(key, value) {
@@ -8614,24 +8825,24 @@
8614
8825
  tweened.push(value);
8615
8826
  }
8616
8827
  });
8828
+ ease = transition.ease;
8829
+ duration = transition.duration;
8617
8830
  d3.timer(function() {
8618
8831
  timer.c = tick(elapsed || 1) ? d3_true : tick;
8619
8832
  return 1;
8620
8833
  }, 0, time);
8621
8834
  }
8622
8835
  function tick(elapsed) {
8623
- if (lock.active !== id) return stop();
8836
+ if (lock.active !== id) return stop(false);
8624
8837
  var t = elapsed / duration, e = ease(t), n = tweened.length;
8625
8838
  while (n > 0) {
8626
8839
  tweened[--n].call(node, e);
8627
8840
  }
8628
- if (t >= 1) {
8629
- transition.event && transition.event.end.call(node, d, i);
8630
- return stop();
8631
- }
8841
+ if (t >= 1) return stop(true);
8632
8842
  }
8633
- function stop() {
8634
- if (--lock.count) delete lock[id]; else delete node.__transition__;
8843
+ function stop(end) {
8844
+ if (transition.event) transition.event[end ? "end" : "interrupt"].call(node, d, i);
8845
+ if (--lock.count) delete lock[id]; else delete node[namespace];
8635
8846
  return 1;
8636
8847
  }
8637
8848
  }, 0, time);