d3-rails 3.4.13 → 3.5.2

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: 448b4456604b6b4ec016e2df9cd2f9071dc5dee7
4
- data.tar.gz: b74cf5c2c333af859432610867924a42fbfd1391
3
+ metadata.gz: 232c84ecce17e1d7f13f4548d41ea61e6d36512e
4
+ data.tar.gz: 5927be0430202eb134dd659e9db92b79a6a2f7c9
5
5
  SHA512:
6
- metadata.gz: 5e0e3ac25b4e49bc1079bfc68a418cc716c69575e4d66e181222805dedaba0458613f6e5e416226f722550e93dd6fd6f18e849379de9e95b49b265d357eced36
7
- data.tar.gz: 28d4e1376ae65ff571fe49178307ab8ac9ae940b1d41ce04f2d9a212bccd126165151db0aab7308e64cebe15c713e0717704b991ec74b8c32dfd95c9c38056ea
6
+ metadata.gz: 966fcb2b9551092b9b0e22d680633afdfb4d69f55c5372f5a8095b9c33bd0dcd5fa87db02c16ba030604d883fe40a0718a24ba26d1cdb2419cd6bb732f498343
7
+ data.tar.gz: d0befe60f2ebbe200107c4ff48ee56b7d2675cbd85ece0f4af394b6e3cc018d58dfa51ca8e4593ea8c2ae8ffc627385ce4cff6666365bd76fcd115632e288d10
@@ -1,3 +1,7 @@
1
+ ## 3.5.2 (16 December 2014)
2
+
3
+ * Upgrade D3 to 3.5.2
4
+
1
5
  ## 3.4.13 (3 November 2014)
2
6
 
3
7
  * Upgrade D3 to 3.4.13
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.13 of D3.js. and will track the always
9
+ d3-rails comes with version 3.5.2 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.13"
3
+ version: "3.5.2"
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,32 @@
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);
135
+ };
136
+ d3.variance = function(array, f) {
137
+ var n = array.length, m = 0, a, d, s = 0, i = -1, j = 0;
138
+ if (arguments.length === 1) {
139
+ while (++i < n) {
140
+ if (d3_numeric(a = d3_number(array[i]))) {
141
+ d = a - m;
142
+ m += d / ++j;
143
+ s += d * (a - m);
144
+ }
145
+ }
146
+ } else {
147
+ while (++i < n) {
148
+ if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) {
149
+ d = a - m;
150
+ m += d / ++j;
151
+ s += d * (a - m);
152
+ }
153
+ }
154
+ }
155
+ if (j > 1) return s / (j - 1);
156
+ };
157
+ d3.deviation = function() {
158
+ var v = d3.variance.apply(this, arguments);
159
+ return v ? Math.sqrt(v) : v;
117
160
  };
118
161
  function d3_bisector(compare) {
119
162
  return {
@@ -145,11 +188,15 @@
145
188
  return d3_ascending(f(d), x);
146
189
  } : f);
147
190
  };
148
- d3.shuffle = function(array) {
149
- var m = array.length, t, i;
191
+ d3.shuffle = function(array, i0, i1) {
192
+ if ((m = arguments.length) < 3) {
193
+ i1 = array.length;
194
+ if (m < 2) i0 = 0;
195
+ }
196
+ var m = i1 - i0, t, i;
150
197
  while (m) {
151
198
  i = Math.random() * m-- | 0;
152
- t = array[m], array[m] = array[i], array[i] = t;
199
+ t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t;
153
200
  }
154
201
  return array;
155
202
  };
@@ -237,11 +284,18 @@
237
284
  });
238
285
  }
239
286
  }
240
- d3.map = function(object) {
287
+ d3.map = function(object, f) {
241
288
  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]);
289
+ if (object instanceof d3_Map) {
290
+ object.forEach(function(key, value) {
291
+ map.set(key, value);
292
+ });
293
+ } else if (Array.isArray(object)) {
294
+ var i = -1, n = object.length, o;
295
+ 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);
296
+ } else {
297
+ for (var key in object) map.set(key, object[key]);
298
+ }
245
299
  return map;
246
300
  };
247
301
  function d3_Map() {
@@ -746,11 +800,12 @@
746
800
  });
747
801
  };
748
802
  d3_selectionPrototype.remove = function() {
749
- return this.each(function() {
750
- var parent = this.parentNode;
751
- if (parent) parent.removeChild(this);
752
- });
803
+ return this.each(d3_selectionRemove);
753
804
  };
805
+ function d3_selectionRemove() {
806
+ var parent = this.parentNode;
807
+ if (parent) parent.removeChild(this);
808
+ }
754
809
  d3_selectionPrototype.data = function(value, key) {
755
810
  var i = -1, n = this.length, group, node;
756
811
  if (!arguments.length) {
@@ -959,29 +1014,6 @@
959
1014
  return node;
960
1015
  };
961
1016
  }
