d3c3-rails 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  !function() {
2
2
  var d3 = {
3
- version: "3.4.11"
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;
@@ -78,35 +96,42 @@
78
96
  }
79
97
  return [ a, c ];
80
98
  };
99
+ function d3_number(x) {
100
+ return x === null ? NaN : +x;
101
+ }
102
+ function d3_numeric(x) {
103
+ return !isNaN(x);
104
+ }
81
105
  d3.sum = function(array, f) {
82
106
  var s = 0, n = array.length, a, i = -1;
83
107
  if (arguments.length === 1) {
84
- while (++i < n) if (!isNaN(a = +array[i])) s += a;
108
+ while (++i < n) if (d3_numeric(a = +array[i])) s += a;
85
109
  } else {
86
- while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a;
110
+ while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a;
87
111
  }
88
112
  return s;
89
113
  };
90
- function d3_number(x) {
91
- return x != null && !isNaN(x);
92
- }
93
114
  d3.mean = function(array, f) {
94
115
  var s = 0, n = array.length, a, i = -1, j = n;
95
116
  if (arguments.length === 1) {
96
- while (++i < n) if (d3_number(a = array[i])) s += a; else --j;
117
+ while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j;
97
118
  } else {
98
- while (++i < n) if (d3_number(a = f.call(array, array[i], i))) s += a; else --j;
119
+ while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j;
99
120
  }
100
- return j ? s / j : undefined;
121
+ if (j) return s / j;
101
122
  };
102
123
  d3.quantile = function(values, p) {
103
124
  var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;
104
125
  return e ? v + e * (values[h] - v) : v;
105
126
  };
106
127
  d3.median = function(array, f) {
107
- if (arguments.length > 1) array = array.map(f);
108
- array = array.filter(d3_number);
109
- return array.length ? d3.quantile(array.sort(d3_ascending), .5) : undefined;
128
+ var numbers = [], n = array.length, a, i = -1;
129
+ if (arguments.length === 1) {
130
+ while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a);
131
+ } else {
132
+ while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a);
133
+ }
134
+ if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5);
110
135
  };
111
136
  function d3_bisector(compare) {
112
137
  return {
@@ -138,11 +163,15 @@
138
163
  return d3_ascending(f(d), x);
139
164
  } : f);
140
165
  };
141
- d3.shuffle = function(array) {
142
- 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;
143
172
  while (m) {
144
173
  i = Math.random() * m-- | 0;
145
- 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;
146
175
  }
147
176
  return array;
148
177
  };
@@ -223,80 +252,84 @@
223
252
  return k;
224
253
  }
225
254
  function d3_class(ctor, properties) {
226
- try {
227
- for (var key in properties) {
228
- Object.defineProperty(ctor.prototype, key, {
229
- value: properties[key],
230
- enumerable: false
231
- });
232
- }
233
- } catch (e) {
234
- ctor.prototype = properties;
255
+ for (var key in properties) {
256
+ Object.defineProperty(ctor.prototype, key, {
257
+ value: properties[key],
258
+ enumerable: false
259
+ });
235
260
  }
236
261
  }
237
- d3.map = function(object) {
262
+ d3.map = function(object, f) {
238
263
  var map = new d3_Map();
239
- if (object instanceof d3_Map) object.forEach(function(key, value) {
240
- map.set(key, value);
241
- }); 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
+ }
242
274
  return map;
243
275
  };
244
- function d3_Map() {}
276
+ function d3_Map() {
277
+ this._ = Object.create(null);
278
+ }
279
+ var d3_map_proto = "__proto__", d3_map_zero = "\x00";
245
280
  d3_class(d3_Map, {
246
281
  has: d3_map_has,
247
282
  get: function(key) {
248
- return this[d3_map_prefix + key];
283
+ return this._[d3_map_escape(key)];
249
284
  },
250
285
  set: function(key, value) {
251
- return this[d3_map_prefix + key] = value;
286
+ return this._[d3_map_escape(key)] = value;
252
287
  },
253
288
  remove: d3_map_remove,
254
289
  keys: d3_map_keys,
255
290
  values: function() {
256
291
  var values = [];
257
- this.forEach(function(key, value) {
258
- values.push(value);
259
- });
292
+ for (var key in this._) values.push(this._[key]);
260
293
  return values;
261
294
  },
262
295
  entries: function() {
263
296
  var entries = [];
264
- this.forEach(function(key, value) {
265
- entries.push({
266
- key: key,
267
- value: value
268
- });
297
+ for (var key in this._) entries.push({
298
+ key: d3_map_unescape(key),
299
+ value: this._[key]
269
300
  });
270
301
  return entries;
271
302
  },
272
303
  size: d3_map_size,
273
304
  empty: d3_map_empty,
274
305
  forEach: function(f) {
275
- for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) f.call(this, key.substring(1), this[key]);
306
+ for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]);
276
307
  }
277
308
  });
278
- var d3_map_prefix = "\x00", d3_map_prefixCode = d3_map_prefix.charCodeAt(0);
309
+ function d3_map_escape(key) {
310
+ return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key;
311
+ }
312
+ function d3_map_unescape(key) {
313
+ return (key += "")[0] === d3_map_zero ? key.slice(1) : key;
314
+ }
279
315
  function d3_map_has(key) {
280
- return d3_map_prefix + key in this;
316
+ return d3_map_escape(key) in this._;
281
317
  }
282
318
  function d3_map_remove(key) {
283
- key = d3_map_prefix + key;
284
- return key in this && delete this[key];
319
+ return (key = d3_map_escape(key)) in this._ && delete this._[key];
285
320
  }
286
321
  function d3_map_keys() {
287
322
  var keys = [];
288
- this.forEach(function(key) {
289
- keys.push(key);
290
- });
323
+ for (var key in this._) keys.push(d3_map_unescape(key));
291
324
  return keys;
292
325
  }
293
326
  function d3_map_size() {
294
327
  var size = 0;
295
- for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) ++size;
328
+ for (var key in this._) ++size;
296
329
  return size;
297
330
  }
298
331
  function d3_map_empty() {
299
- for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) return false;
332
+ for (var key in this._) return false;
300
333
  return true;
301
334
  }
302
335
  d3.nest = function() {
@@ -367,22 +400,21 @@
367
400
  if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]);
368
401
  return set;
369
402
  };
370
- function d3_Set() {}
403
+ function d3_Set() {
404
+ this._ = Object.create(null);
405
+ }
371
406
  d3_class(d3_Set, {
372
407
  has: d3_map_has,
373
- add: function(value) {
374
- this[d3_map_prefix + value] = true;
375
- return value;
376
- },
377
- remove: function(value) {
378
- value = d3_map_prefix + value;
379
- return value in this && delete this[value];
408
+ add: function(key) {
409
+ this._[d3_map_escape(key += "")] = true;
410
+ return key;
380
411
  },
412
+ remove: d3_map_remove,
381
413
  values: d3_map_keys,
382
414
  size: d3_map_size,
383
415
  empty: d3_map_empty,
384
416
  forEach: function(f) {
385
- for (var value in this) if (value.charCodeAt(0) === d3_map_prefixCode) f.call(this, value.substring(1));
417
+ for (var key in this._) f.call(this, d3_map_unescape(key));
386
418
  }
387
419
  });
388
420
  d3.behavior = {};
@@ -399,7 +431,7 @@
399
431
  }
