d3_rails 3.2.8 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d62e03de5269f59e312eacd580c63cbfb268fc0d
4
- data.tar.gz: 309f52936f6a6307a82067c1039912cab7ee3026
3
+ metadata.gz: 276cdeda4d3639c73795696370dbf1bbfd337d4a
4
+ data.tar.gz: b6b760a77e864b953b71ef3627fce16844105b10
5
5
  SHA512:
6
- metadata.gz: 5f7b1c0c91883f6fd62accfea9818f3975ca6f9e46e89015a7ee93ffbb0092843ad0e3ad7e274ff6d33b5317c4c7a25c13cf522835277a627424952f4ed5da6b
7
- data.tar.gz: b06570a4fa1a81b3c4a815503cfad5e2ddf6460f13512b188cdf16d51c51bf8718c2ba42f7cd3e2dfbf6c67f6288ab7862a4c40440a06ad02adc9b89910bbcc7
6
+ metadata.gz: e02d2edf7cdf5c601782a5b276076b76b22fb13c848ea47482fd9d085fa894042c23e6bdfa1ce2d6828429e5c553d6e1473c3beaa9f559f8088ce1a3336ff3c7
7
+ data.tar.gz: bb367294fd6b4e42a3810a905f4bd0bc39ce0fb90284336de0d4247a2b29dd25cb2178b62857bef16d1e57fd63b560d5d63622ad57f441ec02eff80b54f209d0
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # D3_Rails
2
- ## Version 3.2.7 (of d3 in most current gem)
2
+ ## Version 3.2.8 (of d3 in most current gem)
3
3
 
4
4
  **D3_Rails** is a small, lightweight gem which allows you to include any
5
5
  and all of D3 Javascripts into your 3.1 Rails application, merely by
@@ -1,11 +1,23 @@
1
1
  d3 = function() {
2
2
  var d3 = {
3
- version: "3.2.8"
3
+ version: "3.3.0"
4
4
  };
5
5
  if (!Date.now) Date.now = function() {
6
6
  return +new Date();
7
7
  };
8
+ var d3_arraySlice = [].slice, d3_array = function(list) {
9
+ return d3_arraySlice.call(list);
10
+ };
8
11
  var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
12
+ try {
13
+ d3_array(d3_documentElement.childNodes)[0].nodeType;
14
+ } catch (e) {
15
+ d3_array = function(list) {
16
+ var i = list.length, array = new Array(i);
17
+ while (i--) array[i] = list[i];
18
+ return array;
19
+ };
20
+ }
9
21
  try {
10
22
  d3_document.createElement("div").style.setProperty("opacity", 0, "");
11
23
  } catch (error) {
@@ -135,6 +147,11 @@ d3 = function() {
135
147
  while (i--) permutes[i] = array[indexes[i]];
136
148
  return permutes;
137
149
  };
150
+ d3.pairs = function(array) {
151
+ var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n);
152
+ while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ];
153
+ return pairs;
154
+ };
138
155
  d3.zip = function() {
139
156
  if (!(n = arguments.length)) return [];
140
157
  for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) {
@@ -374,20 +391,6 @@ d3 = function() {
374
391
  }
375
392
  }
376
393
  var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ];
377
- var d3_array = d3_arraySlice;
378
- function d3_arrayCopy(pseudoarray) {
379
- var i = pseudoarray.length, array = new Array(i);
380
- while (i--) array[i] = pseudoarray[i];
381
- return array;
382
- }
383
- function d3_arraySlice(pseudoarray) {
384
- return Array.prototype.slice.call(pseudoarray);
385
- }
386
- try {
387
- d3_array(d3_documentElement.childNodes)[0].nodeType;
388
- } catch (e) {
389
- d3_array = d3_arrayCopy;
390
- }
391
394
  function d3_noop() {}
392
395
  d3.dispatch = function() {
393
396
  var dispatch = new d3_dispatch(), i = -1, n = arguments.length;
@@ -940,22 +943,6 @@ d3 = function() {
940
943
  return node;
941
944
  };
942
945
  }
943
- d3_selectionPrototype.transition = function() {
944
- var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = d3_transitionInherit || {
945
- time: Date.now(),
946
- ease: d3_ease_cubicInOut,
947
- delay: 0,
948
- duration: 250
949
- };
950
- for (var j = -1, m = this.length; ++j < m; ) {
951
- subgroups.push(subgroup = []);
952
- for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
953
- if (node = group[i]) d3_transitionNode(node, i, id, transition);
954
- subgroup.push(node);
955
- }
956
- }
957
- return d3_transition(subgroups, id);
958
- };
959
946
  d3.select = function(node) {
960
947
  var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ];
961
948
  group.parentNode = d3_documentElement;
@@ -1153,92 +1140,205 @@ d3 = function() {
1153
1140
  };
1154
1141
  return d3.rebind(drag, event, "on");
1155
1142
  };
1156
- d3.behavior.zoom = function() {
1157
- var translate = [ 0, 0 ], translate0, scale = 1, scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", touchstart = "touchstart.zoom", touchmove = "touchmove.zoom", touchend = "touchend.zoom", touchtime, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1;
1158
- function zoom() {
1159
- this.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on(mousemove, mousewheelreset).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1143
+ var π = Math.PI, ε = 1e-6, ε2 = ε * ε, d3_radians = π / 180, d3_degrees = 180 / π;
1144
+ function d3_sgn(x) {
1145
+ return x > 0 ? 1 : x < 0 ? -1 : 0;
1146
+ }
1147
+ function d3_acos(x) {
1148
+ return x > 1 ? 0 : x < -1 ? π : Math.acos(x);
1149
+ }
1150
+ function d3_asin(x) {
1151
+ return x > 1 ? π / 2 : x < -1 ? -π / 2 : Math.asin(x);
1152
+ }
1153
+ function d3_sinh(x) {
1154
+ return (Math.exp(x) - Math.exp(-x)) / 2;
1155
+ }
1156
+ function d3_cosh(x) {
1157
+ return (Math.exp(x) + Math.exp(-x)) / 2;
1158
+ }
1159
+ function d3_tanh(x) {
1160
+ return d3_sinh(x) / d3_cosh(x);
1161
+ }
1162
+ function d3_haversin(x) {
1163
+ return (x = Math.sin(x / 2)) * x;
1164
+ }
1165
+ var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4;
1166
+ d3.interpolateZoom = function(p0, p1) {
1167
+ var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2];
1168
+ var dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1), dr = r1 - r0, S = (dr || Math.log(w1 / w0)) / ρ;
1169
+ function interpolate(t) {
1170
+ var s = t * S;
1171
+ if (dr) {
1172
+ var coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0));
1173
+ return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ];
1174
+ }
1175
+ return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * s) ];
1160
1176
  }
1161
- zoom.translate = function(x) {
1162
- if (!arguments.length) return translate;
1163
- translate = x.map(Number);
1177
+ interpolate.duration = S * 1e3;
1178
+ return interpolate;
1179
+ };
1180
+ d3.behavior.zoom = function() {
1181
+ var view = {
1182
+ x: 0,
1183
+ y: 0,
1184
+ k: 1
1185
+ }, translate0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchmove = "touchmove.zoom", touchend = "touchend.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1;
1186
+ function zoom(g) {
1187
+ g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on(mousemove, mousewheelreset).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1188
+ }
1189
+ zoom.event = function(g) {
1190
+ g.each(function() {
1191
+ var event_ = event.of(this, arguments), view1 = view;
1192
+ if (d3_transitionInheritId) {
1193
+ d3.select(this).transition().each("start.zoom", function() {
1194
+ view = this.__chart__ || {
1195
+ x: 0,
1196
+ y: 0,
1197
+ k: 1
1198
+ };
1199
+ zoomstarted(event_);
1200
+ }).tween("zoom:zoom", function() {
1201
+ 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 ]);
1202
+ return function(t) {
1203
+ var l = i(t), k = dx / l[2];
1204
+ this.__chart__ = view = {
1205
+ x: cx - l[0] * k,
1206
+ y: cy - l[1] * k,
1207
+ k: k
1208
+ };
1209
+ zoomed(event_);
1210
+ };
1211
+ }).each("end.zoom", function() {
1212
+ zoomended(event_);
1213
+ });
1214
+ } else {
1215
+ this.__chart__ = view;
1216
+ zoomstarted(event_);
1217
+ zoomed(event_);
1218
+ zoomended(event_);
1219
+ }
1220
+ });
1221
+ };
1222
+ zoom.translate = function(_) {
1223
+ if (!arguments.length) return [ view.x, view.y ];
1224
+ view = {
1225
+ x: +_[0],
1226
+ y: +_[1],
1227
+ k: view.k
1228
+ };
1164
1229
  rescale();
1165
1230
  return zoom;
1166
1231
  };
1167
- zoom.scale = function(x) {
1168
- if (!arguments.length) return scale;
1169
- scale = +x;
1232
+ zoom.scale = function(_) {
1233
+ if (!arguments.length) return view.k;
1234
+ view = {
1235
+ x: view.x,
1236
+ y: view.y,
1237
+ k: +_
1238
+ };
1170
1239
  rescale();
1171
1240
  return zoom;
1172
1241
  };
1173
- zoom.scaleExtent = function(x) {
1242
+ zoom.scaleExtent = function(_) {
1174
1243
  if (!arguments.length) return scaleExtent;
1175
- scaleExtent = x == null ? d3_behavior_zoomInfinity : x.map(Number);
1244
+ scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ];
1245
+ return zoom;
1246
+ };
1247
+ zoom.center = function(_) {
1248
+ if (!arguments.length) return center;
1249
+ center = _ && [ +_[0], +_[1] ];
1250
+ return zoom;
1251
+ };
1252
+ zoom.size = function(_) {
1253
+ if (!arguments.length) return size;
1254
+ size = _ && [ +_[0], +_[1] ];
1176
1255
  return zoom;
1177
1256
  };
1178
1257
  zoom.x = function(z) {
1179
1258
  if (!arguments.length) return x1;
1180
1259
  x1 = z;
1181
1260
  x0 = z.copy();
1182
- translate = [ 0, 0 ];
1183
- scale = 1;
1261
+ view = {
1262
+ x: 0,
1263
+ y: 0,
1264
+ k: 1
1265
+ };
1184
1266
  return zoom;
1185
1267
  };
1186
1268
  zoom.y = function(z) {
1187
1269
  if (!arguments.length) return y1;
1188
1270
  y1 = z;
1189
1271
  y0 = z.copy();
1190
- translate = [ 0, 0 ];
1191
- scale = 1;
1272
+ view = {
1273
+ x: 0,
1274
+ y: 0,
1275
+ k: 1
1276
+ };
1192
1277
  return zoom;
1193
1278
  };
1194
1279
  function location(p) {
1195
- return [ (p[0] - translate[0]) / scale, (p[1] - translate[1]) / scale ];
1280
+ return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ];
1196
1281
  }