962
- d3_selectionPrototype.transition = function() {
963
- var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = d3_transitionInherit || {
964
- time: Date.now(),
965
- ease: d3_ease_cubicInOut,
966
- delay: 0,
967
- duration: 250
968
- };
969
- for (var j = -1, m = this.length; ++j < m; ) {
970
- subgroups.push(subgroup = []);
971
- for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
972
- if (node = group[i]) d3_transitionNode(node, i, id, transition);
973
- subgroup.push(node);
974
- }
975
- }
976
- return d3_transition(subgroups, id);
977
- };
978
- d3_selectionPrototype.interrupt = function() {
979
- return this.each(d3_selection_interrupt);
980
- };
981
- function d3_selection_interrupt() {
982
- var lock = this.__transition__;
983
- if (lock) ++lock.active;
984
- }
985
1017
  d3.select = function(node) {
986
1018
  var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ];
987
1019
  group.parentNode = d3_documentElement;
@@ -1075,9 +1107,9 @@
1075
1107
  w.on(name, null);
1076
1108
  if (d3_event_dragSelect) style[d3_event_dragSelect] = select;
1077
1109
  if (suppressClick) {
1078
- function off() {
1110
+ var off = function() {
1079
1111
  w.on(click, null);
1080
- }
1112
+ };
1081
1113
  w.on(click, function() {
1082
1114
  d3_eventPreventDefault();
1083
1115
  off();
@@ -1190,7 +1222,7 @@
1190
1222
  return point;
1191
1223
  }) : [];
1192
1224
  };
1193
- var π = Math.PI, τ = 2 * π, halfπ = π / 2, ε = 1e-6, ε2 = ε * ε, d3_radians = π / 180, d3_degrees = 180 / π;
1225
+ var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
1194
1226
  function d3_sgn(x) {
1195
1227
  return x > 0 ? 1 : x < 0 ? -1 : 0;
1196
1228
  }
@@ -1235,7 +1267,7 @@
1235
1267
  x: 0,
1236
1268
  y: 0,
1237
1269
  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;
1270
+ }, 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
1271
  function zoom(g) {
1240
1272
  g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1241
1273
  }
@@ -1251,7 +1283,7 @@
1251
1283
  };
1252
1284
  zoomstarted(dispatch);
1253
1285
  }).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 ]);
1286
+ 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
1287
  return function(t) {
1256
1288
  var l = i(t), k = dx / l[2];
1257
1289
  this.__chart__ = view = {
@@ -1261,6 +1293,8 @@
1261
1293
  };
1262
1294
  zoomed(dispatch);
1263
1295
  };
1296
+ }).each("interrupt.zoom", function() {
1297
+ zoomended(dispatch);
1264
1298
  }).each("end.zoom", function() {
1265
1299
  zoomended(dispatch);
1266
1300
  });
@@ -1307,6 +1341,11 @@
1307
1341
  size = _ && [ +_[0], +_[1] ];
1308
1342
  return zoom;
1309
1343
  };
1344
+ zoom.duration = function(_) {
1345
+ if (!arguments.length) return duration;
1346
+ duration = +_;
1347
+ return zoom;
1348
+ };
1310
1349
  zoom.x = function(z) {
1311
1350
  if (!arguments.length) return x1;
1312
1351
  x1 = z;
@@ -1343,6 +1382,18 @@
1343
1382
  view.x += p[0] - l[0];
1344
1383
  view.y += p[1] - l[1];
1345
1384
  }
1385
+ function zoomTo(that, p, l, k) {
1386
+ that.__chart__ = {
1387
+ x: view.x,
1388
+ y: view.y,
1389
+ k: view.k
1390
+ };
1391
+ scaleTo(Math.pow(2, k));
1392
+ translateTo(center0 = p, l);
1393
+ that = d3.select(that);
1394
+ if (duration > 0) that = that.transition().duration(duration);
1395
+ that.call(zoom.event);
1396
+ }
1346
1397
  function rescale() {
1347
1398
  if (x1) x1.domain(x0.range().map(function(x) {
1348
1399
  return (x - view.x) / view.k;
@@ -1352,7 +1403,7 @@
1352
1403
  }).map(y0.invert));
1353
1404
  }
1354
1405
  function zoomstarted(dispatch) {
1355
- dispatch({
1406
+ if (!zooming++) dispatch({
1356
1407
  type: "zoomstart"
1357
1408
  });
1358
1409
  }
@@ -1365,9 +1416,10 @@
1365
1416
  });
1366
1417
  }