400
432
  function d3_vendorSymbol(object, name) {
401
433
  if (name in object) return name;
402
- name = name.charAt(0).toUpperCase() + name.substring(1);
434
+ name = name.charAt(0).toUpperCase() + name.slice(1);
403
435
  for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) {
404
436
  var prefixName = d3_vendorPrefixes[i] + name;
405
437
  if (prefixName in object) return prefixName;
@@ -416,8 +448,8 @@
416
448
  d3_dispatch.prototype.on = function(type, listener) {
417
449
  var i = type.indexOf("."), name = "";
418
450
  if (i >= 0) {
419
- name = type.substring(i + 1);
420
- type = type.substring(0, i);
451
+ name = type.slice(i + 1);
452
+ type = type.slice(0, i);
421
453
  }
422
454
  if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener);
423
455
  if (arguments.length === 2) {
@@ -558,8 +590,8 @@
558
590
  qualify: function(name) {
559
591
  var i = name.indexOf(":"), prefix = name;
560
592
  if (i >= 0) {
561
- prefix = name.substring(0, i);
562
- name = name.substring(i + 1);
593
+ prefix = name.slice(0, i);
594
+ name = name.slice(i + 1);
563
595
  }
564
596
  return d3_nsPrefix.hasOwnProperty(prefix) ? {
565
597
  space: d3_nsPrefix[prefix],
@@ -743,11 +775,12 @@
743
775
  });
744
776
  };
745
777
  d3_selectionPrototype.remove = function() {
746
- return this.each(function() {
747
- var parent = this.parentNode;
748
- if (parent) parent.removeChild(this);
749
- });
778
+ return this.each(d3_selectionRemove);
750
779
  };
780
+ function d3_selectionRemove() {
781
+ var parent = this.parentNode;
782
+ if (parent) parent.removeChild(this);
783
+ }
751
784
  d3_selectionPrototype.data = function(value, key) {
752
785
  var i = -1, n = this.length, group, node;
753
786
  if (!arguments.length) {
@@ -762,29 +795,26 @@
762
795
  function bind(group, groupData) {
763
796
  var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData;
764
797
  if (key) {
765
- var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue;
798
+ var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue;
766
799
  for (i = -1; ++i < n; ) {
767
- keyValue = key.call(node = group[i], node.__data__, i);
768
- if (nodeByKeyValue.has(keyValue)) {
800
+ if (nodeByKeyValue.has(keyValue = key.call(node = group[i], node.__data__, i))) {
769
801
  exitNodes[i] = node;
770
802
  } else {
771
803
  nodeByKeyValue.set(keyValue, node);
772
804
  }
773
- keyValues.push(keyValue);
805
+ keyValues[i] = keyValue;
774
806
  }
775
807
  for (i = -1; ++i < m; ) {
776
- keyValue = key.call(groupData, nodeData = groupData[i], i);
777
- if (node = nodeByKeyValue.get(keyValue)) {
808
+ if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) {
809
+ enterNodes[i] = d3_selection_dataNode(nodeData);
810
+ } else if (node !== true) {
778
811
  updateNodes[i] = node;
779
812
  node.__data__ = nodeData;
780
- } else if (!dataByKeyValue.has(keyValue)) {
781
- enterNodes[i] = d3_selection_dataNode(nodeData);
782
813
  }
783
- dataByKeyValue.set(keyValue, nodeData);
784
- nodeByKeyValue.remove(keyValue);
814
+ nodeByKeyValue.set(keyValue, true);
785
815
  }
786
816
  for (i = -1; ++i < n; ) {
787
- if (nodeByKeyValue.has(keyValues[i])) {
817
+ if (nodeByKeyValue.get(keyValues[i]) !== true) {
788
818
  exitNodes[i] = group[i];
789
819
  }
790
820
  }
@@ -911,7 +941,7 @@
911
941
  };
912
942
  d3_selectionPrototype.size = function() {
913
943
  var n = 0;
914
- this.each(function() {
944
+ d3_selection_each(this, function() {
915
945
  ++n;
916
946
  });
917
947
  return n;
@@ -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) {
@@ -1008,7 +1042,7 @@
1008
1042
  };
1009
1043
  function d3_selection_on(type, listener, capture) {
1010
1044
  var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener;
1011
- if (i > 0) type = type.substring(0, i);
1045
+ if (i > 0) type = type.slice(0, i);
1012
1046
  var filter = d3_selection_onFilters.get(type);
1013
1047
  if (filter) type = filter, wrap = d3_selection_onFilter;
1014
1048
  function onRemove() {
@@ -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();
@@ -1116,13 +1150,13 @@
1116
1150
  var rect = container.getBoundingClientRect();
1117
1151
  return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];
1118
1152
  }
1119
- d3.touches = function(container, touches) {
1120
- if (arguments.length < 2) touches = d3_eventSource().touches;
1121
- return touches ? d3_array(touches).map(function(touch) {
1122
- var point = d3_mousePoint(container, touch);
1123
- point.identifier = touch.identifier;
1124
- return point;
1125
- }) : [];
1153
+ d3.touch = function(container, touches, identifier) {
1154
+ if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches;
1155
+ if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) {
1156
+ if ((touch = touches[i]).identifier === identifier) {
1157
+ return d3_mousePoint(container, touch);
1158
+ }
1159
+ }
1126
1160
  };
1127
1161
  d3.behavior.drag = function() {
1128
1162
  var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_behavior_dragMouseSubject, "mousemove", "mouseup"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_behavior_dragTouchSubject, "touchmove", "touchend");
@@ -1182,7 +1216,15 @@
1182
1216
  function d3_behavior_dragMouseSubject() {
1183
1217
  return d3_window;
1184
1218
  }
1185
- var π = Math.PI, τ = 2 * π, halfπ = π / 2, ε = 1e-6, ε2 = ε * ε, d3_radians = π / 180, d3_degrees = 180 / π;
1219
+ d3.touches = function(container, touches) {
1220
+ if (arguments.length < 2) touches = d3_eventSource().touches;
1221
+ return touches ? d3_array(touches).map(function(touch) {
1222
+ var point = d3_mousePoint(container, touch);
1223
+ point.identifier = touch.identifier;
1224
+ return point;
1225
+ }) : [];
1226
+ };
1227
+ var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
1186
1228
  function d3_sgn(x) {
1187
1229
  return x > 0 ? 1 : x < 0 ? -1 : 0;
1188
1230
  }
@@ -1227,7 +1269,7 @@
1227
1269
  x: 0,
1228
1270
  y: 0,
1229
1271
  k: 1
1230
- }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1;
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;
1231
1273
  function zoom(g) {
1232
1274
  g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1233
1275
  }
@@ -1243,7 +1285,7 @@
1243
1285
  };
1244
1286
  zoomstarted(dispatch);
1245
1287
  }).tween("zoom:zoom", function() {
1246
- 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 ]);
1247
1289
  return function(t) {
1248
1290
  var l = i(t), k = dx / l[2];
1249
1291
  this.__chart__ = view = {
@@ -1253,6 +1295,8 @@
1253
1295
  };
1254
1296
  zoomed(dispatch);
1255
1297
  };
1298
+ }).each("interrupt.zoom", function() {
1299
+ zoomended(dispatch);
1256
1300
  }).each("end.zoom", function() {
1257
1301
  zoomended(dispatch);
1258
1302
  });
@@ -1299,6 +1343,11 @@
1299
1343
  size = _ && [ +_[0], +_[1] ];
1300
1344
  return zoom;
1301
1345
  };
1346
+ zoom.duration = function(_) {
1347
+ if (!arguments.length) return duration;
1348
+ duration = +_;
1349
+ return zoom;
1350
+ };
1302
1351
  zoom.x = function(z) {
1303
1352
  if (!arguments.length) return x1;
1304
1353
  x1 = z;
@@ -1335,6 +1384,18 @@
1335
1384
  view.x += p[0] - l[0];
1336
1385
  view.y += p[1] - l[1];
1337
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
+ }
1338
1399
  function rescale() {
1339
1400
  if (x1) x1.domain(x0.range().map(function(x) {
1340
1401
  return (x - view.x) / view.k;
@@ -1344,7 +1405,7 @@
1344
1405
  }).map(y0.invert));
1345
1406
  }
1346
1407
  function zoomstarted(dispatch) {
1347
- dispatch({
1408
+ if (!zooming++) dispatch({
1348
1409
  type: "zoomstart"
1349
1410
  });
1350
1411
  }
@@ -1357,13 +1418,14 @@
1357
1418
  });
1358
1419
  }