1197
1282
  function point(l) {
1198
- return [ l[0] * scale + translate[0], l[1] * scale + translate[1] ];
1283
+ return [ l[0] * view.k + view.x, l[1] * view.k + view.y ];
1199
1284
  }
1200
1285
  function scaleTo(s) {
1201
- scale = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));
1286
+ view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));
1202
1287
  }
1203
1288
  function translateTo(p, l) {
1204
1289
  l = point(l);
1205
- translate[0] += p[0] - l[0];
1206
- translate[1] += p[1] - l[1];
1290
+ view.x += p[0] - l[0];
1291
+ view.y += p[1] - l[1];
1207
1292
  }
1208
1293
  function rescale() {
1209
1294
  if (x1) x1.domain(x0.range().map(function(x) {
1210
- return (x - translate[0]) / scale;
1295
+ return (x - view.x) / view.k;
1211
1296
  }).map(x0.invert));
1212
1297
  if (y1) y1.domain(y0.range().map(function(y) {
1213
- return (y - translate[1]) / scale;
1298
+ return (y - view.y) / view.k;
1214
1299
  }).map(y0.invert));
1215
1300
  }
1216
- function dispatch(event) {
1301
+ function zoomstarted(event) {
1302
+ event({
1303
+ type: "zoomstart"
1304
+ });
1305
+ }
1306
+ function zoomed(event) {
1217
1307
  rescale();
1218
1308
  event({
1219
1309
  type: "zoom",
1220
- scale: scale,
1221
- translate: translate
1310
+ scale: view.k,
1311
+ translate: [ view.x, view.y ]
1312
+ });
1313
+ }
1314
+ function zoomended(event) {
1315
+ event({
1316
+ type: "zoomend"
1222
1317
  });
1223
1318
  }
1224
1319
  function mousedowned() {
1225
1320
  var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, dragged = 0, w = d3.select(d3_window).on(mousemove, moved).on(mouseup, ended), l = location(d3.mouse(target)), dragRestore = d3_event_dragSuppress();
1321
+ d3_selection_interrupt.call(target);
1322
+ zoomstarted(event_);
1226
1323
  function moved() {
1227
1324
  dragged = 1;
1228
1325
  translateTo(d3.mouse(target), l);
1229
- dispatch(event_);
1326
+ zoomed(event_);
1230
1327
  }
1231
1328
  function ended() {
1232
1329
  w.on(mousemove, d3_window === target ? mousewheelreset : null).on(mouseup, null);
1233
1330
  dragRestore(dragged && d3.event.target === eventTarget);
1331
+ zoomended(event_);
1234
1332
  }
1235
1333
  }
1236
1334
  function touchstarted() {
1237
1335
  var target = this, event_ = event.of(target, arguments), locations0, distance0 = 0, scale0, w = d3.select(d3_window).on(touchmove, moved).on(touchend, ended), t = d3.select(target).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress();
1336
+ d3_selection_interrupt.call(target);
1238
1337
  started();
1338
+ zoomstarted(event_);
1239
1339
  function relocate() {
1240
1340
  var touches = d3.touches(target);
1241
- scale0 = scale;
1341
+ scale0 = view.k;
1242
1342
  locations0 = {};
1243
1343
  touches.forEach(function(t) {
1244
1344
  locations0[t.identifier] = location(t);
@@ -1250,10 +1350,10 @@ d3 = function() {
1250
1350
  if (touches.length === 1) {
1251
1351
  if (now - touchtime < 500) {
1252
1352
  var p = touches[0], l = locations0[p.identifier];
1253
- scaleTo(scale * 2);
1353
+ scaleTo(view.k * 2);
1254
1354
  translateTo(p, l);
1255
1355
  d3_eventPreventDefault();
1256
- dispatch(event_);
1356
+ zoomed(event_);
1257
1357
  }
1258
1358
  touchtime = now;
1259
1359
  } else if (touches.length > 1) {
@@ -1275,7 +1375,7 @@ d3 = function() {
1275
1375
  }
1276
1376
  touchtime = null;
1277
1377
  translateTo(p0, l0);
1278
- dispatch(event_);
1378
+ zoomed(event_);
1279
1379
  }
1280
1380
  function ended() {
1281
1381
  if (d3.event.touches.length) {
@@ -1284,24 +1384,35 @@ d3 = function() {
1284
1384
  w.on(touchmove, null).on(touchend, null);
1285
1385
  t.on(mousedown, mousedowned).on(touchstart, touchstarted);
1286
1386
  dragRestore();
1387
+ zoomended(event_);
1287
1388
  }
1288
1389
  }
1289
1390
  }
1290
1391
  function mousewheeled() {
1392
+ var event_ = event.of(this, arguments);
1393
+ if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this),
1394
+ zoomstarted(event_);
1395
+ mousewheelTimer = setTimeout(function() {
1396
+ mousewheelTimer = null;
1397
+ zoomended(event_);
1398
+ }, 50);
1291
1399
  d3_eventPreventDefault();
1292
- if (!translate0) translate0 = location(d3.mouse(this));
1293
- scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * scale);
1294
- translateTo(d3.mouse(this), translate0);
1295
- dispatch(event.of(this, arguments));
1400
+ var point = center || d3.mouse(this);
1401
+ if (!translate0) translate0 = location(point);
1402
+ scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k);
1403
+ translateTo(point, translate0);
1404
+ zoomed(event_);
1296
1405
  }
1297
1406
  function mousewheelreset() {
1298
1407
  translate0 = null;
1299
1408
  }
1300
1409
  function dblclicked() {
1301
- var p = d3.mouse(this), l = location(p), k = Math.log(scale) / Math.LN2;
1410
+ var event_ = event.of(this, arguments), p = d3.mouse(this), l = location(p), k = Math.log(view.k) / Math.LN2;
1411
+ zoomstarted(event_);
1302
1412
  scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1));
1303
1413
  translateTo(p, l);
1304
- dispatch(event.of(this, arguments));
1414
+ zoomed(event_);
1415
+ zoomended(event_);
1305
1416
  }
1306
1417
  return d3.rebind(zoom, event, "on");
1307
1418
  };
@@ -1359,25 +1470,6 @@ d3 = function() {
1359
1470
  }
1360
1471
  return d3_rgb(vv(h + 120), vv(h), vv(h - 120));
1361
1472
  }
1362
- var π = Math.PI, ε = 1e-6, ε2 = ε * ε, d3_radians = π / 180, d3_degrees = 180 / π;
1363
- function d3_sgn(x) {
1364
- return x > 0 ? 1 : x < 0 ? -1 : 0;
1365
- }
1366
- function d3_acos(x) {
1367
- return x > 1 ? 0 : x < -1 ? π : Math.acos(x);
1368
- }
1369
- function d3_asin(x) {
1370
- return x > 1 ? π / 2 : x < -1 ? -π / 2 : Math.asin(x);
1371
- }
1372
- function d3_sinh(x) {
1373
- return (Math.exp(x) - Math.exp(-x)) / 2;
1374
- }
1375
- function d3_cosh(x) {
1376
- return (Math.exp(x) + Math.exp(-x)) / 2;
1377
- }
1378
- function d3_haversin(x) {
1379
- return (x = Math.sin(x / 2)) * x;
1380
- }
1381
1473
  d3.hcl = function(h, c, l) {
1382
1474
  return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l);
1383
1475
  };
@@ -1719,7 +1811,7 @@ d3 = function() {
1719
1811
  };
1720
1812
  }
1721
1813
  function d3_xhr(url, mimeType, response, callback) {
1722
- var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null;
1814
+ var xhr = {}, dispatch = d3.dispatch("beforesend", "progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null;
1723
1815
  if (d3_window.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest();
1724
1816
  "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {
1725
1817
  request.readyState > 3 && respond();
@@ -1782,6 +1874,7 @@ d3 = function() {
1782
1874
  if (callback != null) xhr.on("error", callback).on("load", function(request) {
1783
1875
  callback(null, request);
1784
1876
  });
1877
+ dispatch.beforesend.call(xhr, request);
1785
1878
  request.send(data == null ? null : data);
1786
1879
  return xhr;
1787
1880
  };
@@ -2159,12 +2252,12 @@ d3 = function() {
2159
2252
  listener.sphere();
2160
2253
  },
2161
2254
  Point: function(object, listener) {
2162
- var coordinate = object.coordinates;
2163
- listener.point(coordinate[0], coordinate[1]);
2255
+ object = object.coordinates;
2256
+ listener.point(object[0], object[1], object[2]);
2164
2257
  },
2165
2258
  MultiPoint: function(object, listener) {
2166
- var coordinates = object.coordinates, i = -1, n = coordinates.length, coordinate;
2167
- while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1]);
2259
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
2260
+ while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]);
2168
2261
  },
2169
2262
  LineString: function(object, listener) {
2170
2263
  d3_geo_streamLine(object.coordinates, listener, 0);
@@ -2188,7 +2281,7 @@ d3 = function() {
2188
2281
  function d3_geo_streamLine(coordinates, listener, closed) {
2189
2282
  var i = -1, n = coordinates.length - closed, coordinate;
2190
2283
  listener.lineStart();
2191
- while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1]);
2284
+ while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]);
2192
2285
  listener.lineEnd();