1367
1418
  function zoomended(dispatch) {
1368
- dispatch({
1419
+ if (!--zooming) dispatch({
1369
1420
  type: "zoomend"
1370
1421
  });
1422
+ center0 = null;
1371
1423
  }
1372
1424
  function mousedowned() {
1373
1425
  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();
@@ -1386,7 +1438,6 @@
1386
1438
  }
1387
1439
  function touchstarted() {
1388
1440
  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
1441
  started();
1391
1442
  zoomstarted(dispatch);
1392
1443
  subject.on(mousedown, null).on(touchstart, started);
@@ -1409,11 +1460,9 @@
1409
1460
  var touches = relocate(), now = Date.now();
1410
1461
  if (touches.length === 1) {
1411
1462
  if (now - touchtime < 500) {
1412
- var p = touches[0], l = locations0[p.identifier];
1413
- scaleTo(view.k * 2);
1414
- translateTo(p, l);
1463
+ var p = touches[0];
1464
+ zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1);
1415
1465
  d3_eventPreventDefault();
1416
- zoomed(dispatch);
1417
1466
  }
1418
1467
  touchtime = now;
1419
1468
  } else if (touches.length > 1) {
@@ -1423,6 +1472,7 @@
1423
1472
  }
1424
1473
  function moved() {
1425
1474
  var touches = d3.touches(that), p0, l0, p1, l1;
1475
+ d3_selection_interrupt.call(that);
1426
1476
  for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {
1427
1477
  p1 = touches[i];
1428
1478
  if (l1 = locations0[p1.identifier]) {
@@ -1470,12 +1520,8 @@
1470
1520
  zoomed(dispatch);
1471
1521
  }
1472
1522
  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);
1523
+ var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2;
1524
+ zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1);
1479
1525
  }
1480
1526
  return d3.rebind(zoom, event, "on");
1481
1527
  };
@@ -3131,6 +3177,15 @@
3131
3177
  d3_geo_centroidPointXYZ(x0, y0, z0);
3132
3178
  }
3133
3179
  }
3180
+ function d3_geo_compose(a, b) {
3181
+ function compose(x, y) {
3182
+ return x = a(x, y), b(x[0], x[1]);
3183
+ }
3184
+ if (a.invert && b.invert) compose.invert = function(x, y) {
3185
+ return x = b.invert(x, y), x && a.invert(x[0], x[1]);
3186
+ };
3187
+ return compose;
3188
+ }
3134
3189
  function d3_true() {
3135
3190
  return true;
3136
3191
  }
@@ -3729,15 +3784,6 @@
3729
3784
  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
3785
  }
3731
3786
  }
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
3787
  function d3_geo_conic(projectAt) {
3742
3788
  var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1);
3743
3789
  p.parallels = function(_) {
@@ -4009,7 +4055,7 @@
4009
4055
  result: d3_noop
4010
4056
  };
4011
4057
  function point(x, y) {
4012
- context.moveTo(x, y);
4058
+ context.moveTo(x + pointRadius, y);
4013
4059
  context.arc(x, y, pointRadius, 0, τ);
4014
4060
  }
4015
4061
  function pointLineStart(x, y) {
@@ -5517,11 +5563,11 @@
5517
5563
  }
5518
5564
  }
5519
5565
  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;
5566
+ var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right;
5521
5567
  n.leaf = false;
5522
5568
  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;
5569
+ if (right) x1 = xm; else x2 = xm;
5570
+ if (below) y1 = ym; else y2 = ym;
5525
5571
  insert(n, d, x, y, x1, y1, x2, y2);
5526
5572
  }
5527
5573
  var root = d3_geom_quadtreeNode();
@@ -5531,6 +5577,9 @@
5531
5577
  root.visit = function(f) {
5532
5578
  d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_);
5533
5579
  };
5580
+ root.find = function(point) {
5581
+ return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_);
5582
+ };
5534
5583
  i = -1;
5535
5584
  if (x1 == null) {
5536
5585
  while (++i < n) {
@@ -5584,6 +5633,42 @@
5584
5633
  if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
5585
5634
  }
5586
5635
  }
5636
+ function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) {
5637
+ var minDistance2 = Infinity, closestPoint;
5638
+ (function find(node, x1, y1, x2, y2) {
5639
+ if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return;
5640
+ if (point = node.point) {
5641
+ var point, dx = x - point[0], dy = y - point[1], distance2 = dx * dx + dy * dy;
5642
+ if (distance2 < minDistance2) {
5643
+ var distance = Math.sqrt(minDistance2 = distance2);
5644
+ x0 = x - distance, y0 = y - distance;
5645
+ x3 = x + distance, y3 = y + distance;
5646
+ closestPoint = point;
5647
+ }
5648
+ }
5649
+ var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym;
5650
+ for (var i = below << 1 | right, j = i + 4; i < j; ++i) {
5651
+ if (node = children[i & 3]) switch (i & 3) {
5652
+ case 0:
5653
+ find(node, x1, y1, xm, ym);
5654
+ break;
5655
+
5656
+ case 1:
5657
+ find(node, xm, y1, x2, ym);
5658
+ break;
5659
+
5660
+ case 2:
5661
+ find(node, x1, ym, xm, y2);
5662
+ break;
5663
+
5664
+ case 3:
5665
+ find(node, xm, ym, x2, y2);
5666
+ break;
5667
+ }
5668
+ }
5669
+ })(root, x0, y0, x3, y3);
5670
+ return closestPoint;
5671
+ }
5587
5672
  d3.interpolateRgb = d3_interpolateRgb;
5588
5673
  function d3_interpolateRgb(a, b) {
5589
5674
  a = d3.rgb(a);
@@ -6475,49 +6560,50 @@
6475
6560
  return d3_layout_hierarchyRebind(partition, hierarchy);
6476
6561
  };