1359
1420
  function zoomended(dispatch) {
1360
- dispatch({
1421
+ if (!--zooming) dispatch({
1361
1422
  type: "zoomend"
1362
1423
  });
1424
+ center0 = null;
1363
1425
  }
1364
1426
  function mousedowned() {
1365
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();
1366
- d3_selection_interrupt.call(that);
1428
+ d3_selection_interrupt(that);
1367
1429
  zoomstarted(dispatch);
1368
1430
  function moved() {
1369
1431
  dragged = 1;
@@ -1377,10 +1439,10 @@
1377
1439
  }
1378
1440
  }
1379
1441
  function touchstarted() {
1380
- var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress();
1381
- d3_selection_interrupt.call(that);
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();
1382
1443
  started();
1383
1444
  zoomstarted(dispatch);
1445
+ subject.on(mousedown, null).on(touchstart, started);
1384
1446
  function relocate() {
1385
1447
  var touches = d3.touches(that);
1386
1448
  scale0 = view.k;
@@ -1400,11 +1462,9 @@
1400
1462
  var touches = relocate(), now = Date.now();
1401
1463
  if (touches.length === 1) {
1402
1464
  if (now - touchtime < 500) {
1403
- var p = touches[0], l = locations0[p.identifier];
1404
- scaleTo(view.k * 2);
1405
- translateTo(p, l);
1465
+ var p = touches[0];
1466
+ zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1);
1406
1467
  d3_eventPreventDefault();
1407
- zoomed(dispatch);
1408
1468
  }
1409
1469
  touchtime = now;
1410
1470
  } else if (touches.length > 1) {
@@ -1414,6 +1474,7 @@
1414
1474
  }
1415
1475
  function moved() {
1416
1476
  var touches = d3.touches(that), p0, l0, p1, l1;
1477
+ d3_selection_interrupt(that);
1417
1478
  for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {
1418
1479
  p1 = touches[i];
1419
1480
  if (l1 = locations0[p1.identifier]) {
@@ -1450,7 +1511,7 @@
1450
1511
  function mousewheeled() {
1451
1512
  var dispatch = event.of(this, arguments);
1452
1513
  if (mousewheelTimer) clearTimeout(mousewheelTimer); else translate0 = location(center0 = center || d3.mouse(this)),
1453
- d3_selection_interrupt.call(this), zoomstarted(dispatch);
1514
+ d3_selection_interrupt(this), zoomstarted(dispatch);
1454
1515
  mousewheelTimer = setTimeout(function() {
1455
1516
  mousewheelTimer = null;
1456
1517
  zoomended(dispatch);
@@ -1461,12 +1522,8 @@
1461
1522
  zoomed(dispatch);
1462
1523
  }
1463
1524
  function dblclicked() {
1464
- var dispatch = event.of(this, arguments), p = d3.mouse(this), l = location(p), k = Math.log(view.k) / Math.LN2;
1465
- zoomstarted(dispatch);
1466
- scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1));
1467
- translateTo(p, l);
1468
- zoomed(dispatch);
1469
- 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);
1470
1527
  }
1471
1528
  return d3.rebind(zoom, event, "on");
1472
1529
  };
@@ -1539,7 +1596,7 @@
1539
1596
  }
1540
1597
  d3.lab = d3_lab;
1541
1598
  function d3_lab(l, a, b) {
1542
- return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b);
1599
+ return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b);
1543
1600
  }
1544
1601
  var d3_lab_K = 18;
1545
1602
  var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;
@@ -1623,7 +1680,7 @@
1623
1680
  }
1624
1681
  }
1625
1682
  if (color = d3_rgb_names.get(format)) return rgb(color.r, color.g, color.b);
1626
- if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.substring(1), 16))) {
1683
+ if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) {
1627
1684
  if (format.length === 4) {
1628
1685
  r = (color & 3840) >> 4;
1629
1686
  r = r >> 4 | r;
@@ -1842,7 +1899,7 @@
1842
1899
  };
1843
1900
  function respond() {
1844
1901
  var status = request.status, result;
1845
- if (!status && request.responseText || status >= 200 && status < 300 || status === 304) {
1902
+ if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) {
1846
1903
  try {
1847
1904
  result = response.call(xhr, request);
1848
1905
  } catch (e) {
@@ -1914,6 +1971,10 @@
1914
1971
  callback(error == null ? request : null);
1915
1972
  } : callback;
1916
1973
  }
1974
+ function d3_xhrHasResponse(request) {
1975
+ var type = request.responseType;
1976
+ return type && type !== "text" ? request.response : request.responseText;
1977
+ }
1917
1978
  d3.dsv = function(delimiter, mimeType) {
1918
1979
  var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0);
1919
1980
  function dsv(url, row, callback) {
@@ -1966,7 +2027,7 @@
1966
2027
  } else if (c === 10) {
1967
2028
  eol = true;
1968
2029
  }
1969
- return text.substring(j + 1, i).replace(/""/g, '"');
2030
+ return text.slice(j + 1, i).replace(/""/g, '"');
1970
2031
  }
1971
2032
  while (I < N) {
1972
2033
  var c = text.charCodeAt(I++), k = 1;
@@ -1974,9 +2035,9 @@
1974
2035
  eol = true;
1975
2036
  if (text.charCodeAt(I) === 10) ++I, ++k;
1976
2037
  } else if (c !== delimiterCode) continue;
1977
- return text.substring(j, I - k);
2038
+ return text.slice(j, I - k);
1978
2039
  }
1979
- return text.substring(j);
2040
+ return text.slice(j);
1980
2041
  }
1981
2042
  while ((t = token()) !== EOF) {
1982
2043
  var a = [];
@@ -1984,7 +2045,7 @@
1984
2045
  a.push(t);
1985
2046
  t = token();
1986
2047
  }
1987
- if (f && !(a = f(a, n++))) continue;
2048
+ if (f && (a = f(a, n++)) == null) continue;
1988
2049
  rows.push(a);
1989
2050
  }
1990
2051
  return rows;
@@ -2018,14 +2079,6 @@
2018
2079
  };
2019
2080
  d3.csv = d3.dsv(",", "text/csv");
2020
2081
  d3.tsv = d3.dsv(" ", "text/tab-separated-values");
2021
- d3.touch = function(container, touches, identifier) {
2022
- if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches;
2023
- if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) {
2024
- if ((touch = touches[i]).identifier === identifier) {
2025
- return d3_mousePoint(container, touch);
2026
- }
2027
- }
2028
- };
2029
2082
  var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_active, d3_timer_frame = d3_window[d3_vendorSymbol(d3_window, "requestAnimationFrame")] || function(callback) {
2030
2083
  setTimeout(callback, 17);
2031
2084
  };
@@ -2115,21 +2168,22 @@
2115
2168
  };
2116
2169
  }
2117
2170
  function d3_locale_numberFormat(locale) {
2118
- var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping ? function(value) {
2119
- var i = value.length, t = [], j = 0, g = locale_grouping[0];
2171
+ var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping && locale_thousands ? function(value, width) {
2172
+ var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0;
2120
2173
  while (i > 0 && g > 0) {
2174
+ if (length + g + 1 > width) g = Math.max(1, width - length);
2121
2175
  t.push(value.substring(i -= g, i + g));
2176
+ if ((length += g + 1) > width) break;
2122
2177
  g = locale_grouping[j = (j + 1) % locale_grouping.length];
2123
2178
  }
2124
2179
  return t.reverse().join(locale_thousands);
2125
2180
  } : d3_identity;
2126
2181
  return function(specifier) {
2127
- var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = "", suffix = "", integer = false;
2182
+ var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "-", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = "", suffix = "", integer = false, exponent = true;
2128
2183
  if (precision) precision = +precision.substring(1);
2129
2184
  if (zfill || fill === "0" && align === "=") {
2130
2185
  zfill = fill = "0";
2131
2186
  align = "=";
2132
- if (comma) width -= Math.floor((width - 1) / 4);
2133
2187
  }
2134
2188
  switch (type) {
2135
2189
  case "n":
@@ -2156,6 +2210,8 @@
2156
2210
  if (symbol === "#") prefix = "0" + type.toLowerCase();
2157
2211
 
2158
2212
  case "c":
2213
+ exponent = false;
2214
+
2159
2215
  case "d":
2160
2216
  integer = true;
2161
2217
  precision = 0;
@@ -2176,7 +2232,7 @@
2176
2232
  return function(value) {
2177
2233
  var fullSuffix = suffix;
2178
2234
  if (integer && value % 1) return "";
2179
- var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign;
2235
+ var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign === "-" ? "" : sign;
2180
2236
  if (scale < 0) {
2181
2237
  var unit = d3.formatPrefix(value, precision);
2182
2238
  value = unit.scale(value);
@@ -2185,10 +2241,17 @@
2185
2241
  value *= scale;
2186
2242
  }
2187
2243
  value = type(value, precision);
2188
- var i = value.lastIndexOf("."), before = i < 0 ? value : value.substring(0, i), after = i < 0 ? "" : locale_decimal + value.substring(i + 1);
2189
- if (!zfill && comma) before = formatGroup(before);
2244
+ var i = value.lastIndexOf("."), before, after;
2245
+ if (i < 0) {
2246
+ var j = exponent ? value.lastIndexOf("e") : -1;
2247
+ if (j < 0) before = value, after = ""; else before = value.substring(0, j), after = value.substring(j);
2248
+ } else {
2249
+ before = value.substring(0, i);
2250
+ after = locale_decimal + value.substring(i + 1);
2251
+ }
2252
+ if (!zfill && comma) before = formatGroup(before, Infinity);
2190
2253
  var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : "";
2191
- if (zcomma) before = formatGroup(padding + before);
2254
+ if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity);
2192
2255
  negative += prefix;
2193
2256
  value = before + after;
2194
2257
  return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + fullSuffix;
@@ -2411,14 +2474,14 @@
2411
2474
  var string = [], i = -1, j = 0, c, p, f;
2412
2475
  while (++i < n) {
2413
2476
  if (template.charCodeAt(i) === 37) {
2414
- string.push(template.substring(j, i));
2477
+ string.push(template.slice(j, i));
2415
2478
  if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i);
2416
2479
  if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p);
2417
2480
  string.push(c);
2418
2481
  j = i + 1;
2419
2482
  }
2420
2483
  }
2421
- string.push(template.substring(j, i));
2484
+ string.push(template.slice(j, i));
2422
2485
  return string.join("");
2423
2486
  }
2424
2487
  format.parse = function(string) {
@@ -2439,7 +2502,7 @@
2439
2502
  date.setFullYear(d.y, 0, 1);
2440
2503
  date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7);
2441
2504
  } else date.setFullYear(d.y, d.m, d.d);