2193
2286
  }
2194
2287
  function d3_geo_streamPolygon(coordinates, listener) {
@@ -2898,8 +2991,25 @@ d3 = function() {
2898
2991
  return d3_geo_pointInPolygon(point, polygon);
2899
2992
  }
2900
2993
  }
2901
- var d3_geo_clipViewMAX = 1e9;
2902
- function d3_geo_clipView(x0, y0, x1, y1) {
2994
+ var d3_geo_clipExtentMAX = 1e9;
2995
+ d3.geo.clipExtent = function() {
2996
+ var x0, y0, x1, y1, stream, clip, clipExtent = {
2997
+ stream: function(output) {
2998
+ if (stream) stream.valid = false;
2999
+ stream = clip(output);
3000
+ stream.valid = true;
3001
+ return stream;
3002
+ },
3003
+ extent: function(_) {
3004
+ if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];
3005
+ clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]);
3006
+ if (stream) stream.valid = false, stream = null;
3007
+ return clipExtent;
3008
+ }
3009
+ };
3010
+ return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]);
3011
+ };
3012
+ function d3_geo_clipExtent(x0, y0, x1, y1) {
2903
3013
  return function(listener) {
2904
3014
  var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), segments, polygon, ring;
2905
3015
  var clip = {
@@ -2981,8 +3091,8 @@ d3 = function() {
2981
3091
  if (v_) listener.lineEnd();
2982
3092
  }
2983
3093
  function linePoint(x, y) {
2984
- x = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, x));
2985
- y = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, y));
3094
+ x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x));
3095
+ y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y));
2986
3096
  var v = visible(x, y);
2987
3097
  if (polygon) ring.push([ x, y ]);