6477
6562
  d3.layout.pie = function() {
6478
- var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ;
6563
+ var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0;
6479
6564
  function pie(data) {
6480
- var values = data.map(function(d, i) {
6565
+ var n = data.length, values = data.map(function(d, i) {
6481
6566
  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);
6567
+ }), 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
6568
  if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {
6487
6569
  return values[j] - values[i];
6488
6570
  } : function(i, j) {
6489
6571
  return sort(data[i], data[j]);
6490
6572
  });
6491
- var arcs = [];
6492
6573
  index.forEach(function(i) {
6493
- var d;
6494
6574
  arcs[i] = {
6495
6575
  data: data[i],
6496
- value: d = values[i],
6576
+ value: v = values[i],
6497
6577
  startAngle: a,
6498
- endAngle: a += d * k
6578
+ endAngle: a += v * k + pa,
6579
+ padAngle: p
6499
6580
  };
6500
6581
  });
6501
6582
  return arcs;
6502
6583
  }
6503
- pie.value = function(x) {
6584
+ pie.value = function(_) {
6504
6585
  if (!arguments.length) return value;
6505
- value = x;
6586
+ value = _;
6506
6587
  return pie;
6507
6588
  };
6508
- pie.sort = function(x) {
6589
+ pie.sort = function(_) {
6509
6590
  if (!arguments.length) return sort;
6510
- sort = x;
6591
+ sort = _;
6511
6592
  return pie;
6512
6593
  };
6513
- pie.startAngle = function(x) {
6594
+ pie.startAngle = function(_) {
6514
6595
  if (!arguments.length) return startAngle;
6515
- startAngle = x;
6596
+ startAngle = _;
6516
6597
  return pie;
6517
6598
  };
6518
- pie.endAngle = function(x) {
6599
+ pie.endAngle = function(_) {
6519
6600
  if (!arguments.length) return endAngle;
6520
- endAngle = x;
6601
+ endAngle = _;
6602
+ return pie;
6603
+ };
6604
+ pie.padAngle = function(_) {
6605
+ if (!arguments.length) return padAngle;
6606
+ padAngle = _;
6521
6607
  return pie;
6522
6608
  };
6523
6609
  return pie;
@@ -7616,8 +7702,9 @@
7616
7702
  };
7617
7703
  scale.rangePoints = function(x, padding) {
7618
7704
  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);
7705
+ var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2,
7706
+ 0) : (stop - start) / (domain.length - 1 + padding);
7707
+ range = steps(start + step * padding / 2, step);
7621
7708
  rangeBand = 0;
7622
7709
  ranger = {
7623
7710
  t: "rangePoints",
@@ -7625,6 +7712,18 @@
7625
7712
  };
7626
7713
  return scale;
7627
7714
  };
7715
+ scale.rangeRoundPoints = function(x, padding) {
7716
+ if (arguments.length < 2) padding = 0;
7717
+ var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2),
7718
+ 0) : (stop - start) / (domain.length - 1 + padding) | 0;
7719
+ range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step);
7720
+ rangeBand = 0;
7721
+ ranger = {
7722
+ t: "rangeRoundPoints",
7723
+ a: arguments
7724
+ };
7725
+ return scale;
7726
+ };
7628
7727
  scale.rangeBands = function(x, padding, outerPadding) {
7629
7728
  if (arguments.length < 2) padding = 0;
7630
7729
  if (arguments.length < 3) outerPadding = padding;
@@ -7641,8 +7740,8 @@
7641
7740
  scale.rangeRoundBands = function(x, padding, outerPadding) {
7642
7741
  if (arguments.length < 2) padding = 0;
7643
7742
  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);
7743
+ var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding));
7744
+ range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step);
7646
7745
  if (reverse) range.reverse();
7647
7746
  rangeBand = Math.round(step * (1 - padding));
7648
7747
  ranger = {
@@ -7799,12 +7898,86 @@
7799
7898
  return identity;
7800
7899
  }
7801
7900
  d3.svg = {};