2442
- date.setHours(d.H + Math.floor(d.Z / 100), d.M + d.Z % 100, d.S, d.L);
2505
+ date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L);
2443
2506
  return localZ ? date._ : date;
2444
2507
  };
2445
2508
  format.toString = function() {
@@ -2585,22 +2648,22 @@
2585
2648
  };
2586
2649
  function d3_time_parseWeekdayAbbrev(date, string, i) {
2587
2650
  d3_time_dayAbbrevRe.lastIndex = 0;
2588
- var n = d3_time_dayAbbrevRe.exec(string.substring(i));
2651
+ var n = d3_time_dayAbbrevRe.exec(string.slice(i));
2589
2652
  return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2590
2653
  }
2591
2654
  function d3_time_parseWeekday(date, string, i) {
2592
2655
  d3_time_dayRe.lastIndex = 0;
2593
- var n = d3_time_dayRe.exec(string.substring(i));
2656
+ var n = d3_time_dayRe.exec(string.slice(i));
2594
2657
  return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2595
2658
  }
2596
2659
  function d3_time_parseMonthAbbrev(date, string, i) {
2597
2660
  d3_time_monthAbbrevRe.lastIndex = 0;
2598
- var n = d3_time_monthAbbrevRe.exec(string.substring(i));
2661
+ var n = d3_time_monthAbbrevRe.exec(string.slice(i));
2599
2662
  return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2600
2663
  }
2601
2664
  function d3_time_parseMonth(date, string, i) {
2602
2665
  d3_time_monthRe.lastIndex = 0;
2603
- var n = d3_time_monthRe.exec(string.substring(i));
2666
+ var n = d3_time_monthRe.exec(string.slice(i));
2604
2667
  return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2605
2668
  }
2606
2669
  function d3_time_parseLocaleFull(date, string, i) {
@@ -2613,7 +2676,7 @@
2613
2676
  return d3_time_parse(date, d3_time_formats.X.toString(), string, i);
2614
2677
  }
2615
2678
  function d3_time_parseAmPm(date, string, i) {
2616
- var n = d3_time_periodLookup.get(string.substring(i, i += 2).toLowerCase());
2679
+ var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase());
2617
2680
  return n == null ? -1 : (date.p = n, i);
2618
2681
  }
2619
2682
  return d3_time_format;
@@ -2637,31 +2700,31 @@
2637
2700
  }
2638
2701
  function d3_time_parseWeekdayNumber(date, string, i) {
2639
2702
  d3_time_numberRe.lastIndex = 0;
2640
- var n = d3_time_numberRe.exec(string.substring(i, i + 1));
2703
+ var n = d3_time_numberRe.exec(string.slice(i, i + 1));
2641
2704
  return n ? (date.w = +n[0], i + n[0].length) : -1;
2642
2705
  }
2643
2706
  function d3_time_parseWeekNumberSunday(date, string, i) {
2644
2707
  d3_time_numberRe.lastIndex = 0;
2645
- var n = d3_time_numberRe.exec(string.substring(i));
2708
+ var n = d3_time_numberRe.exec(string.slice(i));
2646
2709
  return n ? (date.U = +n[0], i + n[0].length) : -1;
2647
2710
  }
2648
2711
  function d3_time_parseWeekNumberMonday(date, string, i) {
2649
2712
  d3_time_numberRe.lastIndex = 0;
2650
- var n = d3_time_numberRe.exec(string.substring(i));
2713
+ var n = d3_time_numberRe.exec(string.slice(i));
2651
2714
  return n ? (date.W = +n[0], i + n[0].length) : -1;
2652
2715
  }
2653
2716
  function d3_time_parseFullYear(date, string, i) {
2654
2717
  d3_time_numberRe.lastIndex = 0;
2655
- var n = d3_time_numberRe.exec(string.substring(i, i + 4));
2718
+ var n = d3_time_numberRe.exec(string.slice(i, i + 4));
2656
2719
  return n ? (date.y = +n[0], i + n[0].length) : -1;
2657
2720
  }
2658
2721
  function d3_time_parseYear(date, string, i) {
2659
2722
  d3_time_numberRe.lastIndex = 0;
2660
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
2723
+ var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2661
2724
  return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;
2662
2725
  }
2663
2726
  function d3_time_parseZone(date, string, i) {
2664
- return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5)) ? (date.Z = -string,
2727
+ return /^[+-]\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string,
2665
2728
  i + 5) : -1;
2666
2729
  }
2667
2730
  function d3_time_expandYear(d) {
@@ -2669,46 +2732,46 @@
2669
2732
  }
2670
2733
  function d3_time_parseMonthNumber(date, string, i) {
2671
2734
  d3_time_numberRe.lastIndex = 0;
2672
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
2735
+ var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2673
2736
  return n ? (date.m = n[0] - 1, i + n[0].length) : -1;
2674
2737
  }
2675
2738
  function d3_time_parseDay(date, string, i) {
2676
2739
  d3_time_numberRe.lastIndex = 0;
2677
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
2740
+ var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2678
2741
  return n ? (date.d = +n[0], i + n[0].length) : -1;
2679
2742
  }
2680
2743
  function d3_time_parseDayOfYear(date, string, i) {
2681
2744
  d3_time_numberRe.lastIndex = 0;
2682
- var n = d3_time_numberRe.exec(string.substring(i, i + 3));
2745
+ var n = d3_time_numberRe.exec(string.slice(i, i + 3));
2683
2746
  return n ? (date.j = +n[0], i + n[0].length) : -1;
2684
2747
  }
2685
2748
  function d3_time_parseHour24(date, string, i) {
2686
2749
  d3_time_numberRe.lastIndex = 0;
2687
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
2750
+ var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2688
2751
  return n ? (date.H = +n[0], i + n[0].length) : -1;
2689
2752
  }
2690
2753
  function d3_time_parseMinutes(date, string, i) {
2691
2754
  d3_time_numberRe.lastIndex = 0;
2692
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
2755
+ var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2693
2756
  return n ? (date.M = +n[0], i + n[0].length) : -1;
2694
2757
  }
2695
2758
  function d3_time_parseSeconds(date, string, i) {
2696
2759
  d3_time_numberRe.lastIndex = 0;
2697
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
2760
+ var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2698
2761
  return n ? (date.S = +n[0], i + n[0].length) : -1;
2699
2762
  }
2700
2763
  function d3_time_parseMilliseconds(date, string, i) {
2701
2764
  d3_time_numberRe.lastIndex = 0;
2702
- var n = d3_time_numberRe.exec(string.substring(i, i + 3));
2765
+ var n = d3_time_numberRe.exec(string.slice(i, i + 3));
2703
2766
  return n ? (date.L = +n[0], i + n[0].length) : -1;
2704
2767
  }