2988
3098
  if (first) {
@@ -3025,7 +3135,7 @@ d3 = function() {
3025
3135
  function clipLine(a, b) {
3026
3136
  var dx = b[0] - a[0], dy = b[1] - a[1], t = [ 0, 1 ];
3027
3137
  if (Math.abs(dx) < ε && Math.abs(dy) < ε) return x0 <= a[0] && a[0] <= x1 && y0 <= a[1] && a[1] <= y1;
3028
- if (d3_geo_clipViewT(x0 - a[0], dx, t) && d3_geo_clipViewT(a[0] - x1, -dx, t) && d3_geo_clipViewT(y0 - a[1], dy, t) && d3_geo_clipViewT(a[1] - y1, -dy, t)) {
3138
+ if (d3_geo_clipExtentT(x0 - a[0], dx, t) && d3_geo_clipExtentT(a[0] - x1, -dx, t) && d3_geo_clipExtentT(y0 - a[1], dy, t) && d3_geo_clipExtentT(a[1] - y1, -dy, t)) {
3029
3139
  if (t[1] < 1) {
3030
3140
  b[0] = a[0] + t[1] * dx;
3031
3141
  b[1] = a[1] + t[1] * dy;
@@ -3039,7 +3149,7 @@ d3 = function() {
3039
3149
  return false;
3040
3150
  }
3041
3151
  }
3042
- function d3_geo_clipViewT(num, denominator, t) {
3152
+ function d3_geo_clipExtentT(num, denominator, t) {
3043
3153
  if (Math.abs(denominator) < ε) return num <= 0;
3044
3154
  var u = num / denominator;
3045
3155
  if (denominator > 0) {
@@ -3418,6 +3528,38 @@ d3 = function() {
3418
3528
  };
3419
3529
  return resample;
3420
3530
  }
3531
+ d3.geo.transform = function(methods) {
3532
+ return {
3533
+ stream: function(stream) {
3534
+ var transform = new d3_geo_transform(stream);
3535
+ for (var k in methods) transform[k] = methods[k];
3536
+ return transform;
3537
+ }
3538
+ };
3539
+ };
3540
+ function d3_geo_transform(stream) {
3541
+ this.stream = stream;
3542
+ }
3543
+ d3_geo_transform.prototype = {
3544
+ point: function(x, y) {
3545
+ this.stream.point(x, y);
3546
+ },
3547
+ sphere: function() {
3548
+ this.stream.sphere();
3549
+ },
3550
+ lineStart: function() {
3551
+ this.stream.lineStart();
3552
+ },
3553
+ lineEnd: function() {
3554
+ this.stream.lineEnd();
3555
+ },
3556
+ polygonStart: function() {
3557
+ this.stream.polygonStart();
3558
+ },
3559
+ polygonEnd: function() {
3560
+ this.stream.polygonEnd();
3561
+ }
3562
+ };
3421
3563
  d3.geo.path = function() {
3422
3564
  var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream;
3423
3565
  function path(object) {
@@ -3466,31 +3608,15 @@ d3 = function() {
3466
3608
  return path.projection(d3.geo.albersUsa()).context(null);
3467
3609
  };
3468
3610
  function d3_geo_pathProjectStream(project) {
3469
- var resample = d3_geo_resample(function(λ, φ) {
3470
- return project([ λ * d3_degrees, φ * d3_degrees ]);
3611
+ var resample = d3_geo_resample(function(x, y) {
3612
+ return project([ x * d3_degrees, y * d3_degrees ]);
3471
3613
  });
3472
3614
  return function(stream) {
3473
- stream = resample(stream);
3474
- return {
3475
- point: function(λ, φ) {
3476
- stream.point(λ * d3_radians, φ * d3_radians);
3477
- },
3478
- sphere: function() {
3479
- stream.sphere();
3480
- },
3481
- lineStart: function() {
3482
- stream.lineStart();
3483
- },
3484
- lineEnd: function() {
3485
- stream.lineEnd();
3486
- },
3487
- polygonStart: function() {
3488
- stream.polygonStart();
3489
- },
3490
- polygonEnd: function() {
3491
- stream.polygonEnd();
3492
- }
3615
+ var transform = new d3_geo_transform(stream = resample(stream));
3616
+ transform.point = function(x, y) {
3617
+ stream.point(x * d3_radians, y * d3_radians);
3493
3618
  };
3619
+ return transform;
3494
3620
  };
3495
3621
  }
3496
3622
  d3.geo.projection = d3_geo_projection;
@@ -3527,7 +3653,7 @@ d3 = function() {
3527
3653
  projection.clipExtent = function(_) {
3528
3654
  if (!arguments.length) return clipExtent;
3529
3655
  clipExtent = _;
3530
- postclip = _ == null ? d3_identity : d3_geo_clipView(_[0][0], _[0][1], _[1][0], _[1][1]);
3656
+ postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity;
3531
3657
  return invalidate();
3532
3658
  };
3533
3659
  projection.scale = function(_) {
@@ -3563,10 +3689,7 @@ d3 = function() {
3563
3689
  return invalidate();
3564
3690
  }
3565
3691
  function invalidate() {
3566
- if (stream) {
3567
- stream.valid = false;
3568
- stream = null;
3569
- }
3692
+ if (stream) stream.valid = false, stream = null;
3570
3693
  return projection;
3571
3694
  }
3572
3695
  return function() {
@@ -3576,27 +3699,12 @@ d3 = function() {
3576
3699
  };
3577
3700
  }
3578
3701
  function d3_geo_projectionRadiansRotate(rotate, stream) {
3579
- return {
3580
- point: function(x, y) {
3581
- y = rotate(x * d3_radians, y * d3_radians), x = y[0];
3582
- stream.point(x > π ? x - 2 * π : x < -π ? x + 2 * π : x, y[1]);
3583
- },
3584
- sphere: function() {
3585
- stream.sphere();
3586
- },
3587
- lineStart: function() {
3588
- stream.lineStart();
3589
- },
3590
- lineEnd: function() {
3591
- stream.lineEnd();
3592
- },
3593
- polygonStart: function() {
3594
- stream.polygonStart();
3595
- },
3596
- polygonEnd: function() {
3597
- stream.polygonEnd();
3598
- }
3702
+ var transform = new d3_geo_transform(stream);
3703
+ transform.point = function(x, y) {
3704
+ y = rotate(x * d3_radians, y * d3_radians), x = y[0];
3705
+ stream.point(x > π ? x - 2 * π : x < -π ? x + 2 * π : x, y[1]);
3599
3706
  };
3707
+ return transform;
3600
3708
  }
3601
3709
  function d3_geo_equirectangular(λ, φ) {
3602
3710
  return [ λ, φ ];
@@ -6801,13 +6909,10 @@ d3 = function() {
6801
6909
  return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
6802
6910
  }
6803
6911
  function d3_scale_linearNice(domain, m) {
6804
- return d3_scale_nice(domain, d3_scale_niceStep(m ? d3_scale_linearTickRange(domain, m)[2] : d3_scale_linearNiceStep(domain)));
6805
- }
6806
- function d3_scale_linearNiceStep(domain) {
6807
- var extent = d3_scaleExtent(domain), span = extent[1] - extent[0];
6808
- return Math.pow(10, Math.round(Math.log(span) / Math.LN10) - 1);
6912
+ return d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));
6809
6913
  }
6810
6914
  function d3_scale_linearTickRange(domain, m) {
6915
+ if (m == null) m = 10;
6811
6916
  var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step;
6812
6917
  if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2;
6813
6918
  extent[0] = Math.ceil(extent[0] / step) * step;
@@ -7479,6 +7584,29 @@ d3 = function() {
7479
7584
  return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition();
7480
7585
  };
7481
7586
  d3.transition.prototype = d3_transitionPrototype;
7587
+ d3_selectionPrototype.transition = function() {
7588
+ var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = d3_transitionInherit || {
7589
+ time: Date.now(),
7590
+ ease: d3_ease_cubicInOut,
7591
+ delay: 0,
7592
+ duration: 250
7593
+ };
7594
+ for (var j = -1, m = this.length; ++j < m; ) {
7595
+ subgroups.push(subgroup = []);
7596
+ for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
7597
+ if (node = group[i]) d3_transitionNode(node, i, id, transition);
7598
+ subgroup.push(node);
7599
+ }
7600
+ }
7601
+ return d3_transition(subgroups, id);
7602
+ };
7603
+ d3_selectionPrototype.interrupt = function() {
7604
+ return this.each(d3_selection_interrupt);
7605
+ };
7606
+ function d3_selection_interrupt() {
7607
+ var lock = this.__transition__;
7608
+ if (lock) ++lock.active;
7609
+ }
7482
7610
  d3_transitionPrototype.select = function(selector) {
7483
7611
  var id = this.id, subgroups = [], subgroup, subnode, node;
7484
7612
  selector = d3_selection_selector(selector);
@@ -7635,7 +7763,7 @@ d3 = function() {
7635
7763
  d3_transitionPrototype.remove = function() {
7636
7764
  return this.each("end.transition", function() {
7637
7765
  var p;
7638
- if (!this.__transition__ && (p = this.parentNode)) p.removeChild(this);
7766
+ if (this.__transition__.count < 2 && (p = this.parentNode)) p.removeChild(this);
7639
7767
  });
7640
7768
  };
7641
7769
  d3_transitionPrototype.ease = function(value) {
@@ -7649,16 +7777,16 @@ d3 = function() {
7649
7777
  d3_transitionPrototype.delay = function(value) {
7650
7778
  var id = this.id;
7651
7779
  return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
7652
- node.__transition__[id].delay = value.call(node, node.__data__, i, j) | 0;
7653
- } : (value |= 0, function(node) {
7780
+ node.__transition__[id].delay = +value.call(node, node.__data__, i, j);
7781
+ } : (value = +value, function(node) {
7654
7782
  node.__transition__[id].delay = value;
7655
7783
  }));
7656
7784
  };
7657
7785
  d3_transitionPrototype.duration = function(value) {
7658
7786
  var id = this.id;
7659
7787
  return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
7660
- node.__transition__[id].duration = Math.max(1, value.call(node, node.__data__, i, j) | 0);
7661
- } : (value = Math.max(1, value | 0), function(node) {
7788
+ node.__transition__[id].duration = Math.max(1, value.call(node, node.__data__, i, j));
7789
+ } : (value = Math.max(1, value), function(node) {
7662
7790
  node.__transition__[id].duration = value;
7663
7791
  }));
7664
7792
  };
@@ -7734,9 +7862,8 @@ d3 = function() {
7734
7862
  tweened[--n].call(node, e);
7735
7863
  }
7736
7864
  if (t >= 1) {
7737
- stop();
7738
7865
  transition.event && transition.event.end.call(node, d, i);
7739
- return 1;
7866
+ return stop();
7740
7867
  }
7741
7868
  }
7742
7869
  function stop() {
@@ -7747,13 +7874,11 @@ d3 = function() {
7747
7874
  }
7748
7875
  }
7749
7876
  d3.svg.axis = function() {
7750
- var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, tickMajorSize = 6, tickMinorSize = 6, tickEndSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_, tickSubdivide = 0;
7877
+ var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_;
7751
7878
  function axis(g) {
7752
7879
  g.each(function() {
7753
7880
  var g = d3.select(this);
7754
- var ticks = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain() : tickValues, tickFormat = tickFormat_ == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : String : tickFormat_;
7755
- var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide), subtick = g.selectAll(".tick.minor").data(subticks, String), subtickEnter = subtick.enter().insert("line", ".tick").attr("class", "tick minor").style("opacity", 1e-6), subtickExit = d3.transition(subtick.exit()).style("opacity", 1e-6).remove(), subtickUpdate = d3.transition(subtick).style("opacity", 1);
7756
- var tick = g.selectAll(".tick.major").data(ticks, String), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick major").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform;
7881
+ var ticks = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain() : tickValues, tickFormat = tickFormat_ == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick.major").data(ticks, d3_identity), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick major").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform;
7757
7882
  var range = d3_scaleRange(scale), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"),
7758
7883
  d3.transition(path));
7759
7884
  var scale1 = scale.copy(), scale0 = this.__chart__ || scale1;
@@ -7765,56 +7890,48 @@ d3 = function() {
7765
7890
  case "bottom":
7766
7891
  {
7767
7892
  tickTransform = d3_svg_axisX;
7768
- subtickEnter.attr("y2", tickMinorSize);
7769
- subtickUpdate.attr("x2", 0).attr("y2", tickMinorSize);
7770
- lineEnter.attr("y2", tickMajorSize);
7771
- textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding);
7772
- lineUpdate.attr("x2", 0).attr("y2", tickMajorSize);
7773
- textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding);
7893
+ lineEnter.attr("y2", innerTickSize);
7894
+ textEnter.attr("y", Math.max(innerTickSize, 0) + tickPadding);
7895
+ lineUpdate.attr("x2", 0).attr("y2", innerTickSize);
7896
+ textUpdate.attr("x", 0).attr("y", Math.max(innerTickSize, 0) + tickPadding);
7774
7897
  text.attr("dy", ".71em").style("text-anchor", "middle");
7775
- pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize);
7898
+ pathUpdate.attr("d", "M" + range[0] + "," + outerTickSize + "V0H" + range[1] + "V" + outerTickSize);
7776
7899
  break;
7777
7900
  }
7778
7901
 
7779
7902
  case "top":
7780
7903
  {
7781
7904
  tickTransform = d3_svg_axisX;
7782
- subtickEnter.attr("y2", -tickMinorSize);
7783
- subtickUpdate.attr("x2", 0).attr("y2", -tickMinorSize);
7784
- lineEnter.attr("y2", -tickMajorSize);
7785
- textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
7786
- lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize);
7787
- textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
7905
+ lineEnter.attr("y2", -innerTickSize);
7906
+ textEnter.attr("y", -(Math.max(innerTickSize, 0) + tickPadding));
7907
+ lineUpdate.attr("x2", 0).attr("y2", -innerTickSize);
7908
+ textUpdate.attr("x", 0).attr("y", -(Math.max(innerTickSize, 0) + tickPadding));
7788
7909
  text.attr("dy", "0em").style("text-anchor", "middle");
7789
- pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize);
7910
+ pathUpdate.attr("d", "M" + range[0] + "," + -outerTickSize + "V0H" + range[1] + "V" + -outerTickSize);
7790
7911
  break;
7791
7912
  }
7792
7913
 
7793
7914
  case "left":
7794
7915
  {
7795
7916
  tickTransform = d3_svg_axisY;
7796
- subtickEnter.attr("x2", -tickMinorSize);
7797
- subtickUpdate.attr("x2", -tickMinorSize).attr("y2", 0);
7798
- lineEnter.attr("x2", -tickMajorSize);
7799
- textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding));
7800
- lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0);
7801
- textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0);
7917
+ lineEnter.attr("x2", -innerTickSize);
7918
+ textEnter.attr("x", -(Math.max(innerTickSize, 0) + tickPadding));
7919
+ lineUpdate.attr("x2", -innerTickSize).attr("y2", 0);
7920
+ textUpdate.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)).attr("y", 0);
7802
7921
  text.attr("dy", ".32em").style("text-anchor", "end");
7803
- pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize);
7922
+ pathUpdate.attr("d", "M" + -outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + -outerTickSize);
7804
7923
  break;
7805
7924
  }
7806
7925
 
7807
7926
  case "right":
7808
7927
  {
7809
7928
  tickTransform = d3_svg_axisY;
7810
- subtickEnter.attr("x2", tickMinorSize);
7811
- subtickUpdate.attr("x2", tickMinorSize).attr("y2", 0);
7812
- lineEnter.attr("x2", tickMajorSize);
7813
- textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding);
7814
- lineUpdate.attr("x2", tickMajorSize).attr("y2", 0);
7815
- textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0);
7929
+ lineEnter.attr("x2", innerTickSize);
7930
+ textEnter.attr("x", Math.max(innerTickSize, 0) + tickPadding);
7931
+ lineUpdate.attr("x2", innerTickSize).attr("y2", 0);
7932
+ textUpdate.attr("x", Math.max(innerTickSize, 0) + tickPadding).attr("y", 0);
7816
7933
  text.attr("dy", ".32em").style("text-anchor", "start");
7817
- pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize);
7934
+ pathUpdate.attr("d", "M" + outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + outerTickSize);
7818
7935
  break;
7819
7936
  }
7820
7937
  }
@@ -7828,9 +7945,6 @@ d3 = function() {
7828
7945
  tickEnter.call(tickTransform, scale0);
7829
7946
  tickUpdate.call(tickTransform, scale1);
7830
7947
  tickExit.call(tickTransform, scale1);
7831
- subtickEnter.call(tickTransform, scale0);
7832
- subtickUpdate.call(tickTransform, scale1);
7833
- subtickExit.call(tickTransform, scale1);
7834
7948
  }
7835
7949
  });
7836
7950
  }
@@ -7859,12 +7973,21 @@ d3 = function() {
7859
7973
  tickFormat_ = x;
7860
7974
  return axis;
7861
7975
  };