7901
+ function d3_zero() {
7902
+ return 0;
7903
+ }
7802
7904
  d3.svg.arc = function() {
7803
- var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;
7905
+ 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
7906
  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";
7907
+ 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;
7908
+ if (r1 < r0) rc = r1, r1 = r0, r0 = rc;
7909
+ if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : "") + "Z";
7910
+ var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = [];
7911
+ if (ap = (+padAngle.apply(this, arguments) || 0) / 2) {
7912
+ rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments);
7913
+ if (!cw) p1 *= -1;
7914
+ if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap));
7915
+ if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap));
7916
+ }
7917
+ if (r1) {
7918
+ x0 = r1 * Math.cos(a0 + p1);
7919
+ y0 = r1 * Math.sin(a0 + p1);
7920
+ x1 = r1 * Math.cos(a1 - p1);
7921
+ y1 = r1 * Math.sin(a1 - p1);
7922
+ var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1;
7923
+ if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) {
7924
+ var h1 = (a0 + a1) / 2;
7925
+ x0 = r1 * Math.cos(h1);
7926
+ y0 = r1 * Math.sin(h1);
7927
+ x1 = y1 = null;
7928
+ }
7929
+ } else {
7930
+ x0 = y0 = 0;
7931
+ }
7932
+ if (r0) {
7933
+ x2 = r0 * Math.cos(a1 - p0);
7934
+ y2 = r0 * Math.sin(a1 - p0);
7935
+ x3 = r0 * Math.cos(a0 + p0);
7936
+ y3 = r0 * Math.sin(a0 + p0);
7937
+ var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1;
7938
+ if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) {
7939
+ var h0 = (a0 + a1) / 2;
7940
+ x2 = r0 * Math.cos(h0);
7941
+ y2 = r0 * Math.sin(h0);
7942
+ x3 = y3 = null;
7943
+ }
7944
+ } else {
7945
+ x2 = y2 = 0;
7946
+ }
7947
+ if ((rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) {
7948
+ cr = r0 < r1 ^ cw ? 0 : 1;
7949
+ 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]);
7950
+ if (x1 != null) {
7951
+ 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);
7952
+ if (rc === rc1) {
7953
+ 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]);
7954
+ } else {
7955
+ path.push("M", t30[0], "A", rc1, ",", rc1, " 0 1,", cr, " ", t12[0]);
7956
+ }
7957
+ } else {
7958
+ path.push("M", x0, ",", y0);
7959
+ }
7960
+ if (x3 != null) {
7961
+ 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);
7962
+ if (rc === rc0) {
7963
+ 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]);
7964
+ } else {
7965
+ path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]);
7966
+ }
7967
+ } else {
7968
+ path.push("L", x2, ",", y2);
7969
+ }
7970
+ } else {
7971
+ path.push("M", x0, ",", y0);
7972
+ if (x1 != null) path.push("A", r1, ",", r1, " 0 ", l1, ",", cw, " ", x1, ",", y1);
7973
+ path.push("L", x2, ",", y2);
7974
+ if (x3 != null) path.push("A", r0, ",", r0, " 0 ", l0, ",", 1 - cw, " ", x3, ",", y3);
7975
+ }
7976
+ path.push("Z");
7977
+ return path.join("");
7978
+ }
7979
+ function circleSegment(r1, cw) {
7980
+ return "M0," + r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + -r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + r1;
7808
7981
  }
7809
7982
  arc.innerRadius = function(v) {
7810
7983
  if (!arguments.length) return innerRadius;
@@ -7816,6 +7989,16 @@
7816
7989
  outerRadius = d3_functor(v);
7817
7990
  return arc;
7818
7991
  };
7992
+ arc.cornerRadius = function(v) {
7993
+ if (!arguments.length) return cornerRadius;
7994
+ cornerRadius = d3_functor(v);
7995
+ return arc;
7996
+ };
7997
+ arc.padRadius = function(v) {
7998
+ if (!arguments.length) return padRadius;
7999
+ padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v);
8000
+ return arc;
8001
+ };
7819
8002
  arc.startAngle = function(v) {
7820
8003
  if (!arguments.length) return startAngle;
7821
8004
  startAngle = d3_functor(v);
@@ -7826,13 +8009,18 @@
7826
8009
  endAngle = d3_functor(v);
7827
8010
  return arc;
7828
8011
  };
8012
+ arc.padAngle = function(v) {
8013
+ if (!arguments.length) return padAngle;
8014
+ padAngle = d3_functor(v);
8015
+ return arc;
8016
+ };
7829
8017
  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;
8018
+ var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - halfπ;
7831
8019
  return [ Math.cos(a) * r, Math.sin(a) * r ];
7832
8020
  };
7833
8021
  return arc;
7834
8022
  };
7835
- var d3_svg_arcOffset = -halfπ, d3_svg_arcMax = τ - ε;
8023
+ var d3_svg_arcAuto = "auto";
7836
8024
  function d3_svg_arcInnerRadius(d) {
7837
8025
  return d.innerRadius;
7838
8026
  }
@@ -7845,6 +8033,17 @@
7845
8033
  function d3_svg_arcEndAngle(d) {
7846
8034
  return d.endAngle;
7847
8035
  }
8036
+ function d3_svg_arcPadAngle(d) {
8037
+ return d && d.padAngle;
8038
+ }
8039
+ function d3_svg_arcSweep(x0, y0, x1, y1) {
8040
+ return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1;
8041
+ }
8042
+ function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) {
8043
+ 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;
8044
+ if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
8045
+ return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ];
8046
+ }
7848
8047
  function d3_svg_line(projection) {
7849
8048
  var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;
7850
8049
  function line(data) {
@@ -7935,7 +8134,7 @@
7935
8134
  return path.join("");
7936
8135
  }
7937
8136
  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));
8137
+ return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));
7939
8138
  }
7940
8139
  function d3_svg_lineCardinalClosed(points, tension) {
7941
8140
  return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]),