2705
2768
  function d3_time_zone(d) {
2706
- var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = ~~(abs(z) / 60), zm = abs(z) % 60;
2769
+ var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = abs(z) / 60 | 0, zm = abs(z) % 60;
2707
2770
  return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2);
2708
2771
  }
2709
2772
  function d3_time_parseLiteralPercent(date, string, i) {
2710
2773
  d3_time_percentRe.lastIndex = 0;
2711
- var n = d3_time_percentRe.exec(string.substring(i, i + 1));
2774
+ var n = d3_time_percentRe.exec(string.slice(i, i + 1));
2712
2775
  return n ? i + n[0].length : -1;
2713
2776
  }
2714
2777
  function d3_time_formatMulti(formats) {
@@ -3116,6 +3179,15 @@
3116
3179
  d3_geo_centroidPointXYZ(x0, y0, z0);
3117
3180
  }
3118
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
+ }
3119
3191
  function d3_true() {
3120
3192
  return true;
3121
3193
  }
@@ -3316,35 +3388,6 @@
3316
3388
  function d3_geo_clipSort(a, b) {
3317
3389
  return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]);
3318
3390
  }
3319
- function d3_geo_pointInPolygon(point, polygon) {
3320
- var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0;
3321
- d3_geo_areaRingSum.reset();
3322
- for (var i = 0, n = polygon.length; i < n; ++i) {
3323
- var ring = polygon[i], m = ring.length;
3324
- if (!m) continue;
3325
- var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1;
3326
- while (true) {
3327
- if (j === m) j = 0;
3328
- point = ring[j];
3329
- var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ;
3330
- d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ)));
3331
- polarAngle += antimeridian ? dλ + sdλ * τ : dλ;
3332
- if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) {
3333
- var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point));
3334
- d3_geo_cartesianNormalize(arc);
3335
- var intersection = d3_geo_cartesianCross(meridianNormal, arc);
3336
- d3_geo_cartesianNormalize(intersection);
3337
- var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]);
3338
- if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) {
3339
- winding += antimeridian ^ dλ >= 0 ? 1 : -1;
3340
- }
3341
- }
3342
- if (!j++) break;
3343
- λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point;
3344
- }
3345
- }
3346
- return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1;
3347
- }
3348
3391
  var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]);
3349
3392
  function d3_geo_clipAntimeridianLine(listener) {
3350
3393
  var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean;
@@ -3412,6 +3455,35 @@
3412
3455
  listener.point(to[0], to[1]);
3413
3456
  }
3414
3457
  }
3458
+ function d3_geo_pointInPolygon(point, polygon) {
3459
+ var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0;
3460
+ d3_geo_areaRingSum.reset();
3461
+ for (var i = 0, n = polygon.length; i < n; ++i) {
3462
+ var ring = polygon[i], m = ring.length;
3463
+ if (!m) continue;
3464
+ var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1;
3465
+ while (true) {
3466
+ if (j === m) j = 0;
3467
+ point = ring[j];
3468
+ var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ;
3469
+ d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ)));
3470
+ polarAngle += antimeridian ? dλ + sdλ * τ : dλ;
3471
+ if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) {
3472
+ var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point));
3473
+ d3_geo_cartesianNormalize(arc);
3474
+ var intersection = d3_geo_cartesianCross(meridianNormal, arc);
3475
+ d3_geo_cartesianNormalize(intersection);
3476
+ var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]);
3477
+ if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) {
3478
+ winding += antimeridian ^ dλ >= 0 ? 1 : -1;
3479
+ }
3480
+ }
3481
+ if (!j++) break;
3482
+ λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point;
3483
+ }
3484
+ }
3485
+ return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1;
3486
+ }
3415
3487
  function d3_geo_clipCircle(radius) {
3416
3488
  var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians);
3417
3489
  return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]);
@@ -3714,15 +3786,6 @@
3714
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];
3715
3787
  }
3716
3788
  }
3717
- function d3_geo_compose(a, b) {
3718
- function compose(x, y) {
3719
- return x = a(x, y), b(x[0], x[1]);
3720
- }
3721
- if (a.invert && b.invert) compose.invert = function(x, y) {
3722
- return x = b.invert(x, y), x && a.invert(x[0], x[1]);
3723
- };
3724
- return compose;
3725
- }
3726
3789
  function d3_geo_conic(projectAt) {
3727
3790
  var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1);
3728
3791
  p.parallels = function(_) {
@@ -3994,7 +4057,7 @@
3994
4057
  result: d3_noop
3995
4058
  };
3996
4059
  function point(x, y) {
3997
- context.moveTo(x, y);
4060
+ context.moveTo(x + pointRadius, y);
3998
4061
  context.arc(x, y, pointRadius, 0, τ);
3999
4062
  }
4000
4063
  function pointLineStart(x, y) {
@@ -5502,11 +5565,11 @@
5502
5565
  }
5503
5566
  }
5504
5567
  function insertChild(n, d, x, y, x1, y1, x2, y2) {
5505
- 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;
5506
5569
  n.leaf = false;
5507
5570
  n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());
5508
- if (right) x1 = sx; else x2 = sx;
5509
- if (bottom) y1 = sy; else y2 = sy;
5571
+ if (right) x1 = xm; else x2 = xm;
5572
+ if (below) y1 = ym; else y2 = ym;
5510
5573
  insert(n, d, x, y, x1, y1, x2, y2);
5511
5574
  }
5512
5575
  var root = d3_geom_quadtreeNode();
@@ -5516,6 +5579,9 @@
5516
5579
  root.visit = function(f) {
5517
5580
  d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_);
5518
5581
  };
5582
+ root.find = function(point) {
5583
+ return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_);
5584
+ };
5519
5585
  i = -1;
5520
5586
  if (x1 == null) {
5521
5587
  while (++i < n) {
@@ -5569,6 +5635,42 @@
5569
5635
  if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
5570
5636
  }
5571
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
+ }
5572
5674
  d3.interpolateRgb = d3_interpolateRgb;
5573
5675
  function d3_interpolateRgb(a, b) {
5574
5676
  a = d3.rgb(a);
@@ -5600,9 +5702,9 @@
5600
5702
  }
5601
5703
  d3.interpolateNumber = d3_interpolateNumber;
5602
5704
  function d3_interpolateNumber(a, b) {
5603
- b -= a = +a;
5705
+ a = +a, b = +b;
5604
5706
  return function(t) {
5605
- return a + b * t;
5707
+ return a * (1 - t) + b * t;
5606
5708
  };
5607
5709
  }
5608
5710
  d3.interpolateString = d3_interpolateString;
@@ -5611,7 +5713,7 @@
5611
5713
  a = a + "", b = b + "";
5612
5714
  while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) {
5613
5715
  if ((bs = bm.index) > bi) {
5614
- bs = b.substring(bi, bs);
5716
+ bs = b.slice(bi, bs);
5615
5717
  if (s[i]) s[i] += bs; else s[++i] = bs;
5616
5718
  }
5617
5719
  if ((am = am[0]) === (bm = bm[0])) {
@@ -5626,7 +5728,7 @@
5626
5728
  bi = d3_interpolate_numberB.lastIndex;
5627
5729
  }
5628
5730
  if (bi < b.length) {
5629
- bs = b.substring(bi);
5731
+ bs = b.slice(bi);
5630
5732
  if (s[i]) s[i] += bs; else s[++i] = bs;
5631
5733
  }
5632
5734
  return s.length < 2 ? q[0] ? (b = q[0].x, function(t) {
@@ -5696,7 +5798,7 @@
5696
5798
  }
5697
5799
  });
5698
5800
  d3.ease = function(name) {
5699
- var i = name.indexOf("-"), t = i >= 0 ? name.substring(0, i) : name, m = i >= 0 ? name.substring(i + 1) : "in";
5801
+ var i = name.indexOf("-"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : "in";
5700
5802
  t = d3_ease.get(t) || d3_ease_default;
5701
5803
  m = d3_ease_mode.get(m) || d3_identity;
5702
5804
  return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1))));
@@ -5901,15 +6003,15 @@
5901
6003
  };
5902
6004
  }
5903
6005
  function d3_uninterpolateNumber(a, b) {
5904
- b = b - (a = +a) ? 1 / (b - a) : 0;
6006
+ b = (b -= a = +a) || 1 / b;
5905
6007
  return function(x) {
5906
- return (x - a) * b;
6008
+ return (x - a) / b;
5907
6009
  };
5908
6010
  }