7862
- axis.tickSize = function(x, y) {
7863
- if (!arguments.length) return tickMajorSize;
7864
- var n = arguments.length - 1;
7865
- tickMajorSize = +x;
7866
- tickMinorSize = n > 1 ? +y : tickMajorSize;
7867
- tickEndSize = n > 0 ? +arguments[n] : tickMajorSize;
7976
+ axis.tickSize = function(x) {
7977
+ var n = arguments.length;
7978
+ if (!n) return innerTickSize;
7979
+ innerTickSize = +x;
7980
+ outerTickSize = +arguments[n - 1];
7981
+ return axis;
7982
+ };
7983
+ axis.innerTickSize = function(x) {
7984
+ if (!arguments.length) return innerTickSize;
7985
+ innerTickSize = +x;
7986
+ return axis;
7987
+ };
7988
+ axis.outerTickSize = function(x) {
7989
+ if (!arguments.length) return outerTickSize;
7990
+ outerTickSize = +x;
7868
7991
  return axis;
7869
7992
  };
7870
7993
  axis.tickPadding = function(x) {
@@ -7872,10 +7995,8 @@ d3 = function() {
7872
7995
  tickPadding = +x;
7873
7996
  return axis;
7874
7997
  };
7875
- axis.tickSubdivide = function(x) {
7876
- if (!arguments.length) return tickSubdivide;
7877
- tickSubdivide = +x;
7878
- return axis;
7998
+ axis.tickSubdivide = function() {
7999
+ return arguments.length && axis;
7879
8000
  };
7880
8001
  return axis;
7881
8002
  };
@@ -7895,32 +8016,17 @@ d3 = function() {
7895
8016
  return "translate(0," + y(d) + ")";
7896
8017
  });
7897
8018
  }
7898
- function d3_svg_axisSubdivide(scale, ticks, m) {
7899
- subticks = [];
7900
- if (m && ticks.length > 1) {
7901
- var extent = d3_scaleExtent(scale.domain()), subticks, i = -1, n = ticks.length, d = (ticks[1] - ticks[0]) / ++m, j, v;
7902
- while (++i < n) {
7903
- for (j = m; --j > 0; ) {
7904
- if ((v = +ticks[i] - j * d) >= extent[0]) {
7905
- subticks.push(v);
7906
- }
7907
- }
7908
- }
7909
- for (--i, j = 0; ++j < m && (v = +ticks[i] + j * d) < extent[1]; ) {
7910
- subticks.push(v);
7911
- }
7912
- }
7913
- return subticks;
7914
- }
7915
8019
  d3.svg.brush = function() {
7916
- var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, resizes = d3_svg_brushResizes[0], extent = [ [ 0, 0 ], [ 0, 0 ] ], clamp = [ true, true ], extentDomain;
8020
+ var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0];
7917
8021
  function brush(g) {
7918
8022
  g.each(function() {
7919
- var g = d3.select(this), bg = g.selectAll(".background").data([ 0 ]), fg = g.selectAll(".extent").data([ 0 ]), tz = g.selectAll(".resize").data(resizes, String), e;
7920
- g.style("pointer-events", "all").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart);
7921
- bg.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair");
7922
- fg.enter().append("rect").attr("class", "extent").style("cursor", "move");
7923
- tz.enter().append("g").attr("class", function(d) {
8023
+ var g = d3.select(this).style("pointer-events", "all").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart);
8024
+ var background = g.selectAll(".background").data([ 0 ]);
8025
+ background.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair");
8026
+ g.selectAll(".extent").data([ 0 ]).enter().append("rect").attr("class", "extent").style("cursor", "move");
8027
+ var resize = g.selectAll(".resize").data(resizes, d3_identity);
8028
+ resize.exit().remove();
8029
+ resize.enter().append("g").attr("class", function(d) {
7924
8030
  return "resize " + d;
7925
8031
  }).style("cursor", function(d) {
7926
8032
  return d3_svg_brushCursor[d];
@@ -7929,33 +8035,87 @@ d3 = function() {
7929
8035
  }).attr("y", function(d) {
7930
8036
  return /^[ns]/.test(d) ? -3 : null;
7931
8037
  }).attr("width", 6).attr("height", 6).style("visibility", "hidden");
7932
- tz.style("display", brush.empty() ? "none" : null);
7933
- tz.exit().remove();
8038
+ resize.style("display", brush.empty() ? "none" : null);
8039
+ var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range;
7934
8040
  if (x) {
7935
- e = d3_scaleRange(x);
7936
- bg.attr("x", e[0]).attr("width", e[1] - e[0]);
7937
- redrawX(g);
8041
+ range = d3_scaleRange(x);
8042
+ backgroundUpdate.attr("x", range[0]).attr("width", range[1] - range[0]);
8043
+ redrawX(gUpdate);
7938
8044
  }
7939
8045
  if (y) {
7940
- e = d3_scaleRange(y);
7941
- bg.attr("y", e[0]).attr("height", e[1] - e[0]);
7942
- redrawY(g);
8046
+ range = d3_scaleRange(y);
8047
+ backgroundUpdate.attr("y", range[0]).attr("height", range[1] - range[0]);
8048
+ redrawY(gUpdate);
7943
8049
  }
7944
- redraw(g);
8050
+ redraw(gUpdate);
7945
8051
  });
7946
8052
  }
8053
+ brush.event = function(g) {
8054
+ g.each(function() {
8055
+ var event_ = event.of(this, arguments), extent1 = {
8056
+ x: xExtent,
8057
+ y: yExtent,
8058
+ i: xExtentDomain,
8059
+ j: yExtentDomain
8060
+ }, extent0 = this.__chart__ || extent1;
8061
+ this.__chart__ = extent1;
8062
+ if (d3_transitionInheritId) {
8063
+ d3.select(this).transition().each("start.brush", function() {
8064
+ xExtentDomain = extent0.i;
8065
+ yExtentDomain = extent0.j;
8066
+ xExtent = extent0.x;
8067
+ yExtent = extent0.y;
8068
+ event_({
8069
+ type: "brushstart"
8070
+ });
8071
+ }).tween("brush:brush", function() {
8072
+ var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y);
8073
+ xExtentDomain = yExtentDomain = null;
8074
+ return function(t) {
8075
+ xExtent = extent1.x = xi(t);
8076
+ yExtent = extent1.y = yi(t);
8077
+ event_({
8078
+ type: "brush",
8079
+ mode: "resize"
8080
+ });
8081
+ };
8082
+ }).each("end.brush", function() {
8083
+ xExtentDomain = extent1.i;
8084
+ yExtentDomain = extent1.j;
8085
+ event_({
8086
+ type: "brush",
8087
+ mode: "resize"
8088
+ });
8089
+ event_({
8090
+ type: "brushend"
8091
+ });
8092
+ });
8093
+ } else {
8094
+ event_({
8095
+ type: "brushstart"
8096
+ });
8097
+ event_({
8098
+ type: "brush",
8099
+ mode: "resize"
8100
+ });
8101
+ event_({
8102
+ type: "brushend"
8103
+ });
8104
+ }
8105
+ });
8106
+ };
7947
8107
  function redraw(g) {
7948
8108
  g.selectAll(".resize").attr("transform", function(d) {
7949
- return "translate(" + extent[+/e$/.test(d)][0] + "," + extent[+/^s/.test(d)][1] + ")";
8109
+ return "translate(" + xExtent[+/e$/.test(d)] + "," + yExtent[+/^s/.test(d)] + ")";
7950
8110
  });
7951
8111
  }
7952
8112
  function redrawX(g) {
7953
- g.select(".extent").attr("x", extent[0][0]);
7954
- g.selectAll(".extent,.n>rect,.s>rect").attr("width", extent[1][0] - extent[0][0]);
8113
+ g.select(".extent").attr("x", xExtent[0]);
8114
+ g.selectAll(".extent,.n>rect,.s>rect").attr("width", xExtent[1] - xExtent[0]);
7955
8115
  }
7956
8116
  function redrawY(g) {
7957
- g.select(".extent").attr("y", extent[0][1]);
7958
- g.selectAll(".extent,.e>rect,.w>rect").attr("height", extent[1][1] - extent[0][1]);
8117
+ g.select(".extent").attr("y", yExtent[0]);
8118
+ g.selectAll(".extent,.e>rect,.w>rect").attr("height", yExtent[1] - yExtent[0]);
7959
8119
  }
7960
8120
  function brushstart() {
7961
8121
  var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed("extent"), dragRestore = d3_event_dragSuppress(), center, origin = mouse(), offset;
@@ -7965,14 +8125,15 @@ d3 = function() {
7965
8125
  } else {
7966
8126
  w.on("mousemove.brush", brushmove).on("mouseup.brush", brushend);
7967
8127
  }
8128
+ g.interrupt().selectAll("*").interrupt();
7968
8129
  if (dragging) {
7969
- origin[0] = extent[0][0] - origin[0];
7970
- origin[1] = extent[0][1] - origin[1];
8130
+ origin[0] = xExtent[0] - origin[0];
8131
+ origin[1] = yExtent[0] - origin[1];
7971
8132
  } else if (resizing) {
7972
8133
  var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing);
7973
- offset = [ extent[1 - ex][0] - origin[0], extent[1 - ey][1] - origin[1] ];
7974
- origin[0] = extent[ex][0];
7975
- origin[1] = extent[ey][1];
8134
+ offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ];
8135
+ origin[0] = xExtent[ex];
8136
+ origin[1] = yExtent[ey];
7976
8137
  } else if (d3.event.altKey) center = origin.slice();
7977
8138
  g.style("pointer-events", "none").selectAll(".resize").style("display", null);
7978
8139
  d3.select("body").style("cursor", eventTarget.style("cursor"));