@@ -8105,7 +8304,7 @@
8105
8304
  while (++i < n) {
8106
8305
  point = points[i];
8107
8306
  r = point[0];
8108
- a = point[1] + d3_svg_arcOffset;
8307
+ a = point[1] - halfπ;
8109
8308
  point[0] = r * Math.cos(a);
8110
8309
  point[1] = r * Math.sin(a);
8111
8310
  }
@@ -8206,7 +8405,7 @@
8206
8405
  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
8406
  }
8208
8407
  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;
8408
+ 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
8409
  return {
8211
8410
  r: r,
8212
8411
  a0: a0,
@@ -8296,7 +8495,7 @@
8296
8495
  };
8297
8496
  function d3_svg_diagonalRadialProjection(projection) {
8298
8497
  return function() {
8299
- var d = projection.apply(this, arguments), r = d[0], a = d[1] + d3_svg_arcOffset;
8498
+ var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ;
8300
8499
  return [ r * Math.cos(a), r * Math.sin(a) ];
8301
8500
  };
8302
8501
  }
@@ -8352,8 +8551,43 @@
8352
8551
  });
8353
8552
  d3.svg.symbolTypes = d3_svg_symbols.keys();
8354
8553
  var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);
8355
- function d3_transition(groups, id) {
8554
+ d3_selectionPrototype.transition = function(name) {
8555
+ var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || {
8556
+ time: Date.now(),
8557
+ ease: d3_ease_cubicInOut,
8558
+ delay: 0,
8559
+ duration: 250
8560
+ };
8561
+ for (var j = -1, m = this.length; ++j < m; ) {
8562
+ subgroups.push(subgroup = []);
8563
+ for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8564
+ if (node = group[i]) d3_transitionNode(node, i, ns, id, transition);
8565
+ subgroup.push(node);
8566
+ }
8567
+ }
8568
+ return d3_transition(subgroups, ns, id);
8569
+ };
8570
+ d3_selectionPrototype.interrupt = function(name) {
8571
+ return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name)));
8572
+ };
8573
+ var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace());
8574
+ function d3_selection_interruptNS(ns) {
8575
+ return function() {
8576
+ var lock, active;
8577
+ if ((lock = this[ns]) && (active = lock[lock.active])) {
8578
+ if (--lock.count) {
8579
+ delete lock[lock.active];
8580
+ lock.active += .5;
8581
+ } else {
8582
+ delete this[ns];
8583
+ }
8584
+ active.event && active.event.interrupt.call(this, this.__data__, active.index);
8585
+ }
8586
+ };
8587
+ }
8588
+ function d3_transition(groups, ns, id) {
8356
8589
  d3_subclass(groups, d3_transitionPrototype);
8590
+ groups.namespace = ns;
8357
8591
  groups.id = id;
8358
8592
  return groups;
8359
8593
  }
@@ -8362,44 +8596,44 @@
8362
8596
  d3_transitionPrototype.empty = d3_selectionPrototype.empty;
8363
8597
  d3_transitionPrototype.node = d3_selectionPrototype.node;
8364
8598
  d3_transitionPrototype.size = d3_selectionPrototype.size;
8365
- d3.transition = function(selection) {
8366
- return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition();
8599
+ d3.transition = function(selection, name) {
8600
+ return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3_selectionRoot.transition(selection);
8367
8601
  };
8368
8602
  d3.transition.prototype = d3_transitionPrototype;
8369
8603
  d3_transitionPrototype.select = function(selector) {
8370
- var id = this.id, subgroups = [], subgroup, subnode, node;
8604
+ var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node;
8371
8605
  selector = d3_selection_selector(selector);
8372
8606
  for (var j = -1, m = this.length; ++j < m; ) {
8373
8607
  subgroups.push(subgroup = []);
8374
8608
  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8375
8609
  if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) {
8376
8610
  if ("__data__" in node) subnode.__data__ = node.__data__;
8377
- d3_transitionNode(subnode, i, id, node.__transition__[id]);
8611
+ d3_transitionNode(subnode, i, ns, id, node[ns][id]);
8378
8612
  subgroup.push(subnode);
8379
8613
  } else {
8380
8614
  subgroup.push(null);
8381
8615
  }
8382
8616
  }
8383
8617
  }
8384
- return d3_transition(subgroups, id);
8618
+ return d3_transition(subgroups, ns, id);
8385
8619
  };
8386
8620
  d3_transitionPrototype.selectAll = function(selector) {
8387
- var id = this.id, subgroups = [], subgroup, subnodes, node, subnode, transition;
8621
+ var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition;
8388
8622
  selector = d3_selection_selectorAll(selector);
8389
8623
  for (var j = -1, m = this.length; ++j < m; ) {
8390
8624
  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8391
8625
  if (node = group[i]) {
8392
- transition = node.__transition__[id];
8626
+ transition = node[ns][id];
8393
8627
  subnodes = selector.call(node, node.__data__, i, j);
8394
8628
  subgroups.push(subgroup = []);
8395
8629
  for (var k = -1, o = subnodes.length; ++k < o; ) {
8396
- if (subnode = subnodes[k]) d3_transitionNode(subnode, k, id, transition);
8630
+ if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition);
8397
8631
  subgroup.push(subnode);
8398
8632
  }
8399
8633
  }
8400
8634
  }