5909
6011
  function d3_uninterpolateClamp(a, b) {
5910
- b = b - (a = +a) ? 1 / (b - a) : 0;
6012
+ b = (b -= a = +a) || 1 / b;
5911
6013
  return function(x) {
5912
- return Math.max(0, Math.min(1, (x - a) * b));
6014
+ return Math.max(0, Math.min(1, (x - a) / b));
5913
6015
  };
5914
6016
  }
5915
6017
  d3.layout = {};
@@ -6460,49 +6562,50 @@
6460
6562
  return d3_layout_hierarchyRebind(partition, hierarchy);
6461
6563
  };
6462
6564
  d3.layout.pie = function() {
6463
- var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ;
6565
+ var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0;
6464
6566
  function pie(data) {
6465
- var values = data.map(function(d, i) {
6567
+ var n = data.length, values = data.map(function(d, i) {
6466
6568
  return +value.call(pie, d, i);
6467
- });
6468
- var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle);
6469
- var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a) / d3.sum(values);
6470
- 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;
6471
6570
  if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {
6472
6571
  return values[j] - values[i];
6473
6572
  } : function(i, j) {
6474
6573
  return sort(data[i], data[j]);
6475
6574
  });
6476
- var arcs = [];
6477
6575
  index.forEach(function(i) {
6478
- var d;
6479
6576
  arcs[i] = {
6480
6577
  data: data[i],
6481
- value: d = values[i],
6578
+ value: v = values[i],
6482
6579
  startAngle: a,
6483
- endAngle: a += d * k
6580
+ endAngle: a += v * k + pa,
6581
+ padAngle: p
6484
6582
  };
6485
6583
  });
6486
6584
  return arcs;
6487
6585
  }
6488
- pie.value = function(x) {
6586
+ pie.value = function(_) {
6489
6587
  if (!arguments.length) return value;
6490
- value = x;
6588
+ value = _;
6491
6589
  return pie;
6492
6590
  };
6493
- pie.sort = function(x) {
6591
+ pie.sort = function(_) {
6494
6592
  if (!arguments.length) return sort;
6495
- sort = x;
6593
+ sort = _;
6496
6594
  return pie;
6497
6595
  };
6498
- pie.startAngle = function(x) {
6596
+ pie.startAngle = function(_) {
6499
6597
  if (!arguments.length) return startAngle;
6500
- startAngle = x;
6598
+ startAngle = _;
6501
6599
  return pie;
6502
6600
  };
6503
- pie.endAngle = function(x) {
6601
+ pie.endAngle = function(_) {
6504
6602
  if (!arguments.length) return endAngle;
6505
- endAngle = x;
6603
+ endAngle = _;
6604
+ return pie;
6605
+ };
6606
+ pie.padAngle = function(_) {
6607
+ if (!arguments.length) return padAngle;
6608
+ padAngle = _;
6506
6609
  return pie;
6507
6610
  };
6508
6611
  return pie;
@@ -6511,6 +6614,7 @@
6511
6614
  d3.layout.stack = function() {
6512
6615
  var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY;
6513
6616
  function stack(data, index) {
6617
+ if (!(n = data.length)) return data;
6514
6618
  var series = data.map(function(d, i) {
6515
6619
  return values.call(stack, d, i);
6516
6620
  });
@@ -6523,7 +6627,7 @@
6523
6627
  series = d3.permute(series, orders);
6524
6628
  points = d3.permute(points, orders);
6525
6629
  var offsets = offset.call(stack, points, index);
6526
- var n = series.length, m = series[0].length, i, j, o;
6630
+ var m = series[0].length, n, i, j, o;
6527
6631
  for (j = 0; j < m; ++j) {
6528
6632
  out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);
6529
6633
  for (i = 1; i < n; ++i) {
@@ -7600,8 +7704,9 @@
7600
7704
  };
7601
7705
  scale.rangePoints = function(x, padding) {
7602
7706
  if (arguments.length < 2) padding = 0;
7603
- var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding);
7604
- 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);
7605
7710
  rangeBand = 0;
7606
7711
  ranger = {
7607
7712
  t: "rangePoints",
@@ -7609,6 +7714,18 @@
7609
7714
  };
7610
7715
  return scale;
7611
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
+ };
7612
7729
  scale.rangeBands = function(x, padding, outerPadding) {
7613
7730
  if (arguments.length < 2) padding = 0;
7614
7731
  if (arguments.length < 3) outerPadding = padding;
@@ -7625,8 +7742,8 @@
7625
7742
  scale.rangeRoundBands = function(x, padding, outerPadding) {
7626
7743
  if (arguments.length < 2) padding = 0;
7627
7744
  if (arguments.length < 3) outerPadding = padding;
7628
- 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;
7629
- 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);
7630
7747
  if (reverse) range.reverse();
7631
7748
  rangeBand = Math.round(step * (1 - padding));
7632
7749
  ranger = {
@@ -7678,7 +7795,7 @@
7678
7795
  }
7679
7796
  scale.domain = function(x) {
7680
7797
  if (!arguments.length) return domain;
7681
- domain = x.filter(d3_number).sort(d3_ascending);
7798
+ domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending);
7682
7799
  return rescale();
7683
7800
  };
7684
7801
  scale.range = function(x) {
@@ -7783,12 +7900,86 @@
7783
7900
  return identity;
7784
7901
  }
7785
7902
  d3.svg = {};
7903
+ function d3_zero() {
7904
+ return 0;
7905
+ }
7786
7906
  d3.svg.arc = function() {
7787
- 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;
7788
7908
  function arc() {
7789
- var r0 = innerRadius.apply(this, arguments), r1 = outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset, a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset, da = (a1 < a0 && (da = a0,
7790
- a0 = a1, a1 = da), a1 - a0), df = da < π ? "0" : "1", c0 = Math.cos(a0), s0 = Math.sin(a0), c1 = Math.cos(a1), s1 = Math.sin(a1);
7791
- return da >= d3_svg_arcMax ? r0 ? "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "M0," + r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + -r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + r0 + "Z" : "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "Z" : r0 ? "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L" + r0 * c1 + "," + r0 * s1 + "A" + r0 + "," + r0 + " 0 " + df + ",0 " + r0 * c0 + "," + r0 * s0 + "Z" : "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L0,0" + "Z";
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;
7792
7983
  }
7793
7984
  arc.innerRadius = function(v) {
7794
7985
  if (!arguments.length) return innerRadius;
@@ -7800,6 +7991,16 @@
7800
7991
  outerRadius = d3_functor(v);
7801
7992
  return arc;
7802
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
+ };
7803
8004
  arc.startAngle = function(v) {
7804
8005
  if (!arguments.length) return startAngle;
7805
8006
  startAngle = d3_functor(v);
@@ -7810,13 +8011,18 @@
7810
8011
  endAngle = d3_functor(v);
7811
8012
  return arc;
7812
8013
  };
8014
+ arc.padAngle = function(v) {
8015
+ if (!arguments.length) return padAngle;
8016
+ padAngle = d3_functor(v);
8017
+ return arc;
8018
+ };
7813
8019
  arc.centroid = function() {
7814
- 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π;
7815
8021
  return [ Math.cos(a) * r, Math.sin(a) * r ];
7816
8022
  };
7817
8023
  return arc;
7818
8024
  };
7819
- var d3_svg_arcOffset = -halfπ, d3_svg_arcMax = τ - ε;
8025
+ var d3_svg_arcAuto = "auto";
7820
8026
  function d3_svg_arcInnerRadius(d) {
7821
8027
  return d.innerRadius;
7822
8028
  }
@@ -7829,6 +8035,17 @@
7829
8035
  function d3_svg_arcEndAngle(d) {
7830
8036
  return d.endAngle;
7831
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
+ }
7832
8049
  function d3_svg_line(projection) {
7833
8050
  var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;
7834
8051
  function line(data) {
@@ -7919,7 +8136,7 @@
7919
8136
  return path.join("");
7920
8137
  }
7921
8138
  function d3_svg_lineCardinalOpen(points, tension) {
7922
- return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), d3_svg_lineCardinalTangents(points, tension));
8139
+ return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));
7923
8140
  }
7924
8141
  function d3_svg_lineCardinalClosed(points, tension) {
7925
8142
  return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]),