@@ -7988,8 +8149,8 @@ d3 = function() {
7988
8149
  if (d3.event.keyCode == 32) {
7989
8150
  if (!dragging) {
7990
8151
  center = null;
7991
- origin[0] -= extent[1][0];
7992
- origin[1] -= extent[1][1];
8152
+ origin[0] -= xExtent[1];
8153
+ origin[1] -= yExtent[1];
7993
8154
  dragging = 2;
7994
8155
  }
7995
8156
  d3_eventPreventDefault();
@@ -7997,8 +8158,8 @@ d3 = function() {
7997
8158
  }
7998
8159
  function keyup() {
7999
8160
  if (d3.event.keyCode == 32 && dragging == 2) {
8000
- origin[0] += extent[1][0];
8001
- origin[1] += extent[1][1];
8161
+ origin[0] += xExtent[1];
8162
+ origin[1] += yExtent[1];
8002
8163
  dragging = 0;
8003
8164
  d3_eventPreventDefault();
8004
8165
  }
@@ -8011,9 +8172,9 @@ d3 = function() {
8011
8172
  }
8012
8173
  if (!dragging) {
8013
8174
  if (d3.event.altKey) {
8014
- if (!center) center = [ (extent[0][0] + extent[1][0]) / 2, (extent[0][1] + extent[1][1]) / 2 ];
8015
- origin[0] = extent[+(point[0] < center[0])][0];
8016
- origin[1] = extent[+(point[1] < center[1])][1];
8175
+ if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ];
8176
+ origin[0] = xExtent[+(point[0] < center[0])];
8177
+ origin[1] = yExtent[+(point[1] < center[1])];
8017
8178
  } else center = null;
8018
8179
  }
8019
8180
  if (resizingX && move1(point, x, 0)) {
@@ -8033,12 +8194,12 @@ d3 = function() {
8033
8194
  }
8034
8195
  }
8035
8196
  function move1(point, scale, i) {
8036
- var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], size = extent[1][i] - extent[0][i], min, max;
8197
+ var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], extent = i ? yExtent : xExtent, size = extent[1] - extent[0], min, max;
8037
8198
  if (dragging) {
8038
8199
  r0 -= position;
8039
8200
  r1 -= size + position;
8040
8201
  }
8041
- min = clamp[i] ? Math.max(r0, Math.min(r1, point[i])) : point[i];
8202
+ min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i];
8042
8203
  if (dragging) {
8043
8204
  max = (min += position) + size;
8044
8205
  } else {
@@ -8050,10 +8211,10 @@ d3 = function() {
8050
8211
  max = position;
8051
8212
  }
8052
8213
  }
8053
- if (extent[0][i] !== min || extent[1][i] !== max) {
8054
- extentDomain = null;
8055
- extent[0][i] = min;
8056
- extent[1][i] = max;
8214
+ if (extent[0] != min || extent[1] != max) {
8215
+ if (i) yExtentDomain = null; else xExtentDomain = null;
8216
+ extent[0] = min;
8217
+ extent[1] = max;
8057
8218
  return true;
8058
8219
  }
8059
8220
  }
@@ -8081,58 +8242,60 @@ d3 = function() {
8081
8242
  return brush;
8082
8243
  };
8083
8244
  brush.clamp = function(z) {
8084
- if (!arguments.length) return x && y ? clamp : x || y ? clamp[+!x] : null;
8085
- if (x && y) clamp = [ !!z[0], !!z[1] ]; else if (x || y) clamp[+!x] = !!z;
8245
+ if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null;
8246
+ if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z;
8086
8247
  return brush;
8087
8248
  };
8088
8249
  brush.extent = function(z) {
8089
8250
  var x0, x1, y0, y1, t;
8090
8251
  if (!arguments.length) {
8091
- z = extentDomain || extent;
8092
8252
  if (x) {
8093
- x0 = z[0][0], x1 = z[1][0];
8094
- if (!extentDomain) {
8095
- x0 = extent[0][0], x1 = extent[1][0];
8253
+ if (xExtentDomain) {
8254
+ x0 = xExtentDomain[0], x1 = xExtentDomain[1];
8255
+ } else {
8256
+ x0 = xExtent[0], x1 = xExtent[1];
8096
8257
  if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);
8097
8258
  if (x1 < x0) t = x0, x0 = x1, x1 = t;
8098
8259
  }
8099
8260
  }
8100
8261
  if (y) {
8101
- y0 = z[0][1], y1 = z[1][1];
8102
- if (!extentDomain) {
8103
- y0 = extent[0][1], y1 = extent[1][1];
8262
+ if (yExtentDomain) {
8263
+ y0 = yExtentDomain[0], y1 = yExtentDomain[1];
8264
+ } else {
8265
+ y0 = yExtent[0], y1 = yExtent[1];
8104
8266
  if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);
8105
8267
  if (y1 < y0) t = y0, y0 = y1, y1 = t;
8106
8268
  }
8107
8269
  }
8108
8270
  return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ];
8109
8271
  }
8110
- extentDomain = [ [ 0, 0 ], [ 0, 0 ] ];
8111
8272
  if (x) {
8112
8273
  x0 = z[0], x1 = z[1];
8113
8274
  if (y) x0 = x0[0], x1 = x1[0];
8114
- extentDomain[0][0] = x0, extentDomain[1][0] = x1;
8275
+ xExtentDomain = [ x0, x1 ];
8115
8276
  if (x.invert) x0 = x(x0), x1 = x(x1);
8116
8277
  if (x1 < x0) t = x0, x0 = x1, x1 = t;
8117
- extent[0][0] = x0 | 0, extent[1][0] = x1 | 0;
8278
+ if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ];
8118
8279
  }
8119
8280
  if (y) {
8120
8281
  y0 = z[0], y1 = z[1];
8121
8282
  if (x) y0 = y0[1], y1 = y1[1];
8122
- extentDomain[0][1] = y0, extentDomain[1][1] = y1;
8283
+ yExtentDomain = [ y0, y1 ];
8123
8284
  if (y.invert) y0 = y(y0), y1 = y(y1);
8124
8285
  if (y1 < y0) t = y0, y0 = y1, y1 = t;
8125
- extent[0][1] = y0 | 0, extent[1][1] = y1 | 0;
8286
+ if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ];
8126
8287
  }
8127
8288
  return brush;
8128
8289
  };
8129
8290
  brush.clear = function() {
8130
- extentDomain = null;
8131
- extent[0][0] = extent[0][1] = extent[1][0] = extent[1][1] = 0;
8291
+ if (!brush.empty()) {
8292
+ xExtent = [ 0, 0 ], yExtent = [ 0, 0 ];
8293
+ xExtentDomain = yExtentDomain = null;
8294
+ }
8132
8295
  return brush;
8133
8296
  };
8134
8297
  brush.empty = function() {
8135
- return x && extent[0][0] === extent[1][0] || y && extent[0][1] === extent[1][1];
8298
+ return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1];
8136
8299
  };
8137
8300
  return d3.rebind(brush, event, "on");
8138
8301
  };
@@ -8147,12 +8310,11 @@ d3 = function() {
8147
8310
  sw: "nesw-resize"
8148
8311
  };
8149
8312
  var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ];
8150
- d3.time = {};
8151
- var d3_time = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];
8152
- function d3_time_utc() {
8313
+ var d3_time = d3.time = {}, d3_date = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];
8314
+ function d3_date_utc() {
8153
8315
  this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]);
8154
8316
  }