8401
8635
  }
8402
- return d3_transition(subgroups, id);
8636
+ return d3_transition(subgroups, ns, id);
8403
8637
  };
8404
8638
  d3_transitionPrototype.filter = function(filter) {
8405
8639
  var subgroups = [], subgroup, group, node;
@@ -8412,23 +8646,23 @@
8412
8646
  }
8413
8647
  }
8414
8648
  }
8415
- return d3_transition(subgroups, this.id);
8649
+ return d3_transition(subgroups, this.namespace, this.id);
8416
8650
  };
8417
8651
  d3_transitionPrototype.tween = function(name, tween) {
8418
- var id = this.id;
8419
- if (arguments.length < 2) return this.node().__transition__[id].tween.get(name);
8652
+ var id = this.id, ns = this.namespace;
8653
+ if (arguments.length < 2) return this.node()[ns][id].tween.get(name);
8420
8654
  return d3_selection_each(this, tween == null ? function(node) {
8421
- node.__transition__[id].tween.remove(name);
8655
+ node[ns][id].tween.remove(name);
8422
8656
  } : function(node) {
8423
- node.__transition__[id].tween.set(name, tween);
8657
+ node[ns][id].tween.set(name, tween);
8424
8658
  });
8425
8659
  };
8426
8660
  function d3_transition_tween(groups, name, value, tween) {
8427
- var id = groups.id;
8661
+ var id = groups.id, ns = groups.namespace;
8428
8662
  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)));
8663
+ node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j)));
8430
8664
  } : (value = tween(value), function(node) {
8431
- node.__transition__[id].tween.set(name, value);
8665
+ node[ns][id].tween.set(name, value);
8432
8666
  }));
8433
8667
  }
8434
8668
  d3_transitionPrototype.attr = function(nameNS, value) {
@@ -8520,73 +8754,84 @@
8520
8754
  };
8521
8755
  }
8522
8756
  d3_transitionPrototype.remove = function() {
8757
+ var ns = this.namespace;
8523
8758
  return this.each("end.transition", function() {
8524
8759
  var p;
8525
- if (this.__transition__.count < 2 && (p = this.parentNode)) p.removeChild(this);
8760
+ if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this);
8526
8761
  });
8527
8762
  };
8528
8763
  d3_transitionPrototype.ease = function(value) {
8529
- var id = this.id;
8530
- if (arguments.length < 1) return this.node().__transition__[id].ease;
8764
+ var id = this.id, ns = this.namespace;
8765
+ if (arguments.length < 1) return this.node()[ns][id].ease;
8531
8766
  if (typeof value !== "function") value = d3.ease.apply(d3, arguments);
8532
8767
  return d3_selection_each(this, function(node) {
8533
- node.__transition__[id].ease = value;
8768
+ node[ns][id].ease = value;
8534
8769
  });
8535
8770
  };
8536
8771
  d3_transitionPrototype.delay = function(value) {
8537
- var id = this.id;
8538
- if (arguments.length < 1) return this.node().__transition__[id].delay;
8772
+ var id = this.id, ns = this.namespace;
8773
+ if (arguments.length < 1) return this.node()[ns][id].delay;
8539
8774
  return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8540
- node.__transition__[id].delay = +value.call(node, node.__data__, i, j);
8775
+ node[ns][id].delay = +value.call(node, node.__data__, i, j);
8541
8776
  } : (value = +value, function(node) {
8542
- node.__transition__[id].delay = value;
8777
+ node[ns][id].delay = value;
8543
8778
  }));
8544
8779
  };
8545
8780
  d3_transitionPrototype.duration = function(value) {
8546
- var id = this.id;
8547
- if (arguments.length < 1) return this.node().__transition__[id].duration;
8781
+ var id = this.id, ns = this.namespace;
8782
+ if (arguments.length < 1) return this.node()[ns][id].duration;
8548
8783
  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));
8784
+ node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j));
8550
8785
  } : (value = Math.max(1, value), function(node) {
8551
- node.__transition__[id].duration = value;
8786
+ node[ns][id].duration = value;
8552
8787
  }));
8553
8788
  };
8554
8789
  d3_transitionPrototype.each = function(type, listener) {
8555
- var id = this.id;
8790
+ var id = this.id, ns = this.namespace;
8556
8791
  if (arguments.length < 2) {
8557
8792
  var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;
8558
- d3_transitionInheritId = id;
8559
- d3_selection_each(this, function(node, i, j) {
8560
- d3_transitionInherit = node.__transition__[id];
8561
- type.call(node, node.__data__, i, j);
8562
- });
8563
- d3_transitionInherit = inherit;
8564
- d3_transitionInheritId = inheritId;
8793
+ try {
8794
+ d3_transitionInheritId = id;
8795
+ d3_selection_each(this, function(node, i, j) {
8796
+ d3_transitionInherit = node[ns][id];
8797
+ type.call(node, node.__data__, i, j);
8798
+ });
8799
+ } finally {
8800
+ d3_transitionInherit = inherit;
8801
+ d3_transitionInheritId = inheritId;
8802
+ }
8565
8803
  } else {
8566
8804
  d3_selection_each(this, function(node) {
8567
- var transition = node.__transition__[id];
8568
- (transition.event || (transition.event = d3.dispatch("start", "end"))).on(type, listener);
8805
+ var transition = node[ns][id];
8806
+ (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener);
8569
8807
  });
8570
8808
  }
8571
8809
  return this;
8572
8810
  };