@@ -8089,7 +8306,7 @@
8089
8306
  while (++i < n) {
8090
8307
  point = points[i];
8091
8308
  r = point[0];
8092
- a = point[1] + d3_svg_arcOffset;
8309
+ a = point[1] - halfπ;
8093
8310
  point[0] = r * Math.cos(a);
8094
8311
  point[1] = r * Math.sin(a);
8095
8312
  }
@@ -8190,7 +8407,7 @@
8190
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";
8191
8408
  }
8192
8409
  function subgroup(self, f, d, i) {
8193
- 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π;
8194
8411
  return {
8195
8412
  r: r,
8196
8413
  a0: a0,
@@ -8280,7 +8497,7 @@
8280
8497
  };
8281
8498
  function d3_svg_diagonalRadialProjection(projection) {
8282
8499
  return function() {
8283
- 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π;
8284
8501
  return [ r * Math.cos(a), r * Math.sin(a) ];
8285
8502
  };
8286
8503
  }
@@ -8336,8 +8553,9 @@
8336
8553
  });
8337
8554
  d3.svg.symbolTypes = d3_svg_symbols.keys();
8338
8555
  var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);
8339
- function d3_transition(groups, id) {
8556
+ function d3_transition(groups, namespace, id) {
8340
8557
  d3_subclass(groups, d3_transitionPrototype);
8558
+ groups.namespace = namespace;
8341
8559
  groups.id = id;
8342
8560
  return groups;
8343
8561
  }
@@ -8351,39 +8569,39 @@
8351
8569
  };
8352
8570
  d3.transition.prototype = d3_transitionPrototype;
8353
8571
  d3_transitionPrototype.select = function(selector) {
8354
- var id = this.id, subgroups = [], subgroup, subnode, node;
8572
+ var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node;
8355
8573
  selector = d3_selection_selector(selector);
8356
8574
  for (var j = -1, m = this.length; ++j < m; ) {
8357
8575
  subgroups.push(subgroup = []);
8358
8576
  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8359
8577
  if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) {
8360
8578
  if ("__data__" in node) subnode.__data__ = node.__data__;
8361
- d3_transitionNode(subnode, i, id, node.__transition__[id]);
8579
+ d3_transitionNode(subnode, i, ns, id, node[ns][id]);
8362
8580
  subgroup.push(subnode);
8363
8581
  } else {
8364
8582
  subgroup.push(null);
8365
8583
  }
8366
8584
  }
8367
8585
  }
8368
- return d3_transition(subgroups, id);
8586
+ return d3_transition(subgroups, ns, id);
8369
8587
  };
8370
8588
  d3_transitionPrototype.selectAll = function(selector) {
8371
- var id = this.id, subgroups = [], subgroup, subnodes, node, subnode, transition;
8589
+ var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition;
8372
8590
  selector = d3_selection_selectorAll(selector);
8373
8591
  for (var j = -1, m = this.length; ++j < m; ) {
8374
8592
  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8375
8593
  if (node = group[i]) {
8376
- transition = node.__transition__[id];
8594
+ transition = node[ns][id];
8377
8595
  subnodes = selector.call(node, node.__data__, i, j);
8378
8596
  subgroups.push(subgroup = []);
8379
8597
  for (var k = -1, o = subnodes.length; ++k < o; ) {
8380
- if (subnode = subnodes[k]) d3_transitionNode(subnode, k, id, transition);
8598
+ if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition);
8381
8599
  subgroup.push(subnode);
8382
8600
  }
8383
8601
  }
8384
8602
  }
8385
8603
  }
8386
- return d3_transition(subgroups, id);
8604
+ return d3_transition(subgroups, ns, id);
8387
8605
  };
8388
8606
  d3_transitionPrototype.filter = function(filter) {
8389
8607
  var subgroups = [], subgroup, group, node;
@@ -8396,23 +8614,23 @@
8396
8614
  }
8397
8615
  }
8398
8616
  }
8399
- return d3_transition(subgroups, this.id);
8617
+ return d3_transition(subgroups, this.namespace, this.id);
8400
8618
  };
8401
8619
  d3_transitionPrototype.tween = function(name, tween) {
8402
- var id = this.id;
8403
- 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);
8404
8622
  return d3_selection_each(this, tween == null ? function(node) {
8405
- node.__transition__[id].tween.remove(name);
8623
+ node[ns][id].tween.remove(name);
8406
8624
  } : function(node) {
8407
- node.__transition__[id].tween.set(name, tween);
8625
+ node[ns][id].tween.set(name, tween);
8408
8626
  });
8409
8627
  };
8410
8628
  function d3_transition_tween(groups, name, value, tween) {
8411
- var id = groups.id;
8629
+ var id = groups.id, ns = groups.namespace;
8412
8630
  return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) {
8413
- 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)));
8414
8632
  } : (value = tween(value), function(node) {
8415
- node.__transition__[id].tween.set(name, value);
8633
+ node[ns][id].tween.set(name, value);
8416
8634
  }));
8417
8635
  }
8418
8636
  d3_transitionPrototype.attr = function(nameNS, value) {
@@ -8504,73 +8722,81 @@
8504
8722
  };
8505
8723
  }
8506
8724
  d3_transitionPrototype.remove = function() {
8725
+ var ns = this.namespace;
8507
8726
  return this.each("end.transition", function() {
8508
8727
  var p;
8509
- if (this.__transition__.count < 2 && (p = this.parentNode)) p.removeChild(this);
8728
+ if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this);
8510
8729
  });
8511
8730
  };
8512
8731
  d3_transitionPrototype.ease = function(value) {
8513
- var id = this.id;
8514
- 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;
8515
8734
  if (typeof value !== "function") value = d3.ease.apply(d3, arguments);
8516
8735
  return d3_selection_each(this, function(node) {
8517
- node.__transition__[id].ease = value;
8736
+ node[ns][id].ease = value;
8518
8737
  });
8519
8738
  };
8520
8739
  d3_transitionPrototype.delay = function(value) {
8521
- var id = this.id;
8522
- 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;
8523
8742
  return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8524
- node.__transition__[id].delay = +value.call(node, node.__data__, i, j);
8743
+ node[ns][id].delay = +value.call(node, node.__data__, i, j);
8525
8744
  } : (value = +value, function(node) {
8526
- node.__transition__[id].delay = value;
8745
+ node[ns][id].delay = value;
8527
8746
  }));
8528
8747
  };
8529
8748
  d3_transitionPrototype.duration = function(value) {
8530
- var id = this.id;
8531
- 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;
8532
8751
  return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8533
- 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));
8534
8753
  } : (value = Math.max(1, value), function(node) {
8535
- node.__transition__[id].duration = value;
8754
+ node[ns][id].duration = value;
8536
8755
  }));
8537
8756
  };
8538
8757
  d3_transitionPrototype.each = function(type, listener) {
8539
- var id = this.id;
8758
+ var id = this.id, ns = this.namespace;
8540
8759
  if (arguments.length < 2) {
8541
8760
  var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;
8542
8761
  d3_transitionInheritId = id;
8543
8762
  d3_selection_each(this, function(node, i, j) {
8544
- d3_transitionInherit = node.__transition__[id];
8763
+ d3_transitionInherit = node[ns][id];
8545
8764
  type.call(node, node.__data__, i, j);
8546
8765
  });
8547
8766
  d3_transitionInherit = inherit;
8548
8767
  d3_transitionInheritId = inheritId;
8549
8768
  } else {
8550
8769
  d3_selection_each(this, function(node) {
8551
- var transition = node.__transition__[id];
8552
- (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);
8553
8772
  });
8554
8773
  }
8555
8774
  return this;
8556
8775
  };
8557
8776
  d3_transitionPrototype.transition = function() {
8558
- 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;
8559
8778
  for (var j = 0, m = this.length; j < m; j++) {
8560
8779
  subgroups.push(subgroup = []);
8561
8780
  for (var group = this[j], i = 0, n = group.length; i < n; i++) {
8562
8781
  if (node = group[i]) {
8563
- transition = Object.create(node.__transition__[id0]);
8564
- transition.delay += transition.duration;
8565
- 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
+ });
8566
8789
  }
8567
8790
  subgroup.push(node);
8568
8791
  }
8569
8792
  }
8570
- return d3_transition(subgroups, id1);
8793
+ return d3_transition(subgroups, ns, id1);
8571
8794
  };
