opal-d3 0.0.20170205 → 0.0.20170822

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: cd9f2a62cff9bb86ba15ab782cf9f01bfc2dc52f
4
- data.tar.gz: 28b9d79bf4b8bdf3922bbd26b33aa5ed77f70122
3
+ metadata.gz: bf0da071ddbd8da7c59eceede1655360c7f12983
4
+ data.tar.gz: 1f64c540471fbac2d1ad5c4141e139d1da81b26e
5
5
  SHA512:
6
- metadata.gz: 9c71fd06e833720d7eb02fbd8f8caf7b9951c5d30226d58854262c26b31b4c410e29f7a8e5ad8dcaeb23d2551a99c24cfe52114bed88e92b1986ff28e97908a3
7
- data.tar.gz: 4192170c2d783a13fe0dcfcda31ade8aa182d2cccdc564ac5f8aa60dcea26c34112897f8000f5c6345d6238194bcf3a33c17c187a5b65b7600e50e07d46cc234
6
+ metadata.gz: 3620b72503511ed215c94662027cf3013c50e6d98b6242faa5e8a53484fa8d938d3801af401736d3c23bc374815cfcfe426a1fb6d651768e87ad4f1dfeddce4c
7
+ data.tar.gz: 0df3a9c5ca621c961b2c0e49a6014f93de539c39990ec75e449c3350d88587cc155cfa5a6e002548ec1e902c9db334530b0a3eaaf0e9f78c9ffb588245827126
data/README.md CHANGED
@@ -4,4 +4,4 @@ It implements interface fairly closely following javascript API, except with blo
4
4
 
5
5
  About 60% of D3 APIs are implemented. Pull requests for the rest welcome.
6
6
 