8155
- d3_time_utc.prototype = {
8317
+ d3_date_utc.prototype = {
8156
8318
  getDate: function() {
8157
8319
  return this._.getUTCDate();
8158
8320
  },
@@ -8223,11 +8385,11 @@ d3 = function() {
8223
8385
  return date - d0 < d1 - date ? d0 : d1;
8224
8386
  }
8225
8387
  function ceil(date) {
8226
- step(date = local(new d3_time(date - 1)), 1);
8388
+ step(date = local(new d3_date(date - 1)), 1);
8227
8389
  return date;
8228
8390
  }
8229
8391
  function offset(date, k) {
8230
- step(date = new d3_time(+date), k);
8392
+ step(date = new d3_date(+date), k);
8231
8393
  return date;
8232
8394
  }
8233
8395
  function range(t0, t1, dt) {
@@ -8244,12 +8406,12 @@ d3 = function() {
8244
8406
  }
8245
8407
  function range_utc(t0, t1, dt) {
8246
8408
  try {
8247
- d3_time = d3_time_utc;
8248
- var utc = new d3_time_utc();
8409
+ d3_date = d3_date_utc;
8410
+ var utc = new d3_date_utc();
8249
8411
  utc._ = t0;
8250
8412
  return range(utc, t1, dt);
8251
8413
  } finally {
8252
- d3_time = Date;
8414
+ d3_date = Date;
8253
8415
  }
8254
8416
  }
8255
8417
  local.floor = local;
@@ -8268,17 +8430,17 @@ d3 = function() {
8268
8430
  function d3_time_interval_utc(method) {
8269
8431
  return function(date, k) {
8270
8432
  try {
8271
- d3_time = d3_time_utc;
8272
- var utc = new d3_time_utc();
8433
+ d3_date = d3_date_utc;
8434
+ var utc = new d3_date_utc();
8273
8435
  utc._ = date;
8274
8436
  return method(utc, k)._;
8275
8437
  } finally {
8276
- d3_time = Date;
8438
+ d3_date = Date;
8277
8439
  }
8278
8440
  };
8279
8441
  }
8280
- d3.time.year = d3_time_interval(function(date) {
8281
- date = d3.time.day(date);
8442
+ d3_time.year = d3_time_interval(function(date) {
8443
+ date = d3_time.day(date);
8282
8444
  date.setMonth(0, 1);
8283
8445
  return date;
8284
8446
  }, function(date, offset) {
@@ -8286,10 +8448,10 @@ d3 = function() {
8286
8448
  }, function(date) {
8287
8449
  return date.getFullYear();
8288
8450
  });
8289
- d3.time.years = d3.time.year.range;
8290
- d3.time.years.utc = d3.time.year.utc.range;
8291
- d3.time.day = d3_time_interval(function(date) {
8292
- var day = new d3_time(2e3, 0);
8451
+ d3_time.years = d3_time.year.range;
8452
+ d3_time.years.utc = d3_time.year.utc.range;
8453
+ d3_time.day = d3_time_interval(function(date) {
8454
+ var day = new d3_date(2e3, 0);
8293
8455
  day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
8294
8456
  return day;
8295
8457
  }, function(date, offset) {
@@ -8297,36 +8459,37 @@ d3 = function() {
8297
8459
  }, function(date) {
8298
8460
  return date.getDate() - 1;
8299
8461
  });
8300
- d3.time.days = d3.time.day.range;
8301
- d3.time.days.utc = d3.time.day.utc.range;
8302
- d3.time.dayOfYear = function(date) {
8303
- var year = d3.time.year(date);
8462
+ d3_time.days = d3_time.day.range;
8463
+ d3_time.days.utc = d3_time.day.utc.range;
8464
+ d3_time.dayOfYear = function(date) {
8465
+ var year = d3_time.year(date);
8304
8466
  return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5);
8305
8467
  };
8306
8468
  d3_time_daySymbols.forEach(function(day, i) {
8307
8469
  day = day.toLowerCase();
8308
8470
  i = 7 - i;
8309
- var interval = d3.time[day] = d3_time_interval(function(date) {
8310
- (date = d3.time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);
8471
+ var interval = d3_time[day] = d3_time_interval(function(date) {
8472
+ (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);
8311
8473
  return date;
8312
8474
  }, function(date, offset) {
8313
8475
  date.setDate(date.getDate() + Math.floor(offset) * 7);
8314
8476
  }, function(date) {
8315
- var day = d3.time.year(date).getDay();
8316
- return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);
8477
+ var day = d3_time.year(date).getDay();
8478
+ return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);
8317
8479
  });
8318
- d3.time[day + "s"] = interval.range;
8319
- d3.time[day + "s"].utc = interval.utc.range;
8320
- d3.time[day + "OfYear"] = function(date) {
8321
- var day = d3.time.year(date).getDay();
8322
- return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7);
8480
+ d3_time[day + "s"] = interval.range;
8481
+ d3_time[day + "s"].utc = interval.utc.range;
8482
+ d3_time[day + "OfYear"] = function(date) {
8483
+ var day = d3_time.year(date).getDay();
8484
+ return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7);
8323
8485
  };
8324
8486
  });
8325
- d3.time.week = d3.time.sunday;
8326
- d3.time.weeks = d3.time.sunday.range;
8327
- d3.time.weeks.utc = d3.time.sunday.utc.range;
8328
- d3.time.weekOfYear = d3.time.sundayOfYear;
8329
- d3.time.format = function(template) {
8487
+ d3_time.week = d3_time.sunday;
8488
+ d3_time.weeks = d3_time.sunday.range;
8489
+ d3_time.weeks.utc = d3_time.sunday.utc.range;
8490
+ d3_time.weekOfYear = d3_time.sundayOfYear;
8491
+ d3_time.format = d3_time_format;
8492
+ function d3_time_format(template) {
8330
8493
  var n = template.length;
8331
8494
  function format(date) {
8332
8495
  var string = [], i = -1, j = 0, c, p, f;
@@ -8354,7 +8517,7 @@ d3 = function() {
8354
8517
  }, i = d3_time_parse(d, template, string, 0);
8355
8518
  if (i != string.length) return null;
8356
8519
  if ("p" in d) d.H = d.H % 12 + d.p * 12;
8357
- var date = new d3_time();
8520
+ var date = new d3_date();
8358
8521
  if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("w" in d && ("W" in d || "U" in d)) {
8359
8522
  date.setFullYear(d.y, 0, 1);
8360
8523
  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);
@@ -8366,7 +8529,7 @@ d3 = function() {
8366
8529
  return template;
8367
8530
  };
8368
8531
  return format;
8369
- };
8532
+ }
8370
8533
  function d3_time_parse(date, template, string, j) {
8371
8534
  var c, p, i = 0, n = template.length, m = string.length;
8372
8535
  while (i < n) {
@@ -8412,7 +8575,7 @@ d3 = function() {
8412
8575
  B: function(d) {
8413
8576
  return d3_time_months[d.getMonth()];
8414
8577
  },
8415
- c: d3.time.format(d3_time_formatDateTime),
8578
+ c: d3_time_format(d3_time_formatDateTime),
8416
8579
  d: function(d, p) {
8417
8580
  return d3_time_formatPad(d.getDate(), p, 2);
8418
8581
  },
@@ -8426,7 +8589,7 @@ d3 = function() {
8426
8589
  return d3_time_formatPad(d.getHours() % 12 || 12, p, 2);
8427
8590
  },
8428
8591
  j: function(d, p) {
8429
- return d3_time_formatPad(1 + d3.time.dayOfYear(d), p, 3);
8592
+ return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3);
8430
8593
  },
8431
8594
  L: function(d, p) {
8432
8595
  return d3_time_formatPad(d.getMilliseconds(), p, 3);
@@ -8444,16 +8607,16 @@ d3 = function() {
8444
8607
  return d3_time_formatPad(d.getSeconds(), p, 2);
8445
8608
  },
8446
8609
  U: function(d, p) {
8447
- return d3_time_formatPad(d3.time.sundayOfYear(d), p, 2);
8610
+ return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2);
8448
8611
  },
8449
8612
  w: function(d) {
8450
8613
  return d.getDay();
8451
8614
  },
8452
8615
  W: function(d, p) {
8453
- return d3_time_formatPad(d3.time.mondayOfYear(d), p, 2);
8616
+ return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2);
8454
8617
  },
8455
- x: d3.time.format(d3_time_formatDate),
8456
- X: d3.time.format(d3_time_formatTime),
8618
+ x: d3_time_format(d3_time_formatDate),
8619
+ X: d3_time_format(d3_time_formatTime),
8457
8620
  y: function(d, p) {
8458
8621
  return d3_time_formatPad(d.getFullYear() % 100, p, 2);
8459
8622
  },
@@ -8600,32 +8763,33 @@ d3 = function() {
8600
8763
  var n = d3_time_percentRe.exec(string.substring(i, i + 1));
8601
8764
  return n ? i + n[0].length : -1;
8602
8765
  }
8603
- d3.time.format.utc = function(template) {
8604
- var local = d3.time.format(template);
8766
+ d3_time_format.utc = d3_time_formatUtc;
8767
+ function d3_time_formatUtc(template) {
8768
+ var local = d3_time_format(template);
8605
8769
  function format(date) {
8606
8770
  try {
8607
- d3_time = d3_time_utc;
8608
- var utc = new d3_time();
8771
+ d3_date = d3_date_utc;
8772
+ var utc = new d3_date();
8609
8773
  utc._ = date;
8610
8774
  return local(utc);
8611
8775
  } finally {
8612
- d3_time = Date;
8776
+ d3_date = Date;
8613
8777
  }
8614
8778
  }
8615
8779
  format.parse = function(string) {
8616
8780
  try {
8617
- d3_time = d3_time_utc;
8781
+ d3_date = d3_date_utc;
8618
8782
  var date = local.parse(string);
8619
8783
  return date && date._;
8620
8784
  } finally {
8621
- d3_time = Date;
8785
+ d3_date = Date;
8622
8786
  }
8623
8787
  };
8624
8788
  format.toString = local.toString;
8625
8789
  return format;
8626
- };
8627
- var d3_time_formatIso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");
8628
- d3.time.format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso;
8790
+ }
8791
+ var d3_time_formatIso = d3_time_formatUtc("%Y-%m-%dT%H:%M:%S.%LZ");
8792
+ d3_time_format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso;
8629
8793
  function d3_time_formatIsoNative(date) {
8630
8794
  return date.toISOString();
8631
8795
  }
@@ -8634,36 +8798,36 @@ d3 = function() {
8634
8798
  return isNaN(date) ? null : date;
8635
8799
  };
8636
8800
  d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
8637
- d3.time.second = d3_time_interval(function(date) {
8638
- return new d3_time(Math.floor(date / 1e3) * 1e3);
8801
+ d3_time.second = d3_time_interval(function(date) {
8802
+ return new d3_date(Math.floor(date / 1e3) * 1e3);
8639
8803
  }, function(date, offset) {
8640
8804
  date.setTime(date.getTime() + Math.floor(offset) * 1e3);
8641
8805
  }, function(date) {
8642
8806
  return date.getSeconds();
8643
8807
  });
8644
- d3.time.seconds = d3.time.second.range;
8645
- d3.time.seconds.utc = d3.time.second.utc.range;
8646
- d3.time.minute = d3_time_interval(function(date) {
8647
- return new d3_time(Math.floor(date / 6e4) * 6e4);
8808
+ d3_time.seconds = d3_time.second.range;
8809
+ d3_time.seconds.utc = d3_time.second.utc.range;
8810
+ d3_time.minute = d3_time_interval(function(date) {
8811
+ return new d3_date(Math.floor(date / 6e4) * 6e4);
8648
8812
  }, function(date, offset) {
8649
8813
  date.setTime(date.getTime() + Math.floor(offset) * 6e4);
8650
8814
  }, function(date) {
8651
8815
  return date.getMinutes();
8652
8816
  });
8653
- d3.time.minutes = d3.time.minute.range;
8654
- d3.time.minutes.utc = d3.time.minute.utc.range;
8655
- d3.time.hour = d3_time_interval(function(date) {
8817
+ d3_time.minutes = d3_time.minute.range;
8818
+ d3_time.minutes.utc = d3_time.minute.utc.range;
8819
+ d3_time.hour = d3_time_interval(function(date) {
8656
8820
  var timezone = date.getTimezoneOffset() / 60;
8657
- return new d3_time((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);
8821
+ return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);
8658
8822
  }, function(date, offset) {
8659
8823
  date.setTime(date.getTime() + Math.floor(offset) * 36e5);
8660
8824
  }, function(date) {
8661
8825
  return date.getHours();
8662
8826
  });
8663
- d3.time.hours = d3.time.hour.range;
8664
- d3.time.hours.utc = d3.time.hour.utc.range;
8665
- d3.time.month = d3_time_interval(function(date) {
8666
- date = d3.time.day(date);
8827
+ d3_time.hours = d3_time.hour.range;
8828
+ d3_time.hours.utc = d3_time.hour.utc.range;
8829
+ d3_time.month = d3_time_interval(function(date) {
8830
+ date = d3_time.day(date);
8667
8831
  date.setDate(1);
8668
8832
  return date;
8669
8833
  }, function(date, offset) {
@@ -8671,8 +8835,8 @@ d3 = function() {
8671
8835
  }, function(date) {
8672
8836
  return date.getMonth();
8673
8837
  });
8674
- d3.time.months = d3.time.month.range;
8675
- d3.time.months.utc = d3.time.month.utc.range;
8838
+ d3_time.months = d3_time.month.range;
8839
+ d3_time.months.utc = d3_time.month.utc.range;
8676
8840
  function d3_time_scale(linear, methods, format) {
8677
8841
  function scale(x) {
8678
8842
  return linear(x);
@@ -8685,21 +8849,35 @@ d3 = function() {
8685
8849
  linear.domain(x);
8686
8850
  return scale;
8687
8851
  };
8688
- scale.nice = function(m) {
8689
- return scale.domain(d3_scale_nice(scale.domain(), m));
8852
+ function tickMethod(extent, count) {
8853
+ var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target);
8854
+ return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) {
8855
+ return d / 31536e6;
8856
+ }), count)[2] ] : !i ? [ d3_time_scaleMilliseconds, d3_scale_linearTickRange(extent, count)[2] ] : methods[target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target ? i - 1 : i];
8857
+ }
8858
+ scale.nice = function(interval, skip) {
8859
+ var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" && tickMethod(extent, interval);
8860
+ if (method) interval = method[0], skip = method[1];
8861
+ function skipped(date) {
8862
+ return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length;
8863
+ }
8864
+ return scale.domain(d3_scale_nice(domain, skip > 1 ? {
8865
+ floor: function(date) {
8866
+ while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1);
8867
+ return date;
8868
+ },
8869
+ ceil: function(date) {
8870
+ while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1);
8871
+ return date;
8872
+ }
8873
+ } : interval));
8690
8874
  };
8691
- scale.ticks = function(m, k) {
8692
- var extent = d3_scaleExtent(scale.domain());
8693
- if (typeof m !== "function") {
8694
- var span = extent[1] - extent[0], target = span / m, i = d3.bisect(d3_time_scaleSteps, target);
8695
- if (i == d3_time_scaleSteps.length) return methods.year(extent, m);
8696
- if (!i) return linear.ticks(m).map(d3_time_scaleDate);
8697
- if (target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target) --i;
8698
- m = methods[i];
8699
- k = m[1];
8700
- m = m[0].range;
8701
- }
8702
- return m(extent[0], new Date(+extent[1] + 1), k);
8875
+ scale.ticks = function(interval, skip) {
8876
+ var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" ? tickMethod(extent, interval) : !interval.range && [ {
8877
+ range: interval
8878
+ }, skip ];
8879
+ if (method) interval = method[0], skip = method[1];
8880
+ return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip);
8703
8881
  };
8704
8882
  scale.tickFormat = function() {
8705
8883
  return format;
@@ -8719,71 +8897,54 @@ d3 = function() {
8719
8897
  return f[0](date);
8720
8898
  };
8721
8899
  }
8722
- function d3_time_scaleSetYear(y) {
8723
- var d = new Date(y, 0, 1);
8724
- d.setFullYear(y);
8725
- return d;
8726
- }
8727
- function d3_time_scaleGetYear(d) {
8728
- var y = d.getFullYear(), d0 = d3_time_scaleSetYear(y), d1 = d3_time_scaleSetYear(y + 1);
8729
- return y + (d - d0) / (d1 - d0);
8730
- }
8731
8900
  var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ];
8732
- var d3_time_scaleLocalMethods = [ [ d3.time.second, 1 ], [ d3.time.second, 5 ], [ d3.time.second, 15 ], [ d3.time.second, 30 ], [ d3.time.minute, 1 ], [ d3.time.minute, 5 ], [ d3.time.minute, 15 ], [ d3.time.minute, 30 ], [ d3.time.hour, 1 ], [ d3.time.hour, 3 ], [ d3.time.hour, 6 ], [ d3.time.hour, 12 ], [ d3.time.day, 1 ], [ d3.time.day, 2 ], [ d3.time.week, 1 ], [ d3.time.month, 1 ], [ d3.time.month, 3 ], [ d3.time.year, 1 ] ];
8733
- var d3_time_scaleLocalFormats = [ [ d3.time.format("%Y"), d3_true ], [ d3.time.format("%B"), function(d) {
8901
+ var d3_time_scaleLocalMethods = [ [ d3_time.second, 1 ], [ d3_time.second, 5 ], [ d3_time.second, 15 ], [ d3_time.second, 30 ], [ d3_time.minute, 1 ], [ d3_time.minute, 5 ], [ d3_time.minute, 15 ], [ d3_time.minute, 30 ], [ d3_time.hour, 1 ], [ d3_time.hour, 3 ], [ d3_time.hour, 6 ], [ d3_time.hour, 12 ], [ d3_time.day, 1 ], [ d3_time.day, 2 ], [ d3_time.week, 1 ], [ d3_time.month, 1 ], [ d3_time.month, 3 ], [ d3_time.year, 1 ] ];
8902
+ var d3_time_scaleLocalFormats = [ [ d3_time_format("%Y"), d3_true ], [ d3_time_format("%B"), function(d) {
8734
8903
  return d.getMonth();
8735
- } ], [ d3.time.format("%b %d"), function(d) {
8904
+ } ], [ d3_time_format("%b %d"), function(d) {
8736
8905
  return d.getDate() != 1;
8737
- } ], [ d3.time.format("%a %d"), function(d) {
8906
+ } ], [ d3_time_format("%a %d"), function(d) {
8738
8907
  return d.getDay() && d.getDate() != 1;
8739
- } ], [ d3.time.format("%I %p"), function(d) {
8908
+ } ], [ d3_time_format("%I %p"), function(d) {
8740
8909
  return d.getHours();
8741
- } ], [ d3.time.format("%I:%M"), function(d) {
8910
+ } ], [ d3_time_format("%I:%M"), function(d) {
8742
8911
  return d.getMinutes();
8743
- } ], [ d3.time.format(":%S"), function(d) {
8912
+ } ], [ d3_time_format(":%S"), function(d) {
8744
8913
  return d.getSeconds();
8745
- } ], [ d3.time.format(".%L"), function(d) {
8914
+ } ], [ d3_time_format(".%L"), function(d) {
8746
8915
  return d.getMilliseconds();
8747
8916
  } ] ];
8748
- var d3_time_scaleLinear = d3.scale.linear(), d3_time_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats);
8749
- d3_time_scaleLocalMethods.year = function(extent, m) {
8750
- return d3_time_scaleLinear.domain(extent.map(d3_time_scaleGetYear)).ticks(m).map(d3_time_scaleSetYear);
8751
- };
8752
- d3.time.scale = function() {
8917
+ var d3_time_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats);
8918
+ d3_time_scaleLocalMethods.year = d3_time.year;
8919
+ d3_time.scale = function() {
8753
8920
  return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);
8754
8921
  };
8922
+ var d3_time_scaleMilliseconds = {
8923
+ range: function(start, stop, step) {
8924
+ return d3.range(+start, +stop, step).map(d3_time_scaleDate);
8925
+ }
8926
+ };
8755
8927
  var d3_time_scaleUTCMethods = d3_time_scaleLocalMethods.map(function(m) {
8756
8928
  return [ m[0].utc, m[1] ];
8757
8929
  });
8758
- var d3_time_scaleUTCFormats = [ [ d3.time.format.utc("%Y"), d3_true ], [ d3.time.format.utc("%B"), function(d) {
8930
+ var d3_time_scaleUTCFormats = [ [ d3_time_formatUtc("%Y"), d3_true ], [ d3_time_formatUtc("%B"), function(d) {
8759
8931
  return d.getUTCMonth();
8760
- } ], [ d3.time.format.utc("%b %d"), function(d) {
8932
+ } ], [ d3_time_formatUtc("%b %d"), function(d) {
8761
8933
  return d.getUTCDate() != 1;
8762
- } ], [ d3.time.format.utc("%a %d"), function(d) {
8934
+ } ], [ d3_time_formatUtc("%a %d"), function(d) {
8763
8935
  return d.getUTCDay() && d.getUTCDate() != 1;
8764
- } ], [ d3.time.format.utc("%I %p"), function(d) {
8936
+ } ], [ d3_time_formatUtc("%I %p"), function(d) {
8765
8937
  return d.getUTCHours();
8766
- } ], [ d3.time.format.utc("%I:%M"), function(d) {
8938
+ } ], [ d3_time_formatUtc("%I:%M"), function(d) {
8767
8939
  return d.getUTCMinutes();
8768
- } ], [ d3.time.format.utc(":%S"), function(d) {
8940
+ } ], [ d3_time_formatUtc(":%S"), function(d) {
8769
8941
  return d.getUTCSeconds();
8770
- } ], [ d3.time.format.utc(".%L"), function(d) {
8942
+ } ], [ d3_time_formatUtc(".%L"), function(d) {
8771
8943
  return d.getUTCMilliseconds();
8772
8944
  } ] ];
8773
8945
  var d3_time_scaleUTCFormat = d3_time_scaleFormat(d3_time_scaleUTCFormats);
8774
- function d3_time_scaleUTCSetYear(y) {
8775
- var d = new Date(Date.UTC(y, 0, 1));
8776
- d.setUTCFullYear(y);
8777
- return d;
8778
- }
8779
- function d3_time_scaleUTCGetYear(d) {
8780
- var y = d.getUTCFullYear(), d0 = d3_time_scaleUTCSetYear(y), d1 = d3_time_scaleUTCSetYear(y + 1);
8781
- return y + (d - d0) / (d1 - d0);
8782
- }
8783
- d3_time_scaleUTCMethods.year = function(extent, m) {
8784
- return d3_time_scaleLinear.domain(extent.map(d3_time_scaleUTCGetYear)).ticks(m).map(d3_time_scaleUTCSetYear);
8785
- };
8786
- d3.time.scale.utc = function() {
8946
+ d3_time_scaleUTCMethods.year = d3_time.year.utc;
8947
+ d3_time.scale.utc = function() {
8787
8948
  return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat);
8788
8949
  };
8789
8950
  d3.text = d3_xhrType(function(request) {