8572
- function d3_transitionNode(node, i, id, inherit) {
8573
- 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] = {
8574
8800
  active: 0,
8575
8801
  count: 0
8576
8802
  }), transition = lock[id];
@@ -8579,18 +8805,19 @@
8579
8805
  transition = lock[id] = {
8580
8806
  tween: new d3_Map(),
8581
8807
  time: time,
8582
- ease: inherit.ease,
8583
8808
  delay: inherit.delay,
8584
- duration: inherit.duration
8809
+ duration: inherit.duration,
8810
+ ease: inherit.ease
8585
8811
  };
8812
+ inherit = null;
8586
8813
  ++lock.count;
8587
8814
  d3.timer(function(elapsed) {
8588
- 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 = [];
8589
8816
  timer.t = delay + time;
8590
8817
  if (delay <= elapsed) return start(elapsed - delay);
8591
8818
  timer.c = start;
8592
8819
  function start(elapsed) {
8593
- if (lock.active > id) return stop();
8820
+ if (lock.active > id) return stop(false);
8594
8821
  lock.active = id;
8595
8822
  transition.event && transition.event.start.call(node, d, i);
8596
8823
  transition.tween.forEach(function(key, value) {
@@ -8598,24 +8825,24 @@
8598
8825
  tweened.push(value);
8599
8826
  }
8600
8827
  });
8828
+ ease = transition.ease;
8829
+ duration = transition.duration;
8601
8830
  d3.timer(function() {
8602
8831
  timer.c = tick(elapsed || 1) ? d3_true : tick;
8603
8832
  return 1;
8604
8833
  }, 0, time);
8605
8834
  }
8606
8835
  function tick(elapsed) {
8607
- if (lock.active !== id) return stop();
8836
+ if (lock.active !== id) return stop(false);
8608
8837
  var t = elapsed / duration, e = ease(t), n = tweened.length;
8609
8838
  while (n > 0) {
8610
8839
  tweened[--n].call(node, e);
8611
8840
  }
8612
- if (t >= 1) {
8613
- transition.event && transition.event.end.call(node, d, i);
8614
- return stop();
8615
- }
8841
+ if (t >= 1) return stop(true);
8616
8842
  }
8617
- function stop() {
8618
- 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];
8619
8846
  return 1;
8620
8847
  }
8621
8848
  }, 0, time);
@@ -8627,61 +8854,25 @@
8627
8854
  g.each(function() {
8628
8855
  var g = d3.select(this);
8629
8856
  var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy();
8630
- var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickTransform;
8857
+ var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform;
8631
8858
  var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"),
8632
8859
  d3.transition(path));
8633
8860
  tickEnter.append("line");
8634
8861
  tickEnter.append("text");
8635
- var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text");
8636
- switch (orient) {
8637
- case "bottom":
8638
- {
8639
- tickTransform = d3_svg_axisX;
8640
- lineEnter.attr("y2", innerTickSize);
8641
- textEnter.attr("y", Math.max(innerTickSize, 0) + tickPadding);
8642
- lineUpdate.attr("x2", 0).attr("y2", innerTickSize);
8643
- textUpdate.attr("x", 0).attr("y", Math.max(innerTickSize, 0) + tickPadding);
8644
- text.attr("dy", ".71em").style("text-anchor", "middle");
8645
- pathUpdate.attr("d", "M" + range[0] + "," + outerTickSize + "V0H" + range[1] + "V" + outerTickSize);
8646
- break;
8647
- }
8648
-
8649
- case "top":
8650
- {
8651
- tickTransform = d3_svg_axisX;
8652
- lineEnter.attr("y2", -innerTickSize);
8653
- textEnter.attr("y", -(Math.max(innerTickSize, 0) + tickPadding));
8654
- lineUpdate.attr("x2", 0).attr("y2", -innerTickSize);
8655
- textUpdate.attr("x", 0).attr("y", -(Math.max(innerTickSize, 0) + tickPadding));
8656
- text.attr("dy", "0em").style("text-anchor", "middle");
8657
- pathUpdate.attr("d", "M" + range[0] + "," + -outerTickSize + "V0H" + range[1] + "V" + -outerTickSize);
8658
- break;
8659
- }
8660
-
8661
- case "left":
8662
- {
8663
- tickTransform = d3_svg_axisY;
8664
- lineEnter.attr("x2", -innerTickSize);
8665
- textEnter.attr("x", -(Math.max(innerTickSize, 0) + tickPadding));
8666
- lineUpdate.attr("x2", -innerTickSize).attr("y2", 0);
8667
- textUpdate.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)).attr("y", 0);
8668
- text.attr("dy", ".32em").style("text-anchor", "end");
8669
- pathUpdate.attr("d", "M" + -outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + -outerTickSize);
8670
- break;
8671
- }
8672
-
8673
- case "right":
8674
- {
8675
- tickTransform = d3_svg_axisY;
8676
- lineEnter.attr("x2", innerTickSize);
8677
- textEnter.attr("x", Math.max(innerTickSize, 0) + tickPadding);
8678
- lineUpdate.attr("x2", innerTickSize).attr("y2", 0);
8679
- textUpdate.attr("x", Math.max(innerTickSize, 0) + tickPadding).attr("y", 0);
8680
- text.attr("dy", ".32em").style("text-anchor", "start");
8681
- pathUpdate.attr("d", "M" + outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + outerTickSize);
8682
- break;
8683
- }
8684
- }
8862
+ var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"), sign = orient === "top" || orient === "left" ? -1 : 1, x1, x2, y1, y2;
8863
+ if (orient === "bottom" || orient === "top") {
8864
+ tickTransform = d3_svg_axisX, x1 = "x", y1 = "y", x2 = "x2", y2 = "y2";
8865
+ text.attr("dy", sign < 0 ? "0em" : ".71em").style("text-anchor", "middle");
8866
+ pathUpdate.attr("d", "M" + range[0] + "," + sign * outerTickSize + "V0H" + range[1] + "V" + sign * outerTickSize);
8867
+ } else {
8868
+ tickTransform = d3_svg_axisY, x1 = "y", y1 = "x", x2 = "y2", y2 = "x2";
8869
+ text.attr("dy", ".32em").style("text-anchor", sign < 0 ? "end" : "start");
8870
+ pathUpdate.attr("d", "M" + sign * outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + sign * outerTickSize);
8871
+ }
8872
+ lineEnter.attr(y2, sign * innerTickSize);
8873
+ textEnter.attr(y1, sign * tickSpacing);
8874
+ lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize);
8875
+ textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing);
8685
8876
  if (scale1.rangeBand) {
8686
8877
  var x = scale1, dx = x.rangeBand() / 2;
8687
8878
  scale0 = scale1 = function(d) {
@@ -8690,10 +8881,10 @@
8690
8881
  } else if (scale0.rangeBand) {
8691
8882
  scale0 = scale1;
8692
8883
  } else {
8693
- tickExit.call(tickTransform, scale1);
8884
+ tickExit.call(tickTransform, scale1, scale0);
8694
8885
  }
8695
- tickEnter.call(tickTransform, scale0);
8696
- tickUpdate.call(tickTransform, scale1);
8886
+ tickEnter.call(tickTransform, scale0, scale1);
8887
+ tickUpdate.call(tickTransform, scale1, scale1);
8697
8888
  });
8698
8889
  }
8699
8890
  axis.scale = function(x) {
@@ -8754,14 +8945,16 @@
8754
8945
  bottom: 1,
8755
8946
  left: 1
8756
8947
  };
8757
- function d3_svg_axisX(selection, x) {
8948
+ function d3_svg_axisX(selection, x0, x1) {
8758
8949
  selection.attr("transform", function(d) {
8759
- return "translate(" + x(d) + ",0)";
8950
+ var v0 = x0(d);
8951
+ return "translate(" + (isFinite(v0) ? v0 : x1(d)) + ",0)";
8760
8952
  });
8761
8953
  }
8762
- function d3_svg_axisY(selection, y) {
8954
+ function d3_svg_axisY(selection, y0, y1) {
8763
8955
  selection.attr("transform", function(d) {
8764
- return "translate(0," + y(d) + ")";
8956
+ var v0 = y0(d);
8957
+ return "translate(0," + (isFinite(v0) ? v0 : y1(d)) + ")";
8765
8958
  });
8766
8959
  }
8767
8960
  d3.svg.brush = function() {