7
- For some examples check `demo` directory.
7
+ For some examples check `demo` directory or [visit demo site](https://taw.github.io/opal-d3/).
data/d3.js CHANGED
@@ -1,11 +1,11 @@
1
- // https://d3js.org Version 4.4.3. Copyright 2017 Mike Bostock.
1
+ // https://d3js.org Version 4.10.0. Copyright 2017 Mike Bostock.
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
5
5
  (factory((global.d3 = global.d3 || {})));
6
6
  }(this, (function (exports) { 'use strict';
7
7
 
8
- var version = "4.4.3";
8
+ var version = "4.10.0";
9
9
 
10
10
  var ascending = function(a, b) {
11
11
  return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
@@ -47,6 +47,37 @@ var ascendingBisect = bisector(ascending);
47
47
  var bisectRight = ascendingBisect.right;
48
48
  var bisectLeft = ascendingBisect.left;
49
49
 
50
+ var pairs = function(array, f) {
51
+ if (f == null) f = pair;
52
+ var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);
53
+ while (i < n) pairs[i] = f(p, p = array[++i]);
54
+ return pairs;
55
+ };
56
+
57
+ function pair(a, b) {
58
+ return [a, b];
59
+ }
60
+
61
+ var cross = function(values0, values1, reduce) {
62
+ var n0 = values0.length,
63
+ n1 = values1.length,
64
+ values = new Array(n0 * n1),
65
+ i0,
66
+ i1,
67
+ i,
68
+ value0;
69
+
70
+ if (reduce == null) reduce = pair;
71
+
72
+ for (i0 = i = 0; i0 < n0; ++i0) {
73
+ for (value0 = values0[i0], i1 = 0; i1 < n1; ++i1, ++i) {
74
+ values[i] = reduce(value0, values1[i1]);
75
+ }
76
+ }
77
+
78
+ return values;
79
+ };
80
+
50
81
  var descending = function(a, b) {
51
82
  return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
52
83
  };
@@ -55,36 +86,36 @@ var number = function(x) {
55
86
  return x === null ? NaN : +x;
56
87
  };
57
88
 
58
- var variance = function(array, f) {
59
- var n = array.length,
89
+ var variance = function(values, valueof) {
90
+ var n = values.length,
60
91
  m = 0,
61
- a,
62
- d,
63
- s = 0,
64
92
  i = -1,
65
- j = 0;
93
+ mean = 0,
94
+ value,
95
+ delta,
96
+ sum = 0;
66
97
 
67
- if (f == null) {
98
+ if (valueof == null) {
68
99
  while (++i < n) {
69
- if (!isNaN(a = number(array[i]))) {
70
- d = a - m;
71
- m += d / ++j;
72
- s += d * (a - m);
100
+ if (!isNaN(value = number(values[i]))) {
101
+ delta = value - mean;
102
+ mean += delta / ++m;
103
+ sum += delta * (value - mean);
73
104
  }
74
105
  }
75
106
  }
76
107
 
77
108
  else {
78
109
  while (++i < n) {
79
- if (!isNaN(a = number(f(array[i], i, array)))) {
80
- d = a - m;
81
- m += d / ++j;
82
- s += d * (a - m);
110
+ if (!isNaN(value = number(valueof(values[i], i, values)))) {
111
+ delta = value - mean;
112
+ mean += delta / ++m;
113
+ sum += delta * (value - mean);
83
114
  }
84
115
  }
85
116
  }
86
117
 
87
- if (j > 1) return s / (j - 1);
118
+ if (m > 1) return sum / (m - 1);
88
119
  };
89
120
 
90
121
  var deviation = function(array, f) {
@@ -92,30 +123,42 @@ var deviation = function(array, f) {
92
123
  return v ? Math.sqrt(v) : v;
93
124
  };
94
125
 
95
- var extent = function(array, f) {
96
- var i = -1,
97
- n = array.length,
98
- a,
99
- b,
100
- c;
101
-
102
- if (f == null) {
103
- while (++i < n) if ((b = array[i]) != null && b >= b) { a = c = b; break; }
104
- while (++i < n) if ((b = array[i]) != null) {
105
- if (a > b) a = b;
106
- if (c < b) c = b;
126
+ var extent = function(values, valueof) {
127
+ var n = values.length,
128
+ i = -1,
129
+ value,
130
+ min,
131
+ max;
132
+
133
+ if (valueof == null) {
134
+ while (++i < n) { // Find the first comparable value.
135
+ if ((value = values[i]) != null && value >= value) {
136
+ min = max = value;
137
+ while (++i < n) { // Compare the remaining values.
138
+ if ((value = values[i]) != null) {
139
+ if (min > value) min = value;
140
+ if (max < value) max = value;
141
+ }
142
+ }
143
+ }
107
144
  }
108
145
  }
109
146
 
110
147
  else {
111
- while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = c = b; break; }
112
- while (++i < n) if ((b = f(array[i], i, array)) != null) {
113
- if (a > b) a = b;
114
- if (c < b) c = b;
148
+ while (++i < n) { // Find the first comparable value.
149
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
150
+ min = max = value;
151
+ while (++i < n) { // Compare the remaining values.
152
+ if ((value = valueof(values[i], i, values)) != null) {
153
+ if (min > value) min = value;
154
+ if (max < value) max = value;
155
+ }
156
+ }
157
+ }
115
158
  }
116
159
  }
117
160
 
118
- return [a, c];
161
+ return [min, max];
119
162
  };
120
163
 
121
164
  var array = Array.prototype;
@@ -152,14 +195,42 @@ var e5 = Math.sqrt(10);
152
195
  var e2 = Math.sqrt(2);
153
196
 
154
197
  var ticks = function(start, stop, count) {
155
- var step = tickStep(start, stop, count);
156
- return sequence(
157
- Math.ceil(start / step) * step,
158
- Math.floor(stop / step) * step + step / 2, // inclusive
159
- step
160
- );
198
+ var reverse = stop < start,
199
+ i = -1,
200
+ n,
201
+ ticks,
202
+ step;
203
+
204
+ if (reverse) n = start, start = stop, stop = n;
205
+
206
+ if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
207
+
208
+ if (step > 0) {
209
+ start = Math.ceil(start / step);
210
+ stop = Math.floor(stop / step);
211
+ ticks = new Array(n = Math.ceil(stop - start + 1));
212
+ while (++i < n) ticks[i] = (start + i) * step;
213
+ } else {
214
+ start = Math.floor(start * step);
215
+ stop = Math.ceil(stop * step);
216
+ ticks = new Array(n = Math.ceil(start - stop + 1));
217
+ while (++i < n) ticks[i] = (start - i) / step;
218
+ }
219
+
220
+ if (reverse) ticks.reverse();
221
+
222
+ return ticks;
161
223
  };
162
224
 
225
+ function tickIncrement(start, stop, count) {
226
+ var step = (stop - start) / Math.max(0, count),
227
+ power = Math.floor(Math.log(step) / Math.LN10),
228
+ error = step / Math.pow(10, power);
229
+ return power >= 0
230
+ ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
231
+ : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
232
+ }
233
+
163
234
  function tickStep(start, stop, count) {
164
235
  var step0 = Math.abs(stop - start) / Math.max(0, count),
165
236
  step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
@@ -195,12 +266,15 @@ var histogram = function() {
195
266
  tz = threshold(values, x0, x1);
196
267
 
197
268
  // Convert number of thresholds into uniform thresholds.
198
- if (!Array.isArray(tz)) tz = ticks(x0, x1, tz);
269
+ if (!Array.isArray(tz)) {
270
+ tz = tickStep(x0, x1, tz);
271
+ tz = sequence(Math.ceil(x0 / tz) * tz, Math.floor(x1 / tz) * tz, tz); // exclusive
272
+ }
199
273
 
200
274
  // Remove any thresholds outside the domain.
201
275
  var m = tz.length;
202
276
  while (tz[0] <= x0) tz.shift(), --m;
203
- while (tz[m - 1] >= x1) tz.pop(), --m;
277
+ while (tz[m - 1] > x1) tz.pop(), --m;
204
278
 
205
279
  var bins = new Array(m + 1),
206
280
  bin;
@@ -238,17 +312,17 @@ var histogram = function() {
238
312
  return histogram;
239
313
  };
240
314
 
241
- var threshold = function(array, p, f) {
242
- if (f == null) f = number;
243
- if (!(n = array.length)) return;
244
- if ((p = +p) <= 0 || n < 2) return +f(array[0], 0, array);
245
- if (p >= 1) return +f(array[n - 1], n - 1, array);
315
+ var threshold = function(values, p, valueof) {
316
+ if (valueof == null) valueof = number;
317
+ if (!(n = values.length)) return;
318
+ if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
319
+ if (p >= 1) return +valueof(values[n - 1], n - 1, values);
246
320
  var n,
247
- h = (n - 1) * p,
248
- i = Math.floor(h),
249
- a = +f(array[i], i, array),
250
- b = +f(array[i + 1], i + 1, array);
251
- return a + (b - a) * (h - i);
321
+ i = (n - 1) * p,
322
+ i0 = Math.floor(i),
323
+ value0 = +valueof(values[i0], i0, values),
324
+ value1 = +valueof(values[i0 + 1], i0 + 1, values);
325
+ return value0 + (value1 - value0) * (i - i0);
252
326
  };
253
327
 
254
328
  var freedmanDiaconis = function(values, min, max) {
@@ -260,55 +334,85 @@ var scott = function(values, min, max) {
260
334
  return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
261
335
  };
262
336
 
263
- var max = function(array, f) {
264
- var i = -1,
265
- n = array.length,
266
- a,
267
- b;
268
-
269
- if (f == null) {
270
- while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; }
271
- while (++i < n) if ((b = array[i]) != null && b > a) a = b;
337
+ var max = function(values, valueof) {
338
+ var n = values.length,
339
+ i = -1,
340
+ value,
341
+ max;
342
+
343
+ if (valueof == null) {
344
+ while (++i < n) { // Find the first comparable value.
345
+ if ((value = values[i]) != null && value >= value) {
346
+ max = value;
347
+ while (++i < n) { // Compare the remaining values.
348
+ if ((value = values[i]) != null && value > max) {
349
+ max = value;
350
+ }
351
+ }
352
+ }
353
+ }
272
354
  }
273
355
 
274
356
  else {
275
- while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = b; break; }
276
- while (++i < n) if ((b = f(array[i], i, array)) != null && b > a) a = b;
357
+ while (++i < n) { // Find the first comparable value.
358
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
359
+ max = value;
360
+ while (++i < n) { // Compare the remaining values.
361
+ if ((value = valueof(values[i], i, values)) != null && value > max) {
362
+ max = value;
363
+ }
364
+ }
365
+ }
366
+ }
277
367
  }
278
368
 
279
- return a;
369
+ return max;
280
370
  };
281
371
 
282
- var mean = function(array, f) {
283
- var s = 0,
284
- n = array.length,
285
- a,
372
+ var mean = function(values, valueof) {
373
+ var n = values.length,
374
+ m = n,
286
375
  i = -1,
287
- j = n;
376
+ value,
377
+ sum = 0;
288
378
 
289
- if (f == null) {
290
- while (++i < n) if (!isNaN(a = number(array[i]))) s += a; else --j;
379
+ if (valueof == null) {
380
+ while (++i < n) {
381
+ if (!isNaN(value = number(values[i]))) sum += value;
382
+ else --m;
383
+ }
291
384
  }
292
385
 
293
386
  else {
294
- while (++i < n) if (!isNaN(a = number(f(array[i], i, array)))) s += a; else --j;
387
+ while (++i < n) {
388
+ if (!isNaN(value = number(valueof(values[i], i, values)))) sum += value;
389
+ else --m;
390
+ }
295
391
  }
296
392
 
297
- if (j) return s / j;
393
+ if (m) return sum / m;
298
394
  };
299
395
 
300
- var median = function(array, f) {
301
- var numbers = [],
302
- n = array.length,
303
- a,
304
- i = -1;
396
+ var median = function(values, valueof) {
397
+ var n = values.length,
398
+ i = -1,
399
+ value,
400
+ numbers = [];
305
401
 
306
- if (f == null) {
307
- while (++i < n) if (!isNaN(a = number(array[i]))) numbers.push(a);
402
+ if (valueof == null) {
403
+ while (++i < n) {
404
+ if (!isNaN(value = number(values[i]))) {
405
+ numbers.push(value);
406
+ }
407
+ }
308
408
  }
309
409
 
310
410
  else {
311
- while (++i < n) if (!isNaN(a = number(f(array[i], i, array)))) numbers.push(a);
411
+ while (++i < n) {
412
+ if (!isNaN(value = number(valueof(values[i], i, values)))) {
413
+ numbers.push(value);
414
+ }
415
+ }
312
416
  }
313
417
 
314
418
  return threshold(numbers.sort(ascending), 0.5);
@@ -336,29 +440,39 @@ var merge = function(arrays) {
336
440
  return merged;
337
441
  };
338
442
 
339
- var min = function(array, f) {
340
- var i = -1,
341
- n = array.length,
342
- a,
343
- b;
344
-
345
- if (f == null) {
346
- while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; }
347
- while (++i < n) if ((b = array[i]) != null && a > b) a = b;
443
+ var min = function(values, valueof) {
444
+ var n = values.length,
445
+ i = -1,
446
+ value,
447
+ min;
448
+
449
+ if (valueof == null) {
450
+ while (++i < n) { // Find the first comparable value.
451
+ if ((value = values[i]) != null && value >= value) {
452
+ min = value;
453
+ while (++i < n) { // Compare the remaining values.
454
+ if ((value = values[i]) != null && min > value) {
455
+ min = value;
456
+ }
457
+ }
458
+ }
459
+ }
348
460
  }
349
461
 
350
462
  else {
351
- while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = b; break; }
352
- while (++i < n) if ((b = f(array[i], i, array)) != null && a > b) a = b;
463
+ while (++i < n) { // Find the first comparable value.
464
+ if ((value = valueof(values[i], i, values)) != null && value >= value) {
465
+ min = value;
466
+ while (++i < n) { // Compare the remaining values.
467
+ if ((value = valueof(values[i], i, values)) != null && min > value) {
468
+ min = value;
469
+ }
470
+ }
471
+ }
472
+ }
353
473
  }
354
474
 
355
- return a;
356
- };
357
-
358
- var pairs = function(array) {
359
- var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);
360
- while (i < n) pairs[i] = [p, p = array[++i]];
361
- return pairs;
475
+ return min;
362
476
  };
363
477
 
364
478
  var permute = function(array, indexes) {
@@ -367,17 +481,21 @@ var permute = function(array, indexes) {
367
481
  return permutes;
368
482
  };
369
483
 
370
- var scan = function(array, compare) {
371
- if (!(n = array.length)) return;
372
- var i = 0,
373
- n,
484
+ var scan = function(values, compare) {
485
+ if (!(n = values.length)) return;
486
+ var n,
487
+ i = 0,
374
488
  j = 0,
375
489
  xi,
376
- xj = array[j];
490
+ xj = values[j];
377
491
 
378
- if (!compare) compare = ascending;
492
+ if (compare == null) compare = ascending;
379
493
 
380
- while (++i < n) if (compare(xi = array[i], xj) < 0 || compare(xj, xj) !== 0) xj = xi, j = i;
494
+ while (++i < n) {
495
+ if (compare(xi = values[i], xj) < 0 || compare(xj, xj) !== 0) {
496
+ xj = xi, j = i;
497
+ }
498
+ }
381
499
 
382
500
  if (compare(xj, xj) === 0) return j;
383
501
  };
@@ -397,21 +515,25 @@ var shuffle = function(array, i0, i1) {
397
515
  return array;
398
516
  };
399
517
 
400
- var sum = function(array, f) {
401
- var s = 0,
402
- n = array.length,
403
- a,
404
- i = -1;
518
+ var sum = function(values, valueof) {
519
+ var n = values.length,
520
+ i = -1,
521
+ value,
522
+ sum = 0;
405
523
 
406
- if (f == null) {
407
- while (++i < n) if (a = +array[i]) s += a; // Note: zero and null are equivalent.
524
+ if (valueof == null) {
525
+ while (++i < n) {
526
+ if (value = +values[i]) sum += value; // Note: zero and null are equivalent.
527
+ }
408
528
  }
409
529
 
410
530
  else {
411
- while (++i < n) if (a = +f(array[i], i, array)) s += a;
531
+ while (++i < n) {
532
+ if (value = +valueof(values[i], i, values)) sum += value;
533
+ }
412
534
  }
413
535
 
414
- return s;
536
+ return sum;
415
537
  };
416
538
 
417
539
  var transpose = function(matrix) {
@@ -444,21 +566,25 @@ var bottom = 3;
444
566
  var left = 4;
445
567
  var epsilon = 1e-6;
446
568
 
447
- function translateX(scale0, scale1, d) {
448
- var x = scale0(d);
449
- return "translate(" + (isFinite(x) ? x : scale1(d)) + ",0)";
569
+ function translateX(x) {
570
+ return "translate(" + (x + 0.5) + ",0)";
571
+ }
572
+
573
+ function translateY(y) {
574
+ return "translate(0," + (y + 0.5) + ")";
450
575
  }
451
576
 
452
- function translateY(scale0, scale1, d) {
453
- var y = scale0(d);
454
- return "translate(0," + (isFinite(y) ? y : scale1(d)) + ")";
577
+ function number$1(scale) {
578
+ return function(d) {
579
+ return +scale(d);
580
+ };
455
581
  }
456
582
 
457
583
  function center(scale) {
458
- var offset = scale.bandwidth() / 2;
584
+ var offset = Math.max(0, scale.bandwidth() - 1) / 2; // Adjust for 0.5px offset.
459
585
  if (scale.round()) offset = Math.round(offset);
460
586
  return function(d) {
461
- return scale(d) + offset;
587
+ return +scale(d) + offset;
462
588
  };
463
589
  }
464
590
 
@@ -472,26 +598,26 @@ function axis(orient, scale) {
472
598
  tickFormat = null,
473
599
  tickSizeInner = 6,
474
600
  tickSizeOuter = 6,
475
- tickPadding = 3;
601
+ tickPadding = 3,
602
+ k = orient === top || orient === left ? -1 : 1,
603
+ x = orient === left || orient === right ? "x" : "y",
604
+ transform = orient === top || orient === bottom ? translateX : translateY;
476
605
 
477
606
  function axis(context) {
478
607
  var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues,
479
608
  format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$1) : tickFormat,
480
609
  spacing = Math.max(tickSizeInner, 0) + tickPadding,
481
- transform = orient === top || orient === bottom ? translateX : translateY,
482
610
  range = scale.range(),
483
- range0 = range[0] + 0.5,
484
- range1 = range[range.length - 1] + 0.5,
485
- position = (scale.bandwidth ? center : identity$1)(scale.copy()),
611
+ range0 = +range[0] + 0.5,
612
+ range1 = +range[range.length - 1] + 0.5,
613
+ position = (scale.bandwidth ? center : number$1)(scale.copy()),
486
614
  selection = context.selection ? context.selection() : context,
487
615
  path = selection.selectAll(".domain").data([null]),
488
616
  tick = selection.selectAll(".tick").data(values, scale).order(),
489
617
  tickExit = tick.exit(),
490
618
  tickEnter = tick.enter().append("g").attr("class", "tick"),
491
619
  line = tick.select("line"),
492
- text = tick.select("text"),
493
- k = orient === top || orient === left ? -1 : 1,
494
- x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x");
620
+ text = tick.select("text");
495
621
 
496
622
  path = path.merge(path.enter().insert("path", ".tick")
497
623
  .attr("class", "domain")
@@ -501,14 +627,11 @@ function axis(orient, scale) {
501
627
 
502
628
  line = line.merge(tickEnter.append("line")
503
629
  .attr("stroke", "#000")
504
- .attr(x + "2", k * tickSizeInner)
505
- .attr(y + "1", 0.5)
506
- .attr(y + "2", 0.5));
630
+ .attr(x + "2", k * tickSizeInner));
507
631
 
508
632
  text = text.merge(tickEnter.append("text")
509
633
  .attr("fill", "#000")
510
634
  .attr(x, k * spacing)
511
- .attr(y, 0.5)
512
635
  .attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em"));
513
636
 
514
637
  if (context !== selection) {
@@ -519,11 +642,11 @@ function axis(orient, scale) {
519
642
 
520
643
  tickExit = tickExit.transition(context)
521
644
  .attr("opacity", epsilon)
522
- .attr("transform", function(d) { return transform(position, this.parentNode.__axis || position, d); });
645
+ .attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d) : this.getAttribute("transform"); });
523
646
 
524
647
  tickEnter
525
648
  .attr("opacity", epsilon)
526
- .attr("transform", function(d) { return transform(this.parentNode.__axis || position, position, d); });
649
+ .attr("transform", function(d) { var p = this.parentNode.__axis; return transform(p && isFinite(p = p(d)) ? p : position(d)); });
527
650
  }
528
651
 
529
652
  tickExit.remove();
@@ -535,7 +658,7 @@ function axis(orient, scale) {
535
658
 
536
659
  tick
537
660
  .attr("opacity", 1)
538
- .attr("transform", function(d) { return transform(position, position, d); });
661
+ .attr("transform", function(d) { return transform(position(d)); });
539
662
 
540
663
  line
541
664
  .attr(x + "2", k * tickSizeInner);
@@ -1127,9 +1250,9 @@ var selection_exit = function() {
1127
1250
  return new Selection(this._exit || this._groups.map(sparse), this._parents);
1128
1251
  };
1129
1252
 
1130
- var selection_merge = function(selection) {
1253
+ var selection_merge = function(selection$$1) {
1131
1254
 
1132
- for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
1255
+ for (var groups0 = this._groups, groups1 = selection$$1._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
1133
1256
  for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
1134
1257
  if (node = group0[i] || group1[i]) {
1135
1258
  merge[i] = node;
@@ -1283,7 +1406,7 @@ var selection_attr = function(name, value) {
1283
1406
  : (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
1284
1407
  };
1285
1408
 
1286
- var window = function(node) {
1409
+ var defaultView = function(node) {
1287
1410
  return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
1288
1411
  || (node.document && node) // node is a Window
1289
1412
  || node.defaultView; // node is a Document
@@ -1310,17 +1433,19 @@ function styleFunction(name, value, priority) {
1310
1433
  }
1311
1434
 
1312
1435
  var selection_style = function(name, value, priority) {
1313
- var node;
1314
1436
  return arguments.length > 1
1315
1437
  ? this.each((value == null
1316
1438
  ? styleRemove : typeof value === "function"
1317
1439
  ? styleFunction
1318
1440
  : styleConstant)(name, value, priority == null ? "" : priority))
1319
- : window(node = this.node())
1320
- .getComputedStyle(node, null)
1321
- .getPropertyValue(name);
1441
+ : styleValue(this.node(), name);
1322
1442
  };
1323
1443
 
1444
+ function styleValue(node, name) {
1445
+ return node.style.getPropertyValue(name)
1446
+ || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
1447
+ }
1448
+
1324
1449
  function propertyRemove(name) {
1325
1450
  return function() {
1326
1451
  delete this[name];
@@ -1529,13 +1654,13 @@ var selection_datum = function(value) {
1529
1654
  };
1530
1655
 
1531
1656
  function dispatchEvent(node, type, params) {
1532
- var window$$1 = window(node),
1533
- event = window$$1.CustomEvent;
1657
+ var window = defaultView(node),
1658
+ event = window.CustomEvent;
1534
1659
 
1535
- if (event) {
1660
+ if (typeof event === "function") {
1536
1661
  event = new event(type, params);
1537
1662
  } else {
1538
- event = window$$1.document.createEvent("Event");
1663
+ event = window.document.createEvent("Event");
1539
1664
  if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
1540
1665
  else event.initEvent(type, false, false);
1541
1666
  }
@@ -1711,6 +1836,10 @@ function defaultSubject(d) {
1711
1836
  return d == null ? {x: exports.event.x, y: exports.event.y} : d;
1712
1837
  }
1713
1838
 
1839
+ function touchable() {
1840
+ return "ontouchstart" in this;
1841
+ }
1842
+
1714
1843
  var drag = function() {
1715
1844
  var filter = defaultFilter$1,
1716
1845
  container = defaultContainer,
@@ -1718,15 +1847,20 @@ var drag = function() {
1718
1847
  gestures = {},
1719
1848
  listeners = dispatch("start", "drag", "end"),
1720
1849
  active = 0,
1850
+ mousedownx,
1851
+ mousedowny,
1721
1852
  mousemoving,
1722
- touchending;
1853
+ touchending,
1854
+ clickDistance2 = 0;
1723
1855
 
1724
- function drag(selection$$1) {
1725
- selection$$1
1856
+ function drag(selection) {
1857
+ selection
1726
1858
  .on("mousedown.drag", mousedowned)
1859
+ .filter(touchable)
1727
1860
  .on("touchstart.drag", touchstarted)
1728
1861
  .on("touchmove.drag", touchmoved)
1729
1862
  .on("touchend.drag touchcancel.drag", touchended)
1863
+ .style("touch-action", "none")
1730
1864
  .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
1731
1865
  }
1732
1866
 
@@ -1738,12 +1872,17 @@ var drag = function() {
1738
1872
  dragDisable(exports.event.view);
1739
1873
  nopropagation();
1740
1874
  mousemoving = false;
1875
+ mousedownx = exports.event.clientX;
1876
+ mousedowny = exports.event.clientY;
1741
1877
  gesture("start");
1742
1878
  }
1743
1879
 
1744
1880
  function mousemoved() {
1745
1881
  noevent();
1746
- mousemoving = true;
1882
+ if (!mousemoving) {
1883
+ var dx = exports.event.clientX - mousedownx, dy = exports.event.clientY - mousedowny;
1884
+ mousemoving = dx * dx + dy * dy > clickDistance2;
1885
+ }
1747
1886
  gestures.mouse("drag");
1748
1887
  }
1749
1888
 
@@ -1833,6 +1972,10 @@ var drag = function() {
1833
1972
  return value === listeners ? drag : value;
1834
1973
  };
1835
1974
 
1975
+ drag.clickDistance = function(_) {
1976
+ return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2);
1977
+ };
1978
+
1836
1979
  return drag;
1837
1980
  };
1838
1981
 
@@ -2408,7 +2551,7 @@ function nogamma(a, b) {
2408
2551
  return d ? linear(a, d) : constant$3(isNaN(a) ? b : a);
2409
2552
  }
2410
2553
 
2411
- var interpolateRgb = ((function rgbGamma(y) {
2554
+ var interpolateRgb = (function rgbGamma(y) {
2412
2555
  var color$$1 = gamma(y);
2413
2556
 
2414
2557
  function rgb$$1(start, end) {
@@ -2428,7 +2571,7 @@ var interpolateRgb = ((function rgbGamma(y) {
2428
2571
  rgb$$1.gamma = rgbGamma;
2429
2572
 
2430
2573
  return rgb$$1;
2431
- }))(1);
2574
+ })(1);
2432
2575
 
2433
2576
  function rgbSpline(spline) {
2434
2577
  return function(colors) {
@@ -2581,7 +2724,7 @@ var interpolateValue = function(a, b) {
2581
2724
  : b instanceof color ? interpolateRgb
2582
2725
  : b instanceof Date ? date
2583
2726
  : Array.isArray(b) ? array$1
2584
- : isNaN(b) ? object
2727
+ : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
2585
2728
  : reinterpolate)(a, b);
2586
2729
  };
2587
2730
 
@@ -2863,7 +3006,7 @@ var clockLast = 0;
2863
3006
  var clockNow = 0;
2864
3007
  var clockSkew = 0;
2865
3008
  var clock = typeof performance === "object" && performance.now ? performance : Date;
2866
- var setFrame = typeof requestAnimationFrame === "function" ? requestAnimationFrame : function(f) { setTimeout(f, 17); };
3009
+ var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
2867
3010
 
2868
3011
  function now() {
2869
3012
  return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
@@ -2959,7 +3102,7 @@ function sleep(time) {
2959
3102
  if (time < Infinity) timeout = setTimeout(wake, delay);
2960
3103
  if (interval) interval = clearInterval(interval);
2961
3104
  } else {
2962
- if (!interval) interval = setInterval(poke, pokeDelay);
3105
+ if (!interval) clockLast = clockNow, interval = setInterval(poke, pokeDelay);
2963
3106
  frame = 1, setFrame(wake);
2964
3107
  }
2965
3108
  }
@@ -3141,7 +3284,7 @@ function create(node, id, self) {
3141
3284
 
3142
3285
  var interrupt = function(node, name) {
3143
3286
  var schedules = node.__transition,
3144
- schedule,
3287
+ schedule$$1,
3145
3288
  active,
3146
3289
  empty = true,
3147
3290
  i;
@@ -3151,11 +3294,11 @@ var interrupt = function(node, name) {
3151
3294
  name = name == null ? null : name + "";
3152
3295
 
3153
3296
  for (i in schedules) {
3154
- if ((schedule = schedules[i]).name !== name) { empty = false; continue; }
3155
- active = schedule.state > STARTING && schedule.state < ENDING;
3156
- schedule.state = ENDED;
3157
- schedule.timer.stop();
3158
- if (active) schedule.on.call("interrupt", node, node.__data__, schedule.index, schedule.group);
3297
+ if ((schedule$$1 = schedules[i]).name !== name) { empty = false; continue; }
3298
+ active = schedule$$1.state > STARTING && schedule$$1.state < ENDING;
3299
+ schedule$$1.state = ENDED;
3300
+ schedule$$1.timer.stop();
3301
+ if (active) schedule$$1.on.call("interrupt", node, node.__data__, schedule$$1.index, schedule$$1.group);
3159
3302
  delete schedules[i];
3160
3303
  }
3161
3304
 
@@ -3171,8 +3314,8 @@ var selection_interrupt = function(name) {
3171
3314
  function tweenRemove(id, name) {
3172
3315
  var tween0, tween1;
3173
3316
  return function() {
3174
- var schedule = set$1(this, id),
3175
- tween = schedule.tween;
3317
+ var schedule$$1 = set$1(this, id),
3318
+ tween = schedule$$1.tween;
3176
3319
 
3177
3320
  // If this node shared tween with the previous node,
3178
3321
  // just assign the updated shared tween and we’re done!
@@ -3188,7 +3331,7 @@ function tweenRemove(id, name) {
3188
3331
  }
3189
3332
  }
3190
3333
 
3191
- schedule.tween = tween1;
3334
+ schedule$$1.tween = tween1;
3192
3335
  };
3193
3336
  }
3194
3337
 
@@ -3196,8 +3339,8 @@ function tweenFunction(id, name, value) {
3196
3339
  var tween0, tween1;
3197
3340
  if (typeof value !== "function") throw new Error;
3198
3341
  return function() {
3199
- var schedule = set$1(this, id),
3200
- tween = schedule.tween;
3342
+ var schedule$$1 = set$1(this, id),
3343
+ tween = schedule$$1.tween;
3201
3344
 
3202
3345
  // If this node shared tween with the previous node,
3203
3346
  // just assign the updated shared tween and we’re done!
@@ -3213,7 +3356,7 @@ function tweenFunction(id, name, value) {
3213
3356
  if (i === n) tween1.push(t);
3214
3357
  }
3215
3358
 
3216
- schedule.tween = tween1;
3359
+ schedule$$1.tween = tween1;
3217
3360
  };
3218
3361
  }
3219
3362
 
@@ -3239,8 +3382,8 @@ function tweenValue(transition, name, value) {
3239
3382
  var id = transition._id;
3240
3383
 
3241
3384
  transition.each(function() {
3242
- var schedule = set$1(this, id);
3243
- (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments);
3385
+ var schedule$$1 = set$1(this, id);
3386
+ (schedule$$1.value || (schedule$$1.value = {}))[name] = value.apply(this, arguments);
3244
3387
  });
3245
3388
 
3246
3389
  return function(node) {
@@ -3248,7 +3391,7 @@ function tweenValue(transition, name, value) {
3248
3391
  };
3249
3392
  }
3250
3393
 
3251
- var interpolate$$1 = function(a, b) {
3394
+ var interpolate = function(a, b) {
3252
3395
  var c;
3253
3396
  return (typeof b === "number" ? reinterpolate
3254
3397
  : b instanceof color ? interpolateRgb
@@ -3319,11 +3462,11 @@ function attrFunctionNS$1(fullname, interpolate$$1, value) {
3319
3462
  }
3320
3463
 
3321
3464
  var transition_attr = function(name, value) {
3322
- var fullname = namespace(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate$$1;
3465
+ var fullname = namespace(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate;
3323
3466
  return this.attrTween(name, typeof value === "function"
3324
3467
  ? (fullname.local ? attrFunctionNS$1 : attrFunction$1)(fullname, i, tweenValue(this, "attr." + name, value))
3325
3468
  : value == null ? (fullname.local ? attrRemoveNS$1 : attrRemove$1)(fullname)
3326
- : (fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, i, value));
3469
+ : (fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, i, value + ""));
3327
3470
  };
3328
3471
 
3329
3472
  function attrTweenNS(fullname, value) {
@@ -3430,10 +3573,10 @@ var transition_filter = function(match) {
3430
3573
  return new Transition(subgroups, this._parents, this._name, this._id);
3431
3574
  };
3432
3575
 
3433
- var transition_merge = function(transition) {
3434
- if (transition._id !== this._id) throw new Error;
3576
+ var transition_merge = function(transition$$1) {
3577
+ if (transition$$1._id !== this._id) throw new Error;
3435
3578
 
3436
- for (var groups0 = this._groups, groups1 = transition._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
3579
+ for (var groups0 = this._groups, groups1 = transition$$1._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
3437
3580
  for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
3438
3581
  if (node = group0[i] || group1[i]) {
3439
3582
  merge[i] = node;
@@ -3459,15 +3602,15 @@ function start(name) {
3459
3602
  function onFunction(id, name, listener) {
3460
3603
  var on0, on1, sit = start(name) ? init : set$1;
3461
3604
  return function() {
3462
- var schedule = sit(this, id),
3463
- on = schedule.on;
3605
+ var schedule$$1 = sit(this, id),
3606
+ on = schedule$$1.on;
3464
3607
 
3465
3608
  // If this node shared a dispatch with the previous node,
3466
3609
  // just assign the updated shared dispatch and we’re done!
3467
3610
  // Otherwise, copy-on-write.
3468
3611
  if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
3469
3612
 
3470
- schedule.on = on1;
3613
+ schedule$$1.on = on1;
3471
3614
  };
3472
3615
  }
3473
3616
 
@@ -3539,17 +3682,16 @@ var transition_selection = function() {
3539
3682
  return new Selection$1(this._groups, this._parents);
3540
3683
  };
3541
3684
 
3542
- function styleRemove$1(name, interpolate$$2) {
3685
+ function styleRemove$1(name, interpolate$$1) {
3543
3686
  var value00,
3544
3687
  value10,
3545
3688
  interpolate0;
3546
3689
  return function() {
3547
- var style = window(this).getComputedStyle(this, null),
3548
- value0 = style.getPropertyValue(name),
3549
- value1 = (this.style.removeProperty(name), style.getPropertyValue(name));
3690
+ var value0 = styleValue(this, name),
3691
+ value1 = (this.style.removeProperty(name), styleValue(this, name));
3550
3692
  return value0 === value1 ? null
3551
3693
  : value0 === value00 && value1 === value10 ? interpolate0
3552
- : interpolate0 = interpolate$$2(value00 = value0, value10 = value1);
3694
+ : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
3553
3695
  };
3554
3696
  }
3555
3697
 
@@ -3559,40 +3701,39 @@ function styleRemoveEnd(name) {
3559
3701
  };
3560
3702
  }
3561
3703
 
3562
- function styleConstant$1(name, interpolate$$2, value1) {
3704
+ function styleConstant$1(name, interpolate$$1, value1) {
3563
3705
  var value00,
3564
3706
  interpolate0;
3565
3707
  return function() {
3566
- var value0 = window(this).getComputedStyle(this, null).getPropertyValue(name);
3708
+ var value0 = styleValue(this, name);
3567
3709
  return value0 === value1 ? null
3568
3710
  : value0 === value00 ? interpolate0
3569
- : interpolate0 = interpolate$$2(value00 = value0, value1);
3711
+ : interpolate0 = interpolate$$1(value00 = value0, value1);
3570
3712
  };
3571
3713
  }
3572
3714
 
3573
- function styleFunction$1(name, interpolate$$2, value) {
3715
+ function styleFunction$1(name, interpolate$$1, value) {
3574
3716
  var value00,
3575
3717
  value10,
3576
3718
  interpolate0;
3577
3719
  return function() {
3578
- var style = window(this).getComputedStyle(this, null),
3579
- value0 = style.getPropertyValue(name),
3720
+ var value0 = styleValue(this, name),
3580
3721
  value1 = value(this);
3581
- if (value1 == null) value1 = (this.style.removeProperty(name), style.getPropertyValue(name));
3722
+ if (value1 == null) value1 = (this.style.removeProperty(name), styleValue(this, name));
3582
3723
  return value0 === value1 ? null
3583
3724
  : value0 === value00 && value1 === value10 ? interpolate0
3584
- : interpolate0 = interpolate$$2(value00 = value0, value10 = value1);
3725
+ : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
3585
3726
  };
3586
3727
  }
3587
3728
 
3588
3729
  var transition_style = function(name, value, priority) {
3589
- var i = (name += "") === "transform" ? interpolateTransformCss : interpolate$$1;
3730
+ var i = (name += "") === "transform" ? interpolateTransformCss : interpolate;
3590
3731
  return value == null ? this
3591
3732
  .styleTween(name, styleRemove$1(name, i))
3592
3733
  .on("end.style." + name, styleRemoveEnd(name))
3593
3734
  : this.styleTween(name, typeof value === "function"
3594
3735
  ? styleFunction$1(name, i, tweenValue(this, "style." + name, value))
3595
- : styleConstant$1(name, i, value), priority);
3736
+ : styleConstant$1(name, i, value + ""), priority);
3596
3737
  };
3597
3738
 
3598
3739
  function styleTween(name, value, priority) {
@@ -3957,13 +4098,13 @@ var root$1 = [null];
3957
4098
 
3958
4099
  var active = function(node, name) {
3959
4100
  var schedules = node.__transition,
3960
- schedule,
4101
+ schedule$$1,
3961
4102
  i;
3962
4103
 
3963
4104
  if (schedules) {
3964
4105
  name = name == null ? null : name + "";
3965
4106
  for (i in schedules) {
3966
- if ((schedule = schedules[i]).state > SCHEDULED && schedule.name === name) {
4107
+ if ((schedule$$1 = schedules[i]).state > SCHEDULED && schedule$$1.name === name) {
3967
4108
  return new Transition([[node]], root$1, name, +i);
3968
4109
  }
3969
4110
  }
@@ -4172,7 +4313,7 @@ function brush$1(dim) {
4172
4313
  .on("mousedown.brush touchstart.brush", started);
4173
4314
  }
4174
4315
 
4175
- brush.move = function(group, selection$$1) {
4316
+ brush.move = function(group, selection) {
4176
4317
  if (group.selection) {
4177
4318
  group
4178
4319
  .on("start.brush", function() { emitter(this, arguments).beforestart().start(); })
@@ -4182,7 +4323,7 @@ function brush$1(dim) {
4182
4323
  state = that.__brush,
4183
4324
  emit = emitter(that, arguments),
4184
4325
  selection0 = state.selection,
4185
- selection1 = dim.input(typeof selection$$1 === "function" ? selection$$1.apply(this, arguments) : selection$$1, state.extent),
4326
+ selection1 = dim.input(typeof selection === "function" ? selection.apply(this, arguments) : selection, state.extent),
4186
4327
  i = interpolateValue(selection0, selection1);
4187
4328
 
4188
4329
  function tween(t) {
@@ -4199,7 +4340,7 @@ function brush$1(dim) {
4199
4340
  var that = this,
4200
4341
  args = arguments,
4201
4342
  state = that.__brush,
4202
- selection1 = dim.input(typeof selection$$1 === "function" ? selection$$1.apply(that, args) : selection$$1, state.extent),
4343
+ selection1 = dim.input(typeof selection === "function" ? selection.apply(that, args) : selection, state.extent),
4203
4344
  emit = emitter(that, args).beforestart();
4204
4345
 
4205
4346
  interrupt(that);
@@ -4212,22 +4353,22 @@ function brush$1(dim) {
4212
4353
 
4213
4354
  function redraw() {
4214
4355
  var group = select(this),
4215
- selection$$1 = local$$1(this).selection;
4356
+ selection = local$$1(this).selection;
4216
4357
 
4217
- if (selection$$1) {
4358
+ if (selection) {
4218
4359
  group.selectAll(".selection")
4219
4360
  .style("display", null)
4220
- .attr("x", selection$$1[0][0])
4221
- .attr("y", selection$$1[0][1])
4222
- .attr("width", selection$$1[1][0] - selection$$1[0][0])
4223
- .attr("height", selection$$1[1][1] - selection$$1[0][1]);
4361
+ .attr("x", selection[0][0])
4362
+ .attr("y", selection[0][1])
4363
+ .attr("width", selection[1][0] - selection[0][0])
4364
+ .attr("height", selection[1][1] - selection[0][1]);
4224
4365
 
4225
4366
  group.selectAll(".handle")
4226
4367
  .style("display", null)
4227
- .attr("x", function(d) { return d.type[d.type.length - 1] === "e" ? selection$$1[1][0] - handleSize / 2 : selection$$1[0][0] - handleSize / 2; })
4228
- .attr("y", function(d) { return d.type[0] === "s" ? selection$$1[1][1] - handleSize / 2 : selection$$1[0][1] - handleSize / 2; })
4229
- .attr("width", function(d) { return d.type === "n" || d.type === "s" ? selection$$1[1][0] - selection$$1[0][0] + handleSize : handleSize; })
4230
- .attr("height", function(d) { return d.type === "e" || d.type === "w" ? selection$$1[1][1] - selection$$1[0][1] + handleSize : handleSize; });
4368
+ .attr("x", function(d) { return d.type[d.type.length - 1] === "e" ? selection[1][0] - handleSize / 2 : selection[0][0] - handleSize / 2; })
4369
+ .attr("y", function(d) { return d.type[0] === "s" ? selection[1][1] - handleSize / 2 : selection[0][1] - handleSize / 2; })
4370
+ .attr("width", function(d) { return d.type === "n" || d.type === "s" ? selection[1][0] - selection[0][0] + handleSize : handleSize; })
4371
+ .attr("height", function(d) { return d.type === "e" || d.type === "w" ? selection[1][1] - selection[0][1] + handleSize : handleSize; });
4231
4372
  }
4232
4373
 
4233
4374
  else {
@@ -4285,7 +4426,7 @@ function brush$1(dim) {
4285
4426
  signY = dim === X ? null : signsY[type],
4286
4427
  state = local$$1(that),
4287
4428
  extent = state.extent,
4288
- selection$$1 = state.selection,
4429
+ selection = state.selection,
4289
4430
  W = extent[0][0], w0, w1,
4290
4431
  N = extent[0][1], n0, n1,
4291
4432
  E = extent[1][0], e0, e1,
@@ -4301,15 +4442,15 @@ function brush$1(dim) {
4301
4442
  emit = emitter(that, arguments).beforestart();
4302
4443
 
4303
4444
  if (type === "overlay") {
4304
- state.selection = selection$$1 = [
4445
+ state.selection = selection = [
4305
4446
  [w0 = dim === Y ? W : point0[0], n0 = dim === X ? N : point0[1]],
4306
4447
  [e0 = dim === Y ? E : w0, s0 = dim === X ? S : n0]
4307
4448
  ];
4308
4449
  } else {
4309
- w0 = selection$$1[0][0];
4310
- n0 = selection$$1[0][1];
4311
- e0 = selection$$1[1][0];
4312
- s0 = selection$$1[1][1];
4450
+ w0 = selection[0][0];
4451
+ n0 = selection[0][1];
4452
+ e0 = selection[1][0];
4453
+ s0 = selection[1][1];
4313
4454
  }
4314
4455
 
4315
4456
  w1 = w0;
@@ -4395,14 +4536,14 @@ function brush$1(dim) {
4395
4536
  if (type in flipY) overlay.attr("cursor", cursors[type = flipY[type]]);
4396
4537
  }
4397
4538
 
4398
- if (state.selection) selection$$1 = state.selection; // May be set by brush.move!
4399
- if (lockX) w1 = selection$$1[0][0], e1 = selection$$1[1][0];
4400
- if (lockY) n1 = selection$$1[0][1], s1 = selection$$1[1][1];
4539
+ if (state.selection) selection = state.selection; // May be set by brush.move!
4540
+ if (lockX) w1 = selection[0][0], e1 = selection[1][0];
4541
+ if (lockY) n1 = selection[0][1], s1 = selection[1][1];
4401
4542
 
4402
- if (selection$$1[0][0] !== w1
4403
- || selection$$1[0][1] !== n1
4404
- || selection$$1[1][0] !== e1
4405
- || selection$$1[1][1] !== s1) {
4543
+ if (selection[0][0] !== w1
4544
+ || selection[0][1] !== n1
4545
+ || selection[1][0] !== e1
4546
+ || selection[1][1] !== s1) {
4406
4547
  state.selection = [[w1, n1], [e1, s1]];
4407
4548
  redraw.call(that);
4408
4549
  emit.brush();
@@ -4422,8 +4563,8 @@ function brush$1(dim) {
4422
4563
  }
4423
4564
  group.attr("pointer-events", "all");
4424
4565
  overlay.attr("cursor", cursors.overlay);
4425
- if (state.selection) selection$$1 = state.selection; // May be set by brush.move (on start)!
4426
- if (empty(selection$$1)) state.selection = null, redraw.call(that);
4566
+ if (state.selection) selection = state.selection; // May be set by brush.move (on start)!
4567
+ if (empty(selection)) state.selection = null, redraw.call(that);
4427
4568
  emit.end();
4428
4569
  }
4429
4570
 
@@ -4766,14 +4907,16 @@ Path.prototype = path.prototype = {
4766
4907
  // Is this arc empty? We’re done.
4767
4908
  if (!r) return;
4768
4909
 
4910
+ // Does the angle go the wrong way? Flip the direction.
4911
+ if (da < 0) da = da % tau$2 + tau$2;
4912
+
4769
4913
  // Is this a complete circle? Draw two arcs to complete the circle.
4770
4914
  if (da > tauEpsilon) {
4771
4915
  this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
4772
4916
  }
4773
4917
 
4774
- // Otherwise, draw an arc!
4775
- else {
4776
- if (da < 0) da = da % tau$2 + tau$2;
4918
+ // Is this arc non-empty? Draw an arc!
4919
+ else if (da > epsilon$1) {
4777
4920
  this._ += "A" + r + "," + r + ",0," + (+(da >= pi$2)) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
4778
4921
  }
4779
4922
  },
@@ -4950,10 +5093,10 @@ var nest = function() {
4950
5093
  nest;
4951
5094
 
4952
5095
  function apply(array, depth, createResult, setResult) {
4953
- if (depth >= keys.length) return rollup != null
4954
- ? rollup(array) : (sortValues != null
4955
- ? array.sort(sortValues)
4956
- : array);
5096
+ if (depth >= keys.length) {
5097
+ if (sortValues != null) array.sort(sortValues);
5098
+ return rollup != null ? rollup(array) : array;
5099
+ }
4957
5100
 
4958
5101
  var i = -1,
4959
5102
  n = array.length,
@@ -5098,7 +5241,7 @@ function inferColumns(rows) {
5098
5241
  }
5099
5242
 
5100
5243
  var dsv = function(delimiter) {
5101
- var reFormat = new RegExp("[\"" + delimiter + "\n]"),
5244
+ var reFormat = new RegExp("[\"" + delimiter + "\n\r]"),
5102
5245
  delimiterCode = delimiter.charCodeAt(0);
5103
5246
 
5104
5247
  function parse(text, f) {
@@ -6058,17 +6201,17 @@ var manyBody = function() {
6058
6201
  }
6059
6202
 
6060
6203
  function accumulate(quad) {
6061
- var strength = 0, q, c, x$$1, y$$1, i;
6204
+ var strength = 0, q, c, x, y, i;
6062
6205
 
6063
6206
  // For internal nodes, accumulate forces from child quadrants.
6064
6207
  if (quad.length) {
6065
- for (x$$1 = y$$1 = i = 0; i < 4; ++i) {
6208
+ for (x = y = i = 0; i < 4; ++i) {
6066
6209
  if ((q = quad[i]) && (c = q.value)) {
6067
- strength += c, x$$1 += c * q.x, y$$1 += c * q.y;
6210
+ strength += c, x += c * q.x, y += c * q.y;
6068
6211
  }
6069
6212
  }
6070
- quad.x = x$$1 / strength;
6071
- quad.y = y$$1 / strength;
6213
+ quad.x = x / strength;
6214
+ quad.y = y / strength;
6072
6215
  }
6073
6216
 
6074
6217
  // For leaf nodes, accumulate forces from coincident quadrants.
@@ -6086,20 +6229,20 @@ var manyBody = function() {
6086
6229
  function apply(quad, x1, _, x2) {
6087
6230
  if (!quad.value) return true;
6088
6231
 
6089
- var x$$1 = quad.x - node.x,
6090
- y$$1 = quad.y - node.y,
6232
+ var x = quad.x - node.x,
6233
+ y = quad.y - node.y,
6091
6234
  w = x2 - x1,
6092
- l = x$$1 * x$$1 + y$$1 * y$$1;
6235
+ l = x * x + y * y;
6093
6236
 
6094
6237
  // Apply the Barnes-Hut approximation if possible.
6095
6238
  // Limit forces for very close nodes; randomize direction if coincident.
6096
6239
  if (w * w / theta2 < l) {
6097
6240
  if (l < distanceMax2) {
6098
- if (x$$1 === 0) x$$1 = jiggle(), l += x$$1 * x$$1;
6099
- if (y$$1 === 0) y$$1 = jiggle(), l += y$$1 * y$$1;
6241
+ if (x === 0) x = jiggle(), l += x * x;
6242
+ if (y === 0) y = jiggle(), l += y * y;
6100
6243
  if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
6101
- node.vx += x$$1 * quad.value * alpha / l;
6102
- node.vy += y$$1 * quad.value * alpha / l;
6244
+ node.vx += x * quad.value * alpha / l;
6245
+ node.vy += y * quad.value * alpha / l;
6103
6246
  }
6104
6247
  return true;
6105
6248
  }
@@ -6109,15 +6252,15 @@ var manyBody = function() {
6109
6252
 
6110
6253
  // Limit forces for very close nodes; randomize direction if coincident.
6111
6254
  if (quad.data !== node || quad.next) {
6112
- if (x$$1 === 0) x$$1 = jiggle(), l += x$$1 * x$$1;
6113
- if (y$$1 === 0) y$$1 = jiggle(), l += y$$1 * y$$1;
6255
+ if (x === 0) x = jiggle(), l += x * x;
6256
+ if (y === 0) y = jiggle(), l += y * y;
6114
6257
  if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
6115
6258
  }
6116
6259
 
6117
6260
  do if (quad.data !== node) {
6118
6261
  w = strengths[quad.data.index] * alpha / l;
6119
- node.vx += x$$1 * w;
6120
- node.vy += y$$1 * w;
6262
+ node.vx += x * w;
6263
+ node.vy += y * w;
6121
6264
  } while (quad = quad.next);
6122
6265
  }
6123
6266
 
@@ -6263,6 +6406,14 @@ var formatGroup = function(grouping, thousands) {
6263
6406
  };
6264
6407
  };
6265
6408
 
6409
+ var formatNumerals = function(numerals) {
6410
+ return function(value) {
6411
+ return value.replace(/[0-9]/g, function(i) {
6412
+ return numerals[+i];
6413
+ });
6414
+ };
6415
+ };
6416
+
6266
6417
  var formatDefault = function(x, p) {
6267
6418
  x = x.toPrecision(p);
6268
6419
 
@@ -6323,9 +6474,11 @@ var formatTypes = {
6323
6474
  // [[fill]align][sign][symbol][0][width][,][.precision][type]
6324
6475
  var re = /^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;
6325
6476
 
6326
- var formatSpecifier = function(specifier) {
6477
+ function formatSpecifier(specifier) {
6327
6478
  return new FormatSpecifier(specifier);
6328
- };
6479
+ }
6480
+
6481
+ formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
6329
6482
 
6330
6483
  function FormatSpecifier(specifier) {
6331
6484
  if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
@@ -6373,16 +6526,18 @@ FormatSpecifier.prototype.toString = function() {
6373
6526
  + this.type;
6374
6527
  };
6375
6528
 
6376
- var prefixes = ["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"];
6377
-
6378
- function identity$3(x) {
6529
+ var identity$3 = function(x) {
6379
6530
  return x;
6380
- }
6531
+ };
6532
+
6533
+ var prefixes = ["y","z","a","f","p","n","\xB5","m","","k","M","G","T","P","E","Z","Y"];
6381
6534
 
6382
6535
  var formatLocale = function(locale) {
6383
6536
  var group = locale.grouping && locale.thousands ? formatGroup(locale.grouping, locale.thousands) : identity$3,
6384
6537
  currency = locale.currency,
6385
- decimal = locale.decimal;
6538
+ decimal = locale.decimal,
6539
+ numerals = locale.numerals ? formatNumerals(locale.numerals) : identity$3,
6540
+ percent = locale.percent || "%";
6386
6541
 
6387
6542
  function newFormat(specifier) {
6388
6543
  specifier = formatSpecifier(specifier);
@@ -6400,7 +6555,7 @@ var formatLocale = function(locale) {
6400
6555
  // Compute the prefix and suffix.
6401
6556
  // For SI-prefix, the suffix is lazily computed.
6402
6557
  var prefix = symbol === "$" ? currency[0] : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
6403
- suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? "%" : "";
6558
+ suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? percent : "";
6404
6559
 
6405
6560
  // What format function should we use?
6406
6561
  // Is this an integer type?
@@ -6427,27 +6582,12 @@ var formatLocale = function(locale) {
6427
6582
  } else {
6428
6583
  value = +value;
6429
6584
 
6430
- // Convert negative to positive, and compute the prefix.
6431
- // Note that -0 is not less than 0, but 1 / -0 is!
6432
- var valueNegative = (value < 0 || 1 / value < 0) && (value *= -1, true);
6433
-
6434
6585
  // Perform the initial formatting.
6435
- value = formatType(value, precision);
6586
+ var valueNegative = value < 0;
6587
+ value = formatType(Math.abs(value), precision);
6436
6588
 
6437
- // If the original value was negative, it may be rounded to zero during
6438
- // formatting; treat this as (positive) zero.
6439
- if (valueNegative) {
6440
- i = -1, n = value.length;
6441
- valueNegative = false;
6442
- while (++i < n) {
6443
- if (c = value.charCodeAt(i), (48 < c && c < 58)
6444
- || (type === "x" && 96 < c && c < 103)
6445
- || (type === "X" && 64 < c && c < 71)) {
6446
- valueNegative = true;
6447
- break;
6448
- }
6449
- }
6450
- }
6589
+ // If a negative value rounds to zero during formatting, treat as positive.
6590
+ if (valueNegative && +value === 0) valueNegative = false;
6451
6591
 
6452
6592
  // Compute the prefix and suffix.
6453
6593
  valuePrefix = (valueNegative ? (sign === "(" ? sign : "-") : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
@@ -6479,11 +6619,13 @@ var formatLocale = function(locale) {
6479
6619
 
6480
6620
  // Reconstruct the final output based on the desired alignment.
6481
6621
  switch (align) {
6482
- case "<": return valuePrefix + value + valueSuffix + padding;
6483
- case "=": return valuePrefix + padding + value + valueSuffix;
6484
- case "^": return padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length);
6622
+ case "<": value = valuePrefix + value + valueSuffix + padding; break;
6623
+ case "=": value = valuePrefix + padding + value + valueSuffix; break;
6624
+ case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break;
6625
+ default: value = padding + valuePrefix + value + valueSuffix; break;
6485
6626
  }
6486
- return padding + valuePrefix + value + valueSuffix;
6627
+
6628
+ return numerals(value);
6487
6629
  }
6488
6630
 
6489
6631
  format.toString = function() {
@@ -6626,8 +6768,8 @@ function streamGeometry(geometry, stream) {
6626
6768
  }
6627
6769
 
6628
6770
  var streamObjectType = {
6629
- Feature: function(feature, stream) {
6630
- streamGeometry(feature.geometry, stream);
6771
+ Feature: function(object, stream) {
6772
+ streamGeometry(object.geometry, stream);
6631
6773
  },
6632
6774
  FeatureCollection: function(object, stream) {
6633
6775
  var features = object.features, i = -1, n = features.length;
@@ -6874,8 +7016,10 @@ function linePoint(lambda, phi) {
6874
7016
  }
6875
7017
  }
6876
7018
  } else {
6877
- boundsPoint(lambda, phi);
7019
+ ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]);
6878
7020
  }
7021
+ if (phi < phi0) phi0 = phi;
7022
+ if (phi > phi1) phi1 = phi;
6879
7023
  p0 = p, lambda2 = lambda;
6880
7024
  }
6881
7025
 
@@ -7074,9 +7218,8 @@ function centroidRingPoint(lambda, phi) {
7074
7218
  cy = z0 * x - x0 * z,
7075
7219
  cz = x0 * y - y0 * x,
7076
7220
  m = sqrt(cx * cx + cy * cy + cz * cz),
7077
- u = x0 * x + y0 * y + z0 * z,
7078
- v = m && -acos(u) / m, // area weight
7079
- w = atan2(m, u); // line weight
7221
+ w = asin(m), // line weight = angle
7222
+ v = m && -w / m; // area weight multiplier
7080
7223
  X2 += v * cx;
7081
7224
  Y2 += v * cy;
7082
7225
  Z2 += v * cz;
@@ -7643,6 +7786,71 @@ var extent$1 = function() {
7643
7786
  };
7644
7787
  };
7645
7788
 
7789
+ var sum$1 = adder();
7790
+
7791
+ var polygonContains = function(polygon, point) {
7792
+ var lambda = point[0],
7793
+ phi = point[1],
7794
+ normal = [sin$1(lambda), -cos$1(lambda), 0],
7795
+ angle = 0,
7796
+ winding = 0;
7797
+
7798
+ sum$1.reset();
7799
+
7800
+ for (var i = 0, n = polygon.length; i < n; ++i) {
7801
+ if (!(m = (ring = polygon[i]).length)) continue;
7802
+ var ring,
7803
+ m,
7804
+ point0 = ring[m - 1],
7805
+ lambda0 = point0[0],
7806
+ phi0 = point0[1] / 2 + quarterPi,
7807
+ sinPhi0 = sin$1(phi0),
7808
+ cosPhi0 = cos$1(phi0);
7809
+
7810
+ for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {
7811
+ var point1 = ring[j],
7812
+ lambda1 = point1[0],
7813
+ phi1 = point1[1] / 2 + quarterPi,
7814
+ sinPhi1 = sin$1(phi1),
7815
+ cosPhi1 = cos$1(phi1),
7816
+ delta = lambda1 - lambda0,
7817
+ sign$$1 = delta >= 0 ? 1 : -1,
7818
+ absDelta = sign$$1 * delta,
7819
+ antimeridian = absDelta > pi$3,
7820
+ k = sinPhi0 * sinPhi1;
7821
+
7822
+ sum$1.add(atan2(k * sign$$1 * sin$1(absDelta), cosPhi0 * cosPhi1 + k * cos$1(absDelta)));
7823
+ angle += antimeridian ? delta + sign$$1 * tau$3 : delta;
7824
+
7825
+ // Are the longitudes either side of the point’s meridian (lambda),
7826
+ // and are the latitudes smaller than the parallel (phi)?
7827
+ if (antimeridian ^ lambda0 >= lambda ^ lambda1 >= lambda) {
7828
+ var arc = cartesianCross(cartesian(point0), cartesian(point1));
7829
+ cartesianNormalizeInPlace(arc);
7830
+ var intersection = cartesianCross(normal, arc);
7831
+ cartesianNormalizeInPlace(intersection);
7832
+ var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection[2]);
7833
+ if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
7834
+ winding += antimeridian ^ delta >= 0 ? 1 : -1;
7835
+ }
7836
+ }
7837
+ }
7838
+ }
7839
+
7840
+ // First, determine whether the South pole is inside or outside:
7841
+ //
7842
+ // It is inside if:
7843
+ // * the polygon winds around it in a clockwise direction.
7844
+ // * the polygon does not (cumulatively) wind around it, but has a negative
7845
+ // (counter-clockwise) area.
7846
+ //
7847
+ // Second, count the (signed) number of times a segment crosses a lambda
7848
+ // from the point to the South pole. If it is zero, then the point is the
7849
+ // same side as the South pole.
7850
+
7851
+ return (angle < -epsilon$2 || angle < epsilon$2 && sum$1 < -epsilon$2) ^ (winding & 1);
7852
+ };
7853
+
7646
7854
  var lengthSum = adder();
7647
7855
  var lambda0$2;
7648
7856
  var sinPhi0$1;
@@ -7701,6 +7909,87 @@ var distance = function(a, b) {
7701
7909
  return length$1(object$1);
7702
7910
  };
7703
7911
 
7912
+ var containsObjectType = {
7913
+ Feature: function(object, point) {
7914
+ return containsGeometry(object.geometry, point);
7915
+ },
7916
+ FeatureCollection: function(object, point) {
7917
+ var features = object.features, i = -1, n = features.length;
7918
+ while (++i < n) if (containsGeometry(features[i].geometry, point)) return true;
7919
+ return false;
7920
+ }
7921
+ };
7922
+
7923
+ var containsGeometryType = {
7924
+ Sphere: function() {
7925
+ return true;
7926
+ },
7927
+ Point: function(object, point) {
7928
+ return containsPoint(object.coordinates, point);
7929
+ },
7930
+ MultiPoint: function(object, point) {
7931
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
7932
+ while (++i < n) if (containsPoint(coordinates[i], point)) return true;
7933
+ return false;
7934
+ },
7935
+ LineString: function(object, point) {
7936
+ return containsLine(object.coordinates, point);
7937
+ },
7938
+ MultiLineString: function(object, point) {
7939
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
7940
+ while (++i < n) if (containsLine(coordinates[i], point)) return true;
7941
+ return false;
7942
+ },
7943
+ Polygon: function(object, point) {
7944
+ return containsPolygon(object.coordinates, point);
7945
+ },
7946
+ MultiPolygon: function(object, point) {
7947
+ var coordinates = object.coordinates, i = -1, n = coordinates.length;
7948
+ while (++i < n) if (containsPolygon(coordinates[i], point)) return true;
7949
+ return false;
7950
+ },
7951
+ GeometryCollection: function(object, point) {
7952
+ var geometries = object.geometries, i = -1, n = geometries.length;
7953
+ while (++i < n) if (containsGeometry(geometries[i], point)) return true;
7954
+ return false;
7955
+ }
7956
+ };
7957
+
7958
+ function containsGeometry(geometry, point) {
7959
+ return geometry && containsGeometryType.hasOwnProperty(geometry.type)
7960
+ ? containsGeometryType[geometry.type](geometry, point)
7961
+ : false;
7962
+ }
7963
+
7964
+ function containsPoint(coordinates, point) {
7965
+ return distance(coordinates, point) === 0;
7966
+ }
7967
+
7968
+ function containsLine(coordinates, point) {
7969
+ var ab = distance(coordinates[0], coordinates[1]),
7970
+ ao = distance(coordinates[0], point),
7971
+ ob = distance(point, coordinates[1]);
7972
+ return ao + ob <= ab + epsilon$2;
7973
+ }
7974
+
7975
+ function containsPolygon(coordinates, point) {
7976
+ return !!polygonContains(coordinates.map(ringRadians), pointRadians(point));
7977
+ }
7978
+
7979
+ function ringRadians(ring) {
7980
+ return ring = ring.map(pointRadians), ring.pop(), ring;
7981
+ }
7982
+
7983
+ function pointRadians(point) {
7984
+ return [point[0] * radians, point[1] * radians];
7985
+ }
7986
+
7987
+ var contains = function(object, point) {
7988
+ return (object && containsObjectType.hasOwnProperty(object.type)
7989
+ ? containsObjectType[object.type]
7990
+ : containsGeometry)(object, point);
7991
+ };
7992
+
7704
7993
  function graticuleX(y0, y1, dy) {
7705
7994
  var y = sequence(y0, y1 - epsilon$2, dy).concat(y1);
7706
7995
  return function(x) { return y.map(function(y) { return [x, y]; }); };
@@ -8053,16 +8342,58 @@ PathContext.prototype = {
8053
8342
  result: noop$1
8054
8343
  };
8055
8344
 
8056
- function PathString() {
8057
- this._string = [];
8058
- }
8345
+ var lengthSum$1 = adder();
8346
+ var lengthRing;
8347
+ var x00$2;
8348
+ var y00$2;
8349
+ var x0$4;
8350
+ var y0$4;
8059
8351
 
8060
- PathString.prototype = {
8061
- _circle: circle$1(4.5),
8062
- pointRadius: function(_) {
8063
- return this._circle = circle$1(_), this;
8352
+ var lengthStream$1 = {
8353
+ point: noop$1,
8354
+ lineStart: function() {
8355
+ lengthStream$1.point = lengthPointFirst$1;
8064
8356
  },
8065
- polygonStart: function() {
8357
+ lineEnd: function() {
8358
+ if (lengthRing) lengthPoint$1(x00$2, y00$2);
8359
+ lengthStream$1.point = noop$1;
8360
+ },
8361
+ polygonStart: function() {
8362
+ lengthRing = true;
8363
+ },
8364
+ polygonEnd: function() {
8365
+ lengthRing = null;
8366
+ },
8367
+ result: function() {
8368
+ var length = +lengthSum$1;
8369
+ lengthSum$1.reset();
8370
+ return length;
8371
+ }
8372
+ };
8373
+
8374
+ function lengthPointFirst$1(x, y) {
8375
+ lengthStream$1.point = lengthPoint$1;
8376
+ x00$2 = x0$4 = x, y00$2 = y0$4 = y;
8377
+ }
8378
+
8379
+ function lengthPoint$1(x, y) {
8380
+ x0$4 -= x, y0$4 -= y;
8381
+ lengthSum$1.add(sqrt(x0$4 * x0$4 + y0$4 * y0$4));
8382
+ x0$4 = x, y0$4 = y;
8383
+ }
8384
+
8385
+ function PathString() {
8386
+ this._string = [];
8387
+ }
8388
+
8389
+ PathString.prototype = {
8390
+ _radius: 4.5,
8391
+ _circle: circle$1(4.5),
8392
+ pointRadius: function(_) {
8393
+ if ((_ = +_) !== this._radius) this._radius = _, this._circle = null;
8394
+ return this;
8395
+ },
8396
+ polygonStart: function() {
8066
8397
  this._line = 0;
8067
8398
  },
8068
8399
  polygonEnd: function() {
@@ -8087,6 +8418,7 @@ PathString.prototype = {
8087
8418
  break;
8088
8419
  }
8089
8420
  default: {
8421
+ if (this._circle == null) this._circle = circle$1(this._radius);
8090
8422
  this._string.push("M", x, ",", y, this._circle);
8091
8423
  break;
8092
8424
  }
@@ -8097,6 +8429,8 @@ PathString.prototype = {
8097
8429
  var result = this._string.join("");
8098
8430
  this._string = [];
8099
8431
  return result;
8432
+ } else {
8433
+ return null;
8100
8434
  }
8101
8435
  }
8102
8436
  };
@@ -8126,6 +8460,11 @@ var index$1 = function(projection, context) {
8126
8460
  return areaStream$1.result();
8127
8461
  };
8128
8462
 
8463
+ path.measure = function(object) {
8464
+ geoStream(object, projectionStream(lengthStream$1));
8465
+ return lengthStream$1.result();
8466
+ };
8467
+
8129
8468
  path.bounds = function(object) {
8130
8469
  geoStream(object, projectionStream(boundsStream$1));
8131
8470
  return boundsStream$1.result();
@@ -8156,71 +8495,6 @@ var index$1 = function(projection, context) {
8156
8495
  return path.projection(projection).context(context);
8157
8496
  };
8158
8497
 
8159
- var sum$1 = adder();
8160
-
8161
- var polygonContains = function(polygon, point) {
8162
- var lambda = point[0],
8163
- phi = point[1],
8164
- normal = [sin$1(lambda), -cos$1(lambda), 0],
8165
- angle = 0,
8166
- winding = 0;
8167
-
8168
- sum$1.reset();
8169
-
8170
- for (var i = 0, n = polygon.length; i < n; ++i) {
8171
- if (!(m = (ring = polygon[i]).length)) continue;
8172
- var ring,
8173
- m,
8174
- point0 = ring[m - 1],
8175
- lambda0 = point0[0],
8176
- phi0 = point0[1] / 2 + quarterPi,
8177
- sinPhi0 = sin$1(phi0),
8178
- cosPhi0 = cos$1(phi0);
8179
-
8180
- for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {
8181
- var point1 = ring[j],
8182
- lambda1 = point1[0],
8183
- phi1 = point1[1] / 2 + quarterPi,
8184
- sinPhi1 = sin$1(phi1),
8185
- cosPhi1 = cos$1(phi1),
8186
- delta = lambda1 - lambda0,
8187
- sign$$1 = delta >= 0 ? 1 : -1,
8188
- absDelta = sign$$1 * delta,
8189
- antimeridian = absDelta > pi$3,
8190
- k = sinPhi0 * sinPhi1;
8191
-
8192
- sum$1.add(atan2(k * sign$$1 * sin$1(absDelta), cosPhi0 * cosPhi1 + k * cos$1(absDelta)));
8193
- angle += antimeridian ? delta + sign$$1 * tau$3 : delta;
8194
-
8195
- // Are the longitudes either side of the point’s meridian (lambda),
8196
- // and are the latitudes smaller than the parallel (phi)?
8197
- if (antimeridian ^ lambda0 >= lambda ^ lambda1 >= lambda) {
8198
- var arc = cartesianCross(cartesian(point0), cartesian(point1));
8199
- cartesianNormalizeInPlace(arc);
8200
- var intersection = cartesianCross(normal, arc);
8201
- cartesianNormalizeInPlace(intersection);
8202
- var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection[2]);
8203
- if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
8204
- winding += antimeridian ^ delta >= 0 ? 1 : -1;
8205
- }
8206
- }
8207
- }
8208
- }
8209
-
8210
- // First, determine whether the South pole is inside or outside:
8211
- //
8212
- // It is inside if:
8213
- // * the polygon winds around it in a clockwise direction.
8214
- // * the polygon does not (cumulatively) wind around it, but has a negative
8215
- // (counter-clockwise) area.
8216
- //
8217
- // Second, count the (signed) number of times a segment crosses a lambda
8218
- // from the point to the South pole. If it is zero, then the point is the
8219
- // same side as the South pole.
8220
-
8221
- return (angle < -epsilon$2 || angle < epsilon$2 && sum$1 < -epsilon$2) ^ (winding & 1);
8222
- };
8223
-
8224
8498
  var clip = function(pointVisible, clipLine, interpolate, start) {
8225
8499
  return function(rotate, sink) {
8226
8500
  var line = clipLine(sink),
@@ -8481,7 +8755,7 @@ var clipCircle = function(radius, delta) {
8481
8755
  // TODO ignore if not clipping polygons.
8482
8756
  if (v !== v0) {
8483
8757
  point2 = intersect(point0, point1);
8484
- if (pointEqual(point0, point2) || pointEqual(point1, point2)) {
8758
+ if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2)) {
8485
8759
  point1[0] += epsilon$2;
8486
8760
  point1[1] += epsilon$2;
8487
8761
  v = visible(point1[0], point1[1]);
@@ -9098,31 +9372,38 @@ var mercator = function() {
9098
9372
 
9099
9373
  function mercatorProjection(project) {
9100
9374
  var m = projection(project),
9375
+ center = m.center,
9101
9376
  scale = m.scale,
9102
9377
  translate = m.translate,
9103
9378
  clipExtent = m.clipExtent,
9104
- clipAuto;
9379
+ x0 = null, y0, x1, y1; // clip extent
9105
9380
 
9106
9381
  m.scale = function(_) {
9107
- return arguments.length ? (scale(_), clipAuto && m.clipExtent(null), m) : scale();
9382
+ return arguments.length ? (scale(_), reclip()) : scale();
9108
9383
  };
9109
9384
 
9110
9385
  m.translate = function(_) {
9111
- return arguments.length ? (translate(_), clipAuto && m.clipExtent(null), m) : translate();
9386
+ return arguments.length ? (translate(_), reclip()) : translate();
9387
+ };
9388
+
9389
+ m.center = function(_) {
9390
+ return arguments.length ? (center(_), reclip()) : center();
9112
9391
  };
9113
9392
 
9114
9393
  m.clipExtent = function(_) {
9115
- if (!arguments.length) return clipAuto ? null : clipExtent();
9116
- if (clipAuto = _ == null) {
9117
- var k = pi$3 * scale(),
9118
- t = translate();
9119
- _ = [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]];
9120
- }
9121
- clipExtent(_);
9122
- return m;
9394
+ return arguments.length ? ((_ == null ? x0 = y0 = x1 = y1 = null : (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1])), reclip()) : x0 == null ? null : [[x0, y0], [x1, y1]];
9123
9395
  };
9124
9396
 
9125
- return m.clipExtent(null);
9397
+ function reclip() {
9398
+ var k = pi$3 * scale(),
9399
+ t = m(rotation(m.rotate()).invert([0, 0]));
9400
+ return clipExtent(x0 == null
9401
+ ? [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]] : project === mercatorRaw
9402
+ ? [[Math.max(t[0] - k, x0), y0], [Math.min(t[0] + k, x1), y1]]
9403
+ : [[x0, Math.max(t[1] - k, y0)], [x1, Math.min(t[1] + k, y1)]]);
9404
+ }
9405
+
9406
+ return reclip();
9126
9407
  }
9127
9408
 
9128
9409
  function tany(y) {
@@ -9216,7 +9497,7 @@ function scaleTranslate(kx, ky, tx, ty) {
9216
9497
  }
9217
9498
 
9218
9499
  var identity$5 = function() {
9219
- var k = 1, tx = 0, ty = 0, sx = 1, sy = 1, transform = identity$4, // scale, translate and reflect
9500
+ var k = 1, tx = 0, ty = 0, sx = 1, sy = 1, transform$$1 = identity$4, // scale, translate and reflect
9220
9501
  x0 = null, y0, x1, y1, clip = identity$4, // clip extent
9221
9502
  cache,
9222
9503
  cacheStream,
@@ -9229,22 +9510,22 @@ var identity$5 = function() {
9229
9510
 
9230
9511
  return projection = {
9231
9512
  stream: function(stream) {
9232
- return cache && cacheStream === stream ? cache : cache = transform(clip(cacheStream = stream));
9513
+ return cache && cacheStream === stream ? cache : cache = transform$$1(clip(cacheStream = stream));
9233
9514
  },
9234
9515
  clipExtent: function(_) {
9235
9516
  return arguments.length ? (clip = _ == null ? (x0 = y0 = x1 = y1 = null, identity$4) : clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
9236
9517
  },
9237
9518
  scale: function(_) {
9238
- return arguments.length ? (transform = scaleTranslate((k = +_) * sx, k * sy, tx, ty), reset()) : k;
9519
+ return arguments.length ? (transform$$1 = scaleTranslate((k = +_) * sx, k * sy, tx, ty), reset()) : k;
9239
9520
  },
9240
9521
  translate: function(_) {
9241
- return arguments.length ? (transform = scaleTranslate(k * sx, k * sy, tx = +_[0], ty = +_[1]), reset()) : [tx, ty];
9522
+ return arguments.length ? (transform$$1 = scaleTranslate(k * sx, k * sy, tx = +_[0], ty = +_[1]), reset()) : [tx, ty];
9242
9523
  },
9243
9524
  reflectX: function(_) {
9244
- return arguments.length ? (transform = scaleTranslate(k * (sx = _ ? -1 : 1), k * sy, tx, ty), reset()) : sx < 0;
9525
+ return arguments.length ? (transform$$1 = scaleTranslate(k * (sx = _ ? -1 : 1), k * sy, tx, ty), reset()) : sx < 0;
9245
9526
  },
9246
9527
  reflectY: function(_) {
9247
- return arguments.length ? (transform = scaleTranslate(k * sx, k * (sy = _ ? -1 : 1), tx, ty), reset()) : sy < 0;
9528
+ return arguments.length ? (transform$$1 = scaleTranslate(k * sx, k * (sy = _ ? -1 : 1), tx, ty), reset()) : sy < 0;
9248
9529
  },
9249
9530
  fitExtent: function(extent, object) {
9250
9531
  return fitExtent(projection, extent, object);
@@ -9392,6 +9673,19 @@ var cluster = function() {
9392
9673
  return cluster;
9393
9674
  };
9394
9675
 
9676
+ function count(node) {
9677
+ var sum = 0,
9678
+ children = node.children,
9679
+ i = children && children.length;
9680
+ if (!i) sum = 1;
9681
+ else while (--i >= 0) sum += children[i].value;
9682
+ node.value = sum;
9683
+ }
9684
+
9685
+ var node_count = function() {
9686
+ return this.eachAfter(count);
9687
+ };
9688
+
9395
9689
  var node_each = function(callback) {
9396
9690
  var node = this, current, next = [node], children, i, n;
9397
9691
  do {
@@ -9570,6 +9864,7 @@ function Node(data) {
9570
9864
 
9571
9865
  Node.prototype = hierarchy.prototype = {
9572
9866
  constructor: Node,
9867
+ count: node_count,
9573
9868
  each: node_each,
9574
9869
  eachAfter: node_eachAfter,
9575
9870
  eachBefore: node_eachBefore,
@@ -9583,83 +9878,92 @@ Node.prototype = hierarchy.prototype = {
9583
9878
  copy: node_copy
9584
9879
  };
9585
9880
 
9586
- function Node$2(value) {
9587
- this._ = value;
9588
- this.next = null;
9589
- }
9881
+ var slice$3 = Array.prototype.slice;
9590
9882
 
9591
- var shuffle$1 = function(array) {
9592
- var i,
9593
- n = (array = array.slice()).length,
9594
- head = null,
9595
- node = head;
9883
+ function shuffle$1(array) {
9884
+ var m = array.length,
9885
+ t,
9886
+ i;
9596
9887
 
9597
- while (n) {
9598
- var next = new Node$2(array[n - 1]);
9599
- if (node) node = node.next = next;
9600
- else node = head = next;
9601
- array[i] = array[--n];
9888
+ while (m) {
9889
+ i = Math.random() * m-- | 0;
9890
+ t = array[m];
9891
+ array[m] = array[i];
9892
+ array[i] = t;
9602
9893
  }
9603
9894
 
9604
- return {
9605
- head: head,
9606
- tail: node
9607
- };
9608
- };
9895
+ return array;
9896
+ }
9609
9897
 
9610
9898
  var enclose = function(circles) {
9611
- return encloseN(shuffle$1(circles), []);
9899
+ var i = 0, n = (circles = shuffle$1(slice$3.call(circles))).length, B = [], p, e;
9900
+
9901
+ while (i < n) {
9902
+ p = circles[i];
9903
+ if (e && enclosesWeak(e, p)) ++i;
9904
+ else e = encloseBasis(B = extendBasis(B, p)), i = 0;
9905
+ }
9906
+
9907
+ return e;
9612
9908
  };
9613
9909
 
9614
- function encloses(a, b) {
9615
- var dx = b.x - a.x,
9616
- dy = b.y - a.y,
9617
- dr = a.r - b.r;
9618
- return dr * dr + 1e-6 > dx * dx + dy * dy;
9619
- }
9910
+ function extendBasis(B, p) {
9911
+ var i, j;
9620
9912
 
9621
- // Returns the smallest circle that contains circles L and intersects circles B.
9622
- function encloseN(L, B) {
9623
- var circle,
9624
- l0 = null,
9625
- l1 = L.head,
9626
- l2,
9627
- p1;
9913
+ if (enclosesWeakAll(p, B)) return [p];
9628
9914
 
9629
- switch (B.length) {
9630
- case 1: circle = enclose1(B[0]); break;
9631
- case 2: circle = enclose2(B[0], B[1]); break;
9632
- case 3: circle = enclose3(B[0], B[1], B[2]); break;
9915
+ // If we get here then B must have at least one element.
9916
+ for (i = 0; i < B.length; ++i) {
9917
+ if (enclosesNot(p, B[i])
9918
+ && enclosesWeakAll(encloseBasis2(B[i], p), B)) {
9919
+ return [B[i], p];
9920
+ }
9633
9921
  }
9634
9922
 
9635
- while (l1) {
9636
- p1 = l1._, l2 = l1.next;
9637
- if (!circle || !encloses(circle, p1)) {
9923
+ // If we get here then B must have at least two elements.
9924
+ for (i = 0; i < B.length - 1; ++i) {
9925
+ for (j = i + 1; j < B.length; ++j) {
9926
+ if (enclosesNot(encloseBasis2(B[i], B[j]), p)
9927
+ && enclosesNot(encloseBasis2(B[i], p), B[j])
9928
+ && enclosesNot(encloseBasis2(B[j], p), B[i])
9929
+ && enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
9930
+ return [B[i], B[j], p];
9931
+ }
9932
+ }
9933
+ }
9638
9934
 
9639
- // Temporarily truncate L before l1.
9640
- if (l0) L.tail = l0, l0.next = null;
9641
- else L.head = L.tail = null;
9935
+ // If we get here then something is very wrong.
9936
+ throw new Error;
9937
+ }
9642
9938
 
9643
- B.push(p1);
9644
- circle = encloseN(L, B); // Note: reorders L!
9645
- B.pop();
9939
+ function enclosesNot(a, b) {
9940
+ var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
9941
+ return dr < 0 || dr * dr < dx * dx + dy * dy;
9942
+ }
9646
9943
 
9647
- // Move l1 to the front of L and reconnect the truncated list L.
9648
- if (L.head) l1.next = L.head, L.head = l1;
9649
- else l1.next = null, L.head = L.tail = l1;
9650
- l0 = L.tail, l0.next = l2;
9944
+ function enclosesWeak(a, b) {
9945
+ var dr = a.r - b.r + 1e-6, dx = b.x - a.x, dy = b.y - a.y;
9946
+ return dr > 0 && dr * dr > dx * dx + dy * dy;
9947
+ }
9651
9948
 
9652
- } else {
9653
- l0 = l1;
9949
+ function enclosesWeakAll(a, B) {
9950
+ for (var i = 0; i < B.length; ++i) {
9951
+ if (!enclosesWeak(a, B[i])) {
9952
+ return false;
9654
9953
  }
9655
- l1 = l2;
9656
9954
  }
9955
+ return true;
9956
+ }
9657
9957
 
9658
- L.tail = l0;
9659
- return circle;
9958
+ function encloseBasis(B) {
9959
+ switch (B.length) {
9960
+ case 1: return encloseBasis1(B[0]);
9961
+ case 2: return encloseBasis2(B[0], B[1]);
9962
+ case 3: return encloseBasis3(B[0], B[1], B[2]);
9963
+ }
9660
9964
  }
9661
9965
 
9662
- function enclose1(a) {
9966
+ function encloseBasis1(a) {
9663
9967
  return {
9664
9968
  x: a.x,
9665
9969
  y: a.y,
@@ -9667,7 +9971,7 @@ function enclose1(a) {
9667
9971
  };
9668
9972
  }
9669
9973
 
9670
- function enclose2(a, b) {
9974
+ function encloseBasis2(a, b) {
9671
9975
  var x1 = a.x, y1 = a.y, r1 = a.r,
9672
9976
  x2 = b.x, y2 = b.y, r2 = b.r,
9673
9977
  x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1,
@@ -9679,30 +9983,31 @@ function enclose2(a, b) {
9679
9983
  };
9680
9984
  }
9681
9985
 
9682
- function enclose3(a, b, c) {
9986
+ function encloseBasis3(a, b, c) {
9683
9987
  var x1 = a.x, y1 = a.y, r1 = a.r,
9684
9988
  x2 = b.x, y2 = b.y, r2 = b.r,
9685
9989
  x3 = c.x, y3 = c.y, r3 = c.r,
9686
- a2 = 2 * (x1 - x2),
9687
- b2 = 2 * (y1 - y2),
9688
- c2 = 2 * (r2 - r1),
9689
- d2 = x1 * x1 + y1 * y1 - r1 * r1 - x2 * x2 - y2 * y2 + r2 * r2,
9690
- a3 = 2 * (x1 - x3),
9691
- b3 = 2 * (y1 - y3),
9692
- c3 = 2 * (r3 - r1),
9693
- d3 = x1 * x1 + y1 * y1 - r1 * r1 - x3 * x3 - y3 * y3 + r3 * r3,
9990
+ a2 = x1 - x2,
9991
+ a3 = x1 - x3,
9992
+ b2 = y1 - y2,
9993
+ b3 = y1 - y3,
9994
+ c2 = r2 - r1,
9995
+ c3 = r3 - r1,
9996
+ d1 = x1 * x1 + y1 * y1 - r1 * r1,
9997
+ d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2,
9998
+ d3 = d1 - x3 * x3 - y3 * y3 + r3 * r3,
9694
9999
  ab = a3 * b2 - a2 * b3,
9695
- xa = (b2 * d3 - b3 * d2) / ab - x1,
10000
+ xa = (b2 * d3 - b3 * d2) / (ab * 2) - x1,
9696
10001
  xb = (b3 * c2 - b2 * c3) / ab,
9697
- ya = (a3 * d2 - a2 * d3) / ab - y1,
10002
+ ya = (a3 * d2 - a2 * d3) / (ab * 2) - y1,
9698
10003
  yb = (a2 * c3 - a3 * c2) / ab,
9699
10004
  A = xb * xb + yb * yb - 1,
9700
- B = 2 * (xa * xb + ya * yb + r1),
10005
+ B = 2 * (r1 + xa * xb + ya * yb),
9701
10006
  C = xa * xa + ya * ya - r1 * r1,
9702
- r = (-B - Math.sqrt(B * B - 4 * A * C)) / (2 * A);
10007
+ r = -(A ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B);
9703
10008
  return {
9704
- x: xa + xb * r + x1,
9705
- y: ya + yb * r + y1,
10009
+ x: x1 + xa + xb * r,
10010
+ y: y1 + ya + yb * r,
9706
10011
  r: r
9707
10012
  };
9708
10013
  }
@@ -9730,12 +10035,15 @@ function intersects(a, b) {
9730
10035
  var dx = b.x - a.x,
9731
10036
  dy = b.y - a.y,
9732
10037
  dr = a.r + b.r;
9733
- return dr * dr > dx * dx + dy * dy;
10038
+ return dr * dr - 1e-6 > dx * dx + dy * dy;
9734
10039
  }
9735
10040
 
9736
- function distance2(circle, x, y) {
9737
- var dx = circle.x - x,
9738
- dy = circle.y - y;
10041
+ function score(node) {
10042
+ var a = node._,
10043
+ b = node.next._,
10044
+ ab = a.r + b.r,
10045
+ dx = (a.x * b.r + b.x * a.r) / ab,
10046
+ dy = (a.y * b.r + b.y * a.r) / ab;
9739
10047
  return dx * dx + dy * dy;
9740
10048
  }
9741
10049
 
@@ -9748,7 +10056,7 @@ function Node$1(circle) {
9748
10056
  function packEnclose(circles) {
9749
10057
  if (!(n = circles.length)) return 0;
9750
10058
 
9751
- var a, b, c, n;
10059
+ var a, b, c, n, aa, ca, i, j, k, sj, sk;
9752
10060
 
9753
10061
  // Place the first circle.
9754
10062
  a = circles[0], a.x = 0, a.y = 0;
@@ -9761,15 +10069,6 @@ function packEnclose(circles) {
9761
10069
  // Place the third circle.
9762
10070
  place(b, a, c = circles[2]);
9763
10071
 
9764
- // Initialize the weighted centroid.
9765
- var aa = a.r * a.r,
9766
- ba = b.r * b.r,
9767
- ca = c.r * c.r,
9768
- oa = aa + ba + ca,
9769
- ox = aa * a.x + ba * b.x + ca * c.x,
9770
- oy = aa * a.y + ba * b.y + ca * c.y,
9771
- cx, cy, i, j, k, sj, sk;
9772
-
9773
10072
  // Initialize the front-chain using the first three circles a, b and c.
9774
10073
  a = new Node$1(a), b = new Node$1(b), c = new Node$1(c);
9775
10074
  a.next = c.previous = b;
@@ -9780,48 +10079,33 @@ function packEnclose(circles) {
9780
10079
  pack: for (i = 3; i < n; ++i) {
9781
10080
  place(a._, b._, c = circles[i]), c = new Node$1(c);
9782
10081
 
9783
- // If there are only three elements in the front-chain…
9784
- if ((k = a.previous) === (j = b.next)) {
9785
- // If the new circle intersects the third circle,
9786
- // rotate the front chain to try the next position.
9787
- if (intersects(j._, c._)) {
9788
- a = b, b = j, --i;
9789
- continue pack;
9790
- }
9791
- }
9792
-
9793
10082
  // Find the closest intersecting circle on the front-chain, if any.
9794
- else {
9795
- sj = j._.r, sk = k._.r;
9796
- do {
9797
- if (sj <= sk) {
9798
- if (intersects(j._, c._)) {
9799
- b = j, a.next = b, b.previous = a, --i;
9800
- continue pack;
9801
- }
9802
- j = j.next, sj += j._.r;
9803
- } else {
9804
- if (intersects(k._, c._)) {
9805
- a = k, a.next = b, b.previous = a, --i;
9806
- continue pack;
9807
- }
9808
- k = k.previous, sk += k._.r;
10083
+ // “Closeness” is determined by linear distance along the front-chain.
10084
+ // “Ahead” or “behind” is likewise determined by linear distance.
10085
+ j = b.next, k = a.previous, sj = b._.r, sk = a._.r;
10086
+ do {
10087
+ if (sj <= sk) {
10088
+ if (intersects(j._, c._)) {
10089
+ b = j, a.next = b, b.previous = a, --i;
10090
+ continue pack;
9809
10091
  }
9810
- } while (j !== k.next);
9811
- }
10092
+ sj += j._.r, j = j.next;
10093
+ } else {
10094
+ if (intersects(k._, c._)) {
10095
+ a = k, a.next = b, b.previous = a, --i;
10096
+ continue pack;
10097
+ }
10098
+ sk += k._.r, k = k.previous;
10099
+ }
10100
+ } while (j !== k.next);
9812
10101
 
9813
10102
  // Success! Insert the new circle c between a and b.
9814
10103
  c.previous = a, c.next = b, a.next = b.previous = b = c;
9815
10104
 
9816
- // Update the weighted centroid.
9817
- oa += ca = c._.r * c._.r;
9818
- ox += ca * c._.x;
9819
- oy += ca * c._.y;
9820
-
9821
- // Compute the new closest circle a to centroid.
9822
- aa = distance2(a._, cx = ox / oa, cy = oy / oa);
10105
+ // Compute the new closest circle pair to the centroid.
10106
+ aa = score(a);
9823
10107
  while ((c = c.next) !== b) {
9824
- if ((ca = distance2(c._, cx, cy)) < aa) {
10108
+ if ((ca = score(c)) < aa) {
9825
10109
  a = c, aa = ca;
9826
10110
  }
9827
10111
  }
@@ -10378,7 +10662,7 @@ function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
10378
10662
  return rows;
10379
10663
  }
10380
10664
 
10381
- var squarify = ((function custom(ratio) {
10665
+ var squarify = (function custom(ratio) {
10382
10666
 
10383
10667
  function squarify(parent, x0, y0, x1, y1) {
10384
10668
  squarifyRatio(ratio, parent, x0, y0, x1, y1);
@@ -10389,7 +10673,7 @@ var squarify = ((function custom(ratio) {
10389
10673
  };
10390
10674
 
10391
10675
  return squarify;
10392
- }))(phi);
10676
+ })(phi);
10393
10677
 
10394
10678
  var index$3 = function() {
10395
10679
  var tile = squarify,
@@ -10511,17 +10795,19 @@ var binary = function(parent, x0, y0, x1, y1) {
10511
10795
  else hi = mid;
10512
10796
  }
10513
10797
 
10798
+ if ((valueTarget - sums[k - 1]) < (sums[k] - valueTarget) && i + 1 < k) --k;
10799
+
10514
10800
  var valueLeft = sums[k] - valueOffset,
10515
10801
  valueRight = value - valueLeft;
10516
10802
 
10517
- if ((y1 - y0) > (x1 - x0)) {
10518
- var yk = (y0 * valueRight + y1 * valueLeft) / value;
10519
- partition(i, k, valueLeft, x0, y0, x1, yk);
10520
- partition(k, j, valueRight, x0, yk, x1, y1);
10521
- } else {
10803
+ if ((x1 - x0) > (y1 - y0)) {
10522
10804
  var xk = (x0 * valueRight + x1 * valueLeft) / value;
10523
10805
  partition(i, k, valueLeft, x0, y0, xk, y1);
10524
10806
  partition(k, j, valueRight, xk, y0, x1, y1);
10807
+ } else {
10808
+ var yk = (y0 * valueRight + y1 * valueLeft) / value;
10809
+ partition(i, k, valueLeft, x0, y0, x1, yk);
10810
+ partition(k, j, valueRight, x0, yk, x1, y1);
10525
10811
  }
10526
10812
  }
10527
10813
  };
@@ -10530,7 +10816,7 @@ var sliceDice = function(parent, x0, y0, x1, y1) {
10530
10816
  (parent.depth & 1 ? treemapSlice : treemapDice)(parent, x0, y0, x1, y1);
10531
10817
  };
10532
10818
 
10533
- var resquarify = ((function custom(ratio) {
10819
+ var resquarify = (function custom(ratio) {
10534
10820
 
10535
10821
  function resquarify(parent, x0, y0, x1, y1) {
10536
10822
  if ((rows = parent._squarify) && (rows.ratio === ratio)) {
@@ -10561,7 +10847,7 @@ var resquarify = ((function custom(ratio) {
10561
10847
  };
10562
10848
 
10563
10849
  return resquarify;
10564
- }))(phi);
10850
+ })(phi);
10565
10851
 
10566
10852
  var area$1 = function(polygon) {
10567
10853
  var i = -1,
@@ -10604,7 +10890,7 @@ var centroid$1 = function(polygon) {
10604
10890
  // the 3D cross product in a quadrant I Cartesian coordinate system (+x is
10605
10891
  // right, +y is up). Returns a positive value if ABC is counter-clockwise,
10606
10892
  // negative if clockwise, and zero if the points are collinear.
10607
- var cross = function(a, b, c) {
10893
+ var cross$1 = function(a, b, c) {
10608
10894
  return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
10609
10895
  };
10610
10896
 
@@ -10621,7 +10907,7 @@ function computeUpperHullIndexes(points) {
10621
10907
  size = 2;
10622
10908
 
10623
10909
  for (var i = 2; i < n; ++i) {
10624
- while (size > 1 && cross(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size;
10910
+ while (size > 1 && cross$1(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size;
10625
10911
  indexes[size++] = i;
10626
10912
  }
10627
10913
 
@@ -10656,7 +10942,7 @@ var hull = function(points) {
10656
10942
  return hull;
10657
10943
  };
10658
10944
 
10659
- var contains = function(polygon, point) {
10945
+ var contains$1 = function(polygon, point) {
10660
10946
  var n = polygon.length,
10661
10947
  p = polygon[n - 1],
10662
10948
  x = point[0], y = point[1],
@@ -10697,12 +10983,11 @@ var length$2 = function(polygon) {
10697
10983
  return perimeter;
10698
10984
  };
10699
10985
 
10700
- var slice$3 = [].slice;
10986
+ var slice$4 = [].slice;
10701
10987
 
10702
10988
  var noabort = {};
10703
10989
 
10704
10990
  function Queue(size) {
10705
- if (!(size >= 1)) throw new Error;
10706
10991
  this._size = size;
10707
10992
  this._call =
10708
10993
  this._error = null;
@@ -10717,9 +11002,10 @@ function Queue(size) {
10717
11002
  Queue.prototype = queue.prototype = {
10718
11003
  constructor: Queue,
10719
11004
  defer: function(callback) {
10720
- if (typeof callback !== "function" || this._call) throw new Error;
11005
+ if (typeof callback !== "function") throw new Error("invalid callback");
11006
+ if (this._call) throw new Error("defer after await");
10721
11007
  if (this._error != null) return this;
10722
- var t = slice$3.call(arguments, 1);
11008
+ var t = slice$4.call(arguments, 1);
10723
11009
  t.push(callback);
10724
11010
  ++this._waiting, this._tasks.push(t);
10725
11011
  poke$1(this);
@@ -10730,13 +11016,15 @@ Queue.prototype = queue.prototype = {
10730
11016
  return this;
10731
11017
  },
10732
11018
  await: function(callback) {
10733
- if (typeof callback !== "function" || this._call) throw new Error;
11019
+ if (typeof callback !== "function") throw new Error("invalid callback");
11020
+ if (this._call) throw new Error("multiple await");
10734
11021
  this._call = function(error, results) { callback.apply(null, [error].concat(results)); };
10735
11022
  maybeNotify(this);
10736
11023
  return this;
10737
11024
  },
10738
11025
  awaitAll: function(callback) {
10739
- if (typeof callback !== "function" || this._call) throw new Error;
11026
+ if (typeof callback !== "function") throw new Error("invalid callback");
11027
+ if (this._call) throw new Error("multiple await");
10740
11028
  this._call = callback;
10741
11029
  maybeNotify(this);
10742
11030
  return this;
@@ -10812,66 +11100,108 @@ function maybeNotify(q) {
10812
11100
  }
10813
11101
 
10814
11102
  function queue(concurrency) {
10815
- return new Queue(arguments.length ? +concurrency : Infinity);
11103
+ if (concurrency == null) concurrency = Infinity;
11104
+ else if (!((concurrency = +concurrency) >= 1)) throw new Error("invalid concurrency");
11105
+ return new Queue(concurrency);
10816
11106
  }
10817
11107
 
10818
- var uniform = function(min, max) {
10819
- min = min == null ? 0 : +min;
10820
- max = max == null ? 1 : +max;
10821
- if (arguments.length === 1) max = min, min = 0;
10822
- else max -= min;
10823
- return function() {
10824
- return Math.random() * max + min;
10825
- };
11108
+ var defaultSource$1 = function() {
11109
+ return Math.random();
10826
11110
  };
10827
11111
 
10828
- var normal = function(mu, sigma) {
10829
- var x, r;
10830
- mu = mu == null ? 0 : +mu;
10831
- sigma = sigma == null ? 1 : +sigma;
10832
- return function() {
10833
- var y;
11112
+ var uniform = (function sourceRandomUniform(source) {
11113
+ function randomUniform(min, max) {
11114
+ min = min == null ? 0 : +min;
11115
+ max = max == null ? 1 : +max;
11116
+ if (arguments.length === 1) max = min, min = 0;
11117
+ else max -= min;
11118
+ return function() {
11119
+ return source() * max + min;
11120
+ };
11121
+ }
10834
11122
 
10835
- // If available, use the second previously-generated uniform random.
10836
- if (x != null) y = x, x = null;
11123
+ randomUniform.source = sourceRandomUniform;
10837
11124
 
10838
- // Otherwise, generate a new x and y.
10839
- else do {
10840
- x = Math.random() * 2 - 1;
10841
- y = Math.random() * 2 - 1;
10842
- r = x * x + y * y;
10843
- } while (!r || r > 1);
11125
+ return randomUniform;
11126
+ })(defaultSource$1);
10844
11127
 
10845
- return mu + sigma * y * Math.sqrt(-2 * Math.log(r) / r);
10846
- };
10847
- };
11128
+ var normal = (function sourceRandomNormal(source) {
11129
+ function randomNormal(mu, sigma) {
11130
+ var x, r;
11131
+ mu = mu == null ? 0 : +mu;
11132
+ sigma = sigma == null ? 1 : +sigma;
11133
+ return function() {
11134
+ var y;
10848
11135
 
10849
- var logNormal = function() {
10850
- var randomNormal = normal.apply(this, arguments);
10851
- return function() {
10852
- return Math.exp(randomNormal());
10853
- };
10854
- };
11136
+ // If available, use the second previously-generated uniform random.
11137
+ if (x != null) y = x, x = null;
10855
11138
 
10856
- var irwinHall = function(n) {
10857
- return function() {
10858
- for (var sum = 0, i = 0; i < n; ++i) sum += Math.random();
10859
- return sum;
10860
- };
10861
- };
11139
+ // Otherwise, generate a new x and y.
11140
+ else do {
11141
+ x = source() * 2 - 1;
11142
+ y = source() * 2 - 1;
11143
+ r = x * x + y * y;
11144
+ } while (!r || r > 1);
10862
11145
 
10863
- var bates = function(n) {
10864
- var randomIrwinHall = irwinHall(n);
10865
- return function() {
10866
- return randomIrwinHall() / n;
10867
- };
10868
- };
11146
+ return mu + sigma * y * Math.sqrt(-2 * Math.log(r) / r);
11147
+ };
11148
+ }
10869
11149
 
10870
- var exponential$1 = function(lambda) {
10871
- return function() {
10872
- return -Math.log(1 - Math.random()) / lambda;
10873
- };
10874
- };
11150
+ randomNormal.source = sourceRandomNormal;
11151
+
11152
+ return randomNormal;
11153
+ })(defaultSource$1);
11154
+
11155
+ var logNormal = (function sourceRandomLogNormal(source) {
11156
+ function randomLogNormal() {
11157
+ var randomNormal = normal.source(source).apply(this, arguments);
11158
+ return function() {
11159
+ return Math.exp(randomNormal());
11160
+ };
11161
+ }
11162
+
11163
+ randomLogNormal.source = sourceRandomLogNormal;
11164
+
11165
+ return randomLogNormal;
11166
+ })(defaultSource$1);
11167
+
11168
+ var irwinHall = (function sourceRandomIrwinHall(source) {
11169
+ function randomIrwinHall(n) {
11170
+ return function() {
11171
+ for (var sum = 0, i = 0; i < n; ++i) sum += source();
11172
+ return sum;
11173
+ };
11174
+ }
11175
+
11176
+ randomIrwinHall.source = sourceRandomIrwinHall;
11177
+
11178
+ return randomIrwinHall;
11179
+ })(defaultSource$1);
11180
+
11181
+ var bates = (function sourceRandomBates(source) {
11182
+ function randomBates(n) {
11183
+ var randomIrwinHall = irwinHall.source(source)(n);
11184
+ return function() {
11185
+ return randomIrwinHall() / n;
11186
+ };
11187
+ }
11188
+
11189
+ randomBates.source = sourceRandomBates;
11190
+
11191
+ return randomBates;
11192
+ })(defaultSource$1);
11193
+
11194
+ var exponential$1 = (function sourceRandomExponential(source) {
11195
+ function randomExponential(lambda) {
11196
+ return function() {
11197
+ return -Math.log(1 - source()) / lambda;
11198
+ };
11199
+ }
11200
+
11201
+ randomExponential.source = sourceRandomExponential;
11202
+
11203
+ return randomExponential;
11204
+ })(defaultSource$1);
10875
11205
 
10876
11206
  var request = function(url, callback) {
10877
11207
  var request,
@@ -11074,7 +11404,7 @@ var tsv$1 = dsv$1("text/tab-separated-values", tsvParse);
11074
11404
  var array$2 = Array.prototype;
11075
11405
 
11076
11406
  var map$3 = array$2.map;
11077
- var slice$4 = array$2.slice;
11407
+ var slice$5 = array$2.slice;
11078
11408
 
11079
11409
  var implicit = {name: "implicit"};
11080
11410
 
@@ -11083,7 +11413,7 @@ function ordinal(range) {
11083
11413
  domain = [],
11084
11414
  unknown = implicit;
11085
11415
 
11086
- range = range == null ? [] : slice$4.call(range);
11416
+ range = range == null ? [] : slice$5.call(range);
11087
11417
 
11088
11418
  function scale(d) {
11089
11419
  var key = d + "", i = index.get(key);
@@ -11103,7 +11433,7 @@ function ordinal(range) {
11103
11433
  };
11104
11434
 
11105
11435
  scale.range = function(_) {
11106
- return arguments.length ? (range = slice$4.call(_), scale) : range.slice();
11436
+ return arguments.length ? (range = slice$5.call(_), scale) : range.slice();
11107
11437
  };
11108
11438
 
11109
11439
  scale.unknown = function(_) {
@@ -11124,7 +11454,7 @@ function band() {
11124
11454
  var scale = ordinal().unknown(undefined),
11125
11455
  domain = scale.domain,
11126
11456
  ordinalRange = scale.range,
11127
- range$$1 = [0, 1],
11457
+ range = [0, 1],
11128
11458
  step,
11129
11459
  bandwidth,
11130
11460
  round = false,
@@ -11136,9 +11466,9 @@ function band() {
11136
11466
 
11137
11467
  function rescale() {
11138
11468
  var n = domain().length,
11139
- reverse = range$$1[1] < range$$1[0],
11140
- start = range$$1[reverse - 0],
11141
- stop = range$$1[1 - reverse];
11469
+ reverse = range[1] < range[0],
11470
+ start = range[reverse - 0],
11471
+ stop = range[1 - reverse];
11142
11472
  step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2);
11143
11473
  if (round) step = Math.floor(step);
11144
11474
  start += (stop - start - step * (n - paddingInner)) * align;
@@ -11153,11 +11483,11 @@ function band() {
11153
11483
  };
11154
11484
 
11155
11485
  scale.range = function(_) {
11156
- return arguments.length ? (range$$1 = [+_[0], +_[1]], rescale()) : range$$1.slice();
11486
+ return arguments.length ? (range = [+_[0], +_[1]], rescale()) : range.slice();
11157
11487
  };
11158
11488
 
11159
11489
  scale.rangeRound = function(_) {
11160
- return range$$1 = [+_[0], +_[1]], round = true, rescale();
11490
+ return range = [+_[0], +_[1]], round = true, rescale();
11161
11491
  };
11162
11492
 
11163
11493
  scale.bandwidth = function() {
@@ -11191,7 +11521,7 @@ function band() {
11191
11521
  scale.copy = function() {
11192
11522
  return band()
11193
11523
  .domain(domain())
11194
- .range(range$$1)
11524
+ .range(range)
11195
11525
  .round(round)
11196
11526
  .paddingInner(paddingInner)
11197
11527
  .paddingOuter(paddingOuter)
@@ -11225,7 +11555,7 @@ var constant$9 = function(x) {
11225
11555
  };
11226
11556
  };
11227
11557
 
11228
- var number$1 = function(x) {
11558
+ var number$2 = function(x) {
11229
11559
  return +x;
11230
11560
  };
11231
11561
 
@@ -11244,22 +11574,22 @@ function deinterpolateClamp(deinterpolate) {
11244
11574
  };
11245
11575
  }
11246
11576
 
11247
- function reinterpolateClamp(reinterpolate) {
11577
+ function reinterpolateClamp(reinterpolate$$1) {
11248
11578
  return function(a, b) {
11249
- var r = reinterpolate(a = +a, b = +b);
11579
+ var r = reinterpolate$$1(a = +a, b = +b);
11250
11580
  return function(t) { return t <= 0 ? a : t >= 1 ? b : r(t); };
11251
11581
  };
11252
11582
  }
11253
11583
 
11254
- function bimap(domain, range$$1, deinterpolate, reinterpolate) {
11255
- var d0 = domain[0], d1 = domain[1], r0 = range$$1[0], r1 = range$$1[1];
11256
- if (d1 < d0) d0 = deinterpolate(d1, d0), r0 = reinterpolate(r1, r0);
11257
- else d0 = deinterpolate(d0, d1), r0 = reinterpolate(r0, r1);
11584
+ function bimap(domain, range, deinterpolate, reinterpolate$$1) {
11585
+ var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
11586
+ if (d1 < d0) d0 = deinterpolate(d1, d0), r0 = reinterpolate$$1(r1, r0);
11587
+ else d0 = deinterpolate(d0, d1), r0 = reinterpolate$$1(r0, r1);
11258
11588
  return function(x) { return r0(d0(x)); };
11259
11589
  }
11260
11590
 
11261
- function polymap(domain, range$$1, deinterpolate, reinterpolate) {
11262
- var j = Math.min(domain.length, range$$1.length) - 1,
11591
+ function polymap(domain, range, deinterpolate, reinterpolate$$1) {
11592
+ var j = Math.min(domain.length, range.length) - 1,
11263
11593
  d = new Array(j),
11264
11594
  r = new Array(j),
11265
11595
  i = -1;
@@ -11267,12 +11597,12 @@ function polymap(domain, range$$1, deinterpolate, reinterpolate) {
11267
11597
  // Reverse descending domains.
11268
11598
  if (domain[j] < domain[0]) {
11269
11599
  domain = domain.slice().reverse();
11270
- range$$1 = range$$1.slice().reverse();
11600
+ range = range.slice().reverse();
11271
11601
  }
11272
11602
 
11273
11603
  while (++i < j) {
11274
11604
  d[i] = deinterpolate(domain[i], domain[i + 1]);
11275
- r[i] = reinterpolate(range$$1[i], range$$1[i + 1]);
11605
+ r[i] = reinterpolate$$1(range[i], range[i + 1]);
11276
11606
  }
11277
11607
 
11278
11608
  return function(x) {
@@ -11291,39 +11621,39 @@ function copy(source, target) {
11291
11621
 
11292
11622
  // deinterpolate(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
11293
11623
  // reinterpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding domain value x in [a,b].
11294
- function continuous(deinterpolate, reinterpolate) {
11624
+ function continuous(deinterpolate, reinterpolate$$1) {
11295
11625
  var domain = unit,
11296
- range$$1 = unit,
11297
- interpolate$$1 = interpolateValue,
11626
+ range = unit,
11627
+ interpolate = interpolateValue,
11298
11628
  clamp = false,
11299
11629
  piecewise,
11300
11630
  output,
11301
11631
  input;
11302
11632
 
11303
11633
  function rescale() {
11304
- piecewise = Math.min(domain.length, range$$1.length) > 2 ? polymap : bimap;
11634
+ piecewise = Math.min(domain.length, range.length) > 2 ? polymap : bimap;
11305
11635
  output = input = null;
11306
11636
  return scale;
11307
11637
  }
11308
11638
 
11309
11639
  function scale(x) {
11310
- return (output || (output = piecewise(domain, range$$1, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x);
11640
+ return (output || (output = piecewise(domain, range, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate)))(+x);
11311
11641
  }
11312
11642
 
11313
11643
  scale.invert = function(y) {
11314
- return (input || (input = piecewise(range$$1, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate) : reinterpolate)))(+y);
11644
+ return (input || (input = piecewise(range, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate$$1) : reinterpolate$$1)))(+y);
11315
11645
  };
11316
11646
 
11317
11647
  scale.domain = function(_) {
11318
- return arguments.length ? (domain = map$3.call(_, number$1), rescale()) : domain.slice();
11648
+ return arguments.length ? (domain = map$3.call(_, number$2), rescale()) : domain.slice();
11319
11649
  };
11320
11650
 
11321
11651
  scale.range = function(_) {
11322
- return arguments.length ? (range$$1 = slice$4.call(_), rescale()) : range$$1.slice();
11652
+ return arguments.length ? (range = slice$5.call(_), rescale()) : range.slice();
11323
11653
  };
11324
11654
 
11325
11655
  scale.rangeRound = function(_) {
11326
- return range$$1 = slice$4.call(_), interpolate$$1 = interpolateRound, rescale();
11656
+ return range = slice$5.call(_), interpolate = interpolateRound, rescale();
11327
11657
  };
11328
11658
 
11329
11659
  scale.clamp = function(_) {
@@ -11331,7 +11661,7 @@ function continuous(deinterpolate, reinterpolate) {
11331
11661
  };
11332
11662
 
11333
11663
  scale.interpolate = function(_) {
11334
- return arguments.length ? (interpolate$$1 = _, rescale()) : interpolate$$1;
11664
+ return arguments.length ? (interpolate = _, rescale()) : interpolate;
11335
11665
  };
11336
11666
 
11337
11667
  return rescale();
@@ -11379,17 +11709,39 @@ function linearish(scale) {
11379
11709
  };
11380
11710
 
11381
11711
  scale.nice = function(count) {
11712
+ if (count == null) count = 10;
11713
+
11382
11714
  var d = domain(),
11383
- i = d.length - 1,
11384
- n = count == null ? 10 : count,
11385
- start = d[0],
11386
- stop = d[i],
11387
- step = tickStep(start, stop, n);
11388
-
11389
- if (step) {
11390
- step = tickStep(Math.floor(start / step) * step, Math.ceil(stop / step) * step, n);
11391
- d[0] = Math.floor(start / step) * step;
11392
- d[i] = Math.ceil(stop / step) * step;
11715
+ i0 = 0,
11716
+ i1 = d.length - 1,
11717
+ start = d[i0],
11718
+ stop = d[i1],
11719
+ step;
11720
+
11721
+ if (stop < start) {
11722
+ step = start, start = stop, stop = step;
11723
+ step = i0, i0 = i1, i1 = step;
11724
+ }
11725
+
11726
+ step = tickIncrement(start, stop, count);
11727
+
11728
+ if (step > 0) {
11729
+ start = Math.floor(start / step) * step;
11730
+ stop = Math.ceil(stop / step) * step;
11731
+ step = tickIncrement(start, stop, count);
11732
+ } else if (step < 0) {
11733
+ start = Math.ceil(start * step) / step;
11734
+ stop = Math.floor(stop * step) / step;
11735
+ step = tickIncrement(start, stop, count);
11736
+ }
11737
+
11738
+ if (step > 0) {
11739
+ d[i0] = Math.floor(start / step) * step;
11740
+ d[i1] = Math.ceil(stop / step) * step;
11741
+ domain(d);
11742
+ } else if (step < 0) {
11743
+ d[i0] = Math.ceil(start * step) / step;
11744
+ d[i1] = Math.floor(stop * step) / step;
11393
11745
  domain(d);
11394
11746
  }
11395
11747
 
@@ -11419,7 +11771,7 @@ function identity$6() {
11419
11771
  scale.invert = scale;
11420
11772
 
11421
11773
  scale.domain = scale.range = function(_) {
11422
- return arguments.length ? (domain = map$3.call(_, number$1), scale) : domain.slice();
11774
+ return arguments.length ? (domain = map$3.call(_, number$2), scale) : domain.slice();
11423
11775
  };
11424
11776
 
11425
11777
  scale.copy = function() {
@@ -11606,24 +11958,24 @@ function sqrt$1() {
11606
11958
  return pow$1().exponent(0.5);
11607
11959
  }
11608
11960
 
11609
- function quantile$$1() {
11961
+ function quantile() {
11610
11962
  var domain = [],
11611
- range$$1 = [],
11963
+ range = [],
11612
11964
  thresholds = [];
11613
11965
 
11614
11966
  function rescale() {
11615
- var i = 0, n = Math.max(1, range$$1.length);
11967
+ var i = 0, n = Math.max(1, range.length);
11616
11968
  thresholds = new Array(n - 1);
11617
11969
  while (++i < n) thresholds[i - 1] = threshold(domain, i / n);
11618
11970
  return scale;
11619
11971
  }
11620
11972
 
11621
11973
  function scale(x) {
11622
- if (!isNaN(x = +x)) return range$$1[bisectRight(thresholds, x)];
11974
+ if (!isNaN(x = +x)) return range[bisectRight(thresholds, x)];
11623
11975
  }
11624
11976
 
11625
11977
  scale.invertExtent = function(y) {
11626
- var i = range$$1.indexOf(y);
11978
+ var i = range.indexOf(y);
11627
11979
  return i < 0 ? [NaN, NaN] : [
11628
11980
  i > 0 ? thresholds[i - 1] : domain[0],
11629
11981
  i < thresholds.length ? thresholds[i] : domain[domain.length - 1]
@@ -11639,7 +11991,7 @@ function quantile$$1() {
11639
11991
  };
11640
11992
 
11641
11993
  scale.range = function(_) {
11642
- return arguments.length ? (range$$1 = slice$4.call(_), rescale()) : range$$1.slice();
11994
+ return arguments.length ? (range = slice$5.call(_), rescale()) : range.slice();
11643
11995
  };
11644
11996
 
11645
11997
  scale.quantiles = function() {
@@ -11647,9 +11999,9 @@ function quantile$$1() {
11647
11999
  };
11648
12000
 
11649
12001
  scale.copy = function() {
11650
- return quantile$$1()
12002
+ return quantile()
11651
12003
  .domain(domain)
11652
- .range(range$$1);
12004
+ .range(range);
11653
12005
  };
11654
12006
 
11655
12007
  return scale;
@@ -11660,10 +12012,10 @@ function quantize$1() {
11660
12012
  x1 = 1,
11661
12013
  n = 1,
11662
12014
  domain = [0.5],
11663
- range$$1 = [0, 1];
12015
+ range = [0, 1];
11664
12016
 
11665
12017
  function scale(x) {
11666
- if (x <= x) return range$$1[bisectRight(domain, x, 0, n)];
12018
+ if (x <= x) return range[bisectRight(domain, x, 0, n)];
11667
12019
  }
11668
12020
 
11669
12021
  function rescale() {
@@ -11678,11 +12030,11 @@ function quantize$1() {
11678
12030
  };
11679
12031
 
11680
12032
  scale.range = function(_) {
11681
- return arguments.length ? (n = (range$$1 = slice$4.call(_)).length - 1, rescale()) : range$$1.slice();
12033
+ return arguments.length ? (n = (range = slice$5.call(_)).length - 1, rescale()) : range.slice();
11682
12034
  };
11683
12035
 
11684
12036
  scale.invertExtent = function(y) {
11685
- var i = range$$1.indexOf(y);
12037
+ var i = range.indexOf(y);
11686
12038
  return i < 0 ? [NaN, NaN]
11687
12039
  : i < 1 ? [x0, domain[0]]
11688
12040
  : i >= n ? [domain[n - 1], x1]
@@ -11692,7 +12044,7 @@ function quantize$1() {
11692
12044
  scale.copy = function() {
11693
12045
  return quantize$1()
11694
12046
  .domain([x0, x1])
11695
- .range(range$$1);
12047
+ .range(range);
11696
12048
  };
11697
12049
 
11698
12050
  return linearish(scale);
@@ -11700,30 +12052,30 @@ function quantize$1() {
11700
12052
 
11701
12053
  function threshold$1() {
11702
12054
  var domain = [0.5],
11703
- range$$1 = [0, 1],
12055
+ range = [0, 1],
11704
12056
  n = 1;
11705
12057
 
11706
12058
  function scale(x) {
11707
- if (x <= x) return range$$1[bisectRight(domain, x, 0, n)];
12059
+ if (x <= x) return range[bisectRight(domain, x, 0, n)];
11708
12060
  }
11709
12061
 
11710
12062
  scale.domain = function(_) {
11711
- return arguments.length ? (domain = slice$4.call(_), n = Math.min(domain.length, range$$1.length - 1), scale) : domain.slice();
12063
+ return arguments.length ? (domain = slice$5.call(_), n = Math.min(domain.length, range.length - 1), scale) : domain.slice();
11712
12064
  };
11713
12065
 
11714
12066
  scale.range = function(_) {
11715
- return arguments.length ? (range$$1 = slice$4.call(_), n = Math.min(domain.length, range$$1.length - 1), scale) : range$$1.slice();
12067
+ return arguments.length ? (range = slice$5.call(_), n = Math.min(domain.length, range.length - 1), scale) : range.slice();
11716
12068
  };
11717
12069
 
11718
12070
  scale.invertExtent = function(y) {
11719
- var i = range$$1.indexOf(y);
12071
+ var i = range.indexOf(y);
11720
12072
  return [domain[i - 1], domain[i]];
11721
12073
  };
11722
12074
 
11723
12075
  scale.copy = function() {
11724
12076
  return threshold$1()
11725
12077
  .domain(domain)
11726
- .range(range$$1);
12078
+ .range(range);
11727
12079
  };
11728
12080
 
11729
12081
  return scale;
@@ -11767,7 +12119,13 @@ function newInterval(floori, offseti, count, field) {
11767
12119
  return newInterval(function(date) {
11768
12120
  if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1);
11769
12121
  }, function(date, step) {
11770
- if (date >= date) while (--step >= 0) while (offseti(date, 1), !test(date)) {} // eslint-disable-line no-empty
12122
+ if (date >= date) {
12123
+ if (step < 0) while (++step <= 0) {
12124
+ while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty
12125
+ } else while (--step >= 0) {
12126
+ while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty
12127
+ }
12128
+ }
11771
12129
  });
11772
12130
  };
11773
12131
 
@@ -12620,7 +12978,7 @@ function date$1(t) {
12620
12978
  return new Date(t);
12621
12979
  }
12622
12980
 
12623
- function number$2(t) {
12981
+ function number$3(t) {
12624
12982
  return t instanceof Date ? +t : +new Date(+t);
12625
12983
  }
12626
12984
 
@@ -12659,39 +13017,39 @@ function calendar(year$$1, month$$1, week, day$$1, hour$$1, minute$$1, second$$1
12659
13017
  [ year$$1, 1, durationYear ]
12660
13018
  ];
12661
13019
 
12662
- function tickFormat(date) {
12663
- return (second$$1(date) < date ? formatMillisecond
12664
- : minute$$1(date) < date ? formatSecond
12665
- : hour$$1(date) < date ? formatMinute
12666
- : day$$1(date) < date ? formatHour
12667
- : month$$1(date) < date ? (week(date) < date ? formatDay : formatWeek)
12668
- : year$$1(date) < date ? formatMonth
12669
- : formatYear)(date);
13020
+ function tickFormat(date$$1) {
13021
+ return (second$$1(date$$1) < date$$1 ? formatMillisecond
13022
+ : minute$$1(date$$1) < date$$1 ? formatSecond
13023
+ : hour$$1(date$$1) < date$$1 ? formatMinute
13024
+ : day$$1(date$$1) < date$$1 ? formatHour
13025
+ : month$$1(date$$1) < date$$1 ? (week(date$$1) < date$$1 ? formatDay : formatWeek)
13026
+ : year$$1(date$$1) < date$$1 ? formatMonth
13027
+ : formatYear)(date$$1);
12670
13028
  }
12671
13029
 
12672
- function tickInterval(interval, start, stop, step) {
12673
- if (interval == null) interval = 10;
13030
+ function tickInterval(interval$$1, start, stop, step) {
13031
+ if (interval$$1 == null) interval$$1 = 10;
12674
13032
 
12675
13033
  // If a desired tick count is specified, pick a reasonable tick interval
12676
13034
  // based on the extent of the domain and a rough estimate of tick size.
12677
13035
  // Otherwise, assume interval is already a time interval and use it.
12678
- if (typeof interval === "number") {
12679
- var target = Math.abs(stop - start) / interval,
13036
+ if (typeof interval$$1 === "number") {
13037
+ var target = Math.abs(stop - start) / interval$$1,
12680
13038
  i = bisector(function(i) { return i[2]; }).right(tickIntervals, target);
12681
13039
  if (i === tickIntervals.length) {
12682
- step = tickStep(start / durationYear, stop / durationYear, interval);
12683
- interval = year$$1;
13040
+ step = tickStep(start / durationYear, stop / durationYear, interval$$1);
13041
+ interval$$1 = year$$1;
12684
13042
  } else if (i) {
12685
13043
  i = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i];
12686
13044
  step = i[1];
12687
- interval = i[0];
13045
+ interval$$1 = i[0];
12688
13046
  } else {
12689
- step = tickStep(start, stop, interval);
12690
- interval = millisecond$$1;
13047
+ step = tickStep(start, stop, interval$$1);
13048
+ interval$$1 = millisecond$$1;
12691
13049
  }
12692
13050
  }
12693
13051
 
12694
- return step == null ? interval : interval.every(step);
13052
+ return step == null ? interval$$1 : interval$$1.every(step);
12695
13053
  }
12696
13054
 
12697
13055
  scale.invert = function(y) {
@@ -12699,17 +13057,17 @@ function calendar(year$$1, month$$1, week, day$$1, hour$$1, minute$$1, second$$1
12699
13057
  };
12700
13058
 
12701
13059
  scale.domain = function(_) {
12702
- return arguments.length ? domain(map$3.call(_, number$2)) : domain().map(date$1);
13060
+ return arguments.length ? domain(map$3.call(_, number$3)) : domain().map(date$1);
12703
13061
  };
12704
13062
 
12705
- scale.ticks = function(interval, step) {
13063
+ scale.ticks = function(interval$$1, step) {
12706
13064
  var d = domain(),
12707
13065
  t0 = d[0],
12708
13066
  t1 = d[d.length - 1],
12709
13067
  r = t1 < t0,
12710
13068
  t;
12711
13069
  if (r) t = t0, t0 = t1, t1 = t;
12712
- t = tickInterval(interval, t0, t1, step);
13070
+ t = tickInterval(interval$$1, t0, t1, step);
12713
13071
  t = t ? t.range(t0, t1 + 1) : []; // inclusive stop
12714
13072
  return r ? t.reverse() : t;
12715
13073
  };
@@ -12718,10 +13076,10 @@ function calendar(year$$1, month$$1, week, day$$1, hour$$1, minute$$1, second$$1
12718
13076
  return specifier == null ? tickFormat : format(specifier);
12719
13077
  };
12720
13078
 
12721
- scale.nice = function(interval, step) {
13079
+ scale.nice = function(interval$$1, step) {
12722
13080
  var d = domain();
12723
- return (interval = tickInterval(interval, d[0], d[d.length - 1], step))
12724
- ? domain(nice(d, interval))
13081
+ return (interval$$1 = tickInterval(interval$$1, d[0], d[d.length - 1], step))
13082
+ ? domain(nice(d, interval$$1))
12725
13083
  : scale;
12726
13084
  };
12727
13085
 
@@ -12821,11 +13179,27 @@ var constant$10 = function(x) {
12821
13179
  };
12822
13180
  };
12823
13181
 
13182
+ var abs$1 = Math.abs;
13183
+ var atan2$1 = Math.atan2;
13184
+ var cos$2 = Math.cos;
13185
+ var max$2 = Math.max;
13186
+ var min$1 = Math.min;
13187
+ var sin$2 = Math.sin;
13188
+ var sqrt$2 = Math.sqrt;
13189
+
12824
13190
  var epsilon$3 = 1e-12;
12825
13191
  var pi$4 = Math.PI;
12826
13192
  var halfPi$3 = pi$4 / 2;
12827
13193
  var tau$4 = 2 * pi$4;
12828
13194
 
13195
+ function acos$1(x) {
13196
+ return x > 1 ? 0 : x < -1 ? pi$4 : Math.acos(x);
13197
+ }
13198
+
13199
+ function asin$1(x) {
13200
+ return x >= 1 ? halfPi$3 : x <= -1 ? -halfPi$3 : Math.asin(x);
13201
+ }
13202
+
12829
13203
  function arcInnerRadius(d) {
12830
13204
  return d.innerRadius;
12831
13205
  }
@@ -12846,10 +13220,6 @@ function arcPadAngle(d) {
12846
13220
  return d && d.padAngle; // Note: optional!
12847
13221
  }
12848
13222
 
12849
- function asin$1(x) {
12850
- return x >= 1 ? halfPi$3 : x <= -1 ? -halfPi$3 : Math.asin(x);
12851
- }
12852
-
12853
13223
  function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
12854
13224
  var x10 = x1 - x0, y10 = y1 - y0,
12855
13225
  x32 = x3 - x2, y32 = y3 - y2,
@@ -12862,7 +13232,7 @@ function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
12862
13232
  function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
12863
13233
  var x01 = x0 - x1,
12864
13234
  y01 = y0 - y1,
12865
- lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01),
13235
+ lo = (cw ? rc : -rc) / sqrt$2(x01 * x01 + y01 * y01),
12866
13236
  ox = lo * y01,
12867
13237
  oy = -lo * x01,
12868
13238
  x11 = x0 + ox,
@@ -12876,7 +13246,7 @@ function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
12876
13246
  d2 = dx * dx + dy * dy,
12877
13247
  r = r1 - rc,
12878
13248
  D = x11 * y10 - x10 * y11,
12879
- d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D)),
13249
+ d = (dy < 0 ? -1 : 1) * sqrt$2(max$2(0, r * r * d2 - D * D)),
12880
13250
  cx0 = (D * dy - dx * d) / d2,
12881
13251
  cy0 = (-D * dx - dy * d) / d2,
12882
13252
  cx1 = (D * dy + dx * d) / d2,
@@ -12917,7 +13287,7 @@ var arc = function() {
12917
13287
  r1 = +outerRadius.apply(this, arguments),
12918
13288
  a0 = startAngle.apply(this, arguments) - halfPi$3,
12919
13289
  a1 = endAngle.apply(this, arguments) - halfPi$3,
12920
- da = Math.abs(a1 - a0),
13290
+ da = abs$1(a1 - a0),
12921
13291
  cw = a1 > a0;
12922
13292
 
12923
13293
  if (!context) context = buffer = path();
@@ -12930,10 +13300,10 @@ var arc = function() {
12930
13300
 
12931
13301
  // Or is it a circle or annulus?
12932
13302
  else if (da > tau$4 - epsilon$3) {
12933
- context.moveTo(r1 * Math.cos(a0), r1 * Math.sin(a0));
13303
+ context.moveTo(r1 * cos$2(a0), r1 * sin$2(a0));
12934
13304
  context.arc(0, 0, r1, a0, a1, !cw);
12935
13305
  if (r0 > epsilon$3) {
12936
- context.moveTo(r0 * Math.cos(a1), r0 * Math.sin(a1));
13306
+ context.moveTo(r0 * cos$2(a1), r0 * sin$2(a1));
12937
13307
  context.arc(0, 0, r0, a1, a0, cw);
12938
13308
  }
12939
13309
  }
@@ -12947,8 +13317,8 @@ var arc = function() {
12947
13317
  da0 = da,
12948
13318
  da1 = da,
12949
13319
  ap = padAngle.apply(this, arguments) / 2,
12950
- rp = (ap > epsilon$3) && (padRadius ? +padRadius.apply(this, arguments) : Math.sqrt(r0 * r0 + r1 * r1)),
12951
- rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)),
13320
+ rp = (ap > epsilon$3) && (padRadius ? +padRadius.apply(this, arguments) : sqrt$2(r0 * r0 + r1 * r1)),
13321
+ rc = min$1(abs$1(r1 - r0) / 2, +cornerRadius.apply(this, arguments)),
12952
13322
  rc0 = rc,
12953
13323
  rc1 = rc,
12954
13324
  t0,
@@ -12956,25 +13326,25 @@ var arc = function() {
12956
13326
 
12957
13327
  // Apply padding? Note that since r1 ≥ r0, da1 ≥ da0.
12958
13328
  if (rp > epsilon$3) {
12959
- var p0 = asin$1(rp / r0 * Math.sin(ap)),
12960
- p1 = asin$1(rp / r1 * Math.sin(ap));
13329
+ var p0 = asin$1(rp / r0 * sin$2(ap)),
13330
+ p1 = asin$1(rp / r1 * sin$2(ap));
12961
13331
  if ((da0 -= p0 * 2) > epsilon$3) p0 *= (cw ? 1 : -1), a00 += p0, a10 -= p0;
12962
13332
  else da0 = 0, a00 = a10 = (a0 + a1) / 2;
12963
13333
  if ((da1 -= p1 * 2) > epsilon$3) p1 *= (cw ? 1 : -1), a01 += p1, a11 -= p1;
12964
13334
  else da1 = 0, a01 = a11 = (a0 + a1) / 2;
12965
13335
  }
12966
13336
 
12967
- var x01 = r1 * Math.cos(a01),
12968
- y01 = r1 * Math.sin(a01),
12969
- x10 = r0 * Math.cos(a10),
12970
- y10 = r0 * Math.sin(a10);
13337
+ var x01 = r1 * cos$2(a01),
13338
+ y01 = r1 * sin$2(a01),
13339
+ x10 = r0 * cos$2(a10),
13340
+ y10 = r0 * sin$2(a10);
12971
13341
 
12972
13342
  // Apply rounded corners?
12973
13343
  if (rc > epsilon$3) {
12974
- var x11 = r1 * Math.cos(a11),
12975
- y11 = r1 * Math.sin(a11),
12976
- x00 = r0 * Math.cos(a00),
12977
- y00 = r0 * Math.sin(a00);
13344
+ var x11 = r1 * cos$2(a11),
13345
+ y11 = r1 * sin$2(a11),
13346
+ x00 = r0 * cos$2(a00),
13347
+ y00 = r0 * sin$2(a00);
12978
13348
 
12979
13349
  // Restrict the corner radius according to the sector angle.
12980
13350
  if (da < pi$4) {
@@ -12983,10 +13353,10 @@ var arc = function() {
12983
13353
  ay = y01 - oc[1],
12984
13354
  bx = x11 - oc[0],
12985
13355
  by = y11 - oc[1],
12986
- kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2),
12987
- lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
12988
- rc0 = Math.min(rc, (r0 - lc) / (kc - 1));
12989
- rc1 = Math.min(rc, (r1 - lc) / (kc + 1));
13356
+ kc = 1 / sin$2(acos$1((ax * bx + ay * by) / (sqrt$2(ax * ax + ay * ay) * sqrt$2(bx * bx + by * by))) / 2),
13357
+ lc = sqrt$2(oc[0] * oc[0] + oc[1] * oc[1]);
13358
+ rc0 = min$1(rc, (r0 - lc) / (kc - 1));
13359
+ rc1 = min$1(rc, (r1 - lc) / (kc + 1));
12990
13360
  }
12991
13361
  }
12992
13362
 
@@ -13001,13 +13371,13 @@ var arc = function() {
13001
13371
  context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
13002
13372
 
13003
13373
  // Have the corners merged?
13004
- if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, Math.atan2(t0.y01, t0.x01), Math.atan2(t1.y01, t1.x01), !cw);
13374
+ if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2$1(t0.y01, t0.x01), atan2$1(t1.y01, t1.x01), !cw);
13005
13375
 
13006
13376
  // Otherwise, draw the two corners and the ring.
13007
13377
  else {
13008
- context.arc(t0.cx, t0.cy, rc1, Math.atan2(t0.y01, t0.x01), Math.atan2(t0.y11, t0.x11), !cw);
13009
- context.arc(0, 0, r1, Math.atan2(t0.cy + t0.y11, t0.cx + t0.x11), Math.atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
13010
- context.arc(t1.cx, t1.cy, rc1, Math.atan2(t1.y11, t1.x11), Math.atan2(t1.y01, t1.x01), !cw);
13378
+ context.arc(t0.cx, t0.cy, rc1, atan2$1(t0.y01, t0.x01), atan2$1(t0.y11, t0.x11), !cw);
13379
+ context.arc(0, 0, r1, atan2$1(t0.cy + t0.y11, t0.cx + t0.x11), atan2$1(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
13380
+ context.arc(t1.cx, t1.cy, rc1, atan2$1(t1.y11, t1.x11), atan2$1(t1.y01, t1.x01), !cw);
13011
13381
  }
13012
13382
  }
13013
13383
 
@@ -13026,13 +13396,13 @@ var arc = function() {
13026
13396
  context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
13027
13397
 
13028
13398
  // Have the corners merged?
13029
- if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, Math.atan2(t0.y01, t0.x01), Math.atan2(t1.y01, t1.x01), !cw);
13399
+ if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2$1(t0.y01, t0.x01), atan2$1(t1.y01, t1.x01), !cw);
13030
13400
 
13031
13401
  // Otherwise, draw the two corners and the ring.
13032
13402
  else {
13033
- context.arc(t0.cx, t0.cy, rc0, Math.atan2(t0.y01, t0.x01), Math.atan2(t0.y11, t0.x11), !cw);
13034
- context.arc(0, 0, r0, Math.atan2(t0.cy + t0.y11, t0.cx + t0.x11), Math.atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw);
13035
- context.arc(t1.cx, t1.cy, rc0, Math.atan2(t1.y11, t1.x11), Math.atan2(t1.y01, t1.x01), !cw);
13403
+ context.arc(t0.cx, t0.cy, rc0, atan2$1(t0.y01, t0.x01), atan2$1(t0.y11, t0.x11), !cw);
13404
+ context.arc(0, 0, r0, atan2$1(t0.cy + t0.y11, t0.cx + t0.x11), atan2$1(t1.cy + t1.y11, t1.cx + t1.x11), cw);
13405
+ context.arc(t1.cx, t1.cy, rc0, atan2$1(t1.y11, t1.x11), atan2$1(t1.y01, t1.x01), !cw);
13036
13406
  }
13037
13407
  }
13038
13408
 
@@ -13048,7 +13418,7 @@ var arc = function() {
13048
13418
  arc.centroid = function() {
13049
13419
  var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2,
13050
13420
  a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi$4 / 2;
13051
- return [Math.cos(a) * r, Math.sin(a) * r];
13421
+ return [cos$2(a) * r, sin$2(a) * r];
13052
13422
  };
13053
13423
 
13054
13424
  arc.innerRadius = function(_) {
@@ -13127,8 +13497,8 @@ function y$3(p) {
13127
13497
  }
13128
13498
 
13129
13499
  var line = function() {
13130
- var x$$1 = x$3,
13131
- y$$1 = y$3,
13500
+ var x = x$3,
13501
+ y = y$3,
13132
13502
  defined = constant$10(true),
13133
13503
  context = null,
13134
13504
  curve = curveLinear,
@@ -13148,18 +13518,18 @@ var line = function() {
13148
13518
  if (defined0 = !defined0) output.lineStart();
13149
13519
  else output.lineEnd();
13150
13520
  }
13151
- if (defined0) output.point(+x$$1(d, i, data), +y$$1(d, i, data));
13521
+ if (defined0) output.point(+x(d, i, data), +y(d, i, data));
13152
13522
  }
13153
13523
 
13154
13524
  if (buffer) return output = null, buffer + "" || null;
13155
13525
  }
13156
13526
 
13157
13527
  line.x = function(_) {
13158
- return arguments.length ? (x$$1 = typeof _ === "function" ? _ : constant$10(+_), line) : x$$1;
13528
+ return arguments.length ? (x = typeof _ === "function" ? _ : constant$10(+_), line) : x;
13159
13529
  };
13160
13530
 
13161
13531
  line.y = function(_) {
13162
- return arguments.length ? (y$$1 = typeof _ === "function" ? _ : constant$10(+_), line) : y$$1;
13532
+ return arguments.length ? (y = typeof _ === "function" ? _ : constant$10(+_), line) : y;
13163
13533
  };
13164
13534
 
13165
13535
  line.defined = function(_) {
@@ -13399,7 +13769,7 @@ function curveRadial(curve) {
13399
13769
  return radial;
13400
13770
  }
13401
13771
 
13402
- function radialLine(l) {
13772
+ function lineRadial(l) {
13403
13773
  var c = l.curve;
13404
13774
 
13405
13775
  l.angle = l.x, delete l.x;
@@ -13412,11 +13782,11 @@ function radialLine(l) {
13412
13782
  return l;
13413
13783
  }
13414
13784
 
13415
- var radialLine$1 = function() {
13416
- return radialLine(line().curve(curveRadialLinear));
13785
+ var lineRadial$1 = function() {
13786
+ return lineRadial(line().curve(curveRadialLinear));
13417
13787
  };
13418
13788
 
13419
- var radialArea = function() {
13789
+ var areaRadial = function() {
13420
13790
  var a = area$2().curve(curveRadialLinear),
13421
13791
  c = a.curve,
13422
13792
  x0 = a.lineX0,
@@ -13430,10 +13800,10 @@ var radialArea = function() {
13430
13800
  a.radius = a.y, delete a.y;
13431
13801
  a.innerRadius = a.y0, delete a.y0;
13432
13802
  a.outerRadius = a.y1, delete a.y1;
13433
- a.lineStartAngle = function() { return radialLine(x0()); }, delete a.lineX0;
13434
- a.lineEndAngle = function() { return radialLine(x1()); }, delete a.lineX1;
13435
- a.lineInnerRadius = function() { return radialLine(y0()); }, delete a.lineY0;
13436
- a.lineOuterRadius = function() { return radialLine(y1()); }, delete a.lineY1;
13803
+ a.lineStartAngle = function() { return lineRadial(x0()); }, delete a.lineX0;
13804
+ a.lineEndAngle = function() { return lineRadial(x1()); }, delete a.lineX1;
13805
+ a.lineInnerRadius = function() { return lineRadial(y0()); }, delete a.lineY0;
13806
+ a.lineOuterRadius = function() { return lineRadial(y1()); }, delete a.lineY1;
13437
13807
 
13438
13808
  a.curve = function(_) {
13439
13809
  return arguments.length ? c(curveRadial(_)) : c()._curve;
@@ -13442,6 +13812,91 @@ var radialArea = function() {
13442
13812
  return a;
13443
13813
  };
13444
13814
 
13815
+ var pointRadial = function(x, y) {
13816
+ return [(y = +y) * Math.cos(x -= Math.PI / 2), y * Math.sin(x)];
13817
+ };
13818
+
13819
+ var slice$6 = Array.prototype.slice;
13820
+
13821
+ function linkSource(d) {
13822
+ return d.source;
13823
+ }
13824
+
13825
+ function linkTarget(d) {
13826
+ return d.target;
13827
+ }
13828
+
13829
+ function link$2(curve) {
13830
+ var source = linkSource,
13831
+ target = linkTarget,
13832
+ x = x$3,
13833
+ y = y$3,
13834
+ context = null;
13835
+
13836
+ function link() {
13837
+ var buffer, argv = slice$6.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);
13838
+ if (!context) context = buffer = path();
13839
+ curve(context, +x.apply(this, (argv[0] = s, argv)), +y.apply(this, argv), +x.apply(this, (argv[0] = t, argv)), +y.apply(this, argv));
13840
+ if (buffer) return context = null, buffer + "" || null;
13841
+ }
13842
+
13843
+ link.source = function(_) {
13844
+ return arguments.length ? (source = _, link) : source;
13845
+ };
13846
+
13847
+ link.target = function(_) {
13848
+ return arguments.length ? (target = _, link) : target;
13849
+ };
13850
+
13851
+ link.x = function(_) {
13852
+ return arguments.length ? (x = typeof _ === "function" ? _ : constant$10(+_), link) : x;
13853
+ };
13854
+
13855
+ link.y = function(_) {
13856
+ return arguments.length ? (y = typeof _ === "function" ? _ : constant$10(+_), link) : y;
13857
+ };
13858
+
13859
+ link.context = function(_) {
13860
+ return arguments.length ? ((context = _ == null ? null : _), link) : context;
13861
+ };
13862
+
13863
+ return link;
13864
+ }
13865
+
13866
+ function curveHorizontal(context, x0, y0, x1, y1) {
13867
+ context.moveTo(x0, y0);
13868
+ context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);
13869
+ }
13870
+
13871
+ function curveVertical(context, x0, y0, x1, y1) {
13872
+ context.moveTo(x0, y0);
13873
+ context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1);
13874
+ }
13875
+
13876
+ function curveRadial$1(context, x0, y0, x1, y1) {
13877
+ var p0 = pointRadial(x0, y0),
13878
+ p1 = pointRadial(x0, y0 = (y0 + y1) / 2),
13879
+ p2 = pointRadial(x1, y0),
13880
+ p3 = pointRadial(x1, y1);
13881
+ context.moveTo(p0[0], p0[1]);
13882
+ context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);
13883
+ }
13884
+
13885
+ function linkHorizontal() {
13886
+ return link$2(curveHorizontal);
13887
+ }
13888
+
13889
+ function linkVertical() {
13890
+ return link$2(curveVertical);
13891
+ }
13892
+
13893
+ function linkRadial() {
13894
+ var l = link$2(curveRadial$1);
13895
+ l.angle = l.x, delete l.x;
13896
+ l.radius = l.y, delete l.y;
13897
+ return l;
13898
+ }
13899
+
13445
13900
  var circle$2 = {
13446
13901
  draw: function(context, size) {
13447
13902
  var r = Math.sqrt(size / pi$4);
@@ -13450,7 +13905,7 @@ var circle$2 = {
13450
13905
  }
13451
13906
  };
13452
13907
 
13453
- var cross$1 = {
13908
+ var cross$2 = {
13454
13909
  draw: function(context, size) {
13455
13910
  var r = Math.sqrt(size / 5) / 2;
13456
13911
  context.moveTo(-3 * r, -r);
@@ -13556,7 +14011,7 @@ var wye = {
13556
14011
 
13557
14012
  var symbols = [
13558
14013
  circle$2,
13559
- cross$1,
14014
+ cross$2,
13560
14015
  diamond,
13561
14016
  square,
13562
14017
  star,
@@ -13775,7 +14230,7 @@ Bundle.prototype = {
13775
14230
  }
13776
14231
  };
13777
14232
 
13778
- var bundle = ((function custom(beta) {
14233
+ var bundle = (function custom(beta) {
13779
14234
 
13780
14235
  function bundle(context) {
13781
14236
  return beta === 1 ? new Basis(context) : new Bundle(context, beta);
@@ -13786,7 +14241,7 @@ var bundle = ((function custom(beta) {
13786
14241
  };
13787
14242
 
13788
14243
  return bundle;
13789
- }))(0.85);
14244
+ })(0.85);
13790
14245
 
13791
14246
  function point$3(that, x, y) {
13792
14247
  that._context.bezierCurveTo(
@@ -13837,7 +14292,7 @@ Cardinal.prototype = {
13837
14292
  }
13838
14293
  };
13839
14294
 
13840
- var cardinal = ((function custom(tension) {
14295
+ var cardinal = (function custom(tension) {
13841
14296
 
13842
14297
  function cardinal(context) {
13843
14298
  return new Cardinal(context, tension);
@@ -13848,7 +14303,7 @@ var cardinal = ((function custom(tension) {
13848
14303
  };
13849
14304
 
13850
14305
  return cardinal;
13851
- }))(0);
14306
+ })(0);
13852
14307
 
13853
14308
  function CardinalClosed(context, tension) {
13854
14309
  this._context = context;
@@ -13896,18 +14351,18 @@ CardinalClosed.prototype = {
13896
14351
  }
13897
14352
  };
13898
14353
 
13899
- var cardinalClosed = ((function custom(tension) {
14354
+ var cardinalClosed = (function custom(tension) {
13900
14355
 
13901
- function cardinal(context) {
14356
+ function cardinal$$1(context) {
13902
14357
  return new CardinalClosed(context, tension);
13903
14358
  }
13904
14359
 
13905
- cardinal.tension = function(tension) {
14360
+ cardinal$$1.tension = function(tension) {
13906
14361
  return custom(+tension);
13907
14362
  };
13908
14363
 
13909
- return cardinal;
13910
- }))(0);
14364
+ return cardinal$$1;
14365
+ })(0);
13911
14366
 
13912
14367
  function CardinalOpen(context, tension) {
13913
14368
  this._context = context;
@@ -13944,18 +14399,18 @@ CardinalOpen.prototype = {
13944
14399
  }
13945
14400
  };
13946
14401
 
13947
- var cardinalOpen = ((function custom(tension) {
14402
+ var cardinalOpen = (function custom(tension) {
13948
14403
 
13949
- function cardinal(context) {
14404
+ function cardinal$$1(context) {
13950
14405
  return new CardinalOpen(context, tension);
13951
14406
  }
13952
14407
 
13953
- cardinal.tension = function(tension) {
14408
+ cardinal$$1.tension = function(tension) {
13954
14409
  return custom(+tension);
13955
14410
  };
13956
14411
 
13957
- return cardinal;
13958
- }))(0);
14412
+ return cardinal$$1;
14413
+ })(0);
13959
14414
 
13960
14415
  function point$4(that, x, y) {
13961
14416
  var x1 = that._x1,
@@ -14030,7 +14485,7 @@ CatmullRom.prototype = {
14030
14485
  }
14031
14486
  };
14032
14487
 
14033
- var catmullRom = ((function custom(alpha) {
14488
+ var catmullRom = (function custom(alpha) {
14034
14489
 
14035
14490
  function catmullRom(context) {
14036
14491
  return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0);
@@ -14041,7 +14496,7 @@ var catmullRom = ((function custom(alpha) {
14041
14496
  };
14042
14497
 
14043
14498
  return catmullRom;
14044
- }))(0.5);
14499
+ })(0.5);
14045
14500
 
14046
14501
  function CatmullRomClosed(context, alpha) {
14047
14502
  this._context = context;
@@ -14101,18 +14556,18 @@ CatmullRomClosed.prototype = {
14101
14556
  }
14102
14557
  };
14103
14558
 
14104
- var catmullRomClosed = ((function custom(alpha) {
14559
+ var catmullRomClosed = (function custom(alpha) {
14105
14560
 
14106
- function catmullRom(context) {
14561
+ function catmullRom$$1(context) {
14107
14562
  return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0);
14108
14563
  }
14109
14564
 
14110
- catmullRom.alpha = function(alpha) {
14565
+ catmullRom$$1.alpha = function(alpha) {
14111
14566
  return custom(+alpha);
14112
14567
  };
14113
14568
 
14114
- return catmullRom;
14115
- }))(0.5);
14569
+ return catmullRom$$1;
14570
+ })(0.5);
14116
14571
 
14117
14572
  function CatmullRomOpen(context, alpha) {
14118
14573
  this._context = context;
@@ -14161,18 +14616,18 @@ CatmullRomOpen.prototype = {
14161
14616
  }
14162
14617
  };
14163
14618
 
14164
- var catmullRomOpen = ((function custom(alpha) {
14619
+ var catmullRomOpen = (function custom(alpha) {
14165
14620
 
14166
- function catmullRom(context) {
14621
+ function catmullRom$$1(context) {
14167
14622
  return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0);
14168
14623
  }
14169
14624
 
14170
- catmullRom.alpha = function(alpha) {
14625
+ catmullRom$$1.alpha = function(alpha) {
14171
14626
  return custom(+alpha);
14172
14627
  };
14173
14628
 
14174
- return catmullRom;
14175
- }))(0.5);
14629
+ return catmullRom$$1;
14630
+ })(0.5);
14176
14631
 
14177
14632
  function LinearClosed(context) {
14178
14633
  this._context = context;
@@ -14423,13 +14878,11 @@ function stepAfter(context) {
14423
14878
  return new Step(context, 1);
14424
14879
  }
14425
14880
 
14426
- var slice$5 = Array.prototype.slice;
14427
-
14428
14881
  var none$1 = function(series, order) {
14429
14882
  if (!((n = series.length) > 1)) return;
14430
- for (var i = 1, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
14883
+ for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
14431
14884
  s0 = s1, s1 = series[order[i]];
14432
- for (var j = 0; j < m; ++j) {
14885
+ for (j = 0; j < m; ++j) {
14433
14886
  s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
14434
14887
  }
14435
14888
  }
@@ -14476,7 +14929,7 @@ var stack = function() {
14476
14929
  }
14477
14930
 
14478
14931
  stack.keys = function(_) {
14479
- return arguments.length ? (keys = typeof _ === "function" ? _ : constant$10(slice$5.call(_)), stack) : keys;
14932
+ return arguments.length ? (keys = typeof _ === "function" ? _ : constant$10(slice$6.call(_)), stack) : keys;
14480
14933
  };
14481
14934
 
14482
14935
  stack.value = function(_) {
@@ -14484,7 +14937,7 @@ var stack = function() {
14484
14937
  };
14485
14938
 
14486
14939
  stack.order = function(_) {
14487
- return arguments.length ? (order = _ == null ? none$2 : typeof _ === "function" ? _ : constant$10(slice$5.call(_)), stack) : order;
14940
+ return arguments.length ? (order = _ == null ? none$2 : typeof _ === "function" ? _ : constant$10(slice$6.call(_)), stack) : order;
14488
14941
  };
14489
14942
 
14490
14943
  stack.offset = function(_) {
@@ -14503,6 +14956,21 @@ var expand = function(series, order) {
14503
14956
  none$1(series, order);
14504
14957
  };
14505
14958
 
14959
+ var diverging = function(series, order) {
14960
+ if (!((n = series.length) > 1)) return;
14961
+ for (var i, j = 0, d, dy, yp, yn, n, m = series[order[0]].length; j < m; ++j) {
14962
+ for (yp = yn = 0, i = 0; i < n; ++i) {
14963
+ if ((dy = (d = series[order[i]][j])[1] - d[0]) >= 0) {
14964
+ d[0] = yp, d[1] = yp += dy;
14965
+ } else if (dy < 0) {
14966
+ d[1] = yn, d[0] = yn += dy;
14967
+ } else {
14968
+ d[0] = yp;
14969
+ }
14970
+ }
14971
+ }
14972
+ };
14973
+
14506
14974
  var silhouette = function(series, order) {
14507
14975
  if (!((n = series.length) > 0)) return;
14508
14976
  for (var j = 0, s0 = series[order[0]], n, m = s0.length; j < m; ++j) {
@@ -15522,13 +15990,13 @@ Diagram.prototype = {
15522
15990
  };
15523
15991
 
15524
15992
  var voronoi = function() {
15525
- var x$$1 = x$4,
15526
- y$$1 = y$4,
15993
+ var x = x$4,
15994
+ y = y$4,
15527
15995
  extent = null;
15528
15996
 
15529
15997
  function voronoi(data) {
15530
15998
  return new Diagram(data.map(function(d, i) {
15531
- var s = [Math.round(x$$1(d, i, data) / epsilon$4) * epsilon$4, Math.round(y$$1(d, i, data) / epsilon$4) * epsilon$4];
15999
+ var s = [Math.round(x(d, i, data) / epsilon$4) * epsilon$4, Math.round(y(d, i, data) / epsilon$4) * epsilon$4];
15532
16000
  s.index = i;
15533
16001
  s.data = d;
15534
16002
  return s;
@@ -15548,11 +16016,11 @@ var voronoi = function() {
15548
16016
  };
15549
16017
 
15550
16018
  voronoi.x = function(_) {
15551
- return arguments.length ? (x$$1 = typeof _ === "function" ? _ : constant$11(+_), voronoi) : x$$1;
16019
+ return arguments.length ? (x = typeof _ === "function" ? _ : constant$11(+_), voronoi) : x;
15552
16020
  };
15553
16021
 
15554
16022
  voronoi.y = function(_) {
15555
- return arguments.length ? (y$$1 = typeof _ === "function" ? _ : constant$11(+_), voronoi) : y$$1;
16023
+ return arguments.length ? (y = typeof _ === "function" ? _ : constant$11(+_), voronoi) : y;
15556
16024
  };
15557
16025
 
15558
16026
  voronoi.extent = function(_) {
@@ -15660,9 +16128,18 @@ function defaultTransform() {
15660
16128
  return this.__zoom || identity$8;
15661
16129
  }
15662
16130
 
16131
+ function defaultWheelDelta() {
16132
+ return -exports.event.deltaY * (exports.event.deltaMode ? 120 : 1) / 500;
16133
+ }
16134
+
16135
+ function touchable$1() {
16136
+ return "ontouchstart" in this;
16137
+ }
16138
+
15663
16139
  var zoom = function() {
15664
16140
  var filter = defaultFilter$2,
15665
16141
  extent = defaultExtent$1,
16142
+ wheelDelta = defaultWheelDelta,
15666
16143
  k0 = 0,
15667
16144
  k1 = Infinity,
15668
16145
  x0 = -k1,
@@ -15670,36 +16147,39 @@ var zoom = function() {
15670
16147
  y0 = x0,
15671
16148
  y1 = x1,
15672
16149
  duration = 250,
15673
- interpolate$$1 = interpolateZoom,
16150
+ interpolate = interpolateZoom,
15674
16151
  gestures = [],
15675
16152
  listeners = dispatch("start", "zoom", "end"),
15676
16153
  touchstarting,
15677
16154
  touchending,
15678
16155
  touchDelay = 500,
15679
- wheelDelay = 150;
16156
+ wheelDelay = 150,
16157
+ clickDistance2 = 0;
15680
16158
 
15681
16159
  function zoom(selection$$1) {
15682
16160
  selection$$1
16161
+ .property("__zoom", defaultTransform)
15683
16162
  .on("wheel.zoom", wheeled)
15684
16163
  .on("mousedown.zoom", mousedowned)
15685
16164
  .on("dblclick.zoom", dblclicked)
16165
+ .filter(touchable$1)
15686
16166
  .on("touchstart.zoom", touchstarted)
15687
16167
  .on("touchmove.zoom", touchmoved)
15688
16168
  .on("touchend.zoom touchcancel.zoom", touchended)
15689
- .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)")
15690
- .property("__zoom", defaultTransform);
16169
+ .style("touch-action", "none")
16170
+ .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
15691
16171
  }
15692
16172
 
15693
- zoom.transform = function(collection, transform) {
16173
+ zoom.transform = function(collection, transform$$1) {
15694
16174
  var selection$$1 = collection.selection ? collection.selection() : collection;
15695
16175
  selection$$1.property("__zoom", defaultTransform);
15696
16176
  if (collection !== selection$$1) {
15697
- schedule(collection, transform);
16177
+ schedule(collection, transform$$1);
15698
16178
  } else {
15699
16179
  selection$$1.interrupt().each(function() {
15700
16180
  gesture(this, arguments)
15701
16181
  .start()
15702
- .zoom(null, typeof transform === "function" ? transform.apply(this, arguments) : transform)
16182
+ .zoom(null, typeof transform$$1 === "function" ? transform$$1.apply(this, arguments) : transform$$1)
15703
16183
  .end();
15704
16184
  });
15705
16185
  }
@@ -15733,22 +16213,34 @@ var zoom = function() {
15733
16213
  });
15734
16214
  };
15735
16215
 
15736
- function scale(transform, k) {
16216
+ zoom.translateTo = function(selection$$1, x, y) {
16217
+ zoom.transform(selection$$1, function() {
16218
+ var e = extent.apply(this, arguments),
16219
+ t = this.__zoom,
16220
+ p = centroid(e);
16221
+ return constrain(identity$8.translate(p[0], p[1]).scale(t.k).translate(
16222
+ typeof x === "function" ? -x.apply(this, arguments) : -x,
16223
+ typeof y === "function" ? -y.apply(this, arguments) : -y
16224
+ ), e);
16225
+ });
16226
+ };
16227
+
16228
+ function scale(transform$$1, k) {
15737
16229
  k = Math.max(k0, Math.min(k1, k));
15738
- return k === transform.k ? transform : new Transform(k, transform.x, transform.y);
16230
+ return k === transform$$1.k ? transform$$1 : new Transform(k, transform$$1.x, transform$$1.y);
15739
16231
  }
15740
16232
 
15741
- function translate(transform, p0, p1) {
15742
- var x = p0[0] - p1[0] * transform.k, y = p0[1] - p1[1] * transform.k;
15743
- return x === transform.x && y === transform.y ? transform : new Transform(transform.k, x, y);
16233
+ function translate(transform$$1, p0, p1) {
16234
+ var x = p0[0] - p1[0] * transform$$1.k, y = p0[1] - p1[1] * transform$$1.k;
16235
+ return x === transform$$1.x && y === transform$$1.y ? transform$$1 : new Transform(transform$$1.k, x, y);
15744
16236
  }
15745
16237
 
15746
- function constrain(transform, extent) {
15747
- var dx0 = transform.invertX(extent[0][0]) - x0,
15748
- dx1 = transform.invertX(extent[1][0]) - x1,
15749
- dy0 = transform.invertY(extent[0][1]) - y0,
15750
- dy1 = transform.invertY(extent[1][1]) - y1;
15751
- return transform.translate(
16238
+ function constrain(transform$$1, extent) {
16239
+ var dx0 = transform$$1.invertX(extent[0][0]) - x0,
16240
+ dx1 = transform$$1.invertX(extent[1][0]) - x1,
16241
+ dy0 = transform$$1.invertY(extent[0][1]) - y0,
16242
+ dy1 = transform$$1.invertY(extent[1][1]) - y1;
16243
+ return transform$$1.translate(
15752
16244
  dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
15753
16245
  dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
15754
16246
  );
@@ -15758,7 +16250,7 @@ var zoom = function() {
15758
16250
  return [(+extent[0][0] + +extent[1][0]) / 2, (+extent[0][1] + +extent[1][1]) / 2];
15759
16251
  }
15760
16252
 
15761
- function schedule(transition$$1, transform, center) {
16253
+ function schedule(transition$$1, transform$$1, center) {
15762
16254
  transition$$1
15763
16255
  .on("start.zoom", function() { gesture(this, arguments).start(); })
15764
16256
  .on("interrupt.zoom end.zoom", function() { gesture(this, arguments).end(); })
@@ -15770,8 +16262,8 @@ var zoom = function() {
15770
16262
  p = center || centroid(e),
15771
16263
  w = Math.max(e[1][0] - e[0][0], e[1][1] - e[0][1]),
15772
16264
  a = that.__zoom,
15773
- b = typeof transform === "function" ? transform.apply(that, args) : transform,
15774
- i = interpolate$$1(a.invert(p).concat(w / a.k), b.invert(p).concat(w / b.k));
16265
+ b = typeof transform$$1 === "function" ? transform$$1.apply(that, args) : transform$$1,
16266
+ i = interpolate(a.invert(p).concat(w / a.k), b.invert(p).concat(w / b.k));
15775
16267
  return function(t) {
15776
16268
  if (t === 1) t = b; // Avoid rounding error on end.
15777
16269
  else { var l = i(t), k = w / l[2]; t = new Transform(k, p[0] - l[0] * k, p[1] - l[1] * k); }
@@ -15805,11 +16297,11 @@ var zoom = function() {
15805
16297
  }
15806
16298
  return this;
15807
16299
  },
15808
- zoom: function(key, transform) {
15809
- if (this.mouse && key !== "mouse") this.mouse[1] = transform.invert(this.mouse[0]);
15810
- if (this.touch0 && key !== "touch") this.touch0[1] = transform.invert(this.touch0[0]);
15811
- if (this.touch1 && key !== "touch") this.touch1[1] = transform.invert(this.touch1[0]);
15812
- this.that.__zoom = transform;
16300
+ zoom: function(key, transform$$1) {
16301
+ if (this.mouse && key !== "mouse") this.mouse[1] = transform$$1.invert(this.mouse[0]);
16302
+ if (this.touch0 && key !== "touch") this.touch0[1] = transform$$1.invert(this.touch0[0]);
16303
+ if (this.touch1 && key !== "touch") this.touch1[1] = transform$$1.invert(this.touch1[0]);
16304
+ this.that.__zoom = transform$$1;
15813
16305
  this.emit("zoom");
15814
16306
  return this;
15815
16307
  },
@@ -15830,7 +16322,7 @@ var zoom = function() {
15830
16322
  if (!filter.apply(this, arguments)) return;
15831
16323
  var g = gesture(this, arguments),
15832
16324
  t = this.__zoom,
15833
- k = Math.max(k0, Math.min(k1, t.k * Math.pow(2, -exports.event.deltaY * (exports.event.deltaMode ? 120 : 1) / 500))),
16325
+ k = Math.max(k0, Math.min(k1, t.k * Math.pow(2, wheelDelta.apply(this, arguments)))),
15834
16326
  p = mouse(this);
15835
16327
 
15836
16328
  // If the mouse is in the same location as before, reuse it.
@@ -15866,7 +16358,9 @@ var zoom = function() {
15866
16358
  if (touchending || !filter.apply(this, arguments)) return;
15867
16359
  var g = gesture(this, arguments),
15868
16360
  v = select(exports.event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true),
15869
- p = mouse(this);
16361
+ p = mouse(this),
16362
+ x0 = exports.event.clientX,
16363
+ y0 = exports.event.clientY;
15870
16364
 
15871
16365
  dragDisable(exports.event.view);
15872
16366
  nopropagation$2();
@@ -15876,7 +16370,10 @@ var zoom = function() {
15876
16370
 
15877
16371
  function mousemoved() {
15878
16372
  noevent$2();
15879
- g.moved = true;
16373
+ if (!g.moved) {
16374
+ var dx = exports.event.clientX - x0, dy = exports.event.clientY - y0;
16375
+ g.moved = dx * dx + dy * dy > clickDistance2;
16376
+ }
15880
16377
  g.zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = mouse(g.that), g.mouse[1]), g.extent));
15881
16378
  }
15882
16379
 
@@ -15975,9 +16472,14 @@ var zoom = function() {
15975
16472
  else if (g.touch1 && g.touch1[2] === t.identifier) delete g.touch1;
15976
16473
  }
15977
16474
  if (g.touch1 && !g.touch0) g.touch0 = g.touch1, delete g.touch1;
15978
- if (!g.touch0) g.end();
16475
+ if (g.touch0) g.touch0[1] = this.__zoom.invert(g.touch0[0]);
16476
+ else g.end();
15979
16477
  }
15980
16478
 
16479
+ zoom.wheelDelta = function(_) {
16480
+ return arguments.length ? (wheelDelta = typeof _ === "function" ? _ : constant$12(+_), zoom) : wheelDelta;
16481
+ };
16482
+
15981
16483
  zoom.filter = function(_) {
15982
16484
  return arguments.length ? (filter = typeof _ === "function" ? _ : constant$12(!!_), zoom) : filter;
15983
16485
  };
@@ -15999,7 +16501,7 @@ var zoom = function() {
15999
16501
  };
16000
16502
 
16001
16503
  zoom.interpolate = function(_) {
16002
- return arguments.length ? (interpolate$$1 = _, zoom) : interpolate$$1;
16504
+ return arguments.length ? (interpolate = _, zoom) : interpolate;
16003
16505
  };
16004
16506
 
16005
16507
  zoom.on = function() {
@@ -16007,6 +16509,10 @@ var zoom = function() {
16007
16509
  return value === listeners ? zoom : value;
16008
16510
  };
16009
16511
 
16512
+ zoom.clickDistance = function(_) {
16513
+ return arguments.length ? (clickDistance2 = (_ = +_) * _, zoom) : Math.sqrt(clickDistance2);
16514
+ };
16515
+
16010
16516
  return zoom;
16011
16517
  };
16012
16518
 
@@ -16016,6 +16522,7 @@ exports.bisectRight = bisectRight;
16016
16522
  exports.bisectLeft = bisectLeft;
16017
16523
  exports.ascending = ascending;
16018
16524
  exports.bisector = bisector;
16525
+ exports.cross = cross;
16019
16526
  exports.descending = descending;
16020
16527
  exports.deviation = deviation;
16021
16528
  exports.extent = extent;
@@ -16036,6 +16543,7 @@ exports.scan = scan;
16036
16543
  exports.shuffle = shuffle;
16037
16544
  exports.sum = sum;
16038
16545
  exports.ticks = ticks;
16546
+ exports.tickIncrement = tickIncrement;
16039
16547
  exports.tickStep = tickStep;
16040
16548
  exports.transpose = transpose;
16041
16549
  exports.variance = variance;
@@ -16130,6 +16638,7 @@ exports.geoBounds = bounds;
16130
16638
  exports.geoCentroid = centroid;
16131
16639
  exports.geoCircle = circle;
16132
16640
  exports.geoClipExtent = extent$1;
16641
+ exports.geoContains = contains;
16133
16642
  exports.geoDistance = distance;
16134
16643
  exports.geoGraticule = graticule;
16135
16644
  exports.geoGraticule10 = graticule10;
@@ -16208,7 +16717,7 @@ exports.path = path;
16208
16717
  exports.polygonArea = area$1;
16209
16718
  exports.polygonCentroid = centroid$1;
16210
16719
  exports.polygonHull = hull;
16211
- exports.polygonContains = contains;
16720
+ exports.polygonContains = contains$1;
16212
16721
  exports.polygonLength = length$2;
16213
16722
  exports.quadtree = quadtree;
16214
16723
  exports.queue = queue;
@@ -16234,7 +16743,7 @@ exports.scaleOrdinal = ordinal;
16234
16743
  exports.scaleImplicit = implicit;
16235
16744
  exports.scalePow = pow$1;
16236
16745
  exports.scaleSqrt = sqrt$1;
16237
- exports.scaleQuantile = quantile$$1;
16746
+ exports.scaleQuantile = quantile;
16238
16747
  exports.scaleQuantize = quantize$1;
16239
16748
  exports.scaleThreshold = threshold$1;
16240
16749
  exports.scaleTime = time;
@@ -16263,20 +16772,27 @@ exports.selectAll = selectAll;
16263
16772
  exports.selection = selection;
16264
16773
  exports.selector = selector;
16265
16774
  exports.selectorAll = selectorAll;
16775
+ exports.style = styleValue;
16266
16776
  exports.touch = touch;
16267
16777
  exports.touches = touches;
16268
- exports.window = window;
16778
+ exports.window = defaultView;
16269
16779
  exports.customEvent = customEvent;
16270
16780
  exports.arc = arc;
16271
16781
  exports.area = area$2;
16272
16782
  exports.line = line;
16273
16783
  exports.pie = pie;
16274
- exports.radialArea = radialArea;
16275
- exports.radialLine = radialLine$1;
16784
+ exports.areaRadial = areaRadial;
16785
+ exports.radialArea = areaRadial;
16786
+ exports.lineRadial = lineRadial$1;
16787
+ exports.radialLine = lineRadial$1;
16788
+ exports.pointRadial = pointRadial;
16789
+ exports.linkHorizontal = linkHorizontal;
16790
+ exports.linkVertical = linkVertical;
16791
+ exports.linkRadial = linkRadial;
16276
16792
  exports.symbol = symbol;
16277
16793
  exports.symbols = symbols;
16278
16794
  exports.symbolCircle = circle$2;
16279
- exports.symbolCross = cross$1;
16795
+ exports.symbolCross = cross$2;
16280
16796
  exports.symbolDiamond = diamond;
16281
16797
  exports.symbolSquare = square;
16282
16798
  exports.symbolStar = star;
@@ -16302,6 +16818,7 @@ exports.curveStepAfter = stepAfter;
16302
16818
  exports.curveStepBefore = stepBefore;
16303
16819
  exports.stack = stack;
16304
16820
  exports.stackOffsetExpand = expand;
16821
+ exports.stackOffsetDiverging = diverging;
16305
16822
  exports.stackOffsetNone = none$1;
16306
16823
  exports.stackOffsetSilhouette = silhouette;
16307
16824
  exports.stackOffsetWiggle = wiggle;