8573
8811
  d3_transitionPrototype.transition = function() {
8574
- var id0 = this.id, id1 = ++d3_transitionId, subgroups = [], subgroup, group, node, transition;
8812
+ var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition;
8575
8813
  for (var j = 0, m = this.length; j < m; j++) {
8576
8814
  subgroups.push(subgroup = []);
8577
8815
  for (var group = this[j], i = 0, n = group.length; i < n; i++) {
8578
8816
  if (node = group[i]) {
8579
- transition = Object.create(node.__transition__[id0]);
8580
- transition.delay += transition.duration;
8581
- d3_transitionNode(node, i, id1, transition);
8817
+ transition = node[ns][id0];
8818
+ d3_transitionNode(node, i, ns, id1, {
8819
+ time: transition.time,
8820
+ ease: transition.ease,
8821
+ delay: transition.delay + transition.duration,
8822
+ duration: transition.duration
8823
+ });
8582
8824
  }
8583
8825
  subgroup.push(node);
8584
8826
  }
8585
8827
  }
8586
- return d3_transition(subgroups, id1);
8828
+ return d3_transition(subgroups, ns, id1);
8587
8829
  };
8588
- function d3_transitionNode(node, i, id, inherit) {
8589
- var lock = node.__transition__ || (node.__transition__ = {
8830
+ function d3_transitionNamespace(name) {
8831
+ return name == null ? "__transition__" : "__transition_" + name + "__";
8832
+ }
8833
+ function d3_transitionNode(node, i, ns, id, inherit) {
8834
+ var lock = node[ns] || (node[ns] = {
8590
8835
  active: 0,
8591
8836
  count: 0
8592
8837
  }), transition = lock[id];
@@ -8595,43 +8840,53 @@
8595
8840
  transition = lock[id] = {
8596
8841
  tween: new d3_Map(),
8597
8842
  time: time,
8598
- ease: inherit.ease,
8599
8843
  delay: inherit.delay,
8600
- duration: inherit.duration
8844
+ duration: inherit.duration,
8845
+ ease: inherit.ease,
8846
+ index: i
8601
8847
  };
8848
+ inherit = null;
8602
8849
  ++lock.count;
8603
8850
  d3.timer(function(elapsed) {
8604
- var d = node.__data__, ease = transition.ease, delay = transition.delay, duration = transition.duration, timer = d3_timer_active, tweened = [];
8851
+ var delay = transition.delay, duration, ease, timer = d3_timer_active, tweened = [];
8605
8852
  timer.t = delay + time;
8606
8853
  if (delay <= elapsed) return start(elapsed - delay);
8607
8854
  timer.c = start;
8608
8855
  function start(elapsed) {
8609
8856
  if (lock.active > id) return stop();
8857
+ var active = lock[lock.active];
8858
+ if (active) {
8859
+ --lock.count;
8860
+ delete lock[lock.active];
8861
+ active.event && active.event.interrupt.call(node, node.__data__, active.index);
8862
+ }
8610
8863
  lock.active = id;
8611
- transition.event && transition.event.start.call(node, d, i);
8864
+ transition.event && transition.event.start.call(node, node.__data__, i);
8612
8865
  transition.tween.forEach(function(key, value) {
8613
- if (value = value.call(node, d, i)) {
8866
+ if (value = value.call(node, node.__data__, i)) {
8614
8867
  tweened.push(value);
8615
8868
  }
8616
8869
  });
8870
+ ease = transition.ease;
8871
+ duration = transition.duration;
8617
8872
  d3.timer(function() {
8618
8873
  timer.c = tick(elapsed || 1) ? d3_true : tick;
8619
8874
  return 1;
8620
8875
  }, 0, time);
8621
8876
  }
8622
8877
  function tick(elapsed) {
8623
- if (lock.active !== id) return stop();
8878
+ if (lock.active !== id) return 1;
8624
8879
  var t = elapsed / duration, e = ease(t), n = tweened.length;
8625
8880
  while (n > 0) {
8626
8881
  tweened[--n].call(node, e);
8627
8882
  }
8628
8883
  if (t >= 1) {
8629
- transition.event && transition.event.end.call(node, d, i);
8884
+ transition.event && transition.event.end.call(node, node.__data__, i);
8630
8885
  return stop();
8631
8886
  }
8632
8887
  }
8633
8888
  function stop() {
8634
- if (--lock.count) delete lock[id]; else delete node.__transition__;
8889
+ if (--lock.count) delete lock[id]; else delete node[ns];
8635
8890
  return 1;
8636
8891
  }
8637
8892
  }, 0, time);