Project

General

Profile

1
!function() {
2
  var d3 = {
3
    version: "3.5.0"
4
  };
5
  if (!Date.now) Date.now = function() {
6
    return +new Date();
7
  };
8
  var d3_arraySlice = [].slice, d3_array = function(list) {
9
    return d3_arraySlice.call(list);
10
  };
11
  var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window;
12
  try {
13
    d3_array(d3_documentElement.childNodes)[0].nodeType;
14
  } catch (e) {
15
    d3_array = function(list) {
16
      var i = list.length, array = new Array(i);
17
      while (i--) array[i] = list[i];
18
      return array;
19
    };
20
  }
21
  try {
22
    d3_document.createElement("div").style.setProperty("opacity", 0, "");
23
  } catch (error) {
24
    var d3_element_prototype = d3_window.Element.prototype, d3_element_setAttribute = d3_element_prototype.setAttribute, d3_element_setAttributeNS = d3_element_prototype.setAttributeNS, d3_style_prototype = d3_window.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
25
    d3_element_prototype.setAttribute = function(name, value) {
26
      d3_element_setAttribute.call(this, name, value + "");
27
    };
28
    d3_element_prototype.setAttributeNS = function(space, local, value) {
29
      d3_element_setAttributeNS.call(this, space, local, value + "");
30
    };
31
    d3_style_prototype.setProperty = function(name, value, priority) {
32
      d3_style_setProperty.call(this, name, value + "", priority);
33
    };
34
  }
35
  d3.ascending = d3_ascending;
36
  function d3_ascending(a, b) {
37
    return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
38
  }
39
  d3.descending = function(a, b) {
40
    return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
41
  };
42
  d3.min = function(array, f) {
43
    var i = -1, n = array.length, a, b;
44
    if (arguments.length === 1) {
45
      while (++i < n) if ((b = array[i]) != null && b >= b) {
46
        a = b;
47
        break;
48
      }
49
      while (++i < n) if ((b = array[i]) != null && a > b) a = b;
50
    } else {
51
      while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
52
        a = b;
53
        break;
54
      }
55
      while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
56
    }
57
    return a;
58
  };
59
  d3.max = function(array, f) {
60
    var i = -1, n = array.length, a, b;
61
    if (arguments.length === 1) {
62
      while (++i < n) if ((b = array[i]) != null && b >= b) {
63
        a = b;
64
        break;
65
      }
66
      while (++i < n) if ((b = array[i]) != null && b > a) a = b;
67
    } else {
68
      while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
69
        a = b;
70
        break;
71
      }
72
      while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
73
    }
74
    return a;
75
  };
76
  d3.extent = function(array, f) {
77
    var i = -1, n = array.length, a, b, c;
78
    if (arguments.length === 1) {
79
      while (++i < n) if ((b = array[i]) != null && b >= b) {
80
        a = c = b;
81
        break;
82
      }
83
      while (++i < n) if ((b = array[i]) != null) {
84
        if (a > b) a = b;
85
        if (c < b) c = b;
86
      }
87
    } else {
88
      while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
89
        a = c = b;
90
        break;
91
      }
92
      while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
93
        if (a > b) a = b;
94
        if (c < b) c = b;
95
      }
96
    }
97
    return [ a, c ];
98
  };
99
  function d3_number(x) {
100
    return x === null ? NaN : +x;
101
  }
102
  function d3_numeric(x) {
103
    return !isNaN(x);
104
  }
105
  d3.sum = function(array, f) {
106
    var s = 0, n = array.length, a, i = -1;
107
    if (arguments.length === 1) {
108
      while (++i < n) if (d3_numeric(a = +array[i])) s += a;
109
    } else {
110
      while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a;
111
    }
112
    return s;
113
  };
114
  d3.mean = function(array, f) {
115
    var s = 0, n = array.length, a, i = -1, j = n;
116
    if (arguments.length === 1) {
117
      while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j;
118
    } else {
119
      while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j;
120
    }
121
    if (j) return s / j;
122
  };
123
  d3.quantile = function(values, p) {
124
    var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;
125
    return e ? v + e * (values[h] - v) : v;
126
  };
127
  d3.median = function(array, f) {
128
    var numbers = [], n = array.length, a, i = -1;
129
    if (arguments.length === 1) {
130
      while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a);
131
    } else {
132
      while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a);
133
    }
134
    if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5);
135
  };
136
  function d3_bisector(compare) {
137
    return {
138
      left: function(a, x, lo, hi) {
139
        if (arguments.length < 3) lo = 0;
140
        if (arguments.length < 4) hi = a.length;
141
        while (lo < hi) {
142
          var mid = lo + hi >>> 1;
143
          if (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid;
144
        }
145
        return lo;
146
      },
147
      right: function(a, x, lo, hi) {
148
        if (arguments.length < 3) lo = 0;
149
        if (arguments.length < 4) hi = a.length;
150
        while (lo < hi) {
151
          var mid = lo + hi >>> 1;
152
          if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1;
153
        }
154
        return lo;
155
      }
156
    };
157
  }
158
  var d3_bisect = d3_bisector(d3_ascending);
159
  d3.bisectLeft = d3_bisect.left;
160
  d3.bisect = d3.bisectRight = d3_bisect.right;
161
  d3.bisector = function(f) {
162
    return d3_bisector(f.length === 1 ? function(d, x) {
163
      return d3_ascending(f(d), x);
164
    } : f);
165
  };
166
  d3.shuffle = function(array, i0, i1) {
167
    if ((m = arguments.length) < 3) {
168
      i1 = array.length;
169
      if (m < 2) i0 = 0;
170
    }
171
    var m = i1 - i0, t, i;
172
    while (m) {
173
      i = Math.random() * m-- | 0;
174
      t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t;
175
    }
176
    return array;
177
  };
178
  d3.permute = function(array, indexes) {
179
    var i = indexes.length, permutes = new Array(i);
180
    while (i--) permutes[i] = array[indexes[i]];
181
    return permutes;
182
  };
183
  d3.pairs = function(array) {
184
    var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n);
185
    while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ];
186
    return pairs;
187
  };
188
  d3.zip = function() {
189
    if (!(n = arguments.length)) return [];
190
    for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) {
191
      for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n; ) {
192
        zip[j] = arguments[j][i];
193
      }
194
    }
195
    return zips;
196
  };
197
  function d3_zipLength(d) {
198
    return d.length;
199
  }
200
  d3.transpose = function(matrix) {
201
    return d3.zip.apply(d3, matrix);
202
  };
203
  d3.keys = function(map) {
204
    var keys = [];
205
    for (var key in map) keys.push(key);
206
    return keys;
207
  };
208
  d3.values = function(map) {
209
    var values = [];
210
    for (var key in map) values.push(map[key]);
211
    return values;
212
  };
213
  d3.entries = function(map) {
214
    var entries = [];
215
    for (var key in map) entries.push({
216
      key: key,
217
      value: map[key]
218
    });
219
    return entries;
220
  };
221
  d3.merge = function(arrays) {
222
    var n = arrays.length, m, i = -1, j = 0, merged, array;
223
    while (++i < n) j += arrays[i].length;
224
    merged = new Array(j);
225
    while (--n >= 0) {
226
      array = arrays[n];
227
      m = array.length;
228
      while (--m >= 0) {
229
        merged[--j] = array[m];
230
      }
231
    }
232
    return merged;
233
  };
234
  var abs = Math.abs;
235
  d3.range = function(start, stop, step) {
236
    if (arguments.length < 3) {
237
      step = 1;
238
      if (arguments.length < 2) {
239
        stop = start;
240
        start = 0;
241
      }
242
    }
243
    if ((stop - start) / step === Infinity) throw new Error("infinite range");
244
    var range = [], k = d3_range_integerScale(abs(step)), i = -1, j;
245
    start *= k, stop *= k, step *= k;
246
    if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k);
247
    return range;
248
  };
249
  function d3_range_integerScale(x) {
250
    var k = 1;
251
    while (x * k % 1) k *= 10;
252
    return k;
253
  }
254
  function d3_class(ctor, properties) {
255
    for (var key in properties) {
256
      Object.defineProperty(ctor.prototype, key, {
257
        value: properties[key],
258
        enumerable: false
259
      });
260
    }
261
  }
262
  d3.map = function(object, f) {
263
    var map = new d3_Map();
264
    if (object instanceof d3_Map) {
265
      object.forEach(function(key, value) {
266
        map.set(key, value);
267
      });
268
    } else if (Array.isArray(object)) {
269
      var i = -1, n = object.length, o;
270
      if (arguments.length === 1) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f.call(object, o = object[i], i), o);
271
    } else {
272
      for (var key in object) map.set(key, object[key]);
273
    }
274
    return map;
275
  };
276
  function d3_Map() {
277
    this._ = Object.create(null);
278
  }
279
  var d3_map_proto = "__proto__", d3_map_zero = "\x00";
280
  d3_class(d3_Map, {
281
    has: d3_map_has,
282
    get: function(key) {
283
      return this._[d3_map_escape(key)];
284
    },
285
    set: function(key, value) {
286
      return this._[d3_map_escape(key)] = value;
287
    },
288
    remove: d3_map_remove,
289
    keys: d3_map_keys,
290
    values: function() {
291
      var values = [];
292
      for (var key in this._) values.push(this._[key]);
293
      return values;
294
    },
295
    entries: function() {
296
      var entries = [];
297
      for (var key in this._) entries.push({
298
        key: d3_map_unescape(key),
299
        value: this._[key]
300
      });
301
      return entries;
302
    },
303
    size: d3_map_size,
304
    empty: d3_map_empty,
305
    forEach: function(f) {
306
      for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]);
307
    }
308
  });
309
  function d3_map_escape(key) {
310
    return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key;
311
  }
312
  function d3_map_unescape(key) {
313
    return (key += "")[0] === d3_map_zero ? key.slice(1) : key;
314
  }
315
  function d3_map_has(key) {
316
    return d3_map_escape(key) in this._;
317
  }
318
  function d3_map_remove(key) {
319
    return (key = d3_map_escape(key)) in this._ && delete this._[key];
320
  }
321
  function d3_map_keys() {
322
    var keys = [];
323
    for (var key in this._) keys.push(d3_map_unescape(key));
324
    return keys;
325
  }
326
  function d3_map_size() {
327
    var size = 0;
328
    for (var key in this._) ++size;
329
    return size;
330
  }
331
  function d3_map_empty() {
332
    for (var key in this._) return false;
333
    return true;
334
  }
335
  d3.nest = function() {
336
    var nest = {}, keys = [], sortKeys = [], sortValues, rollup;
337
    function map(mapType, array, depth) {
338
      if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array;
339
      var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values;
340
      while (++i < n) {
341
        if (values = valuesByKey.get(keyValue = key(object = array[i]))) {
342
          values.push(object);
343
        } else {
344
          valuesByKey.set(keyValue, [ object ]);
345
        }
346
      }
347
      if (mapType) {
348
        object = mapType();
349
        setter = function(keyValue, values) {
350
          object.set(keyValue, map(mapType, values, depth));
351
        };
352
      } else {
353
        object = {};
354
        setter = function(keyValue, values) {
355
          object[keyValue] = map(mapType, values, depth);
356
        };
357
      }
358
      valuesByKey.forEach(setter);
359
      return object;
360
    }
361
    function entries(map, depth) {
362
      if (depth >= keys.length) return map;
363
      var array = [], sortKey = sortKeys[depth++];
364
      map.forEach(function(key, keyMap) {
365
        array.push({
366
          key: key,
367
          values: entries(keyMap, depth)
368
        });
369
      });
370
      return sortKey ? array.sort(function(a, b) {
371
        return sortKey(a.key, b.key);
372
      }) : array;
373
    }
374
    nest.map = function(array, mapType) {
375
      return map(mapType, array, 0);
376
    };
377
    nest.entries = function(array) {
378
      return entries(map(d3.map, array, 0), 0);
379
    };
380
    nest.key = function(d) {
381
      keys.push(d);
382
      return nest;
383
    };
384
    nest.sortKeys = function(order) {
385
      sortKeys[keys.length - 1] = order;
386
      return nest;
387
    };
388
    nest.sortValues = function(order) {
389
      sortValues = order;
390
      return nest;
391
    };
392
    nest.rollup = function(f) {
393
      rollup = f;
394
      return nest;
395
    };
396
    return nest;
397
  };
398
  d3.set = function(array) {
399
    var set = new d3_Set();
400
    if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]);
401
    return set;
402
  };
403
  function d3_Set() {
404
    this._ = Object.create(null);
405
  }
406
  d3_class(d3_Set, {
407
    has: d3_map_has,
408
    add: function(key) {
409
      this._[d3_map_escape(key += "")] = true;
410
      return key;
411
    },
412
    remove: d3_map_remove,
413
    values: d3_map_keys,
414
    size: d3_map_size,
415
    empty: d3_map_empty,
416
    forEach: function(f) {
417
      for (var key in this._) f.call(this, d3_map_unescape(key));
418
    }
419
  });
420
  d3.behavior = {};
421
  d3.rebind = function(target, source) {
422
    var i = 1, n = arguments.length, method;
423
    while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);
424
    return target;
425
  };
426
  function d3_rebind(target, source, method) {
427
    return function() {
428
      var value = method.apply(source, arguments);
429
      return value === source ? target : value;
430
    };
431
  }
432
  function d3_vendorSymbol(object, name) {
433
    if (name in object) return name;
434
    name = name.charAt(0).toUpperCase() + name.slice(1);
435
    for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) {
436
      var prefixName = d3_vendorPrefixes[i] + name;
437
      if (prefixName in object) return prefixName;
438
    }
439
  }
440
  var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ];
441
  function d3_noop() {}
442
  d3.dispatch = function() {
443
    var dispatch = new d3_dispatch(), i = -1, n = arguments.length;
444
    while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
445
    return dispatch;
446
  };
447
  function d3_dispatch() {}
448
  d3_dispatch.prototype.on = function(type, listener) {
449
    var i = type.indexOf("."), name = "";
450
    if (i >= 0) {
451
      name = type.slice(i + 1);
452
      type = type.slice(0, i);
453
    }
454
    if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener);
455
    if (arguments.length === 2) {
456
      if (listener == null) for (type in this) {
457
        if (this.hasOwnProperty(type)) this[type].on(name, null);
458
      }
459
      return this;
460
    }
461
  };
462
  function d3_dispatch_event(dispatch) {
463
    var listeners = [], listenerByName = new d3_Map();
464
    function event() {
465
      var z = listeners, i = -1, n = z.length, l;
466
      while (++i < n) if (l = z[i].on) l.apply(this, arguments);
467
      return dispatch;
468
    }
469
    event.on = function(name, listener) {
470
      var l = listenerByName.get(name), i;
471
      if (arguments.length < 2) return l && l.on;
472
      if (l) {
473
        l.on = null;
474
        listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));
475
        listenerByName.remove(name);
476
      }
477
      if (listener) listeners.push(listenerByName.set(name, {
478
        on: listener
479
      }));
480
      return dispatch;
481
    };
482
    return event;
483
  }
484
  d3.event = null;
485
  function d3_eventPreventDefault() {
486
    d3.event.preventDefault();
487
  }
488
  function d3_eventSource() {
489
    var e = d3.event, s;
490
    while (s = e.sourceEvent) e = s;
491
    return e;
492
  }
493
  function d3_eventDispatch(target) {
494
    var dispatch = new d3_dispatch(), i = 0, n = arguments.length;
495
    while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
496
    dispatch.of = function(thiz, argumentz) {
497
      return function(e1) {
498
        try {
499
          var e0 = e1.sourceEvent = d3.event;
500
          e1.target = target;
501
          d3.event = e1;
502
          dispatch[e1.type].apply(thiz, argumentz);
503
        } finally {
504
          d3.event = e0;
505
        }
506
      };
507
    };
508
    return dispatch;
509
  }
510
  d3.requote = function(s) {
511
    return s.replace(d3_requote_re, "\\$&");
512
  };
513
  var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
514
  var d3_subclass = {}.__proto__ ? function(object, prototype) {
515
    object.__proto__ = prototype;
516
  } : function(object, prototype) {
517
    for (var property in prototype) object[property] = prototype[property];
518
  };
519
  function d3_selection(groups) {
520
    d3_subclass(groups, d3_selectionPrototype);
521
    return groups;
522
  }
523
  var d3_select = function(s, n) {
524
    return n.querySelector(s);
525
  }, d3_selectAll = function(s, n) {
526
    return n.querySelectorAll(s);
527
  }, d3_selectMatcher = d3_documentElement.matches || d3_documentElement[d3_vendorSymbol(d3_documentElement, "matchesSelector")], d3_selectMatches = function(n, s) {
528
    return d3_selectMatcher.call(n, s);
529
  };
530
  if (typeof Sizzle === "function") {
531
    d3_select = function(s, n) {
532
      return Sizzle(s, n)[0] || null;
533
    };
534
    d3_selectAll = Sizzle;
535
    d3_selectMatches = Sizzle.matchesSelector;
536
  }
537
  d3.selection = function() {
538
    return d3_selectionRoot;
539
  };
540
  var d3_selectionPrototype = d3.selection.prototype = [];
541
  d3_selectionPrototype.select = function(selector) {
542
    var subgroups = [], subgroup, subnode, group, node;
543
    selector = d3_selection_selector(selector);
544
    for (var j = -1, m = this.length; ++j < m; ) {
545
      subgroups.push(subgroup = []);
546
      subgroup.parentNode = (group = this[j]).parentNode;
547
      for (var i = -1, n = group.length; ++i < n; ) {
548
        if (node = group[i]) {
549
          subgroup.push(subnode = selector.call(node, node.__data__, i, j));
550
          if (subnode && "__data__" in node) subnode.__data__ = node.__data__;
551
        } else {
552
          subgroup.push(null);
553
        }
554
      }
555
    }
556
    return d3_selection(subgroups);
557
  };
558
  function d3_selection_selector(selector) {
559
    return typeof selector === "function" ? selector : function() {
560
      return d3_select(selector, this);
561
    };
562
  }
563
  d3_selectionPrototype.selectAll = function(selector) {
564
    var subgroups = [], subgroup, node;
565
    selector = d3_selection_selectorAll(selector);
566
    for (var j = -1, m = this.length; ++j < m; ) {
567
      for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
568
        if (node = group[i]) {
569
          subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j)));
570
          subgroup.parentNode = node;
571
        }
572
      }
573
    }
574
    return d3_selection(subgroups);
575
  };
576
  function d3_selection_selectorAll(selector) {
577
    return typeof selector === "function" ? selector : function() {
578
      return d3_selectAll(selector, this);
579
    };
580
  }
581
  var d3_nsPrefix = {
582
    svg: "http://www.w3.org/2000/svg",
583
    xhtml: "http://www.w3.org/1999/xhtml",
584
    xlink: "http://www.w3.org/1999/xlink",
585
    xml: "http://www.w3.org/XML/1998/namespace",
586
    xmlns: "http://www.w3.org/2000/xmlns/"
587
  };
588
  d3.ns = {
589
    prefix: d3_nsPrefix,
590
    qualify: function(name) {
591
      var i = name.indexOf(":"), prefix = name;
592
      if (i >= 0) {
593
        prefix = name.slice(0, i);
594
        name = name.slice(i + 1);
595
      }
596
      return d3_nsPrefix.hasOwnProperty(prefix) ? {
597
        space: d3_nsPrefix[prefix],
598
        local: name
599
      } : name;
600
    }
601
  };
602
  d3_selectionPrototype.attr = function(name, value) {
603
    if (arguments.length < 2) {
604
      if (typeof name === "string") {
605
        var node = this.node();
606
        name = d3.ns.qualify(name);
607
        return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name);
608
      }
609
      for (value in name) this.each(d3_selection_attr(value, name[value]));
610
      return this;
611
    }
612
    return this.each(d3_selection_attr(name, value));
613
  };
614
  function d3_selection_attr(name, value) {
615
    name = d3.ns.qualify(name);
616
    function attrNull() {
617
      this.removeAttribute(name);
618
    }
619
    function attrNullNS() {
620
      this.removeAttributeNS(name.space, name.local);
621
    }
622
    function attrConstant() {
623
      this.setAttribute(name, value);
624
    }
625
    function attrConstantNS() {
626
      this.setAttributeNS(name.space, name.local, value);
627
    }
628
    function attrFunction() {
629
      var x = value.apply(this, arguments);
630
      if (x == null) this.removeAttribute(name); else this.setAttribute(name, x);
631
    }
632
    function attrFunctionNS() {
633
      var x = value.apply(this, arguments);
634
      if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x);
635
    }
636
    return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant;
637
  }
638
  function d3_collapse(s) {
639
    return s.trim().replace(/\s+/g, " ");
640
  }
641
  d3_selectionPrototype.classed = function(name, value) {
642
    if (arguments.length < 2) {
643
      if (typeof name === "string") {
644
        var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1;
645
        if (value = node.classList) {
646
          while (++i < n) if (!value.contains(name[i])) return false;
647
        } else {
648
          value = node.getAttribute("class");
649
          while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false;
650
        }
651
        return true;
652
      }
653
      for (value in name) this.each(d3_selection_classed(value, name[value]));
654
      return this;
655
    }
656
    return this.each(d3_selection_classed(name, value));
657
  };
658
  function d3_selection_classedRe(name) {
659
    return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g");
660
  }
661
  function d3_selection_classes(name) {
662
    return (name + "").trim().split(/^|\s+/);
663
  }
664
  function d3_selection_classed(name, value) {
665
    name = d3_selection_classes(name).map(d3_selection_classedName);
666
    var n = name.length;
667
    function classedConstant() {
668
      var i = -1;
669
      while (++i < n) name[i](this, value);
670
    }
671
    function classedFunction() {
672
      var i = -1, x = value.apply(this, arguments);
673
      while (++i < n) name[i](this, x);
674
    }
675
    return typeof value === "function" ? classedFunction : classedConstant;
676
  }
677
  function d3_selection_classedName(name) {
678
    var re = d3_selection_classedRe(name);
679
    return function(node, value) {
680
      if (c = node.classList) return value ? c.add(name) : c.remove(name);
681
      var c = node.getAttribute("class") || "";
682
      if (value) {
683
        re.lastIndex = 0;
684
        if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name));
685
      } else {
686
        node.setAttribute("class", d3_collapse(c.replace(re, " ")));
687
      }
688
    };
689
  }
690
  d3_selectionPrototype.style = function(name, value, priority) {
691
    var n = arguments.length;
692
    if (n < 3) {
693
      if (typeof name !== "string") {
694
        if (n < 2) value = "";
695
        for (priority in name) this.each(d3_selection_style(priority, name[priority], value));
696
        return this;
697
      }
698
      if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name);
699
      priority = "";
700
    }
701
    return this.each(d3_selection_style(name, value, priority));
702
  };
703
  function d3_selection_style(name, value, priority) {
704
    function styleNull() {
705
      this.style.removeProperty(name);
706
    }
707
    function styleConstant() {
708
      this.style.setProperty(name, value, priority);
709
    }
710
    function styleFunction() {
711
      var x = value.apply(this, arguments);
712
      if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority);
713
    }
714
    return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant;
715
  }
716
  d3_selectionPrototype.property = function(name, value) {
717
    if (arguments.length < 2) {
718
      if (typeof name === "string") return this.node()[name];
719
      for (value in name) this.each(d3_selection_property(value, name[value]));
720
      return this;
721
    }
722
    return this.each(d3_selection_property(name, value));
723
  };
724
  function d3_selection_property(name, value) {
725
    function propertyNull() {
726
      delete this[name];
727
    }
728
    function propertyConstant() {
729
      this[name] = value;
730
    }
731
    function propertyFunction() {
732
      var x = value.apply(this, arguments);
733
      if (x == null) delete this[name]; else this[name] = x;
734
    }
735
    return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant;
736
  }
737
  d3_selectionPrototype.text = function(value) {
738
    return arguments.length ? this.each(typeof value === "function" ? function() {
739
      var v = value.apply(this, arguments);
740
      this.textContent = v == null ? "" : v;
741
    } : value == null ? function() {
742
      this.textContent = "";
743
    } : function() {
744
      this.textContent = value;
745
    }) : this.node().textContent;
746
  };
747
  d3_selectionPrototype.html = function(value) {
748
    return arguments.length ? this.each(typeof value === "function" ? function() {
749
      var v = value.apply(this, arguments);
750
      this.innerHTML = v == null ? "" : v;
751
    } : value == null ? function() {
752
      this.innerHTML = "";
753
    } : function() {
754
      this.innerHTML = value;
755
    }) : this.node().innerHTML;
756
  };
757
  d3_selectionPrototype.append = function(name) {
758
    name = d3_selection_creator(name);
759
    return this.select(function() {
760
      return this.appendChild(name.apply(this, arguments));
761
    });
762
  };
763
  function d3_selection_creator(name) {
764
    return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? function() {
765
      return this.ownerDocument.createElementNS(name.space, name.local);
766
    } : function() {
767
      return this.ownerDocument.createElementNS(this.namespaceURI, name);
768
    };
769
  }
770
  d3_selectionPrototype.insert = function(name, before) {
771
    name = d3_selection_creator(name);
772
    before = d3_selection_selector(before);
773
    return this.select(function() {
774
      return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null);
775
    });
776
  };
777
  d3_selectionPrototype.remove = function() {
778
    return this.each(d3_selectionRemove);
779
  };
780
  function d3_selectionRemove() {
781
    var parent = this.parentNode;
782
    if (parent) parent.removeChild(this);
783
  }
784
  d3_selectionPrototype.data = function(value, key) {
785
    var i = -1, n = this.length, group, node;
786
    if (!arguments.length) {
787
      value = new Array(n = (group = this[0]).length);
788
      while (++i < n) {
789
        if (node = group[i]) {
790
          value[i] = node.__data__;
791
        }
792
      }
793
      return value;
794
    }
795
    function bind(group, groupData) {
796
      var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData;
797
      if (key) {
798
        var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue;
799
        for (i = -1; ++i < n; ) {
800
          if (nodeByKeyValue.has(keyValue = key.call(node = group[i], node.__data__, i))) {
801
            exitNodes[i] = node;
802
          } else {
803
            nodeByKeyValue.set(keyValue, node);
804
          }
805
          keyValues[i] = keyValue;
806
        }
807
        for (i = -1; ++i < m; ) {
808
          if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) {
809
            enterNodes[i] = d3_selection_dataNode(nodeData);
810
          } else if (node !== true) {
811
            updateNodes[i] = node;
812
            node.__data__ = nodeData;
813
          }
814
          nodeByKeyValue.set(keyValue, true);
815
        }
816
        for (i = -1; ++i < n; ) {
817
          if (nodeByKeyValue.get(keyValues[i]) !== true) {
818
            exitNodes[i] = group[i];
819
          }
820
        }
821
      } else {
822
        for (i = -1; ++i < n0; ) {
823
          node = group[i];
824
          nodeData = groupData[i];
825
          if (node) {
826
            node.__data__ = nodeData;
827
            updateNodes[i] = node;
828
          } else {
829
            enterNodes[i] = d3_selection_dataNode(nodeData);
830
          }
831
        }
832
        for (;i < m; ++i) {
833
          enterNodes[i] = d3_selection_dataNode(groupData[i]);
834
        }
835
        for (;i < n; ++i) {
836
          exitNodes[i] = group[i];
837
        }
838
      }
839
      enterNodes.update = updateNodes;
840
      enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode;
841
      enter.push(enterNodes);
842
      update.push(updateNodes);
843
      exit.push(exitNodes);
844
    }
845
    var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]);
846
    if (typeof value === "function") {
847
      while (++i < n) {
848
        bind(group = this[i], value.call(group, group.parentNode.__data__, i));
849
      }
850
    } else {
851
      while (++i < n) {
852
        bind(group = this[i], value);
853
      }
854
    }
855
    update.enter = function() {
856
      return enter;
857
    };
858
    update.exit = function() {
859
      return exit;
860
    };
861
    return update;
862
  };
863
  function d3_selection_dataNode(data) {
864
    return {
865
      __data__: data
866
    };
867
  }
868
  d3_selectionPrototype.datum = function(value) {
869
    return arguments.length ? this.property("__data__", value) : this.property("__data__");
870
  };
871
  d3_selectionPrototype.filter = function(filter) {
872
    var subgroups = [], subgroup, group, node;
873
    if (typeof filter !== "function") filter = d3_selection_filter(filter);
874
    for (var j = 0, m = this.length; j < m; j++) {
875
      subgroups.push(subgroup = []);
876
      subgroup.parentNode = (group = this[j]).parentNode;
877
      for (var i = 0, n = group.length; i < n; i++) {
878
        if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {
879
          subgroup.push(node);
880
        }
881
      }
882
    }
883
    return d3_selection(subgroups);
884
  };
885
  function d3_selection_filter(selector) {
886
    return function() {
887
      return d3_selectMatches(this, selector);
888
    };
889
  }
890
  d3_selectionPrototype.order = function() {
891
    for (var j = -1, m = this.length; ++j < m; ) {
892
      for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) {
893
        if (node = group[i]) {
894
          if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
895
          next = node;
896
        }
897
      }
898
    }
899
    return this;
900
  };
901
  d3_selectionPrototype.sort = function(comparator) {
902
    comparator = d3_selection_sortComparator.apply(this, arguments);
903
    for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator);
904
    return this.order();
905
  };
906
  function d3_selection_sortComparator(comparator) {
907
    if (!arguments.length) comparator = d3_ascending;
908
    return function(a, b) {
909
      return a && b ? comparator(a.__data__, b.__data__) : !a - !b;
910
    };
911
  }
912
  d3_selectionPrototype.each = function(callback) {
913
    return d3_selection_each(this, function(node, i, j) {
914
      callback.call(node, node.__data__, i, j);
915
    });
916
  };
917
  function d3_selection_each(groups, callback) {
918
    for (var j = 0, m = groups.length; j < m; j++) {
919
      for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {
920
        if (node = group[i]) callback(node, i, j);
921
      }
922
    }
923
    return groups;
924
  }
925
  d3_selectionPrototype.call = function(callback) {
926
    var args = d3_array(arguments);
927
    callback.apply(args[0] = this, args);
928
    return this;
929
  };
930
  d3_selectionPrototype.empty = function() {
931
    return !this.node();
932
  };
933
  d3_selectionPrototype.node = function() {
934
    for (var j = 0, m = this.length; j < m; j++) {
935
      for (var group = this[j], i = 0, n = group.length; i < n; i++) {
936
        var node = group[i];
937
        if (node) return node;
938
      }
939
    }
940
    return null;
941
  };
942
  d3_selectionPrototype.size = function() {
943
    var n = 0;
944
    d3_selection_each(this, function() {
945
      ++n;
946
    });
947
    return n;
948
  };
949
  function d3_selection_enter(selection) {
950
    d3_subclass(selection, d3_selection_enterPrototype);
951
    return selection;
952
  }
953
  var d3_selection_enterPrototype = [];
954
  d3.selection.enter = d3_selection_enter;
955
  d3.selection.enter.prototype = d3_selection_enterPrototype;
956
  d3_selection_enterPrototype.append = d3_selectionPrototype.append;
957
  d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;
958
  d3_selection_enterPrototype.node = d3_selectionPrototype.node;
959
  d3_selection_enterPrototype.call = d3_selectionPrototype.call;
960
  d3_selection_enterPrototype.size = d3_selectionPrototype.size;
961
  d3_selection_enterPrototype.select = function(selector) {
962
    var subgroups = [], subgroup, subnode, upgroup, group, node;
963
    for (var j = -1, m = this.length; ++j < m; ) {
964
      upgroup = (group = this[j]).update;
965
      subgroups.push(subgroup = []);
966
      subgroup.parentNode = group.parentNode;
967
      for (var i = -1, n = group.length; ++i < n; ) {
968
        if (node = group[i]) {
969
          subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j));
970
          subnode.__data__ = node.__data__;
971
        } else {
972
          subgroup.push(null);
973
        }
974
      }
975
    }
976
    return d3_selection(subgroups);
977
  };
978
  d3_selection_enterPrototype.insert = function(name, before) {
979
    if (arguments.length < 2) before = d3_selection_enterInsertBefore(this);
980
    return d3_selectionPrototype.insert.call(this, name, before);
981
  };
982
  function d3_selection_enterInsertBefore(enter) {
983
    var i0, j0;
984
    return function(d, i, j) {
985
      var group = enter[j].update, n = group.length, node;
986
      if (j != j0) j0 = j, i0 = 0;
987
      if (i >= i0) i0 = i + 1;
988
      while (!(node = group[i0]) && ++i0 < n) ;
989
      return node;
990
    };
991
  }
992
  d3_selectionPrototype.transition = function(name) {
993
    var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || {
994
      time: Date.now(),
995
      ease: d3_ease_cubicInOut,
996
      delay: 0,
997
      duration: 250
998
    };
999
    for (var j = -1, m = this.length; ++j < m; ) {
1000
      subgroups.push(subgroup = []);
1001
      for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
1002
        if (node = group[i]) d3_transitionNode(node, i, ns, id, transition);
1003
        subgroup.push(node);
1004
      }
1005
    }
1006
    return d3_transition(subgroups, ns, id);
1007
  };
1008
  d3_selectionPrototype.interrupt = function(name) {
1009
    var ns = d3_transitionNamespace(name);
1010
    return this.each(function() {
1011
      var lock = this[ns];
1012
      if (lock) ++lock.active;
1013
    });
1014
  };
1015
  function d3_selection_interrupt(that) {
1016
    var lock = that.__transition__;
1017
    if (lock) ++lock.active;
1018
  }
1019
  d3.select = function(node) {
1020
    var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ];
1021
    group.parentNode = d3_documentElement;
1022
    return d3_selection([ group ]);
1023
  };
1024
  d3.selectAll = function(nodes) {
1025
    var group = d3_array(typeof nodes === "string" ? d3_selectAll(nodes, d3_document) : nodes);
1026
    group.parentNode = d3_documentElement;
1027
    return d3_selection([ group ]);
1028
  };
1029
  var d3_selectionRoot = d3.select(d3_documentElement);
1030
  d3_selectionPrototype.on = function(type, listener, capture) {
1031
    var n = arguments.length;
1032
    if (n < 3) {
1033
      if (typeof type !== "string") {
1034
        if (n < 2) listener = false;
1035
        for (capture in type) this.each(d3_selection_on(capture, type[capture], listener));
1036
        return this;
1037
      }
1038
      if (n < 2) return (n = this.node()["__on" + type]) && n._;
1039
      capture = false;
1040
    }
1041
    return this.each(d3_selection_on(type, listener, capture));
1042
  };
1043
  function d3_selection_on(type, listener, capture) {
1044
    var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener;
1045
    if (i > 0) type = type.slice(0, i);
1046
    var filter = d3_selection_onFilters.get(type);
1047
    if (filter) type = filter, wrap = d3_selection_onFilter;
1048
    function onRemove() {
1049
      var l = this[name];
1050
      if (l) {
1051
        this.removeEventListener(type, l, l.$);
1052
        delete this[name];
1053
      }
1054
    }
1055
    function onAdd() {
1056
      var l = wrap(listener, d3_array(arguments));
1057
      onRemove.call(this);
1058
      this.addEventListener(type, this[name] = l, l.$ = capture);
1059
      l._ = listener;
1060
    }
1061
    function removeAll() {
1062
      var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match;
1063
      for (var name in this) {
1064
        if (match = name.match(re)) {
1065
          var l = this[name];
1066
          this.removeEventListener(match[1], l, l.$);
1067
          delete this[name];
1068
        }
1069
      }
1070
    }
1071
    return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll;
1072
  }
1073
  var d3_selection_onFilters = d3.map({
1074
    mouseenter: "mouseover",
1075
    mouseleave: "mouseout"
1076
  });
1077
  d3_selection_onFilters.forEach(function(k) {
1078
    if ("on" + k in d3_document) d3_selection_onFilters.remove(k);
1079
  });
1080
  function d3_selection_onListener(listener, argumentz) {
1081
    return function(e) {
1082
      var o = d3.event;
1083
      d3.event = e;
1084
      argumentz[0] = this.__data__;
1085
      try {
1086
        listener.apply(this, argumentz);
1087
      } finally {
1088
        d3.event = o;
1089
      }
1090
    };
1091
  }
1092
  function d3_selection_onFilter(listener, argumentz) {
1093
    var l = d3_selection_onListener(listener, argumentz);
1094
    return function(e) {
1095
      var target = this, related = e.relatedTarget;
1096
      if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) {
1097
        l.call(target, e);
1098
      }
1099
    };
1100
  }
1101
  var d3_event_dragSelect = "onselectstart" in d3_document ? null : d3_vendorSymbol(d3_documentElement.style, "userSelect"), d3_event_dragId = 0;
1102
  function d3_event_dragSuppress() {
1103
    var name = ".dragsuppress-" + ++d3_event_dragId, click = "click" + name, w = d3.select(d3_window).on("touchmove" + name, d3_eventPreventDefault).on("dragstart" + name, d3_eventPreventDefault).on("selectstart" + name, d3_eventPreventDefault);
1104
    if (d3_event_dragSelect) {
1105
      var style = d3_documentElement.style, select = style[d3_event_dragSelect];
1106
      style[d3_event_dragSelect] = "none";
1107
    }
1108
    return function(suppressClick) {
1109
      w.on(name, null);
1110
      if (d3_event_dragSelect) style[d3_event_dragSelect] = select;
1111
      if (suppressClick) {
1112
        var off = function() {
1113
          w.on(click, null);
1114
        };
1115
        w.on(click, function() {
1116
          d3_eventPreventDefault();
1117
          off();
1118
        }, true);
1119
        setTimeout(off, 0);
1120
      }
1121
    };
1122
  }
1123
  d3.mouse = function(container) {
1124
    return d3_mousePoint(container, d3_eventSource());
1125
  };
1126
  var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0;
1127
  function d3_mousePoint(container, e) {
1128
    if (e.changedTouches) e = e.changedTouches[0];
1129
    var svg = container.ownerSVGElement || container;
1130
    if (svg.createSVGPoint) {
1131
      var point = svg.createSVGPoint();
1132
      if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) {
1133
        svg = d3.select("body").append("svg").style({
1134
          position: "absolute",
1135
          top: 0,
1136
          left: 0,
1137
          margin: 0,
1138
          padding: 0,
1139
          border: "none"
1140
        }, "important");
1141
        var ctm = svg[0][0].getScreenCTM();
1142
        d3_mouse_bug44083 = !(ctm.f || ctm.e);
1143
        svg.remove();
1144
      }
1145
      if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX, 
1146
      point.y = e.clientY;
1147
      point = point.matrixTransform(container.getScreenCTM().inverse());
1148
      return [ point.x, point.y ];
1149
    }
1150
    var rect = container.getBoundingClientRect();
1151
    return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];
1152
  }
1153
  d3.touch = function(container, touches, identifier) {
1154
    if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches;
1155
    if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) {
1156
      if ((touch = touches[i]).identifier === identifier) {
1157
        return d3_mousePoint(container, touch);
1158
      }
1159
    }
1160
  };
1161
  d3.behavior.drag = function() {
1162
    var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_behavior_dragMouseSubject, "mousemove", "mouseup"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_behavior_dragTouchSubject, "touchmove", "touchend");
1163
    function drag() {
1164
      this.on("mousedown.drag", mousedown).on("touchstart.drag", touchstart);
1165
    }
1166
    function dragstart(id, position, subject, move, end) {
1167
      return function() {
1168
        var that = this, target = d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = ".drag" + (dragId == null ? "" : "-" + dragId), dragOffset, dragSubject = d3.select(subject()).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(), position0 = position(parent, dragId);
1169
        if (origin) {
1170
          dragOffset = origin.apply(that, arguments);
1171
          dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ];
1172
        } else {
1173
          dragOffset = [ 0, 0 ];
1174
        }
1175
        dispatch({
1176
          type: "dragstart"
1177
        });
1178
        function moved() {
1179
          var position1 = position(parent, dragId), dx, dy;
1180
          if (!position1) return;
1181
          dx = position1[0] - position0[0];
1182
          dy = position1[1] - position0[1];
1183
          dragged |= dx | dy;
1184
          position0 = position1;
1185
          dispatch({
1186
            type: "drag",
1187
            x: position1[0] + dragOffset[0],
1188
            y: position1[1] + dragOffset[1],
1189
            dx: dx,
1190
            dy: dy
1191
          });
1192
        }
1193
        function ended() {
1194
          if (!position(parent, dragId)) return;
1195
          dragSubject.on(move + dragName, null).on(end + dragName, null);
1196
          dragRestore(dragged && d3.event.target === target);
1197
          dispatch({
1198
            type: "dragend"
1199
          });
1200
        }
1201
      };
1202
    }
1203
    drag.origin = function(x) {
1204
      if (!arguments.length) return origin;
1205
      origin = x;
1206
      return drag;
1207
    };
1208
    return d3.rebind(drag, event, "on");
1209
  };
1210
  function d3_behavior_dragTouchId() {
1211
    return d3.event.changedTouches[0].identifier;
1212
  }
1213
  function d3_behavior_dragTouchSubject() {
1214
    return d3.event.target;
1215
  }
1216
  function d3_behavior_dragMouseSubject() {
1217
    return d3_window;
1218
  }
1219
  d3.touches = function(container, touches) {
1220
    if (arguments.length < 2) touches = d3_eventSource().touches;
1221
    return touches ? d3_array(touches).map(function(touch) {
1222
      var point = d3_mousePoint(container, touch);
1223
      point.identifier = touch.identifier;
1224
      return point;
1225
    }) : [];
1226
  };
1227
  var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
1228
  function d3_sgn(x) {
1229
    return x > 0 ? 1 : x < 0 ? -1 : 0;
1230
  }
1231
  function d3_cross2d(a, b, c) {
1232
    return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
1233
  }
1234
  function d3_acos(x) {
1235
    return x > 1 ? 0 : x < -1 ? π : Math.acos(x);
1236
  }
1237
  function d3_asin(x) {
1238
    return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x);
1239
  }
1240
  function d3_sinh(x) {
1241
    return ((x = Math.exp(x)) - 1 / x) / 2;
1242
  }
1243
  function d3_cosh(x) {
1244
    return ((x = Math.exp(x)) + 1 / x) / 2;
1245
  }
1246
  function d3_tanh(x) {
1247
    return ((x = Math.exp(2 * x)) - 1) / (x + 1);
1248
  }
1249
  function d3_haversin(x) {
1250
    return (x = Math.sin(x / 2)) * x;
1251
  }
1252
  var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4;
1253
  d3.interpolateZoom = function(p0, p1) {
1254
    var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2];
1255
    var dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1), dr = r1 - r0, S = (dr || Math.log(w1 / w0)) / ρ;
1256
    function interpolate(t) {
1257
      var s = t * S;
1258
      if (dr) {
1259
        var coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0));
1260
        return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ];
1261
      }
1262
      return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * s) ];
1263
    }
1264
    interpolate.duration = S * 1e3;
1265
    return interpolate;
1266
  };
1267
  d3.behavior.zoom = function() {
1268
    var view = {
1269
      x: 0,
1270
      y: 0,
1271
      k: 1
1272
    }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, duration = 250, zooming = 0, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1;
1273
    function zoom(g) {
1274
      g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1275
    }
1276
    zoom.event = function(g) {
1277
      g.each(function() {
1278
        var dispatch = event.of(this, arguments), view1 = view;
1279
        if (d3_transitionInheritId) {
1280
          d3.select(this).transition().each("start.zoom", function() {
1281
            view = this.__chart__ || {
1282
              x: 0,
1283
              y: 0,
1284
              k: 1
1285
            };
1286
            zoomstarted(dispatch);
1287
          }).tween("zoom:zoom", function() {
1288
            var dx = size[0], dy = size[1], cx = center0 ? center0[0] : dx / 2, cy = center0 ? center0[1] : dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]);
1289
            return function(t) {
1290
              var l = i(t), k = dx / l[2];
1291
              this.__chart__ = view = {
1292
                x: cx - l[0] * k,
1293
                y: cy - l[1] * k,
1294
                k: k
1295
              };
1296
              zoomed(dispatch);
1297
            };
1298
          }).each("interrupt.zoom", function() {
1299
            zoomended(dispatch);
1300
          }).each("end.zoom", function() {
1301
            zoomended(dispatch);
1302
          });
1303
        } else {
1304
          this.__chart__ = view;
1305
          zoomstarted(dispatch);
1306
          zoomed(dispatch);
1307
          zoomended(dispatch);
1308
        }
1309
      });
1310
    };
1311
    zoom.translate = function(_) {
1312
      if (!arguments.length) return [ view.x, view.y ];
1313
      view = {
1314
        x: +_[0],
1315
        y: +_[1],
1316
        k: view.k
1317
      };
1318
      rescale();
1319
      return zoom;
1320
    };
1321
    zoom.scale = function(_) {
1322
      if (!arguments.length) return view.k;
1323
      view = {
1324
        x: view.x,
1325
        y: view.y,
1326
        k: +_
1327
      };
1328
      rescale();
1329
      return zoom;
1330
    };
1331
    zoom.scaleExtent = function(_) {
1332
      if (!arguments.length) return scaleExtent;
1333
      scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ];
1334
      return zoom;
1335
    };
1336
    zoom.center = function(_) {
1337
      if (!arguments.length) return center;
1338
      center = _ && [ +_[0], +_[1] ];
1339
      return zoom;
1340
    };
1341
    zoom.size = function(_) {
1342
      if (!arguments.length) return size;
1343
      size = _ && [ +_[0], +_[1] ];
1344
      return zoom;
1345
    };
1346
    zoom.duration = function(_) {
1347
      if (!arguments.length) return duration;
1348
      duration = +_;
1349
      return zoom;
1350
    };
1351
    zoom.x = function(z) {
1352
      if (!arguments.length) return x1;
1353
      x1 = z;
1354
      x0 = z.copy();
1355
      view = {
1356
        x: 0,
1357
        y: 0,
1358
        k: 1
1359
      };
1360
      return zoom;
1361
    };
1362
    zoom.y = function(z) {
1363
      if (!arguments.length) return y1;
1364
      y1 = z;
1365
      y0 = z.copy();
1366
      view = {
1367
        x: 0,
1368
        y: 0,
1369
        k: 1
1370
      };
1371
      return zoom;
1372
    };
1373
    function location(p) {
1374
      return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ];
1375
    }
1376
    function point(l) {
1377
      return [ l[0] * view.k + view.x, l[1] * view.k + view.y ];
1378
    }
1379
    function scaleTo(s) {
1380
      view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));
1381
    }
1382
    function translateTo(p, l) {
1383
      l = point(l);
1384
      view.x += p[0] - l[0];
1385
      view.y += p[1] - l[1];
1386
    }
1387
    function zoomTo(that, p, l, k) {
1388
      that.__chart__ = {
1389
        x: view.x,
1390
        y: view.y,
1391
        k: view.k
1392
      };
1393
      scaleTo(Math.pow(2, k));
1394
      translateTo(center0 = p, l);
1395
      that = d3.select(that);
1396
      if (duration > 0) that = that.transition().duration(duration);
1397
      that.call(zoom.event);
1398
    }
1399
    function rescale() {
1400
      if (x1) x1.domain(x0.range().map(function(x) {
1401
        return (x - view.x) / view.k;
1402
      }).map(x0.invert));
1403
      if (y1) y1.domain(y0.range().map(function(y) {
1404
        return (y - view.y) / view.k;
1405
      }).map(y0.invert));
1406
    }
1407
    function zoomstarted(dispatch) {
1408
      if (!zooming++) dispatch({
1409
        type: "zoomstart"
1410
      });
1411
    }
1412
    function zoomed(dispatch) {
1413
      rescale();
1414
      dispatch({
1415
        type: "zoom",
1416
        scale: view.k,
1417
        translate: [ view.x, view.y ]
1418
      });
1419
    }
1420
    function zoomended(dispatch) {
1421
      if (!--zooming) dispatch({
1422
        type: "zoomend"
1423
      });
1424
      center0 = null;
1425
    }
1426
    function mousedowned() {
1427
      var that = this, target = d3.event.target, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress();
1428
      d3_selection_interrupt(that);
1429
      zoomstarted(dispatch);
1430
      function moved() {
1431
        dragged = 1;
1432
        translateTo(d3.mouse(that), location0);
1433
        zoomed(dispatch);
1434
      }
1435
      function ended() {
1436
        subject.on(mousemove, null).on(mouseup, null);
1437
        dragRestore(dragged && d3.event.target === target);
1438
        zoomended(dispatch);
1439
      }
1440
    }
1441
    function touchstarted() {
1442
      var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that), dragRestore = d3_event_dragSuppress();
1443
      started();
1444
      zoomstarted(dispatch);
1445
      subject.on(mousedown, null).on(touchstart, started);
1446
      function relocate() {
1447
        var touches = d3.touches(that);
1448
        scale0 = view.k;
1449
        touches.forEach(function(t) {
1450
          if (t.identifier in locations0) locations0[t.identifier] = location(t);
1451
        });
1452
        return touches;
1453
      }
1454
      function started() {
1455
        var target = d3.event.target;
1456
        d3.select(target).on(touchmove, moved).on(touchend, ended);
1457
        targets.push(target);
1458
        var changed = d3.event.changedTouches;
1459
        for (var i = 0, n = changed.length; i < n; ++i) {
1460
          locations0[changed[i].identifier] = null;
1461
        }
1462
        var touches = relocate(), now = Date.now();
1463
        if (touches.length === 1) {
1464
          if (now - touchtime < 500) {
1465
            var p = touches[0];
1466
            zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1);
1467
            d3_eventPreventDefault();
1468
          }
1469
          touchtime = now;
1470
        } else if (touches.length > 1) {
1471
          var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1];
1472
          distance0 = dx * dx + dy * dy;
1473
        }
1474
      }
1475
      function moved() {
1476
        var touches = d3.touches(that), p0, l0, p1, l1;
1477
        d3_selection_interrupt(that);
1478
        for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {
1479
          p1 = touches[i];
1480
          if (l1 = locations0[p1.identifier]) {
1481
            if (l0) break;
1482
            p0 = p1, l0 = l1;
1483
          }
1484
        }
1485
        if (l1) {
1486
          var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0);
1487
          p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];
1488
          l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];
1489
          scaleTo(scale1 * scale0);
1490
        }
1491
        touchtime = null;
1492
        translateTo(p0, l0);
1493
        zoomed(dispatch);
1494
      }
1495
      function ended() {
1496
        if (d3.event.touches.length) {
1497
          var changed = d3.event.changedTouches;
1498
          for (var i = 0, n = changed.length; i < n; ++i) {
1499
            delete locations0[changed[i].identifier];
1500
          }
1501
          for (var identifier in locations0) {
1502
            return void relocate();
1503
          }
1504
        }
1505
        d3.selectAll(targets).on(zoomName, null);
1506
        subject.on(mousedown, mousedowned).on(touchstart, touchstarted);
1507
        dragRestore();
1508
        zoomended(dispatch);
1509
      }
1510
    }
1511
    function mousewheeled() {
1512
      var dispatch = event.of(this, arguments);
1513
      if (mousewheelTimer) clearTimeout(mousewheelTimer); else translate0 = location(center0 = center || d3.mouse(this)), 
1514
      d3_selection_interrupt(this), zoomstarted(dispatch);
1515
      mousewheelTimer = setTimeout(function() {
1516
        mousewheelTimer = null;
1517
        zoomended(dispatch);
1518
      }, 50);
1519
      d3_eventPreventDefault();
1520
      scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k);
1521
      translateTo(center0, translate0);
1522
      zoomed(dispatch);
1523
    }
1524
    function dblclicked() {
1525
      var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2;
1526
      zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1);
1527
    }
1528
    return d3.rebind(zoom, event, "on");
1529
  };
1530
  var d3_behavior_zoomInfinity = [ 0, Infinity ];
1531
  var d3_behavior_zoomDelta, d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() {
1532
    return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1);
1533
  }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() {
1534
    return d3.event.wheelDelta;
1535
  }, "mousewheel") : (d3_behavior_zoomDelta = function() {
1536
    return -d3.event.detail;
1537
  }, "MozMousePixelScroll");
1538
  d3.color = d3_color;
1539
  function d3_color() {}
1540
  d3_color.prototype.toString = function() {
1541
    return this.rgb() + "";
1542
  };
1543
  d3.hsl = d3_hsl;
1544
  function d3_hsl(h, s, l) {
1545
    return this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) : arguments.length < 2 ? h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : new d3_hsl(h, s, l);
1546
  }
1547
  var d3_hslPrototype = d3_hsl.prototype = new d3_color();
1548
  d3_hslPrototype.brighter = function(k) {
1549
    k = Math.pow(.7, arguments.length ? k : 1);
1550
    return new d3_hsl(this.h, this.s, this.l / k);
1551
  };
1552
  d3_hslPrototype.darker = function(k) {
1553
    k = Math.pow(.7, arguments.length ? k : 1);
1554
    return new d3_hsl(this.h, this.s, k * this.l);
1555
  };
1556
  d3_hslPrototype.rgb = function() {
1557
    return d3_hsl_rgb(this.h, this.s, this.l);
1558
  };
1559
  function d3_hsl_rgb(h, s, l) {
1560
    var m1, m2;
1561
    h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h;
1562
    s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s;
1563
    l = l < 0 ? 0 : l > 1 ? 1 : l;
1564
    m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
1565
    m1 = 2 * l - m2;
1566
    function v(h) {
1567
      if (h > 360) h -= 360; else if (h < 0) h += 360;
1568
      if (h < 60) return m1 + (m2 - m1) * h / 60;
1569
      if (h < 180) return m2;
1570
      if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
1571
      return m1;
1572
    }
1573
    function vv(h) {
1574
      return Math.round(v(h) * 255);
1575
    }
1576
    return new d3_rgb(vv(h + 120), vv(h), vv(h - 120));
1577
  }
1578
  d3.hcl = d3_hcl;
1579
  function d3_hcl(h, c, l) {
1580
    return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) : arguments.length < 2 ? h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) : h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : new d3_hcl(h, c, l);
1581
  }
1582
  var d3_hclPrototype = d3_hcl.prototype = new d3_color();
1583
  d3_hclPrototype.brighter = function(k) {
1584
    return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));
1585
  };
1586
  d3_hclPrototype.darker = function(k) {
1587
    return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));
1588
  };
1589
  d3_hclPrototype.rgb = function() {
1590
    return d3_hcl_lab(this.h, this.c, this.l).rgb();
1591
  };
1592
  function d3_hcl_lab(h, c, l) {
1593
    if (isNaN(h)) h = 0;
1594
    if (isNaN(c)) c = 0;
1595
    return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);
1596
  }
1597
  d3.lab = d3_lab;
1598
  function d3_lab(l, a, b) {
1599
    return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b);
1600
  }
1601
  var d3_lab_K = 18;
1602
  var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;
1603
  var d3_labPrototype = d3_lab.prototype = new d3_color();
1604
  d3_labPrototype.brighter = function(k) {
1605
    return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1606
  };
1607
  d3_labPrototype.darker = function(k) {
1608
    return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1609
  };
1610
  d3_labPrototype.rgb = function() {
1611
    return d3_lab_rgb(this.l, this.a, this.b);
1612
  };
1613
  function d3_lab_rgb(l, a, b) {
1614
    var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200;
1615
    x = d3_lab_xyz(x) * d3_lab_X;
1616
    y = d3_lab_xyz(y) * d3_lab_Y;
1617
    z = d3_lab_xyz(z) * d3_lab_Z;
1618
    return new d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z));
1619
  }
1620
  function d3_lab_hcl(l, a, b) {
1621
    return l > 0 ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : new d3_hcl(NaN, NaN, l);
1622
  }
1623
  function d3_lab_xyz(x) {
1624
    return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;
1625
  }
1626
  function d3_xyz_lab(x) {
1627
    return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;
1628
  }
1629
  function d3_xyz_rgb(r) {
1630
    return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055));
1631
  }
1632
  d3.rgb = d3_rgb;
1633
  function d3_rgb(r, g, b) {
1634
    return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) : arguments.length < 2 ? r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : new d3_rgb(r, g, b);
1635
  }
1636
  function d3_rgbNumber(value) {
1637
    return new d3_rgb(value >> 16, value >> 8 & 255, value & 255);
1638
  }
1639
  function d3_rgbString(value) {
1640
    return d3_rgbNumber(value) + "";
1641
  }
1642
  var d3_rgbPrototype = d3_rgb.prototype = new d3_color();
1643
  d3_rgbPrototype.brighter = function(k) {
1644
    k = Math.pow(.7, arguments.length ? k : 1);
1645
    var r = this.r, g = this.g, b = this.b, i = 30;
1646
    if (!r && !g && !b) return new d3_rgb(i, i, i);
1647
    if (r && r < i) r = i;
1648
    if (g && g < i) g = i;
1649
    if (b && b < i) b = i;
1650
    return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k));
1651
  };
1652
  d3_rgbPrototype.darker = function(k) {
1653
    k = Math.pow(.7, arguments.length ? k : 1);
1654
    return new d3_rgb(k * this.r, k * this.g, k * this.b);
1655
  };
1656
  d3_rgbPrototype.hsl = function() {
1657
    return d3_rgb_hsl(this.r, this.g, this.b);
1658
  };
1659
  d3_rgbPrototype.toString = function() {
1660
    return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);
1661
  };
1662
  function d3_rgb_hex(v) {
1663
    return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);
1664
  }
1665
  function d3_rgb_parse(format, rgb, hsl) {
1666
    var r = 0, g = 0, b = 0, m1, m2, color;
1667
    m1 = /([a-z]+)\((.*)\)/i.exec(format);
1668
    if (m1) {
1669
      m2 = m1[2].split(",");
1670
      switch (m1[1]) {
1671
       case "hsl":
1672
        {
1673
          return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100);
1674
        }
1675

    
1676
       case "rgb":
1677
        {
1678
          return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2]));
1679
        }
1680
      }
1681
    }
1682
    if (color = d3_rgb_names.get(format)) return rgb(color.r, color.g, color.b);
1683
    if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) {
1684
      if (format.length === 4) {
1685
        r = (color & 3840) >> 4;
1686
        r = r >> 4 | r;
1687
        g = color & 240;
1688
        g = g >> 4 | g;
1689
        b = color & 15;
1690
        b = b << 4 | b;
1691
      } else if (format.length === 7) {
1692
        r = (color & 16711680) >> 16;
1693
        g = (color & 65280) >> 8;
1694
        b = color & 255;
1695
      }
1696
    }
1697
    return rgb(r, g, b);
1698
  }
1699
  function d3_rgb_hsl(r, g, b) {
1700
    var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2;
1701
    if (d) {
1702
      s = l < .5 ? d / (max + min) : d / (2 - max - min);
1703
      if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4;
1704
      h *= 60;
1705
    } else {
1706
      h = NaN;
1707
      s = l > 0 && l < 1 ? 0 : h;
1708
    }
1709
    return new d3_hsl(h, s, l);
1710
  }
1711
  function d3_rgb_lab(r, g, b) {
1712
    r = d3_rgb_xyz(r);
1713
    g = d3_rgb_xyz(g);
1714
    b = d3_rgb_xyz(b);
1715
    var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z);
1716
    return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z));
1717
  }
1718
  function d3_rgb_xyz(r) {
1719
    return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4);
1720
  }
1721
  function d3_rgb_parseNumber(c) {
1722
    var f = parseFloat(c);
1723
    return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f;
1724
  }
1725
  var d3_rgb_names = d3.map({
1726
    aliceblue: 15792383,
1727
    antiquewhite: 16444375,
1728
    aqua: 65535,
1729
    aquamarine: 8388564,
1730
    azure: 15794175,
1731
    beige: 16119260,
1732
    bisque: 16770244,
1733
    black: 0,
1734
    blanchedalmond: 16772045,
1735
    blue: 255,
1736
    blueviolet: 9055202,
1737
    brown: 10824234,
1738
    burlywood: 14596231,
1739
    cadetblue: 6266528,
1740
    chartreuse: 8388352,
1741
    chocolate: 13789470,
1742
    coral: 16744272,
1743
    cornflowerblue: 6591981,
1744
    cornsilk: 16775388,
1745
    crimson: 14423100,
1746
    cyan: 65535,
1747
    darkblue: 139,
1748
    darkcyan: 35723,
1749
    darkgoldenrod: 12092939,
1750
    darkgray: 11119017,
1751
    darkgreen: 25600,
1752
    darkgrey: 11119017,
1753
    darkkhaki: 12433259,
1754
    darkmagenta: 9109643,
1755
    darkolivegreen: 5597999,
1756
    darkorange: 16747520,
1757
    darkorchid: 10040012,
1758
    darkred: 9109504,
1759
    darksalmon: 15308410,
1760
    darkseagreen: 9419919,
1761
    darkslateblue: 4734347,
1762
    darkslategray: 3100495,
1763
    darkslategrey: 3100495,
1764
    darkturquoise: 52945,
1765
    darkviolet: 9699539,
1766
    deeppink: 16716947,
1767
    deepskyblue: 49151,
1768
    dimgray: 6908265,
1769
    dimgrey: 6908265,
1770
    dodgerblue: 2003199,
1771
    firebrick: 11674146,
1772
    floralwhite: 16775920,
1773
    forestgreen: 2263842,
1774
    fuchsia: 16711935,
1775
    gainsboro: 14474460,
1776
    ghostwhite: 16316671,
1777
    gold: 16766720,
1778
    goldenrod: 14329120,
1779
    gray: 8421504,
1780
    green: 32768,
1781
    greenyellow: 11403055,
1782
    grey: 8421504,
1783
    honeydew: 15794160,
1784
    hotpink: 16738740,
1785
    indianred: 13458524,
1786
    indigo: 4915330,
1787
    ivory: 16777200,
1788
    khaki: 15787660,
1789
    lavender: 15132410,
1790
    lavenderblush: 16773365,
1791
    lawngreen: 8190976,
1792
    lemonchiffon: 16775885,
1793
    lightblue: 11393254,
1794
    lightcoral: 15761536,
1795
    lightcyan: 14745599,
1796
    lightgoldenrodyellow: 16448210,
1797
    lightgray: 13882323,
1798
    lightgreen: 9498256,
1799
    lightgrey: 13882323,
1800
    lightpink: 16758465,
1801
    lightsalmon: 16752762,
1802
    lightseagreen: 2142890,
1803
    lightskyblue: 8900346,
1804
    lightslategray: 7833753,
1805
    lightslategrey: 7833753,
1806
    lightsteelblue: 11584734,
1807
    lightyellow: 16777184,
1808
    lime: 65280,
1809
    limegreen: 3329330,
1810
    linen: 16445670,
1811
    magenta: 16711935,
1812
    maroon: 8388608,
1813
    mediumaquamarine: 6737322,
1814
    mediumblue: 205,
1815
    mediumorchid: 12211667,
1816
    mediumpurple: 9662683,
1817
    mediumseagreen: 3978097,
1818
    mediumslateblue: 8087790,
1819
    mediumspringgreen: 64154,
1820
    mediumturquoise: 4772300,
1821
    mediumvioletred: 13047173,
1822
    midnightblue: 1644912,
1823
    mintcream: 16121850,
1824
    mistyrose: 16770273,
1825
    moccasin: 16770229,
1826
    navajowhite: 16768685,
1827
    navy: 128,
1828
    oldlace: 16643558,
1829
    olive: 8421376,
1830
    olivedrab: 7048739,
1831
    orange: 16753920,
1832
    orangered: 16729344,
1833
    orchid: 14315734,
1834
    palegoldenrod: 15657130,
1835
    palegreen: 10025880,
1836
    paleturquoise: 11529966,
1837
    palevioletred: 14381203,
1838
    papayawhip: 16773077,
1839
    peachpuff: 16767673,
1840
    peru: 13468991,
1841
    pink: 16761035,
1842
    plum: 14524637,
1843
    powderblue: 11591910,
1844
    purple: 8388736,
1845
    red: 16711680,
1846
    rosybrown: 12357519,
1847
    royalblue: 4286945,
1848
    saddlebrown: 9127187,
1849
    salmon: 16416882,
1850
    sandybrown: 16032864,
1851
    seagreen: 3050327,
1852
    seashell: 16774638,
1853
    sienna: 10506797,
1854
    silver: 12632256,
1855
    skyblue: 8900331,
1856
    slateblue: 6970061,
1857
    slategray: 7372944,
1858
    slategrey: 7372944,
1859
    snow: 16775930,
1860
    springgreen: 65407,
1861
    steelblue: 4620980,
1862
    tan: 13808780,
1863
    teal: 32896,
1864
    thistle: 14204888,
1865
    tomato: 16737095,
1866
    turquoise: 4251856,
1867
    violet: 15631086,
1868
    wheat: 16113331,
1869
    white: 16777215,
1870
    whitesmoke: 16119285,
1871
    yellow: 16776960,
1872
    yellowgreen: 10145074
1873
  });
1874
  d3_rgb_names.forEach(function(key, value) {
1875
    d3_rgb_names.set(key, d3_rgbNumber(value));
1876
  });
1877
  function d3_functor(v) {
1878
    return typeof v === "function" ? v : function() {
1879
      return v;
1880
    };
1881
  }
1882
  d3.functor = d3_functor;
1883
  function d3_identity(d) {
1884
    return d;
1885
  }
1886
  d3.xhr = d3_xhrType(d3_identity);
1887
  function d3_xhrType(response) {
1888
    return function(url, mimeType, callback) {
1889
      if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType, 
1890
      mimeType = null;
1891
      return d3_xhr(url, mimeType, response, callback);
1892
    };
1893
  }
1894
  function d3_xhr(url, mimeType, response, callback) {
1895
    var xhr = {}, dispatch = d3.dispatch("beforesend", "progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null;
1896
    if (d3_window.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest();
1897
    "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {
1898
      request.readyState > 3 && respond();
1899
    };
1900
    function respond() {
1901
      var status = request.status, result;
1902
      if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) {
1903
        try {
1904
          result = response.call(xhr, request);
1905
        } catch (e) {
1906
          dispatch.error.call(xhr, e);
1907
          return;
1908
        }
1909
        dispatch.load.call(xhr, result);
1910
      } else {
1911
        dispatch.error.call(xhr, request);
1912
      }
1913
    }
1914
    request.onprogress = function(event) {
1915
      var o = d3.event;
1916
      d3.event = event;
1917
      try {
1918
        dispatch.progress.call(xhr, request);
1919
      } finally {
1920
        d3.event = o;
1921
      }
1922
    };
1923
    xhr.header = function(name, value) {
1924
      name = (name + "").toLowerCase();
1925
      if (arguments.length < 2) return headers[name];
1926
      if (value == null) delete headers[name]; else headers[name] = value + "";
1927
      return xhr;
1928
    };
1929
    xhr.mimeType = function(value) {
1930
      if (!arguments.length) return mimeType;
1931
      mimeType = value == null ? null : value + "";
1932
      return xhr;
1933
    };
1934
    xhr.responseType = function(value) {
1935
      if (!arguments.length) return responseType;
1936
      responseType = value;
1937
      return xhr;
1938
    };
1939
    xhr.response = function(value) {
1940
      response = value;
1941
      return xhr;
1942
    };
1943
    [ "get", "post" ].forEach(function(method) {
1944
      xhr[method] = function() {
1945
        return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments)));
1946
      };
1947
    });
1948
    xhr.send = function(method, data, callback) {
1949
      if (arguments.length === 2 && typeof data === "function") callback = data, data = null;
1950
      request.open(method, url, true);
1951
      if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*";
1952
      if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]);
1953
      if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType);
1954
      if (responseType != null) request.responseType = responseType;
1955
      if (callback != null) xhr.on("error", callback).on("load", function(request) {
1956
        callback(null, request);
1957
      });
1958
      dispatch.beforesend.call(xhr, request);
1959
      request.send(data == null ? null : data);
1960
      return xhr;
1961
    };
1962
    xhr.abort = function() {
1963
      request.abort();
1964
      return xhr;
1965
    };
1966
    d3.rebind(xhr, dispatch, "on");
1967
    return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback));
1968
  }
1969
  function d3_xhr_fixCallback(callback) {
1970
    return callback.length === 1 ? function(error, request) {
1971
      callback(error == null ? request : null);
1972
    } : callback;
1973
  }
1974
  function d3_xhrHasResponse(request) {
1975
    var type = request.responseType;
1976
    return type && type !== "text" ? request.response : request.responseText;
1977
  }
1978
  d3.dsv = function(delimiter, mimeType) {
1979
    var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0);
1980
    function dsv(url, row, callback) {
1981
      if (arguments.length < 3) callback = row, row = null;
1982
      var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback);
1983
      xhr.row = function(_) {
1984
        return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row;
1985
      };
1986
      return xhr;
1987
    }
1988
    function response(request) {
1989
      return dsv.parse(request.responseText);
1990
    }
1991
    function typedResponse(f) {
1992
      return function(request) {
1993
        return dsv.parse(request.responseText, f);
1994
      };
1995
    }
1996
    dsv.parse = function(text, f) {
1997
      var o;
1998
      return dsv.parseRows(text, function(row, i) {
1999
        if (o) return o(row, i - 1);
2000
        var a = new Function("d", "return {" + row.map(function(name, i) {
2001
          return JSON.stringify(name) + ": d[" + i + "]";
2002
        }).join(",") + "}");
2003
        o = f ? function(row, i) {
2004
          return f(a(row), i);
2005
        } : a;
2006
      });
2007
    };
2008
    dsv.parseRows = function(text, f) {
2009
      var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol;
2010
      function token() {
2011
        if (I >= N) return EOF;
2012
        if (eol) return eol = false, EOL;
2013
        var j = I;
2014
        if (text.charCodeAt(j) === 34) {
2015
          var i = j;
2016
          while (i++ < N) {
2017
            if (text.charCodeAt(i) === 34) {
2018
              if (text.charCodeAt(i + 1) !== 34) break;
2019
              ++i;
2020
            }
2021
          }
2022
          I = i + 2;
2023
          var c = text.charCodeAt(i + 1);
2024
          if (c === 13) {
2025
            eol = true;
2026
            if (text.charCodeAt(i + 2) === 10) ++I;
2027
          } else if (c === 10) {
2028
            eol = true;
2029
          }
2030
          return text.slice(j + 1, i).replace(/""/g, '"');
2031
        }
2032
        while (I < N) {
2033
          var c = text.charCodeAt(I++), k = 1;
2034
          if (c === 10) eol = true; else if (c === 13) {
2035
            eol = true;
2036
            if (text.charCodeAt(I) === 10) ++I, ++k;
2037
          } else if (c !== delimiterCode) continue;
2038
          return text.slice(j, I - k);
2039
        }
2040
        return text.slice(j);
2041
      }
2042
      while ((t = token()) !== EOF) {
2043
        var a = [];
2044
        while (t !== EOL && t !== EOF) {
2045
          a.push(t);
2046
          t = token();
2047
        }
2048
        if (f && (a = f(a, n++)) == null) continue;
2049
        rows.push(a);
2050
      }
2051
      return rows;
2052
    };
2053
    dsv.format = function(rows) {
2054
      if (Array.isArray(rows[0])) return dsv.formatRows(rows);
2055
      var fieldSet = new d3_Set(), fields = [];
2056
      rows.forEach(function(row) {
2057
        for (var field in row) {
2058
          if (!fieldSet.has(field)) {
2059
            fields.push(fieldSet.add(field));
2060
          }
2061
        }
2062
      });
2063
      return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) {
2064
        return fields.map(function(field) {
2065
          return formatValue(row[field]);
2066
        }).join(delimiter);
2067
      })).join("\n");
2068
    };
2069
    dsv.formatRows = function(rows) {
2070
      return rows.map(formatRow).join("\n");
2071
    };
2072
    function formatRow(row) {
2073
      return row.map(formatValue).join(delimiter);
2074
    }
2075
    function formatValue(text) {
2076
      return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text;
2077
    }
2078
    return dsv;
2079
  };
2080
  d3.csv = d3.dsv(",", "text/csv");
2081
  d3.tsv = d3.dsv("	", "text/tab-separated-values");
2082
  var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_active, d3_timer_frame = d3_window[d3_vendorSymbol(d3_window, "requestAnimationFrame")] || function(callback) {
2083
    setTimeout(callback, 17);
2084
  };
2085
  d3.timer = function(callback, delay, then) {
2086
    var n = arguments.length;
2087
    if (n < 2) delay = 0;
2088
    if (n < 3) then = Date.now();
2089
    var time = then + delay, timer = {
2090
      c: callback,
2091
      t: time,
2092
      f: false,
2093
      n: null
2094
    };
2095
    if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer;
2096
    d3_timer_queueTail = timer;
2097
    if (!d3_timer_interval) {
2098
      d3_timer_timeout = clearTimeout(d3_timer_timeout);
2099
      d3_timer_interval = 1;
2100
      d3_timer_frame(d3_timer_step);
2101
    }
2102
  };
2103
  function d3_timer_step() {
2104
    var now = d3_timer_mark(), delay = d3_timer_sweep() - now;
2105
    if (delay > 24) {
2106
      if (isFinite(delay)) {
2107
        clearTimeout(d3_timer_timeout);
2108
        d3_timer_timeout = setTimeout(d3_timer_step, delay);
2109
      }
2110
      d3_timer_interval = 0;
2111
    } else {
2112
      d3_timer_interval = 1;
2113
      d3_timer_frame(d3_timer_step);
2114
    }
2115
  }
2116
  d3.timer.flush = function() {
2117
    d3_timer_mark();
2118
    d3_timer_sweep();
2119
  };
2120
  function d3_timer_mark() {
2121
    var now = Date.now();
2122
    d3_timer_active = d3_timer_queueHead;
2123
    while (d3_timer_active) {
2124
      if (now >= d3_timer_active.t) d3_timer_active.f = d3_timer_active.c(now - d3_timer_active.t);
2125
      d3_timer_active = d3_timer_active.n;
2126
    }
2127
    return now;
2128
  }
2129
  function d3_timer_sweep() {
2130
    var t0, t1 = d3_timer_queueHead, time = Infinity;
2131
    while (t1) {
2132
      if (t1.f) {
2133
        t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n;
2134
      } else {
2135
        if (t1.t < time) time = t1.t;
2136
        t1 = (t0 = t1).n;
2137
      }
2138
    }
2139
    d3_timer_queueTail = t0;
2140
    return time;
2141
  }
2142
  function d3_format_precision(x, p) {
2143
    return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1);
2144
  }
2145
  d3.round = function(x, n) {
2146
    return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);
2147
  };
2148
  var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix);
2149
  d3.formatPrefix = function(value, precision) {
2150
    var i = 0;
2151
    if (value) {
2152
      if (value < 0) value *= -1;
2153
      if (precision) value = d3.round(value, d3_format_precision(value, precision));
2154
      i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
2155
      i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3));
2156
    }
2157
    return d3_formatPrefixes[8 + i / 3];
2158
  };
2159
  function d3_formatPrefix(d, i) {
2160
    var k = Math.pow(10, abs(8 - i) * 3);
2161
    return {
2162
      scale: i > 8 ? function(d) {
2163
        return d / k;
2164
      } : function(d) {
2165
        return d * k;
2166
      },
2167
      symbol: d
2168
    };
2169
  }
2170
  function d3_locale_numberFormat(locale) {
2171
    var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping && locale_thousands ? function(value, width) {
2172
      var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0;
2173
      while (i > 0 && g > 0) {
2174
        if (length + g + 1 > width) g = Math.max(1, width - length);
2175
        t.push(value.substring(i -= g, i + g));
2176
        if ((length += g + 1) > width) break;
2177
        g = locale_grouping[j = (j + 1) % locale_grouping.length];
2178
      }
2179
      return t.reverse().join(locale_thousands);
2180
    } : d3_identity;
2181
    return function(specifier) {
2182
      var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "-", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = "", suffix = "", integer = false, exponent = true;
2183
      if (precision) precision = +precision.substring(1);
2184
      if (zfill || fill === "0" && align === "=") {
2185
        zfill = fill = "0";
2186
        align = "=";
2187
      }
2188
      switch (type) {
2189
       case "n":
2190
        comma = true;
2191
        type = "g";
2192
        break;
2193

    
2194
       case "%":
2195
        scale = 100;
2196
        suffix = "%";
2197
        type = "f";
2198
        break;
2199

    
2200
       case "p":
2201
        scale = 100;
2202
        suffix = "%";
2203
        type = "r";
2204
        break;
2205

    
2206
       case "b":
2207
       case "o":
2208
       case "x":
2209
       case "X":
2210
        if (symbol === "#") prefix = "0" + type.toLowerCase();
2211

    
2212
       case "c":
2213
        exponent = false;
2214

    
2215
       case "d":
2216
        integer = true;
2217
        precision = 0;
2218
        break;
2219

    
2220
       case "s":
2221
        scale = -1;
2222
        type = "r";
2223
        break;
2224
      }
2225
      if (symbol === "$") prefix = locale_currency[0], suffix = locale_currency[1];
2226
      if (type == "r" && !precision) type = "g";
2227
      if (precision != null) {
2228
        if (type == "g") precision = Math.max(1, Math.min(21, precision)); else if (type == "e" || type == "f") precision = Math.max(0, Math.min(20, precision));
2229
      }
2230
      type = d3_format_types.get(type) || d3_format_typeDefault;
2231
      var zcomma = zfill && comma;
2232
      return function(value) {
2233
        var fullSuffix = suffix;
2234
        if (integer && value % 1) return "";
2235
        var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign === "-" ? "" : sign;
2236
        if (scale < 0) {
2237
          var unit = d3.formatPrefix(value, precision);
2238
          value = unit.scale(value);
2239
          fullSuffix = unit.symbol + suffix;
2240
        } else {
2241
          value *= scale;
2242
        }
2243
        value = type(value, precision);
2244
        var i = value.lastIndexOf("."), before, after;
2245
        if (i < 0) {
2246
          var j = exponent ? value.lastIndexOf("e") : -1;
2247
          if (j < 0) before = value, after = ""; else before = value.substring(0, j), after = value.substring(j);
2248
        } else {
2249
          before = value.substring(0, i);
2250
          after = locale_decimal + value.substring(i + 1);
2251
        }
2252
        if (!zfill && comma) before = formatGroup(before, Infinity);
2253
        var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : "";
2254
        if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity);
2255
        negative += prefix;
2256
        value = before + after;
2257
        return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + fullSuffix;
2258
      };
2259
    };
2260
  }
2261
  var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i;
2262
  var d3_format_types = d3.map({
2263
    b: function(x) {
2264
      return x.toString(2);
2265
    },
2266
    c: function(x) {
2267
      return String.fromCharCode(x);
2268
    },
2269
    o: function(x) {
2270
      return x.toString(8);
2271
    },
2272
    x: function(x) {
2273
      return x.toString(16);
2274
    },
2275
    X: function(x) {
2276
      return x.toString(16).toUpperCase();
2277
    },
2278
    g: function(x, p) {
2279
      return x.toPrecision(p);
2280
    },
2281
    e: function(x, p) {
2282
      return x.toExponential(p);
2283
    },
2284
    f: function(x, p) {
2285
      return x.toFixed(p);
2286
    },
2287
    r: function(x, p) {
2288
      return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p))));
2289
    }
2290
  });
2291
  function d3_format_typeDefault(x) {
2292
    return x + "";
2293
  }
2294
  var d3_time = d3.time = {}, d3_date = Date;
2295
  function d3_date_utc() {
2296
    this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]);
2297
  }
2298
  d3_date_utc.prototype = {
2299
    getDate: function() {
2300
      return this._.getUTCDate();
2301
    },
2302
    getDay: function() {
2303
      return this._.getUTCDay();
2304
    },
2305
    getFullYear: function() {
2306
      return this._.getUTCFullYear();
2307
    },
2308
    getHours: function() {
2309
      return this._.getUTCHours();
2310
    },
2311
    getMilliseconds: function() {
2312
      return this._.getUTCMilliseconds();
2313
    },
2314
    getMinutes: function() {
2315
      return this._.getUTCMinutes();
2316
    },
2317
    getMonth: function() {
2318
      return this._.getUTCMonth();
2319
    },
2320
    getSeconds: function() {
2321
      return this._.getUTCSeconds();
2322
    },
2323
    getTime: function() {
2324
      return this._.getTime();
2325
    },
2326
    getTimezoneOffset: function() {
2327
      return 0;
2328
    },
2329
    valueOf: function() {
2330
      return this._.valueOf();
2331
    },
2332
    setDate: function() {
2333
      d3_time_prototype.setUTCDate.apply(this._, arguments);
2334
    },
2335
    setDay: function() {
2336
      d3_time_prototype.setUTCDay.apply(this._, arguments);
2337
    },
2338
    setFullYear: function() {
2339
      d3_time_prototype.setUTCFullYear.apply(this._, arguments);
2340
    },
2341
    setHours: function() {
2342
      d3_time_prototype.setUTCHours.apply(this._, arguments);
2343
    },
2344
    setMilliseconds: function() {
2345
      d3_time_prototype.setUTCMilliseconds.apply(this._, arguments);
2346
    },
2347
    setMinutes: function() {
2348
      d3_time_prototype.setUTCMinutes.apply(this._, arguments);
2349
    },
2350
    setMonth: function() {
2351
      d3_time_prototype.setUTCMonth.apply(this._, arguments);
2352
    },
2353
    setSeconds: function() {
2354
      d3_time_prototype.setUTCSeconds.apply(this._, arguments);
2355
    },
2356
    setTime: function() {
2357
      d3_time_prototype.setTime.apply(this._, arguments);
2358
    }
2359
  };
2360
  var d3_time_prototype = Date.prototype;
2361
  function d3_time_interval(local, step, number) {
2362
    function round(date) {
2363
      var d0 = local(date), d1 = offset(d0, 1);
2364
      return date - d0 < d1 - date ? d0 : d1;
2365
    }
2366
    function ceil(date) {
2367
      step(date = local(new d3_date(date - 1)), 1);
2368
      return date;
2369
    }
2370
    function offset(date, k) {
2371
      step(date = new d3_date(+date), k);
2372
      return date;
2373
    }
2374
    function range(t0, t1, dt) {
2375
      var time = ceil(t0), times = [];
2376
      if (dt > 1) {
2377
        while (time < t1) {
2378
          if (!(number(time) % dt)) times.push(new Date(+time));
2379
          step(time, 1);
2380
        }
2381
      } else {
2382
        while (time < t1) times.push(new Date(+time)), step(time, 1);
2383
      }
2384
      return times;
2385
    }
2386
    function range_utc(t0, t1, dt) {
2387
      try {
2388
        d3_date = d3_date_utc;
2389
        var utc = new d3_date_utc();
2390
        utc._ = t0;
2391
        return range(utc, t1, dt);
2392
      } finally {
2393
        d3_date = Date;
2394
      }
2395
    }
2396
    local.floor = local;
2397
    local.round = round;
2398
    local.ceil = ceil;
2399
    local.offset = offset;
2400
    local.range = range;
2401
    var utc = local.utc = d3_time_interval_utc(local);
2402
    utc.floor = utc;
2403
    utc.round = d3_time_interval_utc(round);
2404
    utc.ceil = d3_time_interval_utc(ceil);
2405
    utc.offset = d3_time_interval_utc(offset);
2406
    utc.range = range_utc;
2407
    return local;
2408
  }
2409
  function d3_time_interval_utc(method) {
2410
    return function(date, k) {
2411
      try {
2412
        d3_date = d3_date_utc;
2413
        var utc = new d3_date_utc();
2414
        utc._ = date;
2415
        return method(utc, k)._;
2416
      } finally {
2417
        d3_date = Date;
2418
      }
2419
    };
2420
  }
2421
  d3_time.year = d3_time_interval(function(date) {
2422
    date = d3_time.day(date);
2423
    date.setMonth(0, 1);
2424
    return date;
2425
  }, function(date, offset) {
2426
    date.setFullYear(date.getFullYear() + offset);
2427
  }, function(date) {
2428
    return date.getFullYear();
2429
  });
2430
  d3_time.years = d3_time.year.range;
2431
  d3_time.years.utc = d3_time.year.utc.range;
2432
  d3_time.day = d3_time_interval(function(date) {
2433
    var day = new d3_date(2e3, 0);
2434
    day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
2435
    return day;
2436
  }, function(date, offset) {
2437
    date.setDate(date.getDate() + offset);
2438
  }, function(date) {
2439
    return date.getDate() - 1;
2440
  });
2441
  d3_time.days = d3_time.day.range;
2442
  d3_time.days.utc = d3_time.day.utc.range;
2443
  d3_time.dayOfYear = function(date) {
2444
    var year = d3_time.year(date);
2445
    return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5);
2446
  };
2447
  [ "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" ].forEach(function(day, i) {
2448
    i = 7 - i;
2449
    var interval = d3_time[day] = d3_time_interval(function(date) {
2450
      (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);
2451
      return date;
2452
    }, function(date, offset) {
2453
      date.setDate(date.getDate() + Math.floor(offset) * 7);
2454
    }, function(date) {
2455
      var day = d3_time.year(date).getDay();
2456
      return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);
2457
    });
2458
    d3_time[day + "s"] = interval.range;
2459
    d3_time[day + "s"].utc = interval.utc.range;
2460
    d3_time[day + "OfYear"] = function(date) {
2461
      var day = d3_time.year(date).getDay();
2462
      return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7);
2463
    };
2464
  });
2465
  d3_time.week = d3_time.sunday;
2466
  d3_time.weeks = d3_time.sunday.range;
2467
  d3_time.weeks.utc = d3_time.sunday.utc.range;
2468
  d3_time.weekOfYear = d3_time.sundayOfYear;
2469
  function d3_locale_timeFormat(locale) {
2470
    var locale_dateTime = locale.dateTime, locale_date = locale.date, locale_time = locale.time, locale_periods = locale.periods, locale_days = locale.days, locale_shortDays = locale.shortDays, locale_months = locale.months, locale_shortMonths = locale.shortMonths;
2471
    function d3_time_format(template) {
2472
      var n = template.length;
2473
      function format(date) {
2474
        var string = [], i = -1, j = 0, c, p, f;
2475
        while (++i < n) {
2476
          if (template.charCodeAt(i) === 37) {
2477
            string.push(template.slice(j, i));
2478
            if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i);
2479
            if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p);
2480
            string.push(c);
2481
            j = i + 1;
2482
          }
2483
        }
2484
        string.push(template.slice(j, i));
2485
        return string.join("");
2486
      }
2487
      format.parse = function(string) {
2488
        var d = {
2489
          y: 1900,
2490
          m: 0,
2491
          d: 1,
2492
          H: 0,
2493
          M: 0,
2494
          S: 0,
2495
          L: 0,
2496
          Z: null
2497
        }, i = d3_time_parse(d, template, string, 0);
2498
        if (i != string.length) return null;
2499
        if ("p" in d) d.H = d.H % 12 + d.p * 12;
2500
        var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)();
2501
        if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("w" in d && ("W" in d || "U" in d)) {
2502
          date.setFullYear(d.y, 0, 1);
2503
          date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7);
2504
        } else date.setFullYear(d.y, d.m, d.d);
2505
        date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L);
2506
        return localZ ? date._ : date;
2507
      };
2508
      format.toString = function() {
2509
        return template;
2510
      };
2511
      return format;
2512
    }
2513
    function d3_time_parse(date, template, string, j) {
2514
      var c, p, t, i = 0, n = template.length, m = string.length;
2515
      while (i < n) {
2516
        if (j >= m) return -1;
2517
        c = template.charCodeAt(i++);
2518
        if (c === 37) {
2519
          t = template.charAt(i++);
2520
          p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t];
2521
          if (!p || (j = p(date, string, j)) < 0) return -1;
2522
        } else if (c != string.charCodeAt(j++)) {
2523
          return -1;
2524
        }
2525
      }
2526
      return j;
2527
    }
2528
    d3_time_format.utc = function(template) {
2529
      var local = d3_time_format(template);
2530
      function format(date) {
2531
        try {
2532
          d3_date = d3_date_utc;
2533
          var utc = new d3_date();
2534
          utc._ = date;
2535
          return local(utc);
2536
        } finally {
2537
          d3_date = Date;
2538
        }
2539
      }
2540
      format.parse = function(string) {
2541
        try {
2542
          d3_date = d3_date_utc;
2543
          var date = local.parse(string);
2544
          return date && date._;
2545
        } finally {
2546
          d3_date = Date;
2547
        }
2548
      };
2549
      format.toString = local.toString;
2550
      return format;
2551
    };
2552
    d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti;
2553
    var d3_time_periodLookup = d3.map(), d3_time_dayRe = d3_time_formatRe(locale_days), d3_time_dayLookup = d3_time_formatLookup(locale_days), d3_time_dayAbbrevRe = d3_time_formatRe(locale_shortDays), d3_time_dayAbbrevLookup = d3_time_formatLookup(locale_shortDays), d3_time_monthRe = d3_time_formatRe(locale_months), d3_time_monthLookup = d3_time_formatLookup(locale_months), d3_time_monthAbbrevRe = d3_time_formatRe(locale_shortMonths), d3_time_monthAbbrevLookup = d3_time_formatLookup(locale_shortMonths);
2554
    locale_periods.forEach(function(p, i) {
2555
      d3_time_periodLookup.set(p.toLowerCase(), i);
2556
    });
2557
    var d3_time_formats = {
2558
      a: function(d) {
2559
        return locale_shortDays[d.getDay()];
2560
      },
2561
      A: function(d) {
2562
        return locale_days[d.getDay()];
2563
      },
2564
      b: function(d) {
2565
        return locale_shortMonths[d.getMonth()];
2566
      },
2567
      B: function(d) {
2568
        return locale_months[d.getMonth()];
2569
      },
2570
      c: d3_time_format(locale_dateTime),
2571
      d: function(d, p) {
2572
        return d3_time_formatPad(d.getDate(), p, 2);
2573
      },
2574
      e: function(d, p) {
2575
        return d3_time_formatPad(d.getDate(), p, 2);
2576
      },
2577
      H: function(d, p) {
2578
        return d3_time_formatPad(d.getHours(), p, 2);
2579
      },
2580
      I: function(d, p) {
2581
        return d3_time_formatPad(d.getHours() % 12 || 12, p, 2);
2582
      },
2583
      j: function(d, p) {
2584
        return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3);
2585
      },
2586
      L: function(d, p) {
2587
        return d3_time_formatPad(d.getMilliseconds(), p, 3);
2588
      },
2589
      m: function(d, p) {
2590
        return d3_time_formatPad(d.getMonth() + 1, p, 2);
2591
      },
2592
      M: function(d, p) {
2593
        return d3_time_formatPad(d.getMinutes(), p, 2);
2594
      },
2595
      p: function(d) {
2596
        return locale_periods[+(d.getHours() >= 12)];
2597
      },
2598
      S: function(d, p) {
2599
        return d3_time_formatPad(d.getSeconds(), p, 2);
2600
      },
2601
      U: function(d, p) {
2602
        return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2);
2603
      },
2604
      w: function(d) {
2605
        return d.getDay();
2606
      },
2607
      W: function(d, p) {
2608
        return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2);
2609
      },
2610
      x: d3_time_format(locale_date),
2611
      X: d3_time_format(locale_time),
2612
      y: function(d, p) {
2613
        return d3_time_formatPad(d.getFullYear() % 100, p, 2);
2614
      },
2615
      Y: function(d, p) {
2616
        return d3_time_formatPad(d.getFullYear() % 1e4, p, 4);
2617
      },
2618
      Z: d3_time_zone,
2619
      "%": function() {
2620
        return "%";
2621
      }
2622
    };
2623
    var d3_time_parsers = {
2624
      a: d3_time_parseWeekdayAbbrev,
2625
      A: d3_time_parseWeekday,
2626
      b: d3_time_parseMonthAbbrev,
2627
      B: d3_time_parseMonth,
2628
      c: d3_time_parseLocaleFull,
2629
      d: d3_time_parseDay,
2630
      e: d3_time_parseDay,
2631
      H: d3_time_parseHour24,
2632
      I: d3_time_parseHour24,
2633
      j: d3_time_parseDayOfYear,
2634
      L: d3_time_parseMilliseconds,
2635
      m: d3_time_parseMonthNumber,
2636
      M: d3_time_parseMinutes,
2637
      p: d3_time_parseAmPm,
2638
      S: d3_time_parseSeconds,
2639
      U: d3_time_parseWeekNumberSunday,
2640
      w: d3_time_parseWeekdayNumber,
2641
      W: d3_time_parseWeekNumberMonday,
2642
      x: d3_time_parseLocaleDate,
2643
      X: d3_time_parseLocaleTime,
2644
      y: d3_time_parseYear,
2645
      Y: d3_time_parseFullYear,
2646
      Z: d3_time_parseZone,
2647
      "%": d3_time_parseLiteralPercent
2648
    };
2649
    function d3_time_parseWeekdayAbbrev(date, string, i) {
2650
      d3_time_dayAbbrevRe.lastIndex = 0;
2651
      var n = d3_time_dayAbbrevRe.exec(string.slice(i));
2652
      return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2653
    }
2654
    function d3_time_parseWeekday(date, string, i) {
2655
      d3_time_dayRe.lastIndex = 0;
2656
      var n = d3_time_dayRe.exec(string.slice(i));
2657
      return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2658
    }
2659
    function d3_time_parseMonthAbbrev(date, string, i) {
2660
      d3_time_monthAbbrevRe.lastIndex = 0;
2661
      var n = d3_time_monthAbbrevRe.exec(string.slice(i));
2662
      return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2663
    }
2664
    function d3_time_parseMonth(date, string, i) {
2665
      d3_time_monthRe.lastIndex = 0;
2666
      var n = d3_time_monthRe.exec(string.slice(i));
2667
      return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2668
    }
2669
    function d3_time_parseLocaleFull(date, string, i) {
2670
      return d3_time_parse(date, d3_time_formats.c.toString(), string, i);
2671
    }
2672
    function d3_time_parseLocaleDate(date, string, i) {
2673
      return d3_time_parse(date, d3_time_formats.x.toString(), string, i);
2674
    }
2675
    function d3_time_parseLocaleTime(date, string, i) {
2676
      return d3_time_parse(date, d3_time_formats.X.toString(), string, i);
2677
    }
2678
    function d3_time_parseAmPm(date, string, i) {
2679
      var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase());
2680
      return n == null ? -1 : (date.p = n, i);
2681
    }
2682
    return d3_time_format;
2683
  }
2684
  var d3_time_formatPads = {
2685
    "-": "",
2686
    _: " ",
2687
    "0": "0"
2688
  }, d3_time_numberRe = /^\s*\d+/, d3_time_percentRe = /^%/;
2689
  function d3_time_formatPad(value, fill, width) {
2690
    var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length;
2691
    return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
2692
  }
2693
  function d3_time_formatRe(names) {
2694
    return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i");
2695
  }
2696
  function d3_time_formatLookup(names) {
2697
    var map = new d3_Map(), i = -1, n = names.length;
2698
    while (++i < n) map.set(names[i].toLowerCase(), i);
2699
    return map;
2700
  }
2701
  function d3_time_parseWeekdayNumber(date, string, i) {
2702
    d3_time_numberRe.lastIndex = 0;
2703
    var n = d3_time_numberRe.exec(string.slice(i, i + 1));
2704
    return n ? (date.w = +n[0], i + n[0].length) : -1;
2705
  }
2706
  function d3_time_parseWeekNumberSunday(date, string, i) {
2707
    d3_time_numberRe.lastIndex = 0;
2708
    var n = d3_time_numberRe.exec(string.slice(i));
2709
    return n ? (date.U = +n[0], i + n[0].length) : -1;
2710
  }
2711
  function d3_time_parseWeekNumberMonday(date, string, i) {
2712
    d3_time_numberRe.lastIndex = 0;
2713
    var n = d3_time_numberRe.exec(string.slice(i));
2714
    return n ? (date.W = +n[0], i + n[0].length) : -1;
2715
  }
2716
  function d3_time_parseFullYear(date, string, i) {
2717
    d3_time_numberRe.lastIndex = 0;
2718
    var n = d3_time_numberRe.exec(string.slice(i, i + 4));
2719
    return n ? (date.y = +n[0], i + n[0].length) : -1;
2720
  }
2721
  function d3_time_parseYear(date, string, i) {
2722
    d3_time_numberRe.lastIndex = 0;
2723
    var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2724
    return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;
2725
  }
2726
  function d3_time_parseZone(date, string, i) {
2727
    return /^[+-]\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string, 
2728
    i + 5) : -1;
2729
  }
2730
  function d3_time_expandYear(d) {
2731
    return d + (d > 68 ? 1900 : 2e3);
2732
  }
2733
  function d3_time_parseMonthNumber(date, string, i) {
2734
    d3_time_numberRe.lastIndex = 0;
2735
    var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2736
    return n ? (date.m = n[0] - 1, i + n[0].length) : -1;
2737
  }
2738
  function d3_time_parseDay(date, string, i) {
2739
    d3_time_numberRe.lastIndex = 0;
2740
    var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2741
    return n ? (date.d = +n[0], i + n[0].length) : -1;
2742
  }
2743
  function d3_time_parseDayOfYear(date, string, i) {
2744
    d3_time_numberRe.lastIndex = 0;
2745
    var n = d3_time_numberRe.exec(string.slice(i, i + 3));
2746
    return n ? (date.j = +n[0], i + n[0].length) : -1;
2747
  }
2748
  function d3_time_parseHour24(date, string, i) {
2749
    d3_time_numberRe.lastIndex = 0;
2750
    var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2751
    return n ? (date.H = +n[0], i + n[0].length) : -1;
2752
  }
2753
  function d3_time_parseMinutes(date, string, i) {
2754
    d3_time_numberRe.lastIndex = 0;
2755
    var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2756
    return n ? (date.M = +n[0], i + n[0].length) : -1;
2757
  }
2758
  function d3_time_parseSeconds(date, string, i) {
2759
    d3_time_numberRe.lastIndex = 0;
2760
    var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2761
    return n ? (date.S = +n[0], i + n[0].length) : -1;
2762
  }
2763
  function d3_time_parseMilliseconds(date, string, i) {
2764
    d3_time_numberRe.lastIndex = 0;
2765
    var n = d3_time_numberRe.exec(string.slice(i, i + 3));
2766
    return n ? (date.L = +n[0], i + n[0].length) : -1;
2767
  }
2768
  function d3_time_zone(d) {
2769
    var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = abs(z) / 60 | 0, zm = abs(z) % 60;
2770
    return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2);
2771
  }
2772
  function d3_time_parseLiteralPercent(date, string, i) {
2773
    d3_time_percentRe.lastIndex = 0;
2774
    var n = d3_time_percentRe.exec(string.slice(i, i + 1));
2775
    return n ? i + n[0].length : -1;
2776
  }
2777
  function d3_time_formatMulti(formats) {
2778
    var n = formats.length, i = -1;
2779
    while (++i < n) formats[i][0] = this(formats[i][0]);
2780
    return function(date) {
2781
      var i = 0, f = formats[i];
2782
      while (!f[1](date)) f = formats[++i];
2783
      return f[0](date);
2784
    };
2785
  }
2786
  d3.locale = function(locale) {
2787
    return {
2788
      numberFormat: d3_locale_numberFormat(locale),
2789
      timeFormat: d3_locale_timeFormat(locale)
2790
    };
2791
  };
2792
  var d3_locale_enUS = d3.locale({
2793
    decimal: ".",
2794
    thousands: ",",
2795
    grouping: [ 3 ],
2796
    currency: [ "$", "" ],
2797
    dateTime: "%a %b %e %X %Y",
2798
    date: "%m/%d/%Y",
2799
    time: "%H:%M:%S",
2800
    periods: [ "AM", "PM" ],
2801
    days: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
2802
    shortDays: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
2803
    months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
2804
    shortMonths: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]
2805
  });
2806
  d3.format = d3_locale_enUS.numberFormat;
2807
  d3.geo = {};
2808
  function d3_adder() {}
2809
  d3_adder.prototype = {
2810
    s: 0,
2811
    t: 0,
2812
    add: function(y) {
2813
      d3_adderSum(y, this.t, d3_adderTemp);
2814
      d3_adderSum(d3_adderTemp.s, this.s, this);
2815
      if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t;
2816
    },
2817
    reset: function() {
2818
      this.s = this.t = 0;
2819
    },
2820
    valueOf: function() {
2821
      return this.s;
2822
    }
2823
  };
2824
  var d3_adderTemp = new d3_adder();
2825
  function d3_adderSum(a, b, o) {
2826
    var x = o.s = a + b, bv = x - a, av = x - bv;
2827
    o.t = a - av + (b - bv);
2828
  }
2829
  d3.geo.stream = function(object, listener) {
2830
    if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) {
2831
      d3_geo_streamObjectType[object.type](object, listener);
2832
    } else {
2833
      d3_geo_streamGeometry(object, listener);
2834
    }
2835
  };
2836
  function d3_geo_streamGeometry(geometry, listener) {
2837
    if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {
2838
      d3_geo_streamGeometryType[geometry.type](geometry, listener);
2839
    }
2840
  }
2841
  var d3_geo_streamObjectType = {
2842
    Feature: function(feature, listener) {
2843
      d3_geo_streamGeometry(feature.geometry, listener);
2844
    },
2845
    FeatureCollection: function(object, listener) {
2846
      var features = object.features, i = -1, n = features.length;
2847
      while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener);
2848
    }
2849
  };
2850
  var d3_geo_streamGeometryType = {
2851
    Sphere: function(object, listener) {
2852
      listener.sphere();
2853
    },
2854
    Point: function(object, listener) {
2855
      object = object.coordinates;
2856
      listener.point(object[0], object[1], object[2]);
2857
    },
2858
    MultiPoint: function(object, listener) {
2859
      var coordinates = object.coordinates, i = -1, n = coordinates.length;
2860
      while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]);
2861
    },
2862
    LineString: function(object, listener) {
2863
      d3_geo_streamLine(object.coordinates, listener, 0);
2864
    },
2865
    MultiLineString: function(object, listener) {
2866
      var coordinates = object.coordinates, i = -1, n = coordinates.length;
2867
      while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0);
2868
    },
2869
    Polygon: function(object, listener) {
2870
      d3_geo_streamPolygon(object.coordinates, listener);
2871
    },
2872
    MultiPolygon: function(object, listener) {
2873
      var coordinates = object.coordinates, i = -1, n = coordinates.length;
2874
      while (++i < n) d3_geo_streamPolygon(coordinates[i], listener);
2875
    },
2876
    GeometryCollection: function(object, listener) {
2877
      var geometries = object.geometries, i = -1, n = geometries.length;
2878
      while (++i < n) d3_geo_streamGeometry(geometries[i], listener);
2879
    }
2880
  };
2881
  function d3_geo_streamLine(coordinates, listener, closed) {
2882
    var i = -1, n = coordinates.length - closed, coordinate;
2883
    listener.lineStart();
2884
    while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]);
2885
    listener.lineEnd();
2886
  }
2887
  function d3_geo_streamPolygon(coordinates, listener) {
2888
    var i = -1, n = coordinates.length;
2889
    listener.polygonStart();
2890
    while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1);
2891
    listener.polygonEnd();
2892
  }
2893
  d3.geo.area = function(object) {
2894
    d3_geo_areaSum = 0;
2895
    d3.geo.stream(object, d3_geo_area);
2896
    return d3_geo_areaSum;
2897
  };
2898
  var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder();
2899
  var d3_geo_area = {
2900
    sphere: function() {
2901
      d3_geo_areaSum += 4 * π;
2902
    },
2903
    point: d3_noop,
2904
    lineStart: d3_noop,
2905
    lineEnd: d3_noop,
2906
    polygonStart: function() {
2907
      d3_geo_areaRingSum.reset();
2908
      d3_geo_area.lineStart = d3_geo_areaRingStart;
2909
    },
2910
    polygonEnd: function() {
2911
      var area = 2 * d3_geo_areaRingSum;
2912
      d3_geo_areaSum += area < 0 ? 4 * π + area : area;
2913
      d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop;
2914
    }
2915
  };
2916
  function d3_geo_areaRingStart() {
2917
    var λ00, φ00, λ0, cosφ0, sinφ0;
2918
    d3_geo_area.point = function(λ, φ) {
2919
      d3_geo_area.point = nextPoint;
2920
      λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), 
2921
      sinφ0 = Math.sin(φ);
2922
    };
2923
    function nextPoint(λ, φ) {
2924
      λ *= d3_radians;
2925
      φ = φ * d3_radians / 2 + π / 4;
2926
      var  = λ - λ0, sdλ =  >= 0 ? 1 : -1, adλ = sdλ * , cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(adλ), v = k * sdλ * Math.sin(adλ);
2927
      d3_geo_areaRingSum.add(Math.atan2(v, u));
2928
      λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ;
2929
    }
2930
    d3_geo_area.lineEnd = function() {
2931
      nextPoint(λ00, φ00);
2932
    };
2933
  }
2934
  function d3_geo_cartesian(spherical) {
2935
    var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ);
2936
    return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ];
2937
  }
2938
  function d3_geo_cartesianDot(a, b) {
2939
    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
2940
  }
2941
  function d3_geo_cartesianCross(a, b) {
2942
    return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ];
2943
  }
2944
  function d3_geo_cartesianAdd(a, b) {
2945
    a[0] += b[0];
2946
    a[1] += b[1];
2947
    a[2] += b[2];
2948
  }
2949
  function d3_geo_cartesianScale(vector, k) {
2950
    return [ vector[0] * k, vector[1] * k, vector[2] * k ];
2951
  }
2952
  function d3_geo_cartesianNormalize(d) {
2953
    var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
2954
    d[0] /= l;
2955
    d[1] /= l;
2956
    d[2] /= l;
2957
  }
2958
  function d3_geo_spherical(cartesian) {
2959
    return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ];
2960
  }
2961
  function d3_geo_sphericalEqual(a, b) {
2962
    return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε;
2963
  }
2964
  d3.geo.bounds = function() {
2965
    var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range;
2966
    var bound = {
2967
      point: point,
2968
      lineStart: lineStart,
2969
      lineEnd: lineEnd,
2970
      polygonStart: function() {
2971
        bound.point = ringPoint;
2972
        bound.lineStart = ringStart;
2973
        bound.lineEnd = ringEnd;
2974
        dλSum = 0;
2975
        d3_geo_area.polygonStart();
2976
      },
2977
      polygonEnd: function() {
2978
        d3_geo_area.polygonEnd();
2979
        bound.point = point;
2980
        bound.lineStart = lineStart;
2981
        bound.lineEnd = lineEnd;
2982
        if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90;
2983
        range[0] = λ0, range[1] = λ1;
2984
      }
2985
    };
2986
    function point(λ, φ) {
2987
      ranges.push(range = [ λ0 = λ, λ1 = λ ]);
2988
      if (φ < φ0) φ0 = φ;
2989
      if (φ > φ1) φ1 = φ;
2990
    }
2991
    function linePoint(λ, φ) {
2992
      var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]);
2993
      if (p0) {
2994
        var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal);
2995
        d3_geo_cartesianNormalize(inflection);
2996
        inflection = d3_geo_spherical(inflection);
2997
        var  = λ - λ_, s =  > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs() > 180;
2998
        if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) {
2999
          var φi = inflection[1] * d3_degrees;
3000
          if (φi > φ1) φ1 = φi;
3001
        } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) {
3002
          var φi = -inflection[1] * d3_degrees;
3003
          if (φi < φ0) φ0 = φi;
3004
        } else {
3005
          if (φ < φ0) φ0 = φ;
3006
          if (φ > φ1) φ1 = φ;
3007
        }
3008
        if (antimeridian) {
3009
          if (λ < λ_) {
3010
            if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;
3011
          } else {
3012
            if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;
3013
          }
3014
        } else {
3015
          if (λ1 >= λ0) {
3016
            if (λ < λ0) λ0 = λ;
3017
            if (λ > λ1) λ1 = λ;
3018
          } else {
3019
            if (λ > λ_) {
3020
              if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;
3021
            } else {
3022
              if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;
3023
            }
3024
          }
3025
        }
3026
      } else {
3027
        point(λ, φ);
3028
      }
3029
      p0 = p, λ_ = λ;
3030
    }
3031
    function lineStart() {
3032
      bound.point = linePoint;
3033
    }
3034
    function lineEnd() {
3035
      range[0] = λ0, range[1] = λ1;
3036
      bound.point = point;
3037
      p0 = null;
3038
    }
3039
    function ringPoint(λ, φ) {
3040
      if (p0) {
3041
        var  = λ - λ_;
3042
        dλSum += abs() > 180 ?  + ( > 0 ? 360 : -360) : ;
3043
      } else λ__ = λ, φ__ = φ;
3044
      d3_geo_area.point(λ, φ);
3045
      linePoint(λ, φ);
3046
    }
3047
    function ringStart() {
3048
      d3_geo_area.lineStart();
3049
    }
3050
    function ringEnd() {
3051
      ringPoint(λ__, φ__);
3052
      d3_geo_area.lineEnd();
3053
      if (abs(dλSum) > ε) λ0 = -(λ1 = 180);
3054
      range[0] = λ0, range[1] = λ1;
3055
      p0 = null;
3056
    }
3057
    function angle(λ0, λ1) {
3058
      return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1;
3059
    }
3060
    function compareRanges(a, b) {
3061
      return a[0] - b[0];
3062
    }
3063
    function withinRange(x, range) {
3064
      return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;
3065
    }
3066
    return function(feature) {
3067
      φ1 = λ1 = -(λ0 = φ0 = Infinity);
3068
      ranges = [];
3069
      d3.geo.stream(feature, bound);
3070
      var n = ranges.length;
3071
      if (n) {
3072
        ranges.sort(compareRanges);
3073
        for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) {
3074
          b = ranges[i];
3075
          if (withinRange(b[0], a) || withinRange(b[1], a)) {
3076
            if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];
3077
            if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];
3078
          } else {
3079
            merged.push(a = b);
3080
          }
3081
        }
3082
        var best = -Infinity, ;
3083
        for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) {
3084
          b = merged[i];
3085
          if (( = angle(a[1], b[0])) > best) best = , λ0 = b[0], λ1 = a[1];
3086
        }
3087
      }
3088
      ranges = range = null;
3089
      return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ];
3090
    };
3091
  }();
3092
  d3.geo.centroid = function(object) {
3093
    d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0;
3094
    d3.geo.stream(object, d3_geo_centroid);
3095
    var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z;
3096
    if (m < ε2) {
3097
      x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1;
3098
      if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0;
3099
      m = x * x + y * y + z * z;
3100
      if (m < ε2) return [ NaN, NaN ];
3101
    }
3102
    return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ];
3103
  };
3104
  var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2;
3105
  var d3_geo_centroid = {
3106
    sphere: d3_noop,
3107
    point: d3_geo_centroidPoint,
3108
    lineStart: d3_geo_centroidLineStart,
3109
    lineEnd: d3_geo_centroidLineEnd,
3110
    polygonStart: function() {
3111
      d3_geo_centroid.lineStart = d3_geo_centroidRingStart;
3112
    },
3113
    polygonEnd: function() {
3114
      d3_geo_centroid.lineStart = d3_geo_centroidLineStart;
3115
    }
3116
  };
3117
  function d3_geo_centroidPoint(λ, φ) {
3118
    λ *= d3_radians;
3119
    var cosφ = Math.cos(φ *= d3_radians);
3120
    d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ));
3121
  }
3122
  function d3_geo_centroidPointXYZ(x, y, z) {
3123
    ++d3_geo_centroidW0;
3124
    d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0;
3125
    d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0;
3126
    d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0;
3127
  }
3128
  function d3_geo_centroidLineStart() {
3129
    var x0, y0, z0;
3130
    d3_geo_centroid.point = function(λ, φ) {
3131
      λ *= d3_radians;
3132
      var cosφ = Math.cos(φ *= d3_radians);
3133
      x0 = cosφ * Math.cos(λ);
3134
      y0 = cosφ * Math.sin(λ);
3135
      z0 = Math.sin(φ);
3136
      d3_geo_centroid.point = nextPoint;
3137
      d3_geo_centroidPointXYZ(x0, y0, z0);
3138
    };
3139
    function nextPoint(λ, φ) {
3140
      λ *= d3_radians;
3141
      var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z);
3142
      d3_geo_centroidW1 += w;
3143
      d3_geo_centroidX1 += w * (x0 + (x0 = x));
3144
      d3_geo_centroidY1 += w * (y0 + (y0 = y));
3145
      d3_geo_centroidZ1 += w * (z0 + (z0 = z));
3146
      d3_geo_centroidPointXYZ(x0, y0, z0);
3147
    }
3148
  }
3149
  function d3_geo_centroidLineEnd() {
3150
    d3_geo_centroid.point = d3_geo_centroidPoint;
3151
  }
3152
  function d3_geo_centroidRingStart() {
3153
    var λ00, φ00, x0, y0, z0;
3154
    d3_geo_centroid.point = function(λ, φ) {
3155
      λ00 = λ, φ00 = φ;
3156
      d3_geo_centroid.point = nextPoint;
3157
      λ *= d3_radians;
3158
      var cosφ = Math.cos(φ *= d3_radians);
3159
      x0 = cosφ * Math.cos(λ);
3160
      y0 = cosφ * Math.sin(λ);
3161
      z0 = Math.sin(φ);
3162
      d3_geo_centroidPointXYZ(x0, y0, z0);
3163
    };
3164
    d3_geo_centroid.lineEnd = function() {
3165
      nextPoint(λ00, φ00);
3166
      d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd;
3167
      d3_geo_centroid.point = d3_geo_centroidPoint;
3168
    };
3169
    function nextPoint(λ, φ) {
3170
      λ *= d3_radians;
3171
      var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u);
3172
      d3_geo_centroidX2 += v * cx;
3173
      d3_geo_centroidY2 += v * cy;
3174
      d3_geo_centroidZ2 += v * cz;
3175
      d3_geo_centroidW1 += w;
3176
      d3_geo_centroidX1 += w * (x0 + (x0 = x));
3177
      d3_geo_centroidY1 += w * (y0 + (y0 = y));
3178
      d3_geo_centroidZ1 += w * (z0 + (z0 = z));
3179
      d3_geo_centroidPointXYZ(x0, y0, z0);
3180
    }
3181
  }
3182
  function d3_geo_compose(a, b) {
3183
    function compose(x, y) {
3184
      return x = a(x, y), b(x[0], x[1]);
3185
    }
3186
    if (a.invert && b.invert) compose.invert = function(x, y) {
3187
      return x = b.invert(x, y), x && a.invert(x[0], x[1]);
3188
    };
3189
    return compose;
3190
  }
3191
  function d3_true() {
3192
    return true;
3193
  }
3194
  function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) {
3195
    var subject = [], clip = [];
3196
    segments.forEach(function(segment) {
3197
      if ((n = segment.length - 1) <= 0) return;
3198
      var n, p0 = segment[0], p1 = segment[n];
3199
      if (d3_geo_sphericalEqual(p0, p1)) {
3200
        listener.lineStart();
3201
        for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]);
3202
        listener.lineEnd();
3203
        return;
3204
      }
3205
      var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false);
3206
      a.o = b;
3207
      subject.push(a);
3208
      clip.push(b);
3209
      a = new d3_geo_clipPolygonIntersection(p1, segment, null, false);
3210
      b = new d3_geo_clipPolygonIntersection(p1, null, a, true);
3211
      a.o = b;
3212
      subject.push(a);
3213
      clip.push(b);
3214
    });
3215
    clip.sort(compare);
3216
    d3_geo_clipPolygonLinkCircular(subject);
3217
    d3_geo_clipPolygonLinkCircular(clip);
3218
    if (!subject.length) return;
3219
    for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) {
3220
      clip[i].e = entry = !entry;
3221
    }
3222
    var start = subject[0], points, point;
3223
    while (1) {
3224
      var current = start, isSubject = true;
3225
      while (current.v) if ((current = current.n) === start) return;
3226
      points = current.z;
3227
      listener.lineStart();
3228
      do {
3229
        current.v = current.o.v = true;
3230
        if (current.e) {
3231
          if (isSubject) {
3232
            for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]);
3233
          } else {
3234
            interpolate(current.x, current.n.x, 1, listener);
3235
          }
3236
          current = current.n;
3237
        } else {
3238
          if (isSubject) {
3239
            points = current.p.z;
3240
            for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]);
3241
          } else {
3242
            interpolate(current.x, current.p.x, -1, listener);
3243
          }
3244
          current = current.p;
3245
        }
3246
        current = current.o;
3247
        points = current.z;
3248
        isSubject = !isSubject;
3249
      } while (!current.v);
3250
      listener.lineEnd();
3251
    }
3252
  }
3253
  function d3_geo_clipPolygonLinkCircular(array) {
3254
    if (!(n = array.length)) return;
3255
    var n, i = 0, a = array[0], b;
3256
    while (++i < n) {
3257
      a.n = b = array[i];
3258
      b.p = a;
3259
      a = b;
3260
    }
3261
    a.n = b = array[0];
3262
    b.p = a;
3263
  }
3264
  function d3_geo_clipPolygonIntersection(point, points, other, entry) {
3265
    this.x = point;
3266
    this.z = points;
3267
    this.o = other;
3268
    this.e = entry;
3269
    this.v = false;
3270
    this.n = this.p = null;
3271
  }
3272
  function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) {
3273
    return function(rotate, listener) {
3274
      var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]);
3275
      var clip = {
3276
        point: point,
3277
        lineStart: lineStart,
3278
        lineEnd: lineEnd,
3279
        polygonStart: function() {
3280
          clip.point = pointRing;
3281
          clip.lineStart = ringStart;
3282
          clip.lineEnd = ringEnd;
3283
          segments = [];
3284
          polygon = [];
3285
        },
3286
        polygonEnd: function() {
3287
          clip.point = point;
3288
          clip.lineStart = lineStart;
3289
          clip.lineEnd = lineEnd;
3290
          segments = d3.merge(segments);
3291
          var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon);
3292
          if (segments.length) {
3293
            if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3294
            d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener);
3295
          } else if (clipStartInside) {
3296
            if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3297
            listener.lineStart();
3298
            interpolate(null, null, 1, listener);
3299
            listener.lineEnd();
3300
          }
3301
          if (polygonStarted) listener.polygonEnd(), polygonStarted = false;
3302
          segments = polygon = null;
3303
        },
3304
        sphere: function() {
3305
          listener.polygonStart();
3306
          listener.lineStart();
3307
          interpolate(null, null, 1, listener);
3308
          listener.lineEnd();
3309
          listener.polygonEnd();
3310
        }
3311
      };
3312
      function point(λ, φ) {
3313
        var point = rotate(λ, φ);
3314
        if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ);
3315
      }
3316
      function pointLine(λ, φ) {
3317
        var point = rotate(λ, φ);
3318
        line.point(point[0], point[1]);
3319
      }
3320
      function lineStart() {
3321
        clip.point = pointLine;
3322
        line.lineStart();
3323
      }
3324
      function lineEnd() {
3325
        clip.point = point;
3326
        line.lineEnd();
3327
      }
3328
      var segments;
3329
      var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring;
3330
      function pointRing(λ, φ) {
3331
        ring.push([ λ, φ ]);
3332
        var point = rotate(λ, φ);
3333
        ringListener.point(point[0], point[1]);
3334
      }
3335
      function ringStart() {
3336
        ringListener.lineStart();
3337
        ring = [];
3338
      }
3339
      function ringEnd() {
3340
        pointRing(ring[0][0], ring[0][1]);
3341
        ringListener.lineEnd();
3342
        var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length;
3343
        ring.pop();
3344
        polygon.push(ring);
3345
        ring = null;
3346
        if (!n) return;
3347
        if (clean & 1) {
3348
          segment = ringSegments[0];
3349
          var n = segment.length - 1, i = -1, point;
3350
          if (n > 0) {
3351
            if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3352
            listener.lineStart();
3353
            while (++i < n) listener.point((point = segment[i])[0], point[1]);
3354
            listener.lineEnd();
3355
          }
3356
          return;
3357
        }
3358
        if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
3359
        segments.push(ringSegments.filter(d3_geo_clipSegmentLength1));
3360
      }
3361
      return clip;
3362
    };
3363
  }
3364
  function d3_geo_clipSegmentLength1(segment) {
3365
    return segment.length > 1;
3366
  }
3367
  function d3_geo_clipBufferListener() {
3368
    var lines = [], line;
3369
    return {
3370
      lineStart: function() {
3371
        lines.push(line = []);
3372
      },
3373
      point: function(λ, φ) {
3374
        line.push([ λ, φ ]);
3375
      },
3376
      lineEnd: d3_noop,
3377
      buffer: function() {
3378
        var buffer = lines;
3379
        lines = [];
3380
        line = null;
3381
        return buffer;
3382
      },
3383
      rejoin: function() {
3384
        if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
3385
      }
3386
    };
3387
  }
3388
  function d3_geo_clipSort(a, b) {
3389
    return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]);
3390
  }
3391
  var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]);
3392
  function d3_geo_clipAntimeridianLine(listener) {
3393
    var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean;
3394
    return {
3395
      lineStart: function() {
3396
        listener.lineStart();
3397
        clean = 1;
3398
      },
3399
      point: function(λ1, φ1) {
3400
        var sλ1 = λ1 > 0 ? π : -π,  = abs(λ1 - λ0);
3401
        if (abs( - π) < ε) {
3402
          listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ);
3403
          listener.point(sλ0, φ0);
3404
          listener.lineEnd();
3405
          listener.lineStart();
3406
          listener.point(sλ1, φ0);
3407
          listener.point(λ1, φ0);
3408
          clean = 0;
3409
        } else if (sλ0 !== sλ1 &&  >= π) {
3410
          if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε;
3411
          if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε;
3412
          φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1);
3413
          listener.point(sλ0, φ0);
3414
          listener.lineEnd();
3415
          listener.lineStart();
3416
          listener.point(sλ1, φ0);
3417
          clean = 0;
3418
        }
3419
        listener.point(λ0 = λ1, φ0 = φ1);
3420
        sλ0 = sλ1;
3421
      },
3422
      lineEnd: function() {
3423
        listener.lineEnd();
3424
        λ0 = φ0 = NaN;
3425
      },
3426
      clean: function() {
3427
        return 2 - clean;
3428
      }
3429
    };
3430
  }
3431
  function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) {
3432
    var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1);
3433
    return abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) / (cosφ0 * cosφ1 * sinλ0_λ1)) : (φ0 + φ1) / 2;
3434
  }
3435
  function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) {
3436
    var φ;
3437
    if (from == null) {
3438
      φ = direction * halfπ;
3439
      listener.point(-π, φ);
3440
      listener.point(0, φ);
3441
      listener.point(π, φ);
3442
      listener.point(π, 0);
3443
      listener.point(π, -φ);
3444
      listener.point(0, -φ);
3445
      listener.point(-π, -φ);
3446
      listener.point(-π, 0);
3447
      listener.point(-π, φ);
3448
    } else if (abs(from[0] - to[0]) > ε) {
3449
      var s = from[0] < to[0] ? π : -π;
3450
      φ = direction * s / 2;
3451
      listener.point(-s, φ);
3452
      listener.point(0, φ);
3453
      listener.point(s, φ);
3454
    } else {
3455
      listener.point(to[0], to[1]);
3456
    }
3457
  }
3458
  function d3_geo_pointInPolygon(point, polygon) {
3459
    var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0;
3460
    d3_geo_areaRingSum.reset();
3461
    for (var i = 0, n = polygon.length; i < n; ++i) {
3462
      var ring = polygon[i], m = ring.length;
3463
      if (!m) continue;
3464
      var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1;
3465
      while (true) {
3466
        if (j === m) j = 0;
3467
        point = ring[j];
3468
        var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ),  = λ - λ0, sdλ =  >= 0 ? 1 : -1, adλ = sdλ * , antimeridian = adλ > π, k = sinφ0 * sinφ;
3469
        d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ)));
3470
        polarAngle += antimeridian ?  + sdλ * τ : ;
3471
        if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) {
3472
          var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point));
3473
          d3_geo_cartesianNormalize(arc);
3474
          var intersection = d3_geo_cartesianCross(meridianNormal, arc);
3475
          d3_geo_cartesianNormalize(intersection);
3476
          var φarc = (antimeridian ^  >= 0 ? -1 : 1) * d3_asin(intersection[2]);
3477
          if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) {
3478
            winding += antimeridian ^  >= 0 ? 1 : -1;
3479
          }
3480
        }
3481
        if (!j++) break;
3482
        λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point;
3483
      }
3484
    }
3485
    return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1;
3486
  }
3487
  function d3_geo_clipCircle(radius) {
3488
    var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians);
3489
    return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]);
3490
    function visible(λ, φ) {
3491
      return Math.cos(λ) * Math.cos(φ) > cr;
3492
    }
3493
    function clipLine(listener) {
3494
      var point0, c0, v0, v00, clean;
3495
      return {
3496
        lineStart: function() {
3497
          v00 = v0 = false;
3498
          clean = 1;
3499
        },
3500
        point: function(λ, φ) {
3501
          var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0;
3502
          if (!point0 && (v00 = v0 = v)) listener.lineStart();
3503
          if (v !== v0) {
3504
            point2 = intersect(point0, point1);
3505
            if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) {
3506
              point1[0] += ε;
3507
              point1[1] += ε;
3508
              v = visible(point1[0], point1[1]);
3509
            }
3510
          }
3511
          if (v !== v0) {
3512
            clean = 0;
3513
            if (v) {
3514
              listener.lineStart();
3515
              point2 = intersect(point1, point0);
3516
              listener.point(point2[0], point2[1]);
3517
            } else {
3518
              point2 = intersect(point0, point1);
3519
              listener.point(point2[0], point2[1]);
3520
              listener.lineEnd();
3521
            }
3522
            point0 = point2;
3523
          } else if (notHemisphere && point0 && smallRadius ^ v) {
3524
            var t;
3525
            if (!(c & c0) && (t = intersect(point1, point0, true))) {
3526
              clean = 0;
3527
              if (smallRadius) {
3528
                listener.lineStart();
3529
                listener.point(t[0][0], t[0][1]);
3530
                listener.point(t[1][0], t[1][1]);
3531
                listener.lineEnd();
3532
              } else {
3533
                listener.point(t[1][0], t[1][1]);
3534
                listener.lineEnd();
3535
                listener.lineStart();
3536
                listener.point(t[0][0], t[0][1]);
3537
              }
3538
            }
3539
          }
3540
          if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) {
3541
            listener.point(point1[0], point1[1]);
3542
          }
3543
          point0 = point1, v0 = v, c0 = c;
3544
        },
3545
        lineEnd: function() {
3546
          if (v0) listener.lineEnd();
3547
          point0 = null;
3548
        },
3549
        clean: function() {
3550
          return clean | (v00 && v0) << 1;
3551
        }
3552
      };
3553
    }
3554
    function intersect(a, b, two) {
3555
      var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b);
3556
      var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;
3557
      if (!determinant) return !two && a;
3558
      var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2);
3559
      d3_geo_cartesianAdd(A, B);
3560
      var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1);
3561
      if (t2 < 0) return;
3562
      var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu);
3563
      d3_geo_cartesianAdd(q, A);
3564
      q = d3_geo_spherical(q);
3565
      if (!two) return q;
3566
      var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z;
3567
      if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z;
3568
      var δλ = λ1 - λ0, polar = abs(δλ - π) < ε, meridian = polar || δλ < ε;
3569
      if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z;
3570
      if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) {
3571
        var q1 = d3_geo_cartesianScale(u, (-w + t) / uu);
3572
        d3_geo_cartesianAdd(q1, A);
3573
        return [ q, d3_geo_spherical(q1) ];
3574
      }
3575
    }
3576
    function code(λ, φ) {
3577
      var r = smallRadius ? radius : π - radius, code = 0;
3578
      if (λ < -r) code |= 1; else if (λ > r) code |= 2;
3579
      if (φ < -r) code |= 4; else if (φ > r) code |= 8;
3580
      return code;
3581
    }
3582
  }
3583
  function d3_geom_clipLine(x0, y0, x1, y1) {
3584
    return function(line) {
3585
      var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r;
3586
      r = x0 - ax;
3587
      if (!dx && r > 0) return;
3588
      r /= dx;
3589
      if (dx < 0) {
3590
        if (r < t0) return;
3591
        if (r < t1) t1 = r;
3592
      } else if (dx > 0) {
3593
        if (r > t1) return;
3594
        if (r > t0) t0 = r;
3595
      }
3596
      r = x1 - ax;
3597
      if (!dx && r < 0) return;
3598
      r /= dx;
3599
      if (dx < 0) {
3600
        if (r > t1) return;
3601
        if (r > t0) t0 = r;
3602
      } else if (dx > 0) {
3603
        if (r < t0) return;
3604
        if (r < t1) t1 = r;
3605
      }
3606
      r = y0 - ay;
3607
      if (!dy && r > 0) return;
3608
      r /= dy;
3609
      if (dy < 0) {
3610
        if (r < t0) return;
3611
        if (r < t1) t1 = r;
3612
      } else if (dy > 0) {
3613
        if (r > t1) return;
3614
        if (r > t0) t0 = r;
3615
      }
3616
      r = y1 - ay;
3617
      if (!dy && r < 0) return;
3618
      r /= dy;
3619
      if (dy < 0) {
3620
        if (r > t1) return;
3621
        if (r > t0) t0 = r;
3622
      } else if (dy > 0) {
3623
        if (r < t0) return;
3624
        if (r < t1) t1 = r;
3625
      }
3626
      if (t0 > 0) line.a = {
3627
        x: ax + t0 * dx,
3628
        y: ay + t0 * dy
3629
      };
3630
      if (t1 < 1) line.b = {
3631
        x: ax + t1 * dx,
3632
        y: ay + t1 * dy
3633
      };
3634
      return line;
3635
    };
3636
  }
3637
  var d3_geo_clipExtentMAX = 1e9;
3638
  d3.geo.clipExtent = function() {
3639
    var x0, y0, x1, y1, stream, clip, clipExtent = {
3640
      stream: function(output) {
3641
        if (stream) stream.valid = false;
3642
        stream = clip(output);
3643
        stream.valid = true;
3644
        return stream;
3645
      },
3646
      extent: function(_) {
3647
        if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];
3648
        clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]);
3649
        if (stream) stream.valid = false, stream = null;
3650
        return clipExtent;
3651
      }
3652
    };
3653
    return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]);
3654
  };
3655
  function d3_geo_clipExtent(x0, y0, x1, y1) {
3656
    return function(listener) {
3657
      var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring;
3658
      var clip = {
3659
        point: point,
3660
        lineStart: lineStart,
3661
        lineEnd: lineEnd,
3662
        polygonStart: function() {
3663
          listener = bufferListener;
3664
          segments = [];
3665
          polygon = [];
3666
          clean = true;
3667
        },
3668
        polygonEnd: function() {
3669
          listener = listener_;
3670
          segments = d3.merge(segments);
3671
          var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length;
3672
          if (inside || visible) {
3673
            listener.polygonStart();
3674
            if (inside) {
3675
              listener.lineStart();
3676
              interpolate(null, null, 1, listener);
3677
              listener.lineEnd();
3678
            }
3679
            if (visible) {
3680
              d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener);
3681
            }
3682
            listener.polygonEnd();
3683
          }
3684
          segments = polygon = ring = null;
3685
        }
3686
      };
3687
      function insidePolygon(p) {
3688
        var wn = 0, n = polygon.length, y = p[1];
3689
        for (var i = 0; i < n; ++i) {
3690
          for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {
3691
            b = v[j];
3692
            if (a[1] <= y) {
3693
              if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn;
3694
            } else {
3695
              if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn;
3696
            }
3697
            a = b;
3698
          }
3699
        }
3700
        return wn !== 0;
3701
      }
3702
      function interpolate(from, to, direction, listener) {
3703
        var a = 0, a1 = 0;
3704
        if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) {
3705
          do {
3706
            listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);
3707
          } while ((a = (a + direction + 4) % 4) !== a1);
3708
        } else {
3709
          listener.point(to[0], to[1]);
3710
        }
3711
      }
3712
      function pointVisible(x, y) {
3713
        return x0 <= x && x <= x1 && y0 <= y && y <= y1;
3714
      }
3715
      function point(x, y) {
3716
        if (pointVisible(x, y)) listener.point(x, y);
3717
      }
3718
      var x__, y__, v__, x_, y_, v_, first, clean;
3719
      function lineStart() {
3720
        clip.point = linePoint;
3721
        if (polygon) polygon.push(ring = []);
3722
        first = true;
3723
        v_ = false;
3724
        x_ = y_ = NaN;
3725
      }
3726
      function lineEnd() {
3727
        if (segments) {
3728
          linePoint(x__, y__);
3729
          if (v__ && v_) bufferListener.rejoin();
3730
          segments.push(bufferListener.buffer());
3731
        }
3732
        clip.point = point;
3733
        if (v_) listener.lineEnd();
3734
      }
3735
      function linePoint(x, y) {
3736
        x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x));
3737
        y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y));
3738
        var v = pointVisible(x, y);
3739
        if (polygon) ring.push([ x, y ]);
3740
        if (first) {
3741
          x__ = x, y__ = y, v__ = v;
3742
          first = false;
3743
          if (v) {
3744
            listener.lineStart();
3745
            listener.point(x, y);
3746
          }
3747
        } else {
3748
          if (v && v_) listener.point(x, y); else {
3749
            var l = {
3750
              a: {
3751
                x: x_,
3752
                y: y_
3753
              },
3754
              b: {
3755
                x: x,
3756
                y: y
3757
              }
3758
            };
3759
            if (clipLine(l)) {
3760
              if (!v_) {
3761
                listener.lineStart();
3762
                listener.point(l.a.x, l.a.y);
3763
              }
3764
              listener.point(l.b.x, l.b.y);
3765
              if (!v) listener.lineEnd();
3766
              clean = false;
3767
            } else if (v) {
3768
              listener.lineStart();
3769
              listener.point(x, y);
3770
              clean = false;
3771
            }
3772
          }
3773
        }
3774
        x_ = x, y_ = y, v_ = v;
3775
      }
3776
      return clip;
3777
    };
3778
    function corner(p, direction) {
3779
      return abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2;
3780
    }
3781
    function compare(a, b) {
3782
      return comparePoints(a.x, b.x);
3783
    }
3784
    function comparePoints(a, b) {
3785
      var ca = corner(a, 1), cb = corner(b, 1);
3786
      return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0];
3787
    }
3788
  }
3789
  function d3_geo_conic(projectAt) {
3790
    var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1);
3791
    p.parallels = function(_) {
3792
      if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ];
3793
      return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180);
3794
    };
3795
    return p;
3796
  }
3797
  function d3_geo_conicEqualArea(φ0, φ1) {
3798
    var sinφ0 = Math.sin(φ0), n = (sinφ0 + Math.sin(φ1)) / 2, C = 1 + sinφ0 * (2 * n - sinφ0), ρ0 = Math.sqrt(C) / n;
3799
    function forward(λ, φ) {
3800
      var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n;
3801
      return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ];
3802
    }
3803
    forward.invert = function(x, y) {
3804
      var ρ0_y = ρ0 - y;
3805
      return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ];
3806
    };
3807
    return forward;
3808
  }
3809
  (d3.geo.conicEqualArea = function() {
3810
    return d3_geo_conic(d3_geo_conicEqualArea);
3811
  }).raw = d3_geo_conicEqualArea;
3812
  d3.geo.albers = function() {
3813
    return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070);
3814
  };
3815
  d3.geo.albersUsa = function() {
3816
    var lower48 = d3.geo.albers();
3817
    var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]);
3818
    var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]);
3819
    var point, pointStream = {
3820
      point: function(x, y) {
3821
        point = [ x, y ];
3822
      }
3823
    }, lower48Point, alaskaPoint, hawaiiPoint;
3824
    function albersUsa(coordinates) {
3825
      var x = coordinates[0], y = coordinates[1];
3826
      point = null;
3827
      (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y);
3828
      return point;
3829
    }
3830
    albersUsa.invert = function(coordinates) {
3831
      var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k;
3832
      return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates);
3833
    };
3834
    albersUsa.stream = function(stream) {
3835
      var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream);
3836
      return {
3837
        point: function(x, y) {
3838
          lower48Stream.point(x, y);
3839
          alaskaStream.point(x, y);
3840
          hawaiiStream.point(x, y);
3841
        },
3842
        sphere: function() {
3843
          lower48Stream.sphere();
3844
          alaskaStream.sphere();
3845
          hawaiiStream.sphere();
3846
        },
3847
        lineStart: function() {
3848
          lower48Stream.lineStart();
3849
          alaskaStream.lineStart();
3850
          hawaiiStream.lineStart();
3851
        },
3852
        lineEnd: function() {
3853
          lower48Stream.lineEnd();
3854
          alaskaStream.lineEnd();
3855
          hawaiiStream.lineEnd();
3856
        },
3857
        polygonStart: function() {
3858
          lower48Stream.polygonStart();
3859
          alaskaStream.polygonStart();
3860
          hawaiiStream.polygonStart();
3861
        },
3862
        polygonEnd: function() {
3863
          lower48Stream.polygonEnd();
3864
          alaskaStream.polygonEnd();
3865
          hawaiiStream.polygonEnd();
3866
        }
3867
      };
3868
    };
3869
    albersUsa.precision = function(_) {
3870
      if (!arguments.length) return lower48.precision();
3871
      lower48.precision(_);
3872
      alaska.precision(_);
3873
      hawaii.precision(_);
3874
      return albersUsa;
3875
    };
3876
    albersUsa.scale = function(_) {
3877
      if (!arguments.length) return lower48.scale();
3878
      lower48.scale(_);
3879
      alaska.scale(_ * .35);
3880
      hawaii.scale(_);
3881
      return albersUsa.translate(lower48.translate());
3882
    };
3883
    albersUsa.translate = function(_) {
3884
      if (!arguments.length) return lower48.translate();
3885
      var k = lower48.scale(), x = +_[0], y = +_[1];
3886
      lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point;
3887
      alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + ε, y + .12 * k + ε ], [ x - .214 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point;
3888
      hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + ε, y + .166 * k + ε ], [ x - .115 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point;
3889
      return albersUsa;
3890
    };
3891
    return albersUsa.scale(1070);
3892
  };
3893
  var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = {
3894
    point: d3_noop,
3895
    lineStart: d3_noop,
3896
    lineEnd: d3_noop,
3897
    polygonStart: function() {
3898
      d3_geo_pathAreaPolygon = 0;
3899
      d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart;
3900
    },
3901
    polygonEnd: function() {
3902
      d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop;
3903
      d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2);
3904
    }
3905
  };
3906
  function d3_geo_pathAreaRingStart() {
3907
    var x00, y00, x0, y0;
3908
    d3_geo_pathArea.point = function(x, y) {
3909
      d3_geo_pathArea.point = nextPoint;
3910
      x00 = x0 = x, y00 = y0 = y;
3911
    };
3912
    function nextPoint(x, y) {
3913
      d3_geo_pathAreaPolygon += y0 * x - x0 * y;
3914
      x0 = x, y0 = y;
3915
    }
3916
    d3_geo_pathArea.lineEnd = function() {
3917
      nextPoint(x00, y00);
3918
    };
3919
  }
3920
  var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1;
3921
  var d3_geo_pathBounds = {
3922
    point: d3_geo_pathBoundsPoint,
3923
    lineStart: d3_noop,
3924
    lineEnd: d3_noop,
3925
    polygonStart: d3_noop,
3926
    polygonEnd: d3_noop
3927
  };
3928
  function d3_geo_pathBoundsPoint(x, y) {
3929
    if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x;
3930
    if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x;
3931
    if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y;
3932
    if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y;
3933
  }
3934
  function d3_geo_pathBuffer() {
3935
    var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = [];
3936
    var stream = {
3937
      point: point,
3938
      lineStart: function() {
3939
        stream.point = pointLineStart;
3940
      },
3941
      lineEnd: lineEnd,
3942
      polygonStart: function() {
3943
        stream.lineEnd = lineEndPolygon;
3944
      },
3945
      polygonEnd: function() {
3946
        stream.lineEnd = lineEnd;
3947
        stream.point = point;
3948
      },
3949
      pointRadius: function(_) {
3950
        pointCircle = d3_geo_pathBufferCircle(_);
3951
        return stream;
3952
      },
3953
      result: function() {
3954
        if (buffer.length) {
3955
          var result = buffer.join("");
3956
          buffer = [];
3957
          return result;
3958
        }
3959
      }
3960
    };
3961
    function point(x, y) {
3962
      buffer.push("M", x, ",", y, pointCircle);
3963
    }
3964
    function pointLineStart(x, y) {
3965
      buffer.push("M", x, ",", y);
3966
      stream.point = pointLine;
3967
    }
3968
    function pointLine(x, y) {
3969
      buffer.push("L", x, ",", y);
3970
    }
3971
    function lineEnd() {
3972
      stream.point = point;
3973
    }
3974
    function lineEndPolygon() {
3975
      buffer.push("Z");
3976
    }
3977
    return stream;
3978
  }
3979
  function d3_geo_pathBufferCircle(radius) {
3980
    return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z";
3981
  }
3982
  var d3_geo_pathCentroid = {
3983
    point: d3_geo_pathCentroidPoint,
3984
    lineStart: d3_geo_pathCentroidLineStart,
3985
    lineEnd: d3_geo_pathCentroidLineEnd,
3986
    polygonStart: function() {
3987
      d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart;
3988
    },
3989
    polygonEnd: function() {
3990
      d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;
3991
      d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart;
3992
      d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd;
3993
    }
3994
  };
3995
  function d3_geo_pathCentroidPoint(x, y) {
3996
    d3_geo_centroidX0 += x;
3997
    d3_geo_centroidY0 += y;
3998
    ++d3_geo_centroidZ0;
3999
  }
4000
  function d3_geo_pathCentroidLineStart() {
4001
    var x0, y0;
4002
    d3_geo_pathCentroid.point = function(x, y) {
4003
      d3_geo_pathCentroid.point = nextPoint;
4004
      d3_geo_pathCentroidPoint(x0 = x, y0 = y);
4005
    };
4006
    function nextPoint(x, y) {
4007
      var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);
4008
      d3_geo_centroidX1 += z * (x0 + x) / 2;
4009
      d3_geo_centroidY1 += z * (y0 + y) / 2;
4010
      d3_geo_centroidZ1 += z;
4011
      d3_geo_pathCentroidPoint(x0 = x, y0 = y);
4012
    }
4013
  }
4014
  function d3_geo_pathCentroidLineEnd() {
4015
    d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;
4016
  }
4017
  function d3_geo_pathCentroidRingStart() {
4018
    var x00, y00, x0, y0;
4019
    d3_geo_pathCentroid.point = function(x, y) {
4020
      d3_geo_pathCentroid.point = nextPoint;
4021
      d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y);
4022
    };
4023
    function nextPoint(x, y) {
4024
      var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);
4025
      d3_geo_centroidX1 += z * (x0 + x) / 2;
4026
      d3_geo_centroidY1 += z * (y0 + y) / 2;
4027
      d3_geo_centroidZ1 += z;
4028
      z = y0 * x - x0 * y;
4029
      d3_geo_centroidX2 += z * (x0 + x);
4030
      d3_geo_centroidY2 += z * (y0 + y);
4031
      d3_geo_centroidZ2 += z * 3;
4032
      d3_geo_pathCentroidPoint(x0 = x, y0 = y);
4033
    }
4034
    d3_geo_pathCentroid.lineEnd = function() {
4035
      nextPoint(x00, y00);
4036
    };
4037
  }
4038
  function d3_geo_pathContext(context) {
4039
    var pointRadius = 4.5;
4040
    var stream = {
4041
      point: point,
4042
      lineStart: function() {
4043
        stream.point = pointLineStart;
4044
      },
4045
      lineEnd: lineEnd,
4046
      polygonStart: function() {
4047
        stream.lineEnd = lineEndPolygon;
4048
      },
4049
      polygonEnd: function() {
4050
        stream.lineEnd = lineEnd;
4051
        stream.point = point;
4052
      },
4053
      pointRadius: function(_) {
4054
        pointRadius = _;
4055
        return stream;
4056
      },
4057
      result: d3_noop
4058
    };
4059
    function point(x, y) {
4060
      context.moveTo(x + pointRadius, y);
4061
      context.arc(x, y, pointRadius, 0, τ);
4062
    }
4063
    function pointLineStart(x, y) {
4064
      context.moveTo(x, y);
4065
      stream.point = pointLine;
4066
    }
4067
    function pointLine(x, y) {
4068
      context.lineTo(x, y);
4069
    }
4070
    function lineEnd() {
4071
      stream.point = point;
4072
    }
4073
    function lineEndPolygon() {
4074
      context.closePath();
4075
    }
4076
    return stream;
4077
  }
4078
  function d3_geo_resample(project) {
4079
    var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16;
4080
    function resample(stream) {
4081
      return (maxDepth ? resampleRecursive : resampleNone)(stream);
4082
    }
4083
    function resampleNone(stream) {
4084
      return d3_geo_transformPoint(stream, function(x, y) {
4085
        x = project(x, y);
4086
        stream.point(x[0], x[1]);
4087
      });
4088
    }
4089
    function resampleRecursive(stream) {
4090
      var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0;
4091
      var resample = {
4092
        point: point,
4093
        lineStart: lineStart,
4094
        lineEnd: lineEnd,
4095
        polygonStart: function() {
4096
          stream.polygonStart();
4097
          resample.lineStart = ringStart;
4098
        },
4099
        polygonEnd: function() {
4100
          stream.polygonEnd();
4101
          resample.lineStart = lineStart;
4102
        }
4103
      };
4104
      function point(x, y) {
4105
        x = project(x, y);
4106
        stream.point(x[0], x[1]);
4107
      }
4108
      function lineStart() {
4109
        x0 = NaN;
4110
        resample.point = linePoint;
4111
        stream.lineStart();
4112
      }
4113
      function linePoint(λ, φ) {
4114
        var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ);
4115
        resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);
4116
        stream.point(x0, y0);
4117
      }
4118
      function lineEnd() {
4119
        resample.point = point;
4120
        stream.lineEnd();
4121
      }
4122
      function ringStart() {
4123
        lineStart();
4124
        resample.point = ringPoint;
4125
        resample.lineEnd = ringEnd;
4126
      }
4127
      function ringPoint(λ, φ) {
4128
        linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;
4129
        resample.point = linePoint;
4130
      }
4131
      function ringEnd() {
4132
        resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream);
4133
        resample.lineEnd = lineEnd;
4134
        lineEnd();
4135
      }
4136
      return resample;
4137
    }
4138
    function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) {
4139
      var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;
4140
      if (d2 > 4 * δ2 && depth--) {
4141
        var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), φ2 = Math.asin(c /= m), λ2 = abs(abs(c) - 1) < ε || abs(λ0 - λ1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, φ2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2;
4142
        if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
4143
          resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream);
4144
          stream.point(x2, y2);
4145
          resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream);
4146
        }
4147
      }
4148
    }
4149
    resample.precision = function(_) {
4150
      if (!arguments.length) return Math.sqrt(δ2);
4151
      maxDepth = (δ2 = _ * _) > 0 && 16;
4152
      return resample;
4153
    };
4154
    return resample;
4155
  }
4156
  d3.geo.path = function() {
4157
    var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream;
4158
    function path(object) {
4159
      if (object) {
4160
        if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
4161
        if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream);
4162
        d3.geo.stream(object, cacheStream);
4163
      }
4164
      return contextStream.result();
4165
    }
4166
    path.area = function(object) {
4167
      d3_geo_pathAreaSum = 0;
4168
      d3.geo.stream(object, projectStream(d3_geo_pathArea));
4169
      return d3_geo_pathAreaSum;
4170
    };
4171
    path.centroid = function(object) {
4172
      d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0;
4173
      d3.geo.stream(object, projectStream(d3_geo_pathCentroid));
4174
      return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ];
4175
    };
4176
    path.bounds = function(object) {
4177
      d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity);
4178
      d3.geo.stream(object, projectStream(d3_geo_pathBounds));
4179
      return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ];
4180
    };
4181
    path.projection = function(_) {
4182
      if (!arguments.length) return projection;
4183
      projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity;
4184
      return reset();
4185
    };
4186
    path.context = function(_) {
4187
      if (!arguments.length) return context;
4188
      contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_);
4189
      if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius);
4190
      return reset();
4191
    };
4192
    path.pointRadius = function(_) {
4193
      if (!arguments.length) return pointRadius;
4194
      pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_);
4195
      return path;
4196
    };
4197
    function reset() {
4198
      cacheStream = null;
4199
      return path;
4200
    }
4201
    return path.projection(d3.geo.albersUsa()).context(null);
4202
  };
4203
  function d3_geo_pathProjectStream(project) {
4204
    var resample = d3_geo_resample(function(x, y) {
4205
      return project([ x * d3_degrees, y * d3_degrees ]);
4206
    });
4207
    return function(stream) {
4208
      return d3_geo_projectionRadians(resample(stream));
4209
    };
4210
  }
4211
  d3.geo.transform = function(methods) {
4212
    return {
4213
      stream: function(stream) {
4214
        var transform = new d3_geo_transform(stream);
4215
        for (var k in methods) transform[k] = methods[k];
4216
        return transform;
4217
      }
4218
    };
4219
  };
4220
  function d3_geo_transform(stream) {
4221
    this.stream = stream;
4222
  }
4223
  d3_geo_transform.prototype = {
4224
    point: function(x, y) {
4225
      this.stream.point(x, y);
4226
    },
4227
    sphere: function() {
4228
      this.stream.sphere();
4229
    },
4230
    lineStart: function() {
4231
      this.stream.lineStart();
4232
    },
4233
    lineEnd: function() {
4234
      this.stream.lineEnd();
4235
    },
4236
    polygonStart: function() {
4237
      this.stream.polygonStart();
4238
    },
4239
    polygonEnd: function() {
4240
      this.stream.polygonEnd();
4241
    }
4242
  };
4243
  function d3_geo_transformPoint(stream, point) {
4244
    return {
4245
      point: point,
4246
      sphere: function() {
4247
        stream.sphere();
4248
      },
4249
      lineStart: function() {
4250
        stream.lineStart();
4251
      },
4252
      lineEnd: function() {
4253
        stream.lineEnd();
4254
      },
4255
      polygonStart: function() {
4256
        stream.polygonStart();
4257
      },
4258
      polygonEnd: function() {
4259
        stream.polygonEnd();
4260
      }
4261
    };
4262
  }
4263
  d3.geo.projection = d3_geo_projection;
4264
  d3.geo.projectionMutator = d3_geo_projectionMutator;
4265
  function d3_geo_projection(project) {
4266
    return d3_geo_projectionMutator(function() {
4267
      return project;
4268
    })();
4269
  }
4270
  function d3_geo_projectionMutator(projectAt) {
4271
    var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) {
4272
      x = project(x, y);
4273
      return [ x[0] * k + δx, δy - x[1] * k ];
4274
    }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream;
4275
    function projection(point) {
4276
      point = projectRotate(point[0] * d3_radians, point[1] * d3_radians);
4277
      return [ point[0] * k + δx, δy - point[1] * k ];
4278
    }
4279
    function invert(point) {
4280
      point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k);
4281
      return point && [ point[0] * d3_degrees, point[1] * d3_degrees ];
4282
    }
4283
    projection.stream = function(output) {
4284
      if (stream) stream.valid = false;
4285
      stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output))));
4286
      stream.valid = true;
4287
      return stream;
4288
    };
4289
    projection.clipAngle = function(_) {
4290
      if (!arguments.length) return clipAngle;
4291
      preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians);
4292
      return invalidate();
4293
    };
4294
    projection.clipExtent = function(_) {
4295
      if (!arguments.length) return clipExtent;
4296
      clipExtent = _;
4297
      postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity;
4298
      return invalidate();
4299
    };
4300
    projection.scale = function(_) {
4301
      if (!arguments.length) return k;
4302
      k = +_;
4303
      return reset();
4304
    };
4305
    projection.translate = function(_) {
4306
      if (!arguments.length) return [ x, y ];
4307
      x = +_[0];
4308
      y = +_[1];
4309
      return reset();
4310
    };
4311
    projection.center = function(_) {
4312
      if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ];
4313
      λ = _[0] % 360 * d3_radians;
4314
      φ = _[1] % 360 * d3_radians;
4315
      return reset();
4316
    };
4317
    projection.rotate = function(_) {
4318
      if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ];
4319
      δλ = _[0] % 360 * d3_radians;
4320
      δφ = _[1] % 360 * d3_radians;
4321
      δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0;
4322
      return reset();
4323
    };
4324
    d3.rebind(projection, projectResample, "precision");
4325
    function reset() {
4326
      projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project);
4327
      var center = project(λ, φ);
4328
      δx = x - center[0] * k;
4329
      δy = y + center[1] * k;
4330
      return invalidate();
4331
    }
4332
    function invalidate() {
4333
      if (stream) stream.valid = false, stream = null;
4334
      return projection;
4335
    }
4336
    return function() {
4337
      project = projectAt.apply(this, arguments);
4338
      projection.invert = project.invert && invert;
4339
      return reset();
4340
    };
4341
  }
4342
  function d3_geo_projectionRadians(stream) {
4343
    return d3_geo_transformPoint(stream, function(x, y) {
4344
      stream.point(x * d3_radians, y * d3_radians);
4345
    });
4346
  }
4347
  function d3_geo_equirectangular(λ, φ) {
4348
    return [ λ, φ ];
4349
  }
4350
  (d3.geo.equirectangular = function() {
4351
    return d3_geo_projection(d3_geo_equirectangular);
4352
  }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular;
4353
  d3.geo.rotation = function(rotate) {
4354
    rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0);
4355
    function forward(coordinates) {
4356
      coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
4357
      return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
4358
    }
4359
    forward.invert = function(coordinates) {
4360
      coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
4361
      return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
4362
    };
4363
    return forward;
4364
  };
4365
  function d3_geo_identityRotation(λ, φ) {
4366
    return [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];
4367
  }
4368
  d3_geo_identityRotation.invert = d3_geo_equirectangular;
4369
  function d3_geo_rotation(δλ, δφ, δγ) {
4370
    return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_identityRotation;
4371
  }
4372
  function d3_geo_forwardRotationλ(δλ) {
4373
    return function(λ, φ) {
4374
      return λ += δλ, [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];
4375
    };
4376
  }
4377
  function d3_geo_rotationλ(δλ) {
4378
    var rotation = d3_geo_forwardRotationλ(δλ);
4379
    rotation.invert = d3_geo_forwardRotationλ(-δλ);
4380
    return rotation;
4381
  }
4382
  function d3_geo_rotationφγ(δφ, δγ) {
4383
    var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ);
4384
    function rotation(λ, φ) {
4385
      var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ;
4386
      return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ];
4387
    }
4388
    rotation.invert = function(λ, φ) {
4389
      var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ;
4390
      return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ];
4391
    };
4392
    return rotation;
4393
  }
4394
  d3.geo.circle = function() {
4395
    var origin = [ 0, 0 ], angle, precision = 6, interpolate;
4396
    function circle() {
4397
      var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = [];
4398
      interpolate(null, null, 1, {
4399
        point: function(x, y) {
4400
          ring.push(x = rotate(x, y));
4401
          x[0] *= d3_degrees, x[1] *= d3_degrees;
4402
        }
4403
      });
4404
      return {
4405
        type: "Polygon",
4406
        coordinates: [ ring ]
4407
      };
4408
    }
4409
    circle.origin = function(x) {
4410
      if (!arguments.length) return origin;
4411
      origin = x;
4412
      return circle;
4413
    };
4414
    circle.angle = function(x) {
4415
      if (!arguments.length) return angle;
4416
      interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians);
4417
      return circle;
4418
    };
4419
    circle.precision = function(_) {
4420
      if (!arguments.length) return precision;
4421
      interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians);
4422
      return circle;
4423
    };
4424
    return circle.angle(90);
4425
  };
4426
  function d3_geo_circleInterpolate(radius, precision) {
4427
    var cr = Math.cos(radius), sr = Math.sin(radius);
4428
    return function(from, to, direction, listener) {
4429
      var step = direction * precision;
4430
      if (from != null) {
4431
        from = d3_geo_circleAngle(cr, from);
4432
        to = d3_geo_circleAngle(cr, to);
4433
        if (direction > 0 ? from < to : from > to) from += direction * τ;
4434
      } else {
4435
        from = radius + direction * τ;
4436
        to = radius - .5 * step;
4437
      }
4438
      for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) {
4439
        listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]);
4440
      }
4441
    };
4442
  }
4443
  function d3_geo_circleAngle(cr, point) {
4444
    var a = d3_geo_cartesian(point);
4445
    a[0] -= cr;
4446
    d3_geo_cartesianNormalize(a);
4447
    var angle = d3_acos(-a[1]);
4448
    return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI);
4449
  }
4450
  d3.geo.distance = function(a, b) {
4451
    var Δλ = (b[0] - a[0]) * d3_radians, φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), t;
4452
    return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ);
4453
  };
4454
  d3.geo.graticule = function() {
4455
    var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5;
4456
    function graticule() {
4457
      return {
4458
        type: "MultiLineString",
4459
        coordinates: lines()
4460
      };
4461
    }
4462
    function lines() {
4463
      return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) {
4464
        return abs(x % DX) > ε;
4465
      }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) {
4466
        return abs(y % DY) > ε;
4467
      }).map(y));
4468
    }
4469
    graticule.lines = function() {
4470
      return lines().map(function(coordinates) {
4471
        return {
4472
          type: "LineString",
4473
          coordinates: coordinates
4474
        };
4475
      });
4476
    };
4477
    graticule.outline = function() {
4478
      return {
4479
        type: "Polygon",
4480
        coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ]
4481
      };
4482
    };
4483
    graticule.extent = function(_) {
4484
      if (!arguments.length) return graticule.minorExtent();
4485
      return graticule.majorExtent(_).minorExtent(_);
4486
    };
4487
    graticule.majorExtent = function(_) {
4488
      if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ];
4489
      X0 = +_[0][0], X1 = +_[1][0];
4490
      Y0 = +_[0][1], Y1 = +_[1][1];
4491
      if (X0 > X1) _ = X0, X0 = X1, X1 = _;
4492
      if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;
4493
      return graticule.precision(precision);
4494
    };
4495
    graticule.minorExtent = function(_) {
4496
      if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];
4497
      x0 = +_[0][0], x1 = +_[1][0];
4498
      y0 = +_[0][1], y1 = +_[1][1];
4499
      if (x0 > x1) _ = x0, x0 = x1, x1 = _;
4500
      if (y0 > y1) _ = y0, y0 = y1, y1 = _;
4501
      return graticule.precision(precision);
4502
    };
4503
    graticule.step = function(_) {
4504
      if (!arguments.length) return graticule.minorStep();
4505
      return graticule.majorStep(_).minorStep(_);
4506
    };
4507
    graticule.majorStep = function(_) {
4508
      if (!arguments.length) return [ DX, DY ];
4509
      DX = +_[0], DY = +_[1];
4510
      return graticule;
4511
    };
4512
    graticule.minorStep = function(_) {
4513
      if (!arguments.length) return [ dx, dy ];
4514
      dx = +_[0], dy = +_[1];
4515
      return graticule;
4516
    };
4517
    graticule.precision = function(_) {
4518
      if (!arguments.length) return precision;
4519
      precision = +_;
4520
      x = d3_geo_graticuleX(y0, y1, 90);
4521
      y = d3_geo_graticuleY(x0, x1, precision);
4522
      X = d3_geo_graticuleX(Y0, Y1, 90);
4523
      Y = d3_geo_graticuleY(X0, X1, precision);
4524
      return graticule;
4525
    };
4526
    return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]);
4527
  };
4528
  function d3_geo_graticuleX(y0, y1, dy) {
4529
    var y = d3.range(y0, y1 - ε, dy).concat(y1);
4530
    return function(x) {
4531
      return y.map(function(y) {
4532
        return [ x, y ];
4533
      });
4534
    };
4535
  }
4536
  function d3_geo_graticuleY(x0, x1, dx) {
4537
    var x = d3.range(x0, x1 - ε, dx).concat(x1);
4538
    return function(y) {
4539
      return x.map(function(x) {
4540
        return [ x, y ];
4541
      });
4542
    };
4543
  }
4544
  function d3_source(d) {
4545
    return d.source;
4546
  }
4547
  function d3_target(d) {
4548
    return d.target;
4549
  }
4550
  d3.geo.greatArc = function() {
4551
    var source = d3_source, source_, target = d3_target, target_;
4552
    function greatArc() {
4553
      return {
4554
        type: "LineString",
4555
        coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ]
4556
      };
4557
    }
4558
    greatArc.distance = function() {
4559
      return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments));
4560
    };
4561
    greatArc.source = function(_) {
4562
      if (!arguments.length) return source;
4563
      source = _, source_ = typeof _ === "function" ? null : _;
4564
      return greatArc;
4565
    };
4566
    greatArc.target = function(_) {
4567
      if (!arguments.length) return target;
4568
      target = _, target_ = typeof _ === "function" ? null : _;
4569
      return greatArc;
4570
    };
4571
    greatArc.precision = function() {
4572
      return arguments.length ? greatArc : 0;
4573
    };
4574
    return greatArc;
4575
  };
4576
  d3.geo.interpolate = function(source, target) {
4577
    return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians);
4578
  };
4579
  function d3_geo_interpolate(x0, y0, x1, y1) {
4580
    var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d);
4581
    var interpolate = d ? function(t) {
4582
      var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1;
4583
      return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ];
4584
    } : function() {
4585
      return [ x0 * d3_degrees, y0 * d3_degrees ];
4586
    };
4587
    interpolate.distance = d;
4588
    return interpolate;
4589
  }
4590
  d3.geo.length = function(object) {
4591
    d3_geo_lengthSum = 0;
4592
    d3.geo.stream(object, d3_geo_length);
4593
    return d3_geo_lengthSum;
4594
  };
4595
  var d3_geo_lengthSum;
4596
  var d3_geo_length = {
4597
    sphere: d3_noop,
4598
    point: d3_noop,
4599
    lineStart: d3_geo_lengthLineStart,
4600
    lineEnd: d3_noop,
4601
    polygonStart: d3_noop,
4602
    polygonEnd: d3_noop
4603
  };
4604
  function d3_geo_lengthLineStart() {
4605
    var λ0, sinφ0, cosφ0;
4606
    d3_geo_length.point = function(λ, φ) {
4607
      λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ);
4608
      d3_geo_length.point = nextPoint;
4609
    };
4610
    d3_geo_length.lineEnd = function() {
4611
      d3_geo_length.point = d3_geo_length.lineEnd = d3_noop;
4612
    };
4613
    function nextPoint(λ, φ) {
4614
      var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t);
4615
      d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ);
4616
      λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ;
4617
    }
4618
  }
4619
  function d3_geo_azimuthal(scale, angle) {
4620
    function azimuthal(λ, φ) {
4621
      var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ);
4622
      return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ];
4623
    }
4624
    azimuthal.invert = function(x, y) {
4625
      var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c);
4626
      return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ];
4627
    };
4628
    return azimuthal;
4629
  }
4630
  var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) {
4631
    return Math.sqrt(2 / (1 + cosλcosφ));
4632
  }, function(ρ) {
4633
    return 2 * Math.asin(ρ / 2);
4634
  });
4635
  (d3.geo.azimuthalEqualArea = function() {
4636
    return d3_geo_projection(d3_geo_azimuthalEqualArea);
4637
  }).raw = d3_geo_azimuthalEqualArea;
4638
  var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) {
4639
    var c = Math.acos(cosλcosφ);
4640
    return c && c / Math.sin(c);
4641
  }, d3_identity);
4642
  (d3.geo.azimuthalEquidistant = function() {
4643
    return d3_geo_projection(d3_geo_azimuthalEquidistant);
4644
  }).raw = d3_geo_azimuthalEquidistant;
4645
  function d3_geo_conicConformal(φ0, φ1) {
4646
    var cosφ0 = Math.cos(φ0), t = function(φ) {
4647
      return Math.tan(π / 4 + φ / 2);
4648
    }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n;
4649
    if (!n) return d3_geo_mercator;
4650
    function forward(λ, φ) {
4651
      if (F > 0) {
4652
        if (φ < -halfπ + ε) φ = -halfπ + ε;
4653
      } else {
4654
        if (φ > halfπ - ε) φ = halfπ - ε;
4655
      }
4656
      var ρ = F / Math.pow(t(φ), n);
4657
      return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ];
4658
    }
4659
    forward.invert = function(x, y) {
4660
      var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y);
4661
      return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ ];
4662
    };
4663
    return forward;
4664
  }
4665
  (d3.geo.conicConformal = function() {
4666
    return d3_geo_conic(d3_geo_conicConformal);
4667
  }).raw = d3_geo_conicConformal;
4668
  function d3_geo_conicEquidistant(φ0, φ1) {
4669
    var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0;
4670
    if (abs(n) < ε) return d3_geo_equirectangular;
4671
    function forward(λ, φ) {
4672
      var ρ = G - φ;
4673
      return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ];
4674
    }
4675
    forward.invert = function(x, y) {
4676
      var ρ0_y = G - y;
4677
      return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ];
4678
    };
4679
    return forward;
4680
  }
4681
  (d3.geo.conicEquidistant = function() {
4682
    return d3_geo_conic(d3_geo_conicEquidistant);
4683
  }).raw = d3_geo_conicEquidistant;
4684
  var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) {
4685
    return 1 / cosλcosφ;
4686
  }, Math.atan);
4687
  (d3.geo.gnomonic = function() {
4688
    return d3_geo_projection(d3_geo_gnomonic);
4689
  }).raw = d3_geo_gnomonic;
4690
  function d3_geo_mercator(λ, φ) {
4691
    return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ];
4692
  }
4693
  d3_geo_mercator.invert = function(x, y) {
4694
    return [ x, 2 * Math.atan(Math.exp(y)) - halfπ ];
4695
  };
4696
  function d3_geo_mercatorProjection(project) {
4697
    var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto;
4698
    m.scale = function() {
4699
      var v = scale.apply(m, arguments);
4700
      return v === m ? clipAuto ? m.clipExtent(null) : m : v;
4701
    };
4702
    m.translate = function() {
4703
      var v = translate.apply(m, arguments);
4704
      return v === m ? clipAuto ? m.clipExtent(null) : m : v;
4705
    };
4706
    m.clipExtent = function(_) {
4707
      var v = clipExtent.apply(m, arguments);
4708
      if (v === m) {
4709
        if (clipAuto = _ == null) {
4710
          var k = π * scale(), t = translate();
4711
          clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]);
4712
        }
4713
      } else if (clipAuto) {
4714
        v = null;
4715
      }
4716
      return v;
4717
    };
4718
    return m.clipExtent(null);
4719
  }
4720
  (d3.geo.mercator = function() {
4721
    return d3_geo_mercatorProjection(d3_geo_mercator);
4722
  }).raw = d3_geo_mercator;
4723
  var d3_geo_orthographic = d3_geo_azimuthal(function() {
4724
    return 1;
4725
  }, Math.asin);
4726
  (d3.geo.orthographic = function() {
4727
    return d3_geo_projection(d3_geo_orthographic);
4728
  }).raw = d3_geo_orthographic;
4729
  var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) {
4730
    return 1 / (1 + cosλcosφ);
4731
  }, function(ρ) {
4732
    return 2 * Math.atan(ρ);
4733
  });
4734
  (d3.geo.stereographic = function() {
4735
    return d3_geo_projection(d3_geo_stereographic);
4736
  }).raw = d3_geo_stereographic;
4737
  function d3_geo_transverseMercator(λ, φ) {
4738
    return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ];
4739
  }
4740
  d3_geo_transverseMercator.invert = function(x, y) {
4741
    return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ];
4742
  };
4743
  (d3.geo.transverseMercator = function() {
4744
    var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate;
4745
    projection.center = function(_) {
4746
      return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]);
4747
    };
4748
    projection.rotate = function(_) {
4749
      return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), 
4750
      [ _[0], _[1], _[2] - 90 ]);
4751
    };
4752
    return rotate([ 0, 0, 90 ]);
4753
  }).raw = d3_geo_transverseMercator;
4754
  d3.geom = {};
4755
  function d3_geom_pointX(d) {
4756
    return d[0];
4757
  }
4758
  function d3_geom_pointY(d) {
4759
    return d[1];
4760
  }
4761
  d3.geom.hull = function(vertices) {
4762
    var x = d3_geom_pointX, y = d3_geom_pointY;
4763
    if (arguments.length) return hull(vertices);
4764
    function hull(data) {
4765
      if (data.length < 3) return [];
4766
      var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = [];
4767
      for (i = 0; i < n; i++) {
4768
        points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]);
4769
      }
4770
      points.sort(d3_geom_hullOrder);
4771
      for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]);
4772
      var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints);
4773
      var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = [];
4774
      for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]);
4775
      for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]);
4776
      return polygon;
4777
    }
4778
    hull.x = function(_) {
4779
      return arguments.length ? (x = _, hull) : x;
4780
    };
4781
    hull.y = function(_) {
4782
      return arguments.length ? (y = _, hull) : y;
4783
    };
4784
    return hull;
4785
  };
4786
  function d3_geom_hullUpper(points) {
4787
    var n = points.length, hull = [ 0, 1 ], hs = 2;
4788
    for (var i = 2; i < n; i++) {
4789
      while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs;
4790
      hull[hs++] = i;
4791
    }
4792
    return hull.slice(0, hs);
4793
  }
4794
  function d3_geom_hullOrder(a, b) {
4795
    return a[0] - b[0] || a[1] - b[1];
4796
  }
4797
  d3.geom.polygon = function(coordinates) {
4798
    d3_subclass(coordinates, d3_geom_polygonPrototype);
4799
    return coordinates;
4800
  };
4801
  var d3_geom_polygonPrototype = d3.geom.polygon.prototype = [];
4802
  d3_geom_polygonPrototype.area = function() {
4803
    var i = -1, n = this.length, a, b = this[n - 1], area = 0;
4804
    while (++i < n) {
4805
      a = b;
4806
      b = this[i];
4807
      area += a[1] * b[0] - a[0] * b[1];
4808
    }
4809
    return area * .5;
4810
  };
4811
  d3_geom_polygonPrototype.centroid = function(k) {
4812
    var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c;
4813
    if (!arguments.length) k = -1 / (6 * this.area());
4814
    while (++i < n) {
4815
      a = b;
4816
      b = this[i];
4817
      c = a[0] * b[1] - b[0] * a[1];
4818
      x += (a[0] + b[0]) * c;
4819
      y += (a[1] + b[1]) * c;
4820
    }
4821
    return [ x * k, y * k ];
4822
  };
4823
  d3_geom_polygonPrototype.clip = function(subject) {
4824
    var input, closed = d3_geom_polygonClosed(subject), i = -1, n = this.length - d3_geom_polygonClosed(this), j, m, a = this[n - 1], b, c, d;
4825
    while (++i < n) {
4826
      input = subject.slice();
4827
      subject.length = 0;
4828
      b = this[i];
4829
      c = input[(m = input.length - closed) - 1];
4830
      j = -1;
4831
      while (++j < m) {
4832
        d = input[j];
4833
        if (d3_geom_polygonInside(d, a, b)) {
4834
          if (!d3_geom_polygonInside(c, a, b)) {
4835
            subject.push(d3_geom_polygonIntersect(c, d, a, b));
4836
          }
4837
          subject.push(d);
4838
        } else if (d3_geom_polygonInside(c, a, b)) {
4839
          subject.push(d3_geom_polygonIntersect(c, d, a, b));
4840
        }
4841
        c = d;
4842
      }
4843
      if (closed) subject.push(subject[0]);
4844
      a = b;
4845
    }
4846
    return subject;
4847
  };
4848
  function d3_geom_polygonInside(p, a, b) {
4849
    return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);
4850
  }
4851
  function d3_geom_polygonIntersect(c, d, a, b) {
4852
    var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21);
4853
    return [ x1 + ua * x21, y1 + ua * y21 ];
4854
  }
4855
  function d3_geom_polygonClosed(coordinates) {
4856
    var a = coordinates[0], b = coordinates[coordinates.length - 1];
4857
    return !(a[0] - b[0] || a[1] - b[1]);
4858
  }
4859
  var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = [];
4860
  function d3_geom_voronoiBeach() {
4861
    d3_geom_voronoiRedBlackNode(this);
4862
    this.edge = this.site = this.circle = null;
4863
  }
4864
  function d3_geom_voronoiCreateBeach(site) {
4865
    var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach();
4866
    beach.site = site;
4867
    return beach;
4868
  }
4869
  function d3_geom_voronoiDetachBeach(beach) {
4870
    d3_geom_voronoiDetachCircle(beach);
4871
    d3_geom_voronoiBeaches.remove(beach);
4872
    d3_geom_voronoiBeachPool.push(beach);
4873
    d3_geom_voronoiRedBlackNode(beach);
4874
  }
4875
  function d3_geom_voronoiRemoveBeach(beach) {
4876
    var circle = beach.circle, x = circle.x, y = circle.cy, vertex = {
4877
      x: x,
4878
      y: y
4879
    }, previous = beach.P, next = beach.N, disappearing = [ beach ];
4880
    d3_geom_voronoiDetachBeach(beach);
4881
    var lArc = previous;
4882
    while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) {
4883
      previous = lArc.P;
4884
      disappearing.unshift(lArc);
4885
      d3_geom_voronoiDetachBeach(lArc);
4886
      lArc = previous;
4887
    }
4888
    disappearing.unshift(lArc);
4889
    d3_geom_voronoiDetachCircle(lArc);
4890
    var rArc = next;
4891
    while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) {
4892
      next = rArc.N;
4893
      disappearing.push(rArc);
4894
      d3_geom_voronoiDetachBeach(rArc);
4895
      rArc = next;
4896
    }
4897
    disappearing.push(rArc);
4898
    d3_geom_voronoiDetachCircle(rArc);
4899
    var nArcs = disappearing.length, iArc;
4900
    for (iArc = 1; iArc < nArcs; ++iArc) {
4901
      rArc = disappearing[iArc];
4902
      lArc = disappearing[iArc - 1];
4903
      d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);
4904
    }
4905
    lArc = disappearing[0];
4906
    rArc = disappearing[nArcs - 1];
4907
    rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex);
4908
    d3_geom_voronoiAttachCircle(lArc);
4909
    d3_geom_voronoiAttachCircle(rArc);
4910
  }
4911
  function d3_geom_voronoiAddBeach(site) {
4912
    var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._;
4913
    while (node) {
4914
      dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x;
4915
      if (dxl > ε) node = node.L; else {
4916
        dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix);
4917
        if (dxr > ε) {
4918
          if (!node.R) {
4919
            lArc = node;
4920
            break;
4921
          }
4922
          node = node.R;
4923
        } else {
4924
          if (dxl > -ε) {
4925
            lArc = node.P;
4926
            rArc = node;
4927
          } else if (dxr > -ε) {
4928
            lArc = node;
4929
            rArc = node.N;
4930
          } else {
4931
            lArc = rArc = node;
4932
          }
4933
          break;
4934
        }
4935
      }
4936
    }
4937
    var newArc = d3_geom_voronoiCreateBeach(site);
4938
    d3_geom_voronoiBeaches.insert(lArc, newArc);
4939
    if (!lArc && !rArc) return;
4940
    if (lArc === rArc) {
4941
      d3_geom_voronoiDetachCircle(lArc);
4942
      rArc = d3_geom_voronoiCreateBeach(lArc.site);
4943
      d3_geom_voronoiBeaches.insert(newArc, rArc);
4944
      newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);
4945
      d3_geom_voronoiAttachCircle(lArc);
4946
      d3_geom_voronoiAttachCircle(rArc);
4947
      return;
4948
    }
4949
    if (!rArc) {
4950
      newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);
4951
      return;
4952
    }
4953
    d3_geom_voronoiDetachCircle(lArc);
4954
    d3_geom_voronoiDetachCircle(rArc);
4955
    var lSite = lArc.site, ax = lSite.x, ay = lSite.y, bx = site.x - ax, by = site.y - ay, rSite = rArc.site, cx = rSite.x - ax, cy = rSite.y - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = {
4956
      x: (cy * hb - by * hc) / d + ax,
4957
      y: (bx * hc - cx * hb) / d + ay
4958
    };
4959
    d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex);
4960
    newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex);
4961
    rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex);
4962
    d3_geom_voronoiAttachCircle(lArc);
4963
    d3_geom_voronoiAttachCircle(rArc);
4964
  }
4965
  function d3_geom_voronoiLeftBreakPoint(arc, directrix) {
4966
    var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix;
4967
    if (!pby2) return rfocx;
4968
    var lArc = arc.P;
4969
    if (!lArc) return -Infinity;
4970
    site = lArc.site;
4971
    var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix;
4972
    if (!plby2) return lfocx;
4973
    var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2;
4974
    if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;
4975
    return (rfocx + lfocx) / 2;
4976
  }
4977
  function d3_geom_voronoiRightBreakPoint(arc, directrix) {
4978
    var rArc = arc.N;
4979
    if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix);
4980
    var site = arc.site;
4981
    return site.y === directrix ? site.x : Infinity;
4982
  }
4983
  function d3_geom_voronoiCell(site) {
4984
    this.site = site;
4985
    this.edges = [];
4986
  }
4987
  d3_geom_voronoiCell.prototype.prepare = function() {
4988
    var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge;
4989
    while (iHalfEdge--) {
4990
      edge = halfEdges[iHalfEdge].edge;
4991
      if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1);
4992
    }
4993
    halfEdges.sort(d3_geom_voronoiHalfEdgeOrder);
4994
    return halfEdges.length;
4995
  };
4996
  function d3_geom_voronoiCloseCells(extent) {
4997
    var x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], x2, y2, x3, y3, cells = d3_geom_voronoiCells, iCell = cells.length, cell, iHalfEdge, halfEdges, nHalfEdges, start, end;
4998
    while (iCell--) {
4999
      cell = cells[iCell];
5000
      if (!cell || !cell.prepare()) continue;
5001
      halfEdges = cell.edges;
5002
      nHalfEdges = halfEdges.length;
5003
      iHalfEdge = 0;
5004
      while (iHalfEdge < nHalfEdges) {
5005
        end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y;
5006
        start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y;
5007
        if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) {
5008
          halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? {
5009
            x: x0,
5010
            y: abs(x2 - x0) < ε ? y2 : y1
5011
          } : abs(y3 - y1) < ε && x1 - x3 > ε ? {
5012
            x: abs(y2 - y1) < ε ? x2 : x1,
5013
            y: y1
5014
          } : abs(x3 - x1) < ε && y3 - y0 > ε ? {
5015
            x: x1,
5016
            y: abs(x2 - x1) < ε ? y2 : y0
5017
          } : abs(y3 - y0) < ε && x3 - x0 > ε ? {
5018
            x: abs(y2 - y0) < ε ? x2 : x0,
5019
            y: y0
5020
          } : null), cell.site, null));
5021
          ++nHalfEdges;
5022
        }
5023
      }
5024
    }
5025
  }
5026
  function d3_geom_voronoiHalfEdgeOrder(a, b) {
5027
    return b.angle - a.angle;
5028
  }
5029
  function d3_geom_voronoiCircle() {
5030
    d3_geom_voronoiRedBlackNode(this);
5031
    this.x = this.y = this.arc = this.site = this.cy = null;
5032
  }
5033
  function d3_geom_voronoiAttachCircle(arc) {
5034
    var lArc = arc.P, rArc = arc.N;
5035
    if (!lArc || !rArc) return;
5036
    var lSite = lArc.site, cSite = arc.site, rSite = rArc.site;
5037
    if (lSite === rSite) return;
5038
    var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by;
5039
    var d = 2 * (ax * cy - ay * cx);
5040
    if (d >= -ε2) return;
5041
    var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x = (cy * ha - ay * hc) / d, y = (ax * hc - cx * ha) / d, cy = y + by;
5042
    var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle();
5043
    circle.arc = arc;
5044
    circle.site = cSite;
5045
    circle.x = x + bx;
5046
    circle.y = cy + Math.sqrt(x * x + y * y);
5047
    circle.cy = cy;
5048
    arc.circle = circle;
5049
    var before = null, node = d3_geom_voronoiCircles._;
5050
    while (node) {
5051
      if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) {
5052
        if (node.L) node = node.L; else {
5053
          before = node.P;
5054
          break;
5055
        }
5056
      } else {
5057
        if (node.R) node = node.R; else {
5058
          before = node;
5059
          break;
5060
        }
5061
      }
5062
    }
5063
    d3_geom_voronoiCircles.insert(before, circle);
5064
    if (!before) d3_geom_voronoiFirstCircle = circle;
5065
  }
5066
  function d3_geom_voronoiDetachCircle(arc) {
5067
    var circle = arc.circle;
5068
    if (circle) {
5069
      if (!circle.P) d3_geom_voronoiFirstCircle = circle.N;
5070
      d3_geom_voronoiCircles.remove(circle);
5071
      d3_geom_voronoiCirclePool.push(circle);
5072
      d3_geom_voronoiRedBlackNode(circle);
5073
      arc.circle = null;
5074
    }
5075
  }
5076
  function d3_geom_voronoiClipEdges(extent) {
5077
    var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e;
5078
    while (i--) {
5079
      e = edges[i];
5080
      if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) {
5081
        e.a = e.b = null;
5082
        edges.splice(i, 1);
5083
      }
5084
    }
5085
  }
5086
  function d3_geom_voronoiConnectEdge(edge, extent) {
5087
    var vb = edge.b;
5088
    if (vb) return true;
5089
    var va = edge.a, x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], lSite = edge.l, rSite = edge.r, lx = lSite.x, ly = lSite.y, rx = rSite.x, ry = rSite.y, fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb;
5090
    if (ry === ly) {
5091
      if (fx < x0 || fx >= x1) return;
5092
      if (lx > rx) {
5093
        if (!va) va = {
5094
          x: fx,
5095
          y: y0
5096
        }; else if (va.y >= y1) return;
5097
        vb = {
5098
          x: fx,
5099
          y: y1
5100
        };
5101
      } else {
5102
        if (!va) va = {
5103
          x: fx,
5104
          y: y1
5105
        }; else if (va.y < y0) return;
5106
        vb = {
5107
          x: fx,
5108
          y: y0
5109
        };
5110
      }
5111
    } else {
5112
      fm = (lx - rx) / (ry - ly);
5113
      fb = fy - fm * fx;
5114
      if (fm < -1 || fm > 1) {
5115
        if (lx > rx) {
5116
          if (!va) va = {
5117
            x: (y0 - fb) / fm,
5118
            y: y0
5119
          }; else if (va.y >= y1) return;
5120
          vb = {
5121
            x: (y1 - fb) / fm,
5122
            y: y1
5123
          };
5124
        } else {
5125
          if (!va) va = {
5126
            x: (y1 - fb) / fm,
5127
            y: y1
5128
          }; else if (va.y < y0) return;
5129
          vb = {
5130
            x: (y0 - fb) / fm,
5131
            y: y0
5132
          };
5133
        }
5134
      } else {
5135
        if (ly < ry) {
5136
          if (!va) va = {
5137
            x: x0,
5138
            y: fm * x0 + fb
5139
          }; else if (va.x >= x1) return;
5140
          vb = {
5141
            x: x1,
5142
            y: fm * x1 + fb
5143
          };
5144
        } else {
5145
          if (!va) va = {
5146
            x: x1,
5147
            y: fm * x1 + fb
5148
          }; else if (va.x < x0) return;
5149
          vb = {
5150
            x: x0,
5151
            y: fm * x0 + fb
5152
          };
5153
        }
5154
      }
5155
    }
5156
    edge.a = va;
5157
    edge.b = vb;
5158
    return true;
5159
  }
5160
  function d3_geom_voronoiEdge(lSite, rSite) {
5161
    this.l = lSite;
5162
    this.r = rSite;
5163
    this.a = this.b = null;
5164
  }
5165
  function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) {
5166
    var edge = new d3_geom_voronoiEdge(lSite, rSite);
5167
    d3_geom_voronoiEdges.push(edge);
5168
    if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va);
5169
    if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb);
5170
    d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite));
5171
    d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite));
5172
    return edge;
5173
  }
5174
  function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) {
5175
    var edge = new d3_geom_voronoiEdge(lSite, null);
5176
    edge.a = va;
5177
    edge.b = vb;
5178
    d3_geom_voronoiEdges.push(edge);
5179
    return edge;
5180
  }
5181
  function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) {
5182
    if (!edge.a && !edge.b) {
5183
      edge.a = vertex;
5184
      edge.l = lSite;
5185
      edge.r = rSite;
5186
    } else if (edge.l === rSite) {
5187
      edge.b = vertex;
5188
    } else {
5189
      edge.a = vertex;
5190
    }
5191
  }
5192
  function d3_geom_voronoiHalfEdge(edge, lSite, rSite) {
5193
    var va = edge.a, vb = edge.b;
5194
    this.edge = edge;
5195
    this.site = lSite;
5196
    this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) : Math.atan2(va.x - vb.x, vb.y - va.y);
5197
  }
5198
  d3_geom_voronoiHalfEdge.prototype = {
5199
    start: function() {
5200
      return this.edge.l === this.site ? this.edge.a : this.edge.b;
5201
    },
5202
    end: function() {
5203
      return this.edge.l === this.site ? this.edge.b : this.edge.a;
5204
    }
5205
  };
5206
  function d3_geom_voronoiRedBlackTree() {
5207
    this._ = null;
5208
  }
5209
  function d3_geom_voronoiRedBlackNode(node) {
5210
    node.U = node.C = node.L = node.R = node.P = node.N = null;
5211
  }
5212
  d3_geom_voronoiRedBlackTree.prototype = {
5213
    insert: function(after, node) {
5214
      var parent, grandpa, uncle;
5215
      if (after) {
5216
        node.P = after;
5217
        node.N = after.N;
5218
        if (after.N) after.N.P = node;
5219
        after.N = node;
5220
        if (after.R) {
5221
          after = after.R;
5222
          while (after.L) after = after.L;
5223
          after.L = node;
5224
        } else {
5225
          after.R = node;
5226
        }
5227
        parent = after;
5228
      } else if (this._) {
5229
        after = d3_geom_voronoiRedBlackFirst(this._);
5230
        node.P = null;
5231
        node.N = after;
5232
        after.P = after.L = node;
5233
        parent = after;
5234
      } else {
5235
        node.P = node.N = null;
5236
        this._ = node;
5237
        parent = null;
5238
      }
5239
      node.L = node.R = null;
5240
      node.U = parent;
5241
      node.C = true;
5242
      after = node;
5243
      while (parent && parent.C) {
5244
        grandpa = parent.U;
5245
        if (parent === grandpa.L) {
5246
          uncle = grandpa.R;
5247
          if (uncle && uncle.C) {
5248
            parent.C = uncle.C = false;
5249
            grandpa.C = true;
5250
            after = grandpa;
5251
          } else {
5252
            if (after === parent.R) {
5253
              d3_geom_voronoiRedBlackRotateLeft(this, parent);
5254
              after = parent;
5255
              parent = after.U;
5256
            }
5257
            parent.C = false;
5258
            grandpa.C = true;
5259
            d3_geom_voronoiRedBlackRotateRight(this, grandpa);
5260
          }
5261
        } else {
5262
          uncle = grandpa.L;
5263
          if (uncle && uncle.C) {
5264
            parent.C = uncle.C = false;
5265
            grandpa.C = true;
5266
            after = grandpa;
5267
          } else {
5268
            if (after === parent.L) {
5269
              d3_geom_voronoiRedBlackRotateRight(this, parent);
5270
              after = parent;
5271
              parent = after.U;
5272
            }
5273
            parent.C = false;
5274
            grandpa.C = true;
5275
            d3_geom_voronoiRedBlackRotateLeft(this, grandpa);
5276
          }
5277
        }
5278
        parent = after.U;
5279
      }
5280
      this._.C = false;
5281
    },
5282
    remove: function(node) {
5283
      if (node.N) node.N.P = node.P;
5284
      if (node.P) node.P.N = node.N;
5285
      node.N = node.P = null;
5286
      var parent = node.U, sibling, left = node.L, right = node.R, next, red;
5287
      if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right);
5288
      if (parent) {
5289
        if (parent.L === node) parent.L = next; else parent.R = next;
5290
      } else {
5291
        this._ = next;
5292
      }
5293
      if (left && right) {
5294
        red = next.C;
5295
        next.C = node.C;
5296
        next.L = left;
5297
        left.U = next;
5298
        if (next !== right) {
5299
          parent = next.U;
5300
          next.U = node.U;
5301
          node = next.R;
5302
          parent.L = node;
5303
          next.R = right;
5304
          right.U = next;
5305
        } else {
5306
          next.U = parent;
5307
          parent = next;
5308
          node = next.R;
5309
        }
5310
      } else {
5311
        red = node.C;
5312
        node = next;
5313
      }
5314
      if (node) node.U = parent;
5315
      if (red) return;
5316
      if (node && node.C) {
5317
        node.C = false;
5318
        return;
5319
      }
5320
      do {
5321
        if (node === this._) break;
5322
        if (node === parent.L) {
5323
          sibling = parent.R;
5324
          if (sibling.C) {
5325
            sibling.C = false;
5326
            parent.C = true;
5327
            d3_geom_voronoiRedBlackRotateLeft(this, parent);
5328
            sibling = parent.R;
5329
          }
5330
          if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
5331
            if (!sibling.R || !sibling.R.C) {
5332
              sibling.L.C = false;
5333
              sibling.C = true;
5334
              d3_geom_voronoiRedBlackRotateRight(this, sibling);
5335
              sibling = parent.R;
5336
            }
5337
            sibling.C = parent.C;
5338
            parent.C = sibling.R.C = false;
5339
            d3_geom_voronoiRedBlackRotateLeft(this, parent);
5340
            node = this._;
5341
            break;
5342
          }
5343
        } else {
5344
          sibling = parent.L;
5345
          if (sibling.C) {
5346
            sibling.C = false;
5347
            parent.C = true;
5348
            d3_geom_voronoiRedBlackRotateRight(this, parent);
5349
            sibling = parent.L;
5350
          }
5351
          if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
5352
            if (!sibling.L || !sibling.L.C) {
5353
              sibling.R.C = false;
5354
              sibling.C = true;
5355
              d3_geom_voronoiRedBlackRotateLeft(this, sibling);
5356
              sibling = parent.L;
5357
            }
5358
            sibling.C = parent.C;
5359
            parent.C = sibling.L.C = false;
5360
            d3_geom_voronoiRedBlackRotateRight(this, parent);
5361
            node = this._;
5362
            break;
5363
          }
5364
        }
5365
        sibling.C = true;
5366
        node = parent;
5367
        parent = parent.U;
5368
      } while (!node.C);
5369
      if (node) node.C = false;
5370
    }
5371
  };
5372
  function d3_geom_voronoiRedBlackRotateLeft(tree, node) {
5373
    var p = node, q = node.R, parent = p.U;
5374
    if (parent) {
5375
      if (parent.L === p) parent.L = q; else parent.R = q;
5376
    } else {
5377
      tree._ = q;
5378
    }
5379
    q.U = parent;
5380
    p.U = q;
5381
    p.R = q.L;
5382
    if (p.R) p.R.U = p;
5383
    q.L = p;
5384
  }
5385
  function d3_geom_voronoiRedBlackRotateRight(tree, node) {
5386
    var p = node, q = node.L, parent = p.U;
5387
    if (parent) {
5388
      if (parent.L === p) parent.L = q; else parent.R = q;
5389
    } else {
5390
      tree._ = q;
5391
    }
5392
    q.U = parent;
5393
    p.U = q;
5394
    p.L = q.R;
5395
    if (p.L) p.L.U = p;
5396
    q.R = p;
5397
  }
5398
  function d3_geom_voronoiRedBlackFirst(node) {
5399
    while (node.L) node = node.L;
5400
    return node;
5401
  }
5402
  function d3_geom_voronoi(sites, bbox) {
5403
    var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle;
5404
    d3_geom_voronoiEdges = [];
5405
    d3_geom_voronoiCells = new Array(sites.length);
5406
    d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree();
5407
    d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree();
5408
    while (true) {
5409
      circle = d3_geom_voronoiFirstCircle;
5410
      if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) {
5411
        if (site.x !== x0 || site.y !== y0) {
5412
          d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site);
5413
          d3_geom_voronoiAddBeach(site);
5414
          x0 = site.x, y0 = site.y;
5415
        }
5416
        site = sites.pop();
5417
      } else if (circle) {
5418
        d3_geom_voronoiRemoveBeach(circle.arc);
5419
      } else {
5420
        break;
5421
      }
5422
    }
5423
    if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox);
5424
    var diagram = {
5425
      cells: d3_geom_voronoiCells,
5426
      edges: d3_geom_voronoiEdges
5427
    };
5428
    d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null;
5429
    return diagram;
5430
  }
5431
  function d3_geom_voronoiVertexOrder(a, b) {
5432
    return b.y - a.y || b.x - a.x;
5433
  }
5434
  d3.geom.voronoi = function(points) {
5435
    var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent;
5436
    if (points) return voronoi(points);
5437
    function voronoi(data) {
5438
      var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1];
5439
      d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) {
5440
        var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) {
5441
          var s = e.start();
5442
          return [ s.x, s.y ];
5443
        }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : [];
5444
        polygon.point = data[i];
5445
      });
5446
      return polygons;
5447
    }
5448
    function sites(data) {
5449
      return data.map(function(d, i) {
5450
        return {
5451
          x: Math.round(fx(d, i) / ε) * ε,
5452
          y: Math.round(fy(d, i) / ε) * ε,
5453
          i: i
5454
        };
5455
      });
5456
    }
5457
    voronoi.links = function(data) {
5458
      return d3_geom_voronoi(sites(data)).edges.filter(function(edge) {
5459
        return edge.l && edge.r;
5460
      }).map(function(edge) {
5461
        return {
5462
          source: data[edge.l.i],
5463
          target: data[edge.r.i]
5464
        };
5465
      });
5466
    };
5467
    voronoi.triangles = function(data) {
5468
      var triangles = [];
5469
      d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) {
5470
        var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, e0, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l;
5471
        while (++j < m) {
5472
          e0 = e1;
5473
          s0 = s1;
5474
          e1 = edges[j].edge;
5475
          s1 = e1.l === site ? e1.r : e1.l;
5476
          if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) {
5477
            triangles.push([ data[i], data[s0.i], data[s1.i] ]);
5478
          }
5479
        }
5480
      });
5481
      return triangles;
5482
    };
5483
    voronoi.x = function(_) {
5484
      return arguments.length ? (fx = d3_functor(x = _), voronoi) : x;
5485
    };
5486
    voronoi.y = function(_) {
5487
      return arguments.length ? (fy = d3_functor(y = _), voronoi) : y;
5488
    };
5489
    voronoi.clipExtent = function(_) {
5490
      if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent;
5491
      clipExtent = _ == null ? d3_geom_voronoiClipExtent : _;
5492
      return voronoi;
5493
    };
5494
    voronoi.size = function(_) {
5495
      if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1];
5496
      return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]);
5497
    };
5498
    return voronoi;
5499
  };
5500
  var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ];
5501
  function d3_geom_voronoiTriangleArea(a, b, c) {
5502
    return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y);
5503
  }
5504
  d3.geom.delaunay = function(vertices) {
5505
    return d3.geom.voronoi().triangles(vertices);
5506
  };
5507
  d3.geom.quadtree = function(points, x1, y1, x2, y2) {
5508
    var x = d3_geom_pointX, y = d3_geom_pointY, compat;
5509
    if (compat = arguments.length) {
5510
      x = d3_geom_quadtreeCompatX;
5511
      y = d3_geom_quadtreeCompatY;
5512
      if (compat === 3) {
5513
        y2 = y1;
5514
        x2 = x1;
5515
        y1 = x1 = 0;
5516
      }
5517
      return quadtree(points);
5518
    }
5519
    function quadtree(data) {
5520
      var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_;
5521
      if (x1 != null) {
5522
        x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2;
5523
      } else {
5524
        x2_ = y2_ = -(x1_ = y1_ = Infinity);
5525
        xs = [], ys = [];
5526
        n = data.length;
5527
        if (compat) for (i = 0; i < n; ++i) {
5528
          d = data[i];
5529
          if (d.x < x1_) x1_ = d.x;
5530
          if (d.y < y1_) y1_ = d.y;
5531
          if (d.x > x2_) x2_ = d.x;
5532
          if (d.y > y2_) y2_ = d.y;
5533
          xs.push(d.x);
5534
          ys.push(d.y);
5535
        } else for (i = 0; i < n; ++i) {
5536
          var x_ = +fx(d = data[i], i), y_ = +fy(d, i);
5537
          if (x_ < x1_) x1_ = x_;
5538
          if (y_ < y1_) y1_ = y_;
5539
          if (x_ > x2_) x2_ = x_;
5540
          if (y_ > y2_) y2_ = y_;
5541
          xs.push(x_);
5542
          ys.push(y_);
5543
        }
5544
      }
5545
      var dx = x2_ - x1_, dy = y2_ - y1_;
5546
      if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy;
5547
      function insert(n, d, x, y, x1, y1, x2, y2) {
5548
        if (isNaN(x) || isNaN(y)) return;
5549
        if (n.leaf) {
5550
          var nx = n.x, ny = n.y;
5551
          if (nx != null) {
5552
            if (abs(nx - x) + abs(ny - y) < .01) {
5553
              insertChild(n, d, x, y, x1, y1, x2, y2);
5554
            } else {
5555
              var nPoint = n.point;
5556
              n.x = n.y = n.point = null;
5557
              insertChild(n, nPoint, nx, ny, x1, y1, x2, y2);
5558
              insertChild(n, d, x, y, x1, y1, x2, y2);
5559
            }
5560
          } else {
5561
            n.x = x, n.y = y, n.point = d;
5562
          }
5563
        } else {
5564
          insertChild(n, d, x, y, x1, y1, x2, y2);
5565
        }
5566
      }
5567
      function insertChild(n, d, x, y, x1, y1, x2, y2) {
5568
        var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right;
5569
        n.leaf = false;
5570
        n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());
5571
        if (right) x1 = xm; else x2 = xm;
5572
        if (below) y1 = ym; else y2 = ym;
5573
        insert(n, d, x, y, x1, y1, x2, y2);
5574
      }
5575
      var root = d3_geom_quadtreeNode();
5576
      root.add = function(d) {
5577
        insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_);
5578
      };
5579
      root.visit = function(f) {
5580
        d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_);
5581
      };
5582
      root.find = function(point) {
5583
        return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_);
5584
      };
5585
      i = -1;
5586
      if (x1 == null) {
5587
        while (++i < n) {
5588
          insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_);
5589
        }
5590
        --i;
5591
      } else data.forEach(root.add);
5592
      xs = ys = data = d = null;
5593
      return root;
5594
    }
5595
    quadtree.x = function(_) {
5596
      return arguments.length ? (x = _, quadtree) : x;
5597
    };
5598
    quadtree.y = function(_) {
5599
      return arguments.length ? (y = _, quadtree) : y;
5600
    };
5601
    quadtree.extent = function(_) {
5602
      if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ];
5603
      if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], 
5604
      y2 = +_[1][1];
5605
      return quadtree;
5606
    };
5607
    quadtree.size = function(_) {
5608
      if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ];
5609
      if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1];
5610
      return quadtree;
5611
    };
5612
    return quadtree;
5613
  };
5614
  function d3_geom_quadtreeCompatX(d) {
5615
    return d.x;
5616
  }
5617
  function d3_geom_quadtreeCompatY(d) {
5618
    return d.y;
5619
  }
5620
  function d3_geom_quadtreeNode() {
5621
    return {
5622
      leaf: true,
5623
      nodes: [],
5624
      point: null,
5625
      x: null,
5626
      y: null
5627
    };
5628
  }
5629
  function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {
5630
    if (!f(node, x1, y1, x2, y2)) {
5631
      var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes;
5632
      if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);
5633
      if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);
5634
      if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);
5635
      if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
5636
    }
5637
  }
5638
  function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) {
5639
    var minDistance2 = Infinity, closestPoint;
5640
    (function find(node, x1, y1, x2, y2) {
5641
      if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return;
5642
      if (point = node.point) {
5643
        var point, dx = x - point[0], dy = y - point[1], distance2 = dx * dx + dy * dy;
5644
        if (distance2 < minDistance2) {
5645
          var distance = Math.sqrt(minDistance2 = distance2);
5646
          x0 = x - distance, y0 = y - distance;
5647
          x3 = x + distance, y3 = y + distance;
5648
          closestPoint = point;
5649
        }
5650
      }
5651
      var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym;
5652
      for (var i = below << 1 | right, j = i + 4; i < j; ++i) {
5653
        if (node = children[i & 3]) switch (i & 3) {
5654
         case 0:
5655
          find(node, x1, y1, xm, ym);
5656
          break;
5657

    
5658
         case 1:
5659
          find(node, xm, y1, x2, ym);
5660
          break;
5661

    
5662
         case 2:
5663
          find(node, x1, ym, xm, y2);
5664
          break;
5665

    
5666
         case 3:
5667
          find(node, xm, ym, x2, y2);
5668
          break;
5669
        }
5670
      }
5671
    })(root, x0, y0, x3, y3);
5672
    return closestPoint;
5673
  }
5674
  d3.interpolateRgb = d3_interpolateRgb;
5675
  function d3_interpolateRgb(a, b) {
5676
    a = d3.rgb(a);
5677
    b = d3.rgb(b);
5678
    var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab;
5679
    return function(t) {
5680
      return "#" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t));
5681
    };
5682
  }
5683
  d3.interpolateObject = d3_interpolateObject;
5684
  function d3_interpolateObject(a, b) {
5685
    var i = {}, c = {}, k;
5686
    for (k in a) {
5687
      if (k in b) {
5688
        i[k] = d3_interpolate(a[k], b[k]);
5689
      } else {
5690
        c[k] = a[k];
5691
      }
5692
    }
5693
    for (k in b) {
5694
      if (!(k in a)) {
5695
        c[k] = b[k];
5696
      }
5697
    }
5698
    return function(t) {
5699
      for (k in i) c[k] = i[k](t);
5700
      return c;
5701
    };
5702
  }
5703
  d3.interpolateNumber = d3_interpolateNumber;
5704
  function d3_interpolateNumber(a, b) {
5705
    a = +a, b = +b;
5706
    return function(t) {
5707
      return a * (1 - t) + b * t;
5708
    };
5709
  }
5710
  d3.interpolateString = d3_interpolateString;
5711
  function d3_interpolateString(a, b) {
5712
    var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = [];
5713
    a = a + "", b = b + "";
5714
    while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) {
5715
      if ((bs = bm.index) > bi) {
5716
        bs = b.slice(bi, bs);
5717
        if (s[i]) s[i] += bs; else s[++i] = bs;
5718
      }
5719
      if ((am = am[0]) === (bm = bm[0])) {
5720
        if (s[i]) s[i] += bm; else s[++i] = bm;
5721
      } else {
5722
        s[++i] = null;
5723
        q.push({
5724
          i: i,
5725
          x: d3_interpolateNumber(am, bm)
5726
        });
5727
      }
5728
      bi = d3_interpolate_numberB.lastIndex;
5729
    }
5730
    if (bi < b.length) {
5731
      bs = b.slice(bi);
5732
      if (s[i]) s[i] += bs; else s[++i] = bs;
5733
    }
5734
    return s.length < 2 ? q[0] ? (b = q[0].x, function(t) {
5735
      return b(t) + "";
5736
    }) : function() {
5737
      return b;
5738
    } : (b = q.length, function(t) {
5739
      for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
5740
      return s.join("");
5741
    });
5742
  }
5743
  var d3_interpolate_numberA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, "g");
5744
  d3.interpolate = d3_interpolate;
5745
  function d3_interpolate(a, b) {
5746
    var i = d3.interpolators.length, f;
5747
    while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ;
5748
    return f;
5749
  }
5750
  d3.interpolators = [ function(a, b) {
5751
    var t = typeof b;
5752
    return (t === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === "object" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b);
5753
  } ];
5754
  d3.interpolateArray = d3_interpolateArray;
5755
  function d3_interpolateArray(a, b) {
5756
    var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i;
5757
    for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i]));
5758
    for (;i < na; ++i) c[i] = a[i];
5759
    for (;i < nb; ++i) c[i] = b[i];
5760
    return function(t) {
5761
      for (i = 0; i < n0; ++i) c[i] = x[i](t);
5762
      return c;
5763
    };
5764
  }
5765
  var d3_ease_default = function() {
5766
    return d3_identity;
5767
  };
5768
  var d3_ease = d3.map({
5769
    linear: d3_ease_default,
5770
    poly: d3_ease_poly,
5771
    quad: function() {
5772
      return d3_ease_quad;
5773
    },
5774
    cubic: function() {
5775
      return d3_ease_cubic;
5776
    },
5777
    sin: function() {
5778
      return d3_ease_sin;
5779
    },
5780
    exp: function() {
5781
      return d3_ease_exp;
5782
    },
5783
    circle: function() {
5784
      return d3_ease_circle;
5785
    },
5786
    elastic: d3_ease_elastic,
5787
    back: d3_ease_back,
5788
    bounce: function() {
5789
      return d3_ease_bounce;
5790
    }
5791
  });
5792
  var d3_ease_mode = d3.map({
5793
    "in": d3_identity,
5794
    out: d3_ease_reverse,
5795
    "in-out": d3_ease_reflect,
5796
    "out-in": function(f) {
5797
      return d3_ease_reflect(d3_ease_reverse(f));
5798
    }
5799
  });
5800
  d3.ease = function(name) {
5801
    var i = name.indexOf("-"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : "in";
5802
    t = d3_ease.get(t) || d3_ease_default;
5803
    m = d3_ease_mode.get(m) || d3_identity;
5804
    return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1))));
5805
  };
5806
  function d3_ease_clamp(f) {
5807
    return function(t) {
5808
      return t <= 0 ? 0 : t >= 1 ? 1 : f(t);
5809
    };
5810
  }
5811
  function d3_ease_reverse(f) {
5812
    return function(t) {
5813
      return 1 - f(1 - t);
5814
    };
5815
  }
5816
  function d3_ease_reflect(f) {
5817
    return function(t) {
5818
      return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t));
5819
    };
5820
  }
5821
  function d3_ease_quad(t) {
5822
    return t * t;
5823
  }
5824
  function d3_ease_cubic(t) {
5825
    return t * t * t;
5826
  }
5827
  function d3_ease_cubicInOut(t) {
5828
    if (t <= 0) return 0;
5829
    if (t >= 1) return 1;
5830
    var t2 = t * t, t3 = t2 * t;
5831
    return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75);
5832
  }
5833
  function d3_ease_poly(e) {
5834
    return function(t) {
5835
      return Math.pow(t, e);
5836
    };
5837
  }
5838
  function d3_ease_sin(t) {
5839
    return 1 - Math.cos(t * halfπ);
5840
  }
5841
  function d3_ease_exp(t) {
5842
    return Math.pow(2, 10 * (t - 1));
5843
  }
5844
  function d3_ease_circle(t) {
5845
    return 1 - Math.sqrt(1 - t * t);
5846
  }
5847
  function d3_ease_elastic(a, p) {
5848
    var s;
5849
    if (arguments.length < 2) p = .45;
5850
    if (arguments.length) s = p / τ * Math.asin(1 / a); else a = 1, s = p / 4;
5851
    return function(t) {
5852
      return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p);
5853
    };
5854
  }
5855
  function d3_ease_back(s) {
5856
    if (!s) s = 1.70158;
5857
    return function(t) {
5858
      return t * t * ((s + 1) * t - s);
5859
    };
5860
  }
5861
  function d3_ease_bounce(t) {
5862
    return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
5863
  }
5864
  d3.interpolateHcl = d3_interpolateHcl;
5865
  function d3_interpolateHcl(a, b) {
5866
    a = d3.hcl(a);
5867
    b = d3.hcl(b);
5868
    var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al;
5869
    if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac;
5870
    if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
5871
    return function(t) {
5872
      return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + "";
5873
    };
5874
  }
5875
  d3.interpolateHsl = d3_interpolateHsl;
5876
  function d3_interpolateHsl(a, b) {
5877
    a = d3.hsl(a);
5878
    b = d3.hsl(b);
5879
    var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al;
5880
    if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as;
5881
    if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
5882
    return function(t) {
5883
      return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + "";
5884
    };
5885
  }
5886
  d3.interpolateLab = d3_interpolateLab;
5887
  function d3_interpolateLab(a, b) {
5888
    a = d3.lab(a);
5889
    b = d3.lab(b);
5890
    var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab;
5891
    return function(t) {
5892
      return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + "";
5893
    };
5894
  }
5895
  d3.interpolateRound = d3_interpolateRound;
5896
  function d3_interpolateRound(a, b) {
5897
    b -= a;
5898
    return function(t) {
5899
      return Math.round(a + b * t);
5900
    };
5901
  }
5902
  d3.transform = function(string) {
5903
    var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
5904
    return (d3.transform = function(string) {
5905
      if (string != null) {
5906
        g.setAttribute("transform", string);
5907
        var t = g.transform.baseVal.consolidate();
5908
      }
5909
      return new d3_transform(t ? t.matrix : d3_transformIdentity);
5910
    })(string);
5911
  };
5912
  function d3_transform(m) {
5913
    var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0;
5914
    if (r0[0] * r1[1] < r1[0] * r0[1]) {
5915
      r0[0] *= -1;
5916
      r0[1] *= -1;
5917
      kx *= -1;
5918
      kz *= -1;
5919
    }
5920
    this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees;
5921
    this.translate = [ m.e, m.f ];
5922
    this.scale = [ kx, ky ];
5923
    this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0;
5924
  }
5925
  d3_transform.prototype.toString = function() {
5926
    return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")";
5927
  };
5928
  function d3_transformDot(a, b) {
5929
    return a[0] * b[0] + a[1] * b[1];
5930
  }
5931
  function d3_transformNormalize(a) {
5932
    var k = Math.sqrt(d3_transformDot(a, a));
5933
    if (k) {
5934
      a[0] /= k;
5935
      a[1] /= k;
5936
    }
5937
    return k;
5938
  }
5939
  function d3_transformCombine(a, b, k) {
5940
    a[0] += k * b[0];
5941
    a[1] += k * b[1];
5942
    return a;
5943
  }
5944
  var d3_transformIdentity = {
5945
    a: 1,
5946
    b: 0,
5947
    c: 0,
5948
    d: 1,
5949
    e: 0,
5950
    f: 0
5951
  };
5952
  d3.interpolateTransform = d3_interpolateTransform;
5953
  function d3_interpolateTransform(a, b) {
5954
    var s = [], q = [], n, A = d3.transform(a), B = d3.transform(b), ta = A.translate, tb = B.translate, ra = A.rotate, rb = B.rotate, wa = A.skew, wb = B.skew, ka = A.scale, kb = B.scale;
5955
    if (ta[0] != tb[0] || ta[1] != tb[1]) {
5956
      s.push("translate(", null, ",", null, ")");
5957
      q.push({
5958
        i: 1,
5959
        x: d3_interpolateNumber(ta[0], tb[0])
5960
      }, {
5961
        i: 3,
5962
        x: d3_interpolateNumber(ta[1], tb[1])
5963
      });
5964
    } else if (tb[0] || tb[1]) {
5965
      s.push("translate(" + tb + ")");
5966
    } else {
5967
      s.push("");
5968
    }
5969
    if (ra != rb) {
5970
      if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360;
5971
      q.push({
5972
        i: s.push(s.pop() + "rotate(", null, ")") - 2,
5973
        x: d3_interpolateNumber(ra, rb)
5974
      });
5975
    } else if (rb) {
5976
      s.push(s.pop() + "rotate(" + rb + ")");
5977
    }
5978
    if (wa != wb) {
5979
      q.push({
5980
        i: s.push(s.pop() + "skewX(", null, ")") - 2,
5981
        x: d3_interpolateNumber(wa, wb)
5982
      });
5983
    } else if (wb) {
5984
      s.push(s.pop() + "skewX(" + wb + ")");
5985
    }
5986
    if (ka[0] != kb[0] || ka[1] != kb[1]) {
5987
      n = s.push(s.pop() + "scale(", null, ",", null, ")");
5988
      q.push({
5989
        i: n - 4,
5990
        x: d3_interpolateNumber(ka[0], kb[0])
5991
      }, {
5992
        i: n - 2,
5993
        x: d3_interpolateNumber(ka[1], kb[1])
5994
      });
5995
    } else if (kb[0] != 1 || kb[1] != 1) {
5996
      s.push(s.pop() + "scale(" + kb + ")");
5997
    }
5998
    n = q.length;
5999
    return function(t) {
6000
      var i = -1, o;
6001
      while (++i < n) s[(o = q[i]).i] = o.x(t);
6002
      return s.join("");
6003
    };
6004
  }
6005
  function d3_uninterpolateNumber(a, b) {
6006
    b = (b -= a = +a) || 1 / b;
6007
    return function(x) {
6008
      return (x - a) / b;
6009
    };
6010
  }
6011
  function d3_uninterpolateClamp(a, b) {
6012
    b = (b -= a = +a) || 1 / b;
6013
    return function(x) {
6014
      return Math.max(0, Math.min(1, (x - a) / b));
6015
    };
6016
  }
6017
  d3.layout = {};
6018
  d3.layout.bundle = function() {
6019
    return function(links) {
6020
      var paths = [], i = -1, n = links.length;
6021
      while (++i < n) paths.push(d3_layout_bundlePath(links[i]));
6022
      return paths;
6023
    };
6024
  };
6025
  function d3_layout_bundlePath(link) {
6026
    var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ];
6027
    while (start !== lca) {
6028
      start = start.parent;
6029
      points.push(start);
6030
    }
6031
    var k = points.length;
6032
    while (end !== lca) {
6033
      points.splice(k, 0, end);
6034
      end = end.parent;
6035
    }
6036
    return points;
6037
  }
6038
  function d3_layout_bundleAncestors(node) {
6039
    var ancestors = [], parent = node.parent;
6040
    while (parent != null) {
6041
      ancestors.push(node);
6042
      node = parent;
6043
      parent = parent.parent;
6044
    }
6045
    ancestors.push(node);
6046
    return ancestors;
6047
  }
6048
  function d3_layout_bundleLeastCommonAncestor(a, b) {
6049
    if (a === b) return a;
6050
    var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null;
6051
    while (aNode === bNode) {
6052
      sharedNode = aNode;
6053
      aNode = aNodes.pop();
6054
      bNode = bNodes.pop();
6055
    }
6056
    return sharedNode;
6057
  }
6058
  d3.layout.chord = function() {
6059
    var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;
6060
    function relayout() {
6061
      var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j;
6062
      chords = [];
6063
      groups = [];
6064
      k = 0, i = -1;
6065
      while (++i < n) {
6066
        x = 0, j = -1;
6067
        while (++j < n) {
6068
          x += matrix[i][j];
6069
        }
6070
        groupSums.push(x);
6071
        subgroupIndex.push(d3.range(n));
6072
        k += x;
6073
      }
6074
      if (sortGroups) {
6075
        groupIndex.sort(function(a, b) {
6076
          return sortGroups(groupSums[a], groupSums[b]);
6077
        });
6078
      }
6079
      if (sortSubgroups) {
6080
        subgroupIndex.forEach(function(d, i) {
6081
          d.sort(function(a, b) {
6082
            return sortSubgroups(matrix[i][a], matrix[i][b]);
6083
          });
6084
        });
6085
      }
6086
      k = (τ - padding * n) / k;
6087
      x = 0, i = -1;
6088
      while (++i < n) {
6089
        x0 = x, j = -1;
6090
        while (++j < n) {
6091
          var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;
6092
          subgroups[di + "-" + dj] = {
6093
            index: di,
6094
            subindex: dj,
6095
            startAngle: a0,
6096
            endAngle: a1,
6097
            value: v
6098
          };
6099
        }
6100
        groups[di] = {
6101
          index: di,
6102
          startAngle: x0,
6103
          endAngle: x,
6104
          value: (x - x0) / k
6105
        };
6106
        x += padding;
6107
      }
6108
      i = -1;
6109
      while (++i < n) {
6110
        j = i - 1;
6111
        while (++j < n) {
6112
          var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i];
6113
          if (source.value || target.value) {
6114
            chords.push(source.value < target.value ? {
6115
              source: target,
6116
              target: source
6117
            } : {
6118
              source: source,
6119
              target: target
6120
            });
6121
          }
6122
        }
6123
      }
6124
      if (sortChords) resort();
6125
    }
6126
    function resort() {
6127
      chords.sort(function(a, b) {
6128
        return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2);
6129
      });
6130
    }
6131
    chord.matrix = function(x) {
6132
      if (!arguments.length) return matrix;
6133
      n = (matrix = x) && matrix.length;
6134
      chords = groups = null;
6135
      return chord;
6136
    };
6137
    chord.padding = function(x) {
6138
      if (!arguments.length) return padding;
6139
      padding = x;
6140
      chords = groups = null;
6141
      return chord;
6142
    };
6143
    chord.sortGroups = function(x) {
6144
      if (!arguments.length) return sortGroups;
6145
      sortGroups = x;
6146
      chords = groups = null;
6147
      return chord;
6148
    };
6149
    chord.sortSubgroups = function(x) {
6150
      if (!arguments.length) return sortSubgroups;
6151
      sortSubgroups = x;
6152
      chords = null;
6153
      return chord;
6154
    };
6155
    chord.sortChords = function(x) {
6156
      if (!arguments.length) return sortChords;
6157
      sortChords = x;
6158
      if (chords) resort();
6159
      return chord;
6160
    };
6161
    chord.chords = function() {
6162
      if (!chords) relayout();
6163
      return chords;
6164
    };
6165
    chord.groups = function() {
6166
      if (!groups) relayout();
6167
      return groups;
6168
    };
6169
    return chord;
6170
  };
6171
  d3.layout.force = function() {
6172
    var force = {}, event = d3.dispatch("start", "tick", "end"), size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges;
6173
    function repulse(node) {
6174
      return function(quad, x1, _, x2) {
6175
        if (quad.point !== node) {
6176
          var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy;
6177
          if (dw * dw / theta2 < dn) {
6178
            if (dn < chargeDistance2) {
6179
              var k = quad.charge / dn;
6180
              node.px -= dx * k;
6181
              node.py -= dy * k;
6182
            }
6183
            return true;
6184
          }
6185
          if (quad.point && dn && dn < chargeDistance2) {
6186
            var k = quad.pointCharge / dn;
6187
            node.px -= dx * k;
6188
            node.py -= dy * k;
6189
          }
6190
        }
6191
        return !quad.charge;
6192
      };
6193
    }
6194
    force.tick = function() {
6195
      if ((alpha *= .99) < .005) {
6196
        event.end({
6197
          type: "end",
6198
          alpha: alpha = 0
6199
        });
6200
        return true;
6201
      }
6202
      var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y;
6203
      for (i = 0; i < m; ++i) {
6204
        o = links[i];
6205
        s = o.source;
6206
        t = o.target;
6207
        x = t.x - s.x;
6208
        y = t.y - s.y;
6209
        if (l = x * x + y * y) {
6210
          l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;
6211
          x *= l;
6212
          y *= l;
6213
          t.x -= x * (k = s.weight / (t.weight + s.weight));
6214
          t.y -= y * k;
6215
          s.x += x * (k = 1 - k);
6216
          s.y += y * k;
6217
        }
6218
      }
6219
      if (k = alpha * gravity) {
6220
        x = size[0] / 2;
6221
        y = size[1] / 2;
6222
        i = -1;
6223
        if (k) while (++i < n) {
6224
          o = nodes[i];
6225
          o.x += (x - o.x) * k;
6226
          o.y += (y - o.y) * k;
6227
        }
6228
      }
6229
      if (charge) {
6230
        d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges);
6231
        i = -1;
6232
        while (++i < n) {
6233
          if (!(o = nodes[i]).fixed) {
6234
            q.visit(repulse(o));
6235
          }
6236
        }
6237
      }
6238
      i = -1;
6239
      while (++i < n) {
6240
        o = nodes[i];
6241
        if (o.fixed) {
6242
          o.x = o.px;
6243
          o.y = o.py;
6244
        } else {
6245
          o.x -= (o.px - (o.px = o.x)) * friction;
6246
          o.y -= (o.py - (o.py = o.y)) * friction;
6247
        }
6248
      }
6249
      event.tick({
6250
        type: "tick",
6251
        alpha: alpha
6252
      });
6253
    };
6254
    force.nodes = function(x) {
6255
      if (!arguments.length) return nodes;
6256
      nodes = x;
6257
      return force;
6258
    };
6259
    force.links = function(x) {
6260
      if (!arguments.length) return links;
6261
      links = x;
6262
      return force;
6263
    };
6264
    force.size = function(x) {
6265
      if (!arguments.length) return size;
6266
      size = x;
6267
      return force;
6268
    };
6269
    force.linkDistance = function(x) {
6270
      if (!arguments.length) return linkDistance;
6271
      linkDistance = typeof x === "function" ? x : +x;
6272
      return force;
6273
    };
6274
    force.distance = force.linkDistance;
6275
    force.linkStrength = function(x) {
6276
      if (!arguments.length) return linkStrength;
6277
      linkStrength = typeof x === "function" ? x : +x;
6278
      return force;
6279
    };
6280
    force.friction = function(x) {
6281
      if (!arguments.length) return friction;
6282
      friction = +x;
6283
      return force;
6284
    };
6285
    force.charge = function(x) {
6286
      if (!arguments.length) return charge;
6287
      charge = typeof x === "function" ? x : +x;
6288
      return force;
6289
    };
6290
    force.chargeDistance = function(x) {
6291
      if (!arguments.length) return Math.sqrt(chargeDistance2);
6292
      chargeDistance2 = x * x;
6293
      return force;
6294
    };
6295
    force.gravity = function(x) {
6296
      if (!arguments.length) return gravity;
6297
      gravity = +x;
6298
      return force;
6299
    };
6300
    force.theta = function(x) {
6301
      if (!arguments.length) return Math.sqrt(theta2);
6302
      theta2 = x * x;
6303
      return force;
6304
    };
6305
    force.alpha = function(x) {
6306
      if (!arguments.length) return alpha;
6307
      x = +x;
6308
      if (alpha) {
6309
        if (x > 0) alpha = x; else alpha = 0;
6310
      } else if (x > 0) {
6311
        event.start({
6312
          type: "start",
6313
          alpha: alpha = x
6314
        });
6315
        d3.timer(force.tick);
6316
      }
6317
      return force;
6318
    };
6319
    force.start = function() {
6320
      var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o;
6321
      for (i = 0; i < n; ++i) {
6322
        (o = nodes[i]).index = i;
6323
        o.weight = 0;
6324
      }
6325
      for (i = 0; i < m; ++i) {
6326
        o = links[i];
6327
        if (typeof o.source == "number") o.source = nodes[o.source];
6328
        if (typeof o.target == "number") o.target = nodes[o.target];
6329
        ++o.source.weight;
6330
        ++o.target.weight;
6331
      }
6332
      for (i = 0; i < n; ++i) {
6333
        o = nodes[i];
6334
        if (isNaN(o.x)) o.x = position("x", w);
6335
        if (isNaN(o.y)) o.y = position("y", h);
6336
        if (isNaN(o.px)) o.px = o.x;
6337
        if (isNaN(o.py)) o.py = o.y;
6338
      }
6339
      distances = [];
6340
      if (typeof linkDistance === "function") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance;
6341
      strengths = [];
6342
      if (typeof linkStrength === "function") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength;
6343
      charges = [];
6344
      if (typeof charge === "function") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge;
6345
      function position(dimension, size) {
6346
        if (!neighbors) {
6347
          neighbors = new Array(n);
6348
          for (j = 0; j < n; ++j) {
6349
            neighbors[j] = [];
6350
          }
6351
          for (j = 0; j < m; ++j) {
6352
            var o = links[j];
6353
            neighbors[o.source.index].push(o.target);
6354
            neighbors[o.target.index].push(o.source);
6355
          }
6356
        }
6357
        var candidates = neighbors[i], j = -1, m = candidates.length, x;
6358
        while (++j < m) if (!isNaN(x = candidates[j][dimension])) return x;
6359
        return Math.random() * size;
6360
      }
6361
      return force.resume();
6362
    };
6363
    force.resume = function() {
6364
      return force.alpha(.1);
6365
    };
6366
    force.stop = function() {
6367
      return force.alpha(0);
6368
    };
6369
    force.drag = function() {
6370
      if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart.force", d3_layout_forceDragstart).on("drag.force", dragmove).on("dragend.force", d3_layout_forceDragend);
6371
      if (!arguments.length) return drag;
6372
      this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag);
6373
    };
6374
    function dragmove(d) {
6375
      d.px = d3.event.x, d.py = d3.event.y;
6376
      force.resume();
6377
    }
6378
    return d3.rebind(force, event, "on");
6379
  };
6380
  function d3_layout_forceDragstart(d) {
6381
    d.fixed |= 2;
6382
  }
6383
  function d3_layout_forceDragend(d) {
6384
    d.fixed &= ~6;
6385
  }
6386
  function d3_layout_forceMouseover(d) {
6387
    d.fixed |= 4;
6388
    d.px = d.x, d.py = d.y;
6389
  }
6390
  function d3_layout_forceMouseout(d) {
6391
    d.fixed &= ~4;
6392
  }
6393
  function d3_layout_forceAccumulate(quad, alpha, charges) {
6394
    var cx = 0, cy = 0;
6395
    quad.charge = 0;
6396
    if (!quad.leaf) {
6397
      var nodes = quad.nodes, n = nodes.length, i = -1, c;
6398
      while (++i < n) {
6399
        c = nodes[i];
6400
        if (c == null) continue;
6401
        d3_layout_forceAccumulate(c, alpha, charges);
6402
        quad.charge += c.charge;
6403
        cx += c.charge * c.cx;
6404
        cy += c.charge * c.cy;
6405
      }
6406
    }
6407
    if (quad.point) {
6408
      if (!quad.leaf) {
6409
        quad.point.x += Math.random() - .5;
6410
        quad.point.y += Math.random() - .5;
6411
      }
6412
      var k = alpha * charges[quad.point.index];
6413
      quad.charge += quad.pointCharge = k;
6414
      cx += k * quad.point.x;
6415
      cy += k * quad.point.y;
6416
    }
6417
    quad.cx = cx / quad.charge;
6418
    quad.cy = cy / quad.charge;
6419
  }
6420
  var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity;
6421
  d3.layout.hierarchy = function() {
6422
    var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue;
6423
    function hierarchy(root) {
6424
      var stack = [ root ], nodes = [], node;
6425
      root.depth = 0;
6426
      while ((node = stack.pop()) != null) {
6427
        nodes.push(node);
6428
        if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) {
6429
          var n, childs, child;
6430
          while (--n >= 0) {
6431
            stack.push(child = childs[n]);
6432
            child.parent = node;
6433
            child.depth = node.depth + 1;
6434
          }
6435
          if (value) node.value = 0;
6436
          node.children = childs;
6437
        } else {
6438
          if (value) node.value = +value.call(hierarchy, node, node.depth) || 0;
6439
          delete node.children;
6440
        }
6441
      }
6442
      d3_layout_hierarchyVisitAfter(root, function(node) {
6443
        var childs, parent;
6444
        if (sort && (childs = node.children)) childs.sort(sort);
6445
        if (value && (parent = node.parent)) parent.value += node.value;
6446
      });
6447
      return nodes;
6448
    }
6449
    hierarchy.sort = function(x) {
6450
      if (!arguments.length) return sort;
6451
      sort = x;
6452
      return hierarchy;
6453
    };
6454
    hierarchy.children = function(x) {
6455
      if (!arguments.length) return children;
6456
      children = x;
6457
      return hierarchy;
6458
    };
6459
    hierarchy.value = function(x) {
6460
      if (!arguments.length) return value;
6461
      value = x;
6462
      return hierarchy;
6463
    };
6464
    hierarchy.revalue = function(root) {
6465
      if (value) {
6466
        d3_layout_hierarchyVisitBefore(root, function(node) {
6467
          if (node.children) node.value = 0;
6468
        });
6469
        d3_layout_hierarchyVisitAfter(root, function(node) {
6470
          var parent;
6471
          if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;
6472
          if (parent = node.parent) parent.value += node.value;
6473
        });
6474
      }
6475
      return root;
6476
    };
6477
    return hierarchy;
6478
  };
6479
  function d3_layout_hierarchyRebind(object, hierarchy) {
6480
    d3.rebind(object, hierarchy, "sort", "children", "value");
6481
    object.nodes = object;
6482
    object.links = d3_layout_hierarchyLinks;
6483
    return object;
6484
  }
6485
  function d3_layout_hierarchyVisitBefore(node, callback) {
6486
    var nodes = [ node ];
6487
    while ((node = nodes.pop()) != null) {
6488
      callback(node);
6489
      if ((children = node.children) && (n = children.length)) {
6490
        var n, children;
6491
        while (--n >= 0) nodes.push(children[n]);
6492
      }
6493
    }
6494
  }
6495
  function d3_layout_hierarchyVisitAfter(node, callback) {
6496
    var nodes = [ node ], nodes2 = [];
6497
    while ((node = nodes.pop()) != null) {
6498
      nodes2.push(node);
6499
      if ((children = node.children) && (n = children.length)) {
6500
        var i = -1, n, children;
6501
        while (++i < n) nodes.push(children[i]);
6502
      }
6503
    }
6504
    while ((node = nodes2.pop()) != null) {
6505
      callback(node);
6506
    }
6507
  }
6508
  function d3_layout_hierarchyChildren(d) {
6509
    return d.children;
6510
  }
6511
  function d3_layout_hierarchyValue(d) {
6512
    return d.value;
6513
  }
6514
  function d3_layout_hierarchySort(a, b) {
6515
    return b.value - a.value;
6516
  }
6517
  function d3_layout_hierarchyLinks(nodes) {
6518
    return d3.merge(nodes.map(function(parent) {
6519
      return (parent.children || []).map(function(child) {
6520
        return {
6521
          source: parent,
6522
          target: child
6523
        };
6524
      });
6525
    }));
6526
  }
6527
  d3.layout.partition = function() {
6528
    var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ];
6529
    function position(node, x, dx, dy) {
6530
      var children = node.children;
6531
      node.x = x;
6532
      node.y = node.depth * dy;
6533
      node.dx = dx;
6534
      node.dy = dy;
6535
      if (children && (n = children.length)) {
6536
        var i = -1, n, c, d;
6537
        dx = node.value ? dx / node.value : 0;
6538
        while (++i < n) {
6539
          position(c = children[i], x, d = c.value * dx, dy);
6540
          x += d;
6541
        }
6542
      }
6543
    }
6544
    function depth(node) {
6545
      var children = node.children, d = 0;
6546
      if (children && (n = children.length)) {
6547
        var i = -1, n;
6548
        while (++i < n) d = Math.max(d, depth(children[i]));
6549
      }
6550
      return 1 + d;
6551
    }
6552
    function partition(d, i) {
6553
      var nodes = hierarchy.call(this, d, i);
6554
      position(nodes[0], 0, size[0], size[1] / depth(nodes[0]));
6555
      return nodes;
6556
    }
6557
    partition.size = function(x) {
6558
      if (!arguments.length) return size;
6559
      size = x;
6560
      return partition;
6561
    };
6562
    return d3_layout_hierarchyRebind(partition, hierarchy);
6563
  };
6564
  d3.layout.pie = function() {
6565
    var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0;
6566
    function pie(data) {
6567
      var n = data.length, values = data.map(function(d, i) {
6568
        return +value.call(pie, d, i);
6569
      }), a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === "function" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), k = (da - n * pa) / d3.sum(values), index = d3.range(n), arcs = [], v;
6570
      if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {
6571
        return values[j] - values[i];
6572
      } : function(i, j) {
6573
        return sort(data[i], data[j]);
6574
      });
6575
      index.forEach(function(i) {
6576
        arcs[i] = {
6577
          data: data[i],
6578
          value: v = values[i],
6579
          startAngle: a,
6580
          endAngle: a += v * k + pa,
6581
          padAngle: p
6582
        };
6583
      });
6584
      return arcs;
6585
    }
6586
    pie.value = function(_) {
6587
      if (!arguments.length) return value;
6588
      value = _;
6589
      return pie;
6590
    };
6591
    pie.sort = function(_) {
6592
      if (!arguments.length) return sort;
6593
      sort = _;
6594
      return pie;
6595
    };
6596
    pie.startAngle = function(_) {
6597
      if (!arguments.length) return startAngle;
6598
      startAngle = _;
6599
      return pie;
6600
    };
6601
    pie.endAngle = function(_) {
6602
      if (!arguments.length) return endAngle;
6603
      endAngle = _;
6604
      return pie;
6605
    };
6606
    pie.padAngle = function(_) {
6607
      if (!arguments.length) return padAngle;
6608
      padAngle = _;
6609
      return pie;
6610
    };
6611
    return pie;
6612
  };
6613
  var d3_layout_pieSortByValue = {};
6614
  d3.layout.stack = function() {
6615
    var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY;
6616
    function stack(data, index) {
6617
      if (!(n = data.length)) return data;
6618
      var series = data.map(function(d, i) {
6619
        return values.call(stack, d, i);
6620
      });
6621
      var points = series.map(function(d) {
6622
        return d.map(function(v, i) {
6623
          return [ x.call(stack, v, i), y.call(stack, v, i) ];
6624
        });
6625
      });
6626
      var orders = order.call(stack, points, index);
6627
      series = d3.permute(series, orders);
6628
      points = d3.permute(points, orders);
6629
      var offsets = offset.call(stack, points, index);
6630
      var m = series[0].length, n, i, j, o;
6631
      for (j = 0; j < m; ++j) {
6632
        out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);
6633
        for (i = 1; i < n; ++i) {
6634
          out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]);
6635
        }
6636
      }
6637
      return data;
6638
    }
6639
    stack.values = function(x) {
6640
      if (!arguments.length) return values;
6641
      values = x;
6642
      return stack;
6643
    };
6644
    stack.order = function(x) {
6645
      if (!arguments.length) return order;
6646
      order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault;
6647
      return stack;
6648
    };
6649
    stack.offset = function(x) {
6650
      if (!arguments.length) return offset;
6651
      offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero;
6652
      return stack;
6653
    };
6654
    stack.x = function(z) {
6655
      if (!arguments.length) return x;
6656
      x = z;
6657
      return stack;
6658
    };
6659
    stack.y = function(z) {
6660
      if (!arguments.length) return y;
6661
      y = z;
6662
      return stack;
6663
    };
6664
    stack.out = function(z) {
6665
      if (!arguments.length) return out;
6666
      out = z;
6667
      return stack;
6668
    };
6669
    return stack;
6670
  };
6671
  function d3_layout_stackX(d) {
6672
    return d.x;
6673
  }
6674
  function d3_layout_stackY(d) {
6675
    return d.y;
6676
  }
6677
  function d3_layout_stackOut(d, y0, y) {
6678
    d.y0 = y0;
6679
    d.y = y;
6680
  }
6681
  var d3_layout_stackOrders = d3.map({
6682
    "inside-out": function(data) {
6683
      var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) {
6684
        return max[a] - max[b];
6685
      }), top = 0, bottom = 0, tops = [], bottoms = [];
6686
      for (i = 0; i < n; ++i) {
6687
        j = index[i];
6688
        if (top < bottom) {
6689
          top += sums[j];
6690
          tops.push(j);
6691
        } else {
6692
          bottom += sums[j];
6693
          bottoms.push(j);
6694
        }
6695
      }
6696
      return bottoms.reverse().concat(tops);
6697
    },
6698
    reverse: function(data) {
6699
      return d3.range(data.length).reverse();
6700
    },
6701
    "default": d3_layout_stackOrderDefault
6702
  });
6703
  var d3_layout_stackOffsets = d3.map({
6704
    silhouette: function(data) {
6705
      var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = [];
6706
      for (j = 0; j < m; ++j) {
6707
        for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
6708
        if (o > max) max = o;
6709
        sums.push(o);
6710
      }
6711
      for (j = 0; j < m; ++j) {
6712
        y0[j] = (max - sums[j]) / 2;
6713
      }
6714
      return y0;
6715
    },
6716
    wiggle: function(data) {
6717
      var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = [];
6718
      y0[0] = o = o0 = 0;
6719
      for (j = 1; j < m; ++j) {
6720
        for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1];
6721
        for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) {
6722
          for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) {
6723
            s3 += (data[k][j][1] - data[k][j - 1][1]) / dx;
6724
          }
6725
          s2 += s3 * data[i][j][1];
6726
        }
6727
        y0[j] = o -= s1 ? s2 / s1 * dx : 0;
6728
        if (o < o0) o0 = o;
6729
      }
6730
      for (j = 0; j < m; ++j) y0[j] -= o0;
6731
      return y0;
6732
    },
6733
    expand: function(data) {
6734
      var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = [];
6735
      for (j = 0; j < m; ++j) {
6736
        for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
6737
        if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k;
6738
      }
6739
      for (j = 0; j < m; ++j) y0[j] = 0;
6740
      return y0;
6741
    },
6742
    zero: d3_layout_stackOffsetZero
6743
  });
6744
  function d3_layout_stackOrderDefault(data) {
6745
    return d3.range(data.length);
6746
  }
6747
  function d3_layout_stackOffsetZero(data) {
6748
    var j = -1, m = data[0].length, y0 = [];
6749
    while (++j < m) y0[j] = 0;
6750
    return y0;
6751
  }
6752
  function d3_layout_stackMaxIndex(array) {
6753
    var i = 1, j = 0, v = array[0][1], k, n = array.length;
6754
    for (;i < n; ++i) {
6755
      if ((k = array[i][1]) > v) {
6756
        j = i;
6757
        v = k;
6758
      }
6759
    }
6760
    return j;
6761
  }
6762
  function d3_layout_stackReduceSum(d) {
6763
    return d.reduce(d3_layout_stackSum, 0);
6764
  }
6765
  function d3_layout_stackSum(p, d) {
6766
    return p + d[1];
6767
  }
6768
  d3.layout.histogram = function() {
6769
    var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges;
6770
    function histogram(data, i) {
6771
      var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x;
6772
      while (++i < m) {
6773
        bin = bins[i] = [];
6774
        bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);
6775
        bin.y = 0;
6776
      }
6777
      if (m > 0) {
6778
        i = -1;
6779
        while (++i < n) {
6780
          x = values[i];
6781
          if (x >= range[0] && x <= range[1]) {
6782
            bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
6783
            bin.y += k;
6784
            bin.push(data[i]);
6785
          }
6786
        }
6787
      }
6788
      return bins;
6789
    }
6790
    histogram.value = function(x) {
6791
      if (!arguments.length) return valuer;
6792
      valuer = x;
6793
      return histogram;
6794
    };
6795
    histogram.range = function(x) {
6796
      if (!arguments.length) return ranger;
6797
      ranger = d3_functor(x);
6798
      return histogram;
6799
    };
6800
    histogram.bins = function(x) {
6801
      if (!arguments.length) return binner;
6802
      binner = typeof x === "number" ? function(range) {
6803
        return d3_layout_histogramBinFixed(range, x);
6804
      } : d3_functor(x);
6805
      return histogram;
6806
    };
6807
    histogram.frequency = function(x) {
6808
      if (!arguments.length) return frequency;
6809
      frequency = !!x;
6810
      return histogram;
6811
    };
6812
    return histogram;
6813
  };
6814
  function d3_layout_histogramBinSturges(range, values) {
6815
    return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));
6816
  }
6817
  function d3_layout_histogramBinFixed(range, n) {
6818
    var x = -1, b = +range[0], m = (range[1] - b) / n, f = [];
6819
    while (++x <= n) f[x] = m * x + b;
6820
    return f;
6821
  }
6822
  function d3_layout_histogramRange(values) {
6823
    return [ d3.min(values), d3.max(values) ];
6824
  }
6825
  d3.layout.pack = function() {
6826
    var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius;
6827
    function pack(d, i) {
6828
      var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === "function" ? radius : function() {
6829
        return radius;
6830
      };
6831
      root.x = root.y = 0;
6832
      d3_layout_hierarchyVisitAfter(root, function(d) {
6833
        d.r = +r(d.value);
6834
      });
6835
      d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
6836
      if (padding) {
6837
        var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2;
6838
        d3_layout_hierarchyVisitAfter(root, function(d) {
6839
          d.r += dr;
6840
        });
6841
        d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
6842
        d3_layout_hierarchyVisitAfter(root, function(d) {
6843
          d.r -= dr;
6844
        });
6845
      }
6846
      d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h));
6847
      return nodes;
6848
    }
6849
    pack.size = function(_) {
6850
      if (!arguments.length) return size;
6851
      size = _;
6852
      return pack;
6853
    };
6854
    pack.radius = function(_) {
6855
      if (!arguments.length) return radius;
6856
      radius = _ == null || typeof _ === "function" ? _ : +_;
6857
      return pack;
6858
    };
6859
    pack.padding = function(_) {
6860
      if (!arguments.length) return padding;
6861
      padding = +_;
6862
      return pack;
6863
    };
6864
    return d3_layout_hierarchyRebind(pack, hierarchy);
6865
  };
6866
  function d3_layout_packSort(a, b) {
6867
    return a.value - b.value;
6868
  }
6869
  function d3_layout_packInsert(a, b) {
6870
    var c = a._pack_next;
6871
    a._pack_next = b;
6872
    b._pack_prev = a;
6873
    b._pack_next = c;
6874
    c._pack_prev = b;
6875
  }
6876
  function d3_layout_packSplice(a, b) {
6877
    a._pack_next = b;
6878
    b._pack_prev = a;
6879
  }
6880
  function d3_layout_packIntersects(a, b) {
6881
    var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r;
6882
    return .999 * dr * dr > dx * dx + dy * dy;
6883
  }
6884
  function d3_layout_packSiblings(node) {
6885
    if (!(nodes = node.children) || !(n = nodes.length)) return;
6886
    var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n;
6887
    function bound(node) {
6888
      xMin = Math.min(node.x - node.r, xMin);
6889
      xMax = Math.max(node.x + node.r, xMax);
6890
      yMin = Math.min(node.y - node.r, yMin);
6891
      yMax = Math.max(node.y + node.r, yMax);
6892
    }
6893
    nodes.forEach(d3_layout_packLink);
6894
    a = nodes[0];
6895
    a.x = -a.r;
6896
    a.y = 0;
6897
    bound(a);
6898
    if (n > 1) {
6899
      b = nodes[1];
6900
      b.x = b.r;
6901
      b.y = 0;
6902
      bound(b);
6903
      if (n > 2) {
6904
        c = nodes[2];
6905
        d3_layout_packPlace(a, b, c);
6906
        bound(c);
6907
        d3_layout_packInsert(a, c);
6908
        a._pack_prev = c;
6909
        d3_layout_packInsert(c, b);
6910
        b = a._pack_next;
6911
        for (i = 3; i < n; i++) {
6912
          d3_layout_packPlace(a, b, c = nodes[i]);
6913
          var isect = 0, s1 = 1, s2 = 1;
6914
          for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {
6915
            if (d3_layout_packIntersects(j, c)) {
6916
              isect = 1;
6917
              break;
6918
            }
6919
          }
6920
          if (isect == 1) {
6921
            for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {
6922
              if (d3_layout_packIntersects(k, c)) {
6923
                break;
6924
              }
6925
            }
6926
          }
6927
          if (isect) {
6928
            if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b);
6929
            i--;
6930
          } else {
6931
            d3_layout_packInsert(a, c);
6932
            b = c;
6933
            bound(c);
6934
          }
6935
        }
6936
      }
6937
    }
6938
    var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0;
6939
    for (i = 0; i < n; i++) {
6940
      c = nodes[i];
6941
      c.x -= cx;
6942
      c.y -= cy;
6943
      cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y));
6944
    }
6945
    node.r = cr;
6946
    nodes.forEach(d3_layout_packUnlink);
6947
  }
6948
  function d3_layout_packLink(node) {
6949
    node._pack_next = node._pack_prev = node;
6950
  }
6951
  function d3_layout_packUnlink(node) {
6952
    delete node._pack_next;
6953
    delete node._pack_prev;
6954
  }
6955
  function d3_layout_packTransform(node, x, y, k) {
6956
    var children = node.children;
6957
    node.x = x += k * node.x;
6958
    node.y = y += k * node.y;
6959
    node.r *= k;
6960
    if (children) {
6961
      var i = -1, n = children.length;
6962
      while (++i < n) d3_layout_packTransform(children[i], x, y, k);
6963
    }
6964
  }
6965
  function d3_layout_packPlace(a, b, c) {
6966
    var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y;
6967
    if (db && (dx || dy)) {
6968
      var da = b.r + c.r, dc = dx * dx + dy * dy;
6969
      da *= da;
6970
      db *= db;
6971
      var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc);
6972
      c.x = a.x + x * dx + y * dy;
6973
      c.y = a.y + x * dy - y * dx;
6974
    } else {
6975
      c.x = a.x + db;
6976
      c.y = a.y;
6977
    }
6978
  }
6979
  d3.layout.tree = function() {
6980
    var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null;
6981
    function tree(d, i) {
6982
      var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0);
6983
      d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z;
6984
      d3_layout_hierarchyVisitBefore(root1, secondWalk);
6985
      if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else {
6986
        var left = root0, right = root0, bottom = root0;
6987
        d3_layout_hierarchyVisitBefore(root0, function(node) {
6988
          if (node.x < left.x) left = node;
6989
          if (node.x > right.x) right = node;
6990
          if (node.depth > bottom.depth) bottom = node;
6991
        });
6992
        var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1);
6993
        d3_layout_hierarchyVisitBefore(root0, function(node) {
6994
          node.x = (node.x + tx) * kx;
6995
          node.y = node.depth * ky;
6996
        });
6997
      }
6998
      return nodes;
6999
    }
7000
    function wrapTree(root0) {
7001
      var root1 = {
7002
        A: null,
7003
        children: [ root0 ]
7004
      }, queue = [ root1 ], node1;
7005
      while ((node1 = queue.pop()) != null) {
7006
        for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) {
7007
          queue.push((children[i] = child = {
7008
            _: children[i],
7009
            parent: node1,
7010
            children: (child = children[i].children) && child.slice() || [],
7011
            A: null,
7012
            a: null,
7013
            z: 0,
7014
            m: 0,
7015
            c: 0,
7016
            s: 0,
7017
            t: null,
7018
            i: i
7019
          }).a = child);
7020
        }
7021
      }
7022
      return root1.children[0];
7023
    }
7024
    function firstWalk(v) {
7025
      var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;
7026
      if (children.length) {
7027
        d3_layout_treeShift(v);
7028
        var midpoint = (children[0].z + children[children.length - 1].z) / 2;
7029
        if (w) {
7030
          v.z = w.z + separation(v._, w._);
7031
          v.m = v.z - midpoint;
7032
        } else {
7033
          v.z = midpoint;
7034
        }
7035
      } else if (w) {
7036
        v.z = w.z + separation(v._, w._);
7037
      }
7038
      v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
7039
    }
7040
    function secondWalk(v) {
7041
      v._.x = v.z + v.parent.m;
7042
      v.m += v.parent.m;
7043
    }
7044
    function apportion(v, w, ancestor) {
7045
      if (w) {
7046
        var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift;
7047
        while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
7048
          vom = d3_layout_treeLeft(vom);
7049
          vop = d3_layout_treeRight(vop);
7050
          vop.a = v;
7051
          shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
7052
          if (shift > 0) {
7053
            d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift);
7054
            sip += shift;
7055
            sop += shift;
7056
          }
7057
          sim += vim.m;
7058
          sip += vip.m;
7059
          som += vom.m;
7060
          sop += vop.m;
7061
        }
7062
        if (vim && !d3_layout_treeRight(vop)) {
7063
          vop.t = vim;
7064
          vop.m += sim - sop;
7065
        }
7066
        if (vip && !d3_layout_treeLeft(vom)) {
7067
          vom.t = vip;
7068
          vom.m += sip - som;
7069
          ancestor = v;
7070
        }
7071
      }
7072
      return ancestor;
7073
    }
7074
    function sizeNode(node) {
7075
      node.x *= size[0];
7076
      node.y = node.depth * size[1];
7077
    }
7078
    tree.separation = function(x) {
7079
      if (!arguments.length) return separation;
7080
      separation = x;
7081
      return tree;
7082
    };
7083
    tree.size = function(x) {
7084
      if (!arguments.length) return nodeSize ? null : size;
7085
      nodeSize = (size = x) == null ? sizeNode : null;
7086
      return tree;
7087
    };
7088
    tree.nodeSize = function(x) {
7089
      if (!arguments.length) return nodeSize ? size : null;
7090
      nodeSize = (size = x) == null ? null : sizeNode;
7091
      return tree;
7092
    };
7093
    return d3_layout_hierarchyRebind(tree, hierarchy);
7094
  };
7095
  function d3_layout_treeSeparation(a, b) {
7096
    return a.parent == b.parent ? 1 : 2;
7097
  }
7098
  function d3_layout_treeLeft(v) {
7099
    var children = v.children;
7100
    return children.length ? children[0] : v.t;
7101
  }
7102
  function d3_layout_treeRight(v) {
7103
    var children = v.children, n;
7104
    return (n = children.length) ? children[n - 1] : v.t;
7105
  }
7106
  function d3_layout_treeMove(wm, wp, shift) {
7107
    var change = shift / (wp.i - wm.i);
7108
    wp.c -= change;
7109
    wp.s += shift;
7110
    wm.c += change;
7111
    wp.z += shift;
7112
    wp.m += shift;
7113
  }
7114
  function d3_layout_treeShift(v) {
7115
    var shift = 0, change = 0, children = v.children, i = children.length, w;
7116
    while (--i >= 0) {
7117
      w = children[i];
7118
      w.z += shift;
7119
      w.m += shift;
7120
      shift += w.s + (change += w.c);
7121
    }
7122
  }
7123
  function d3_layout_treeAncestor(vim, v, ancestor) {
7124
    return vim.a.parent === v.parent ? vim.a : ancestor;
7125
  }
7126
  d3.layout.cluster = function() {
7127
    var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;
7128
    function cluster(d, i) {
7129
      var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0;
7130
      d3_layout_hierarchyVisitAfter(root, function(node) {
7131
        var children = node.children;
7132
        if (children && children.length) {
7133
          node.x = d3_layout_clusterX(children);
7134
          node.y = d3_layout_clusterY(children);
7135
        } else {
7136
          node.x = previousNode ? x += separation(node, previousNode) : 0;
7137
          node.y = 0;
7138
          previousNode = node;
7139
        }
7140
      });
7141
      var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2;
7142
      d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) {
7143
        node.x = (node.x - root.x) * size[0];
7144
        node.y = (root.y - node.y) * size[1];
7145
      } : function(node) {
7146
        node.x = (node.x - x0) / (x1 - x0) * size[0];
7147
        node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];
7148
      });
7149
      return nodes;
7150
    }
7151
    cluster.separation = function(x) {
7152
      if (!arguments.length) return separation;
7153
      separation = x;
7154
      return cluster;
7155
    };
7156
    cluster.size = function(x) {
7157
      if (!arguments.length) return nodeSize ? null : size;
7158
      nodeSize = (size = x) == null;
7159
      return cluster;
7160
    };
7161
    cluster.nodeSize = function(x) {
7162
      if (!arguments.length) return nodeSize ? size : null;
7163
      nodeSize = (size = x) != null;
7164
      return cluster;
7165
    };
7166
    return d3_layout_hierarchyRebind(cluster, hierarchy);
7167
  };
7168
  function d3_layout_clusterY(children) {
7169
    return 1 + d3.max(children, function(child) {
7170
      return child.y;
7171
    });
7172
  }
7173
  function d3_layout_clusterX(children) {
7174
    return children.reduce(function(x, child) {
7175
      return x + child.x;
7176
    }, 0) / children.length;
7177
  }
7178
  function d3_layout_clusterLeft(node) {
7179
    var children = node.children;
7180
    return children && children.length ? d3_layout_clusterLeft(children[0]) : node;
7181
  }
7182
  function d3_layout_clusterRight(node) {
7183
    var children = node.children, n;
7184
    return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;
7185
  }
7186
  d3.layout.treemap = function() {
7187
    var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = "squarify", ratio = .5 * (1 + Math.sqrt(5));
7188
    function scale(children, k) {
7189
      var i = -1, n = children.length, child, area;
7190
      while (++i < n) {
7191
        area = (child = children[i]).value * (k < 0 ? 0 : k);
7192
        child.area = isNaN(area) || area <= 0 ? 0 : area;
7193
      }
7194
    }
7195
    function squarify(node) {
7196
      var children = node.children;
7197
      if (children && children.length) {
7198
        var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" ? rect.dy : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n;
7199
        scale(remaining, rect.dx * rect.dy / node.value);
7200
        row.area = 0;
7201
        while ((n = remaining.length) > 0) {
7202
          row.push(child = remaining[n - 1]);
7203
          row.area += child.area;
7204
          if (mode !== "squarify" || (score = worst(row, u)) <= best) {
7205
            remaining.pop();
7206
            best = score;
7207
          } else {
7208
            row.area -= row.pop().area;
7209
            position(row, u, rect, false);
7210
            u = Math.min(rect.dx, rect.dy);
7211
            row.length = row.area = 0;
7212
            best = Infinity;
7213
          }
7214
        }
7215
        if (row.length) {
7216
          position(row, u, rect, true);
7217
          row.length = row.area = 0;
7218
        }
7219
        children.forEach(squarify);
7220
      }
7221
    }
7222
    function stickify(node) {
7223
      var children = node.children;
7224
      if (children && children.length) {
7225
        var rect = pad(node), remaining = children.slice(), child, row = [];
7226
        scale(remaining, rect.dx * rect.dy / node.value);
7227
        row.area = 0;
7228
        while (child = remaining.pop()) {
7229
          row.push(child);
7230
          row.area += child.area;
7231
          if (child.z != null) {
7232
            position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length);
7233
            row.length = row.area = 0;
7234
          }
7235
        }
7236
        children.forEach(stickify);
7237
      }
7238
    }
7239
    function worst(row, u) {
7240
      var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length;
7241
      while (++i < n) {
7242
        if (!(r = row[i].area)) continue;
7243
        if (r < rmin) rmin = r;
7244
        if (r > rmax) rmax = r;
7245
      }
7246
      s *= s;
7247
      u *= u;
7248
      return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity;
7249
    }
7250
    function position(row, u, rect, flush) {
7251
      var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o;
7252
      if (u == rect.dx) {
7253
        if (flush || v > rect.dy) v = rect.dy;
7254
        while (++i < n) {
7255
          o = row[i];
7256
          o.x = x;
7257
          o.y = y;
7258
          o.dy = v;
7259
          x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0);
7260
        }
7261
        o.z = true;
7262
        o.dx += rect.x + rect.dx - x;
7263
        rect.y += v;
7264
        rect.dy -= v;
7265
      } else {
7266
        if (flush || v > rect.dx) v = rect.dx;
7267
        while (++i < n) {
7268
          o = row[i];
7269
          o.x = x;
7270
          o.y = y;
7271
          o.dx = v;
7272
          y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0);
7273
        }
7274
        o.z = false;
7275
        o.dy += rect.y + rect.dy - y;
7276
        rect.x += v;
7277
        rect.dx -= v;
7278
      }
7279
    }
7280
    function treemap(d) {
7281
      var nodes = stickies || hierarchy(d), root = nodes[0];
7282
      root.x = 0;
7283
      root.y = 0;
7284
      root.dx = size[0];
7285
      root.dy = size[1];
7286
      if (stickies) hierarchy.revalue(root);
7287
      scale([ root ], root.dx * root.dy / root.value);
7288
      (stickies ? stickify : squarify)(root);
7289
      if (sticky) stickies = nodes;
7290
      return nodes;
7291
    }
7292
    treemap.size = function(x) {
7293
      if (!arguments.length) return size;
7294
      size = x;
7295
      return treemap;
7296
    };
7297
    treemap.padding = function(x) {
7298
      if (!arguments.length) return padding;
7299
      function padFunction(node) {
7300
        var p = x.call(treemap, node, node.depth);
7301
        return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p);
7302
      }
7303
      function padConstant(node) {
7304
        return d3_layout_treemapPad(node, x);
7305
      }
7306
      var type;
7307
      pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ], 
7308
      padConstant) : padConstant;
7309
      return treemap;
7310
    };
7311
    treemap.round = function(x) {
7312
      if (!arguments.length) return round != Number;
7313
      round = x ? Math.round : Number;
7314
      return treemap;
7315
    };
7316
    treemap.sticky = function(x) {
7317
      if (!arguments.length) return sticky;
7318
      sticky = x;
7319
      stickies = null;
7320
      return treemap;
7321
    };
7322
    treemap.ratio = function(x) {
7323
      if (!arguments.length) return ratio;
7324
      ratio = x;
7325
      return treemap;
7326
    };
7327
    treemap.mode = function(x) {
7328
      if (!arguments.length) return mode;
7329
      mode = x + "";
7330
      return treemap;
7331
    };
7332
    return d3_layout_hierarchyRebind(treemap, hierarchy);
7333
  };
7334
  function d3_layout_treemapPadNull(node) {
7335
    return {
7336
      x: node.x,
7337
      y: node.y,
7338
      dx: node.dx,
7339
      dy: node.dy
7340
    };
7341
  }
7342
  function d3_layout_treemapPad(node, padding) {
7343
    var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2];
7344
    if (dx < 0) {
7345
      x += dx / 2;
7346
      dx = 0;
7347
    }
7348
    if (dy < 0) {
7349
      y += dy / 2;
7350
      dy = 0;
7351
    }
7352
    return {
7353
      x: x,
7354
      y: y,
7355
      dx: dx,
7356
      dy: dy
7357
    };
7358
  }
7359
  d3.random = {
7360
    normal: function(µ, σ) {
7361
      var n = arguments.length;
7362
      if (n < 2) σ = 1;
7363
      if (n < 1) µ = 0;
7364
      return function() {
7365
        var x, y, r;
7366
        do {
7367
          x = Math.random() * 2 - 1;
7368
          y = Math.random() * 2 - 1;
7369
          r = x * x + y * y;
7370
        } while (!r || r > 1);
7371
        return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r);
7372
      };
7373
    },
7374
    logNormal: function() {
7375
      var random = d3.random.normal.apply(d3, arguments);
7376
      return function() {
7377
        return Math.exp(random());
7378
      };
7379
    },
7380
    bates: function(m) {
7381
      var random = d3.random.irwinHall(m);
7382
      return function() {
7383
        return random() / m;
7384
      };
7385
    },
7386
    irwinHall: function(m) {
7387
      return function() {
7388
        for (var s = 0, j = 0; j < m; j++) s += Math.random();
7389
        return s;
7390
      };
7391
    }
7392
  };
7393
  d3.scale = {};
7394
  function d3_scaleExtent(domain) {
7395
    var start = domain[0], stop = domain[domain.length - 1];
7396
    return start < stop ? [ start, stop ] : [ stop, start ];
7397
  }
7398
  function d3_scaleRange(scale) {
7399
    return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());
7400
  }
7401
  function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {
7402
    var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]);
7403
    return function(x) {
7404
      return i(u(x));
7405
    };
7406
  }
7407
  function d3_scale_nice(domain, nice) {
7408
    var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx;
7409
    if (x1 < x0) {
7410
      dx = i0, i0 = i1, i1 = dx;
7411
      dx = x0, x0 = x1, x1 = dx;
7412
    }
7413
    domain[i0] = nice.floor(x0);
7414
    domain[i1] = nice.ceil(x1);
7415
    return domain;
7416
  }
7417
  function d3_scale_niceStep(step) {
7418
    return step ? {
7419
      floor: function(x) {
7420
        return Math.floor(x / step) * step;
7421
      },
7422
      ceil: function(x) {
7423
        return Math.ceil(x / step) * step;
7424
      }
7425
    } : d3_scale_niceIdentity;
7426
  }
7427
  var d3_scale_niceIdentity = {
7428
    floor: d3_identity,
7429
    ceil: d3_identity
7430
  };
7431
  function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
7432
    var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1;
7433
    if (domain[k] < domain[0]) {
7434
      domain = domain.slice().reverse();
7435
      range = range.slice().reverse();
7436
    }
7437
    while (++j <= k) {
7438
      u.push(uninterpolate(domain[j - 1], domain[j]));
7439
      i.push(interpolate(range[j - 1], range[j]));
7440
    }
7441
    return function(x) {
7442
      var j = d3.bisect(domain, x, 1, k) - 1;
7443
      return i[j](u[j](x));
7444
    };
7445
  }
7446
  d3.scale.linear = function() {
7447
    return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false);
7448
  };
7449
  function d3_scale_linear(domain, range, interpolate, clamp) {
7450
    var output, input;
7451
    function rescale() {
7452
      var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
7453
      output = linear(domain, range, uninterpolate, interpolate);
7454
      input = linear(range, domain, uninterpolate, d3_interpolate);
7455
      return scale;
7456
    }
7457
    function scale(x) {
7458
      return output(x);
7459
    }
7460
    scale.invert = function(y) {
7461
      return input(y);
7462
    };
7463
    scale.domain = function(x) {
7464
      if (!arguments.length) return domain;
7465
      domain = x.map(Number);
7466
      return rescale();
7467
    };
7468
    scale.range = function(x) {
7469
      if (!arguments.length) return range;
7470
      range = x;
7471
      return rescale();
7472
    };
7473
    scale.rangeRound = function(x) {
7474
      return scale.range(x).interpolate(d3_interpolateRound);
7475
    };
7476
    scale.clamp = function(x) {
7477
      if (!arguments.length) return clamp;
7478
      clamp = x;
7479
      return rescale();
7480
    };
7481
    scale.interpolate = function(x) {
7482
      if (!arguments.length) return interpolate;
7483
      interpolate = x;
7484
      return rescale();
7485
    };
7486
    scale.ticks = function(m) {
7487
      return d3_scale_linearTicks(domain, m);
7488
    };
7489
    scale.tickFormat = function(m, format) {
7490
      return d3_scale_linearTickFormat(domain, m, format);
7491
    };
7492
    scale.nice = function(m) {
7493
      d3_scale_linearNice(domain, m);
7494
      return rescale();
7495
    };
7496
    scale.copy = function() {
7497
      return d3_scale_linear(domain, range, interpolate, clamp);
7498
    };
7499
    return rescale();
7500
  }
7501
  function d3_scale_linearRebind(scale, linear) {
7502
    return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
7503
  }
7504
  function d3_scale_linearNice(domain, m) {
7505
    return d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));
7506
  }
7507
  function d3_scale_linearTickRange(domain, m) {
7508
    if (m == null) m = 10;
7509
    var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step;
7510
    if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2;
7511
    extent[0] = Math.ceil(extent[0] / step) * step;
7512
    extent[1] = Math.floor(extent[1] / step) * step + step * .5;
7513
    extent[2] = step;
7514
    return extent;
7515
  }
7516
  function d3_scale_linearTicks(domain, m) {
7517
    return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));
7518
  }
7519
  function d3_scale_linearTickFormat(domain, m, format) {
7520
    var range = d3_scale_linearTickRange(domain, m);
7521
    if (format) {
7522
      var match = d3_format_re.exec(format);
7523
      match.shift();
7524
      if (match[8] === "s") {
7525
        var prefix = d3.formatPrefix(Math.max(abs(range[0]), abs(range[1])));
7526
        if (!match[7]) match[7] = "." + d3_scale_linearPrecision(prefix.scale(range[2]));
7527
        match[8] = "f";
7528
        format = d3.format(match.join(""));
7529
        return function(d) {
7530
          return format(prefix.scale(d)) + prefix.symbol;
7531
        };
7532
      }
7533
      if (!match[7]) match[7] = "." + d3_scale_linearFormatPrecision(match[8], range);
7534
      format = match.join("");
7535
    } else {
7536
      format = ",." + d3_scale_linearPrecision(range[2]) + "f";
7537
    }
7538
    return d3.format(format);
7539
  }
7540
  var d3_scale_linearFormatSignificant = {
7541
    s: 1,
7542
    g: 1,
7543
    p: 1,
7544
    r: 1,
7545
    e: 1
7546
  };
7547
  function d3_scale_linearPrecision(value) {
7548
    return -Math.floor(Math.log(value) / Math.LN10 + .01);
7549
  }
7550
  function d3_scale_linearFormatPrecision(type, range) {
7551
    var p = d3_scale_linearPrecision(range[2]);
7552
    return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range[0]), abs(range[1])))) + +(type !== "e") : p - (type === "%") * 2;
7553
  }
7554
  d3.scale.log = function() {
7555
    return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]);
7556
  };
7557
  function d3_scale_log(linear, base, positive, domain) {
7558
    function log(x) {
7559
      return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base);
7560
    }
7561
    function pow(x) {
7562
      return positive ? Math.pow(base, x) : -Math.pow(base, -x);
7563
    }
7564
    function scale(x) {
7565
      return linear(log(x));
7566
    }
7567
    scale.invert = function(x) {
7568
      return pow(linear.invert(x));
7569
    };
7570
    scale.domain = function(x) {
7571
      if (!arguments.length) return domain;
7572
      positive = x[0] >= 0;
7573
      linear.domain((domain = x.map(Number)).map(log));
7574
      return scale;
7575
    };
7576
    scale.base = function(_) {
7577
      if (!arguments.length) return base;
7578
      base = +_;
7579
      linear.domain(domain.map(log));
7580
      return scale;
7581
    };
7582
    scale.nice = function() {
7583
      var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative);
7584
      linear.domain(niced);
7585
      domain = niced.map(pow);
7586
      return scale;
7587
    };
7588
    scale.ticks = function() {
7589
      var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base;
7590
      if (isFinite(j - i)) {
7591
        if (positive) {
7592
          for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k);
7593
          ticks.push(pow(i));
7594
        } else {
7595
          ticks.push(pow(i));
7596
          for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k);
7597
        }
7598
        for (i = 0; ticks[i] < u; i++) {}
7599
        for (j = ticks.length; ticks[j - 1] > v; j--) {}
7600
        ticks = ticks.slice(i, j);
7601
      }
7602
      return ticks;
7603
    };
7604
    scale.tickFormat = function(n, format) {
7605
      if (!arguments.length) return d3_scale_logFormat;
7606
      if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format);
7607
      var k = Math.max(.1, n / scale.ticks().length), f = positive ? (e = 1e-12, Math.ceil) : (e = -1e-12, 
7608
      Math.floor), e;
7609
      return function(d) {
7610
        return d / pow(f(log(d) + e)) <= k ? format(d) : "";
7611
      };
7612
    };
7613
    scale.copy = function() {
7614
      return d3_scale_log(linear.copy(), base, positive, domain);
7615
    };
7616
    return d3_scale_linearRebind(scale, linear);
7617
  }
7618
  var d3_scale_logFormat = d3.format(".0e"), d3_scale_logNiceNegative = {
7619
    floor: function(x) {
7620
      return -Math.ceil(-x);
7621
    },
7622
    ceil: function(x) {
7623
      return -Math.floor(-x);
7624
    }
7625
  };
7626
  d3.scale.pow = function() {
7627
    return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]);
7628
  };
7629
  function d3_scale_pow(linear, exponent, domain) {
7630
    var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent);
7631
    function scale(x) {
7632
      return linear(powp(x));
7633
    }
7634
    scale.invert = function(x) {
7635
      return powb(linear.invert(x));
7636
    };
7637
    scale.domain = function(x) {
7638
      if (!arguments.length) return domain;
7639
      linear.domain((domain = x.map(Number)).map(powp));
7640
      return scale;
7641
    };
7642
    scale.ticks = function(m) {
7643
      return d3_scale_linearTicks(domain, m);
7644
    };
7645
    scale.tickFormat = function(m, format) {
7646
      return d3_scale_linearTickFormat(domain, m, format);
7647
    };
7648
    scale.nice = function(m) {
7649
      return scale.domain(d3_scale_linearNice(domain, m));
7650
    };
7651
    scale.exponent = function(x) {
7652
      if (!arguments.length) return exponent;
7653
      powp = d3_scale_powPow(exponent = x);
7654
      powb = d3_scale_powPow(1 / exponent);
7655
      linear.domain(domain.map(powp));
7656
      return scale;
7657
    };
7658
    scale.copy = function() {
7659
      return d3_scale_pow(linear.copy(), exponent, domain);
7660
    };
7661
    return d3_scale_linearRebind(scale, linear);
7662
  }
7663
  function d3_scale_powPow(e) {
7664
    return function(x) {
7665
      return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);
7666
    };
7667
  }
7668
  d3.scale.sqrt = function() {
7669
    return d3.scale.pow().exponent(.5);
7670
  };
7671
  d3.scale.ordinal = function() {
7672
    return d3_scale_ordinal([], {
7673
      t: "range",
7674
      a: [ [] ]
7675
    });
7676
  };
7677
  function d3_scale_ordinal(domain, ranger) {
7678
    var index, range, rangeBand;
7679
    function scale(x) {
7680
      return range[((index.get(x) || (ranger.t === "range" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length];
7681
    }
7682
    function steps(start, step) {
7683
      return d3.range(domain.length).map(function(i) {
7684
        return start + step * i;
7685
      });
7686
    }
7687
    scale.domain = function(x) {
7688
      if (!arguments.length) return domain;
7689
      domain = [];
7690
      index = new d3_Map();
7691
      var i = -1, n = x.length, xi;
7692
      while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));
7693
      return scale[ranger.t].apply(scale, ranger.a);
7694
    };
7695
    scale.range = function(x) {
7696
      if (!arguments.length) return range;
7697
      range = x;
7698
      rangeBand = 0;
7699
      ranger = {
7700
        t: "range",
7701
        a: arguments
7702
      };
7703
      return scale;
7704
    };
7705
    scale.rangePoints = function(x, padding) {
7706
      if (arguments.length < 2) padding = 0;
7707
      var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2, 
7708
      0) : (stop - start) / (domain.length - 1 + padding);
7709
      range = steps(start + step * padding / 2, step);
7710
      rangeBand = 0;
7711
      ranger = {
7712
        t: "rangePoints",
7713
        a: arguments
7714
      };
7715
      return scale;
7716
    };
7717
    scale.rangeRoundPoints = function(x, padding) {
7718
      if (arguments.length < 2) padding = 0;
7719
      var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2), 
7720
      0) : (stop - start) / (domain.length - 1 + padding) | 0;
7721
      range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step);
7722
      rangeBand = 0;
7723
      ranger = {
7724
        t: "rangeRoundPoints",
7725
        a: arguments
7726
      };
7727
      return scale;
7728
    };
7729
    scale.rangeBands = function(x, padding, outerPadding) {
7730
      if (arguments.length < 2) padding = 0;
7731
      if (arguments.length < 3) outerPadding = padding;
7732
      var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding);
7733
      range = steps(start + step * outerPadding, step);
7734
      if (reverse) range.reverse();
7735
      rangeBand = step * (1 - padding);
7736
      ranger = {
7737
        t: "rangeBands",
7738
        a: arguments
7739
      };
7740
      return scale;
7741
    };
7742
    scale.rangeRoundBands = function(x, padding, outerPadding) {
7743
      if (arguments.length < 2) padding = 0;
7744
      if (arguments.length < 3) outerPadding = padding;
7745
      var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding));
7746
      range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step);
7747
      if (reverse) range.reverse();
7748
      rangeBand = Math.round(step * (1 - padding));
7749
      ranger = {
7750
        t: "rangeRoundBands",
7751
        a: arguments
7752
      };
7753
      return scale;
7754
    };
7755
    scale.rangeBand = function() {
7756
      return rangeBand;
7757
    };
7758
    scale.rangeExtent = function() {
7759
      return d3_scaleExtent(ranger.a[0]);
7760
    };
7761
    scale.copy = function() {
7762
      return d3_scale_ordinal(domain, ranger);
7763
    };
7764
    return scale.domain(domain);
7765
  }
7766
  d3.scale.category10 = function() {
7767
    return d3.scale.ordinal().range(d3_category10);
7768
  };
7769
  d3.scale.category20 = function() {
7770
    return d3.scale.ordinal().range(d3_category20);
7771
  };
7772
  d3.scale.category20b = function() {
7773
    return d3.scale.ordinal().range(d3_category20b);
7774
  };
7775
  d3.scale.category20c = function() {
7776
    return d3.scale.ordinal().range(d3_category20c);
7777
  };
7778
  var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString);
7779
  var d3_category20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbString);
7780
  var d3_category20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbString);
7781
  var d3_category20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbString);
7782
  d3.scale.quantile = function() {
7783
    return d3_scale_quantile([], []);
7784
  };
7785
  function d3_scale_quantile(domain, range) {
7786
    var thresholds;
7787
    function rescale() {
7788
      var k = 0, q = range.length;
7789
      thresholds = [];
7790
      while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);
7791
      return scale;
7792
    }
7793
    function scale(x) {
7794
      if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)];
7795
    }
7796
    scale.domain = function(x) {
7797
      if (!arguments.length) return domain;
7798
      domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending);
7799
      return rescale();
7800
    };
7801
    scale.range = function(x) {
7802
      if (!arguments.length) return range;
7803
      range = x;
7804
      return rescale();
7805
    };
7806
    scale.quantiles = function() {
7807
      return thresholds;
7808
    };
7809
    scale.invertExtent = function(y) {
7810
      y = range.indexOf(y);
7811
      return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ];
7812
    };
7813
    scale.copy = function() {
7814
      return d3_scale_quantile(domain, range);
7815
    };
7816
    return rescale();
7817
  }
7818
  d3.scale.quantize = function() {
7819
    return d3_scale_quantize(0, 1, [ 0, 1 ]);
7820
  };
7821
  function d3_scale_quantize(x0, x1, range) {
7822
    var kx, i;
7823
    function scale(x) {
7824
      return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];
7825
    }
7826
    function rescale() {
7827
      kx = range.length / (x1 - x0);
7828
      i = range.length - 1;
7829
      return scale;
7830
    }
7831
    scale.domain = function(x) {
7832
      if (!arguments.length) return [ x0, x1 ];
7833
      x0 = +x[0];
7834
      x1 = +x[x.length - 1];
7835
      return rescale();
7836
    };
7837
    scale.range = function(x) {
7838
      if (!arguments.length) return range;
7839
      range = x;
7840
      return rescale();
7841
    };
7842
    scale.invertExtent = function(y) {
7843
      y = range.indexOf(y);
7844
      y = y < 0 ? NaN : y / kx + x0;
7845
      return [ y, y + 1 / kx ];
7846
    };
7847
    scale.copy = function() {
7848
      return d3_scale_quantize(x0, x1, range);
7849
    };
7850
    return rescale();
7851
  }
7852
  d3.scale.threshold = function() {
7853
    return d3_scale_threshold([ .5 ], [ 0, 1 ]);
7854
  };
7855
  function d3_scale_threshold(domain, range) {
7856
    function scale(x) {
7857
      if (x <= x) return range[d3.bisect(domain, x)];
7858
    }
7859
    scale.domain = function(_) {
7860
      if (!arguments.length) return domain;
7861
      domain = _;
7862
      return scale;
7863
    };
7864
    scale.range = function(_) {
7865
      if (!arguments.length) return range;
7866
      range = _;
7867
      return scale;
7868
    };
7869
    scale.invertExtent = function(y) {
7870
      y = range.indexOf(y);
7871
      return [ domain[y - 1], domain[y] ];
7872
    };
7873
    scale.copy = function() {
7874
      return d3_scale_threshold(domain, range);
7875
    };
7876
    return scale;
7877
  }
7878
  d3.scale.identity = function() {
7879
    return d3_scale_identity([ 0, 1 ]);
7880
  };
7881
  function d3_scale_identity(domain) {
7882
    function identity(x) {
7883
      return +x;
7884
    }
7885
    identity.invert = identity;
7886
    identity.domain = identity.range = function(x) {
7887
      if (!arguments.length) return domain;
7888
      domain = x.map(identity);
7889
      return identity;
7890
    };
7891
    identity.ticks = function(m) {
7892
      return d3_scale_linearTicks(domain, m);
7893
    };
7894
    identity.tickFormat = function(m, format) {
7895
      return d3_scale_linearTickFormat(domain, m, format);
7896
    };
7897
    identity.copy = function() {
7898
      return d3_scale_identity(domain);
7899
    };
7900
    return identity;
7901
  }
7902
  d3.svg = {};
7903
  function d3_zero() {
7904
    return 0;
7905
  }
7906
  d3.svg.arc = function() {
7907
    var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, cornerRadius = d3_zero, padRadius = d3_svg_arcAuto, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle, padAngle = d3_svg_arcPadAngle;
7908
    function arc() {
7909
      var r0 = Math.max(0, +innerRadius.apply(this, arguments)), r1 = Math.max(0, +outerRadius.apply(this, arguments)), a0 = startAngle.apply(this, arguments) - halfπ, a1 = endAngle.apply(this, arguments) - halfπ, da = Math.abs(a1 - a0), cw = a0 > a1 ? 0 : 1;
7910
      if (r1 < r0) rc = r1, r1 = r0, r0 = rc;
7911
      if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : "") + "Z";
7912
      var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = [];
7913
      if (ap = (+padAngle.apply(this, arguments) || 0) / 2) {
7914
        rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments);
7915
        if (!cw) p1 *= -1;
7916
        if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap));
7917
        if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap));
7918
      }
7919
      if (r1) {
7920
        x0 = r1 * Math.cos(a0 + p1);
7921
        y0 = r1 * Math.sin(a0 + p1);
7922
        x1 = r1 * Math.cos(a1 - p1);
7923
        y1 = r1 * Math.sin(a1 - p1);
7924
        var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1;
7925
        if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) {
7926
          var h1 = (a0 + a1) / 2;
7927
          x0 = r1 * Math.cos(h1);
7928
          y0 = r1 * Math.sin(h1);
7929
          x1 = y1 = null;
7930
        }
7931
      } else {
7932
        x0 = y0 = 0;
7933
      }
7934
      if (r0) {
7935
        x2 = r0 * Math.cos(a1 - p0);
7936
        y2 = r0 * Math.sin(a1 - p0);
7937
        x3 = r0 * Math.cos(a0 + p0);
7938
        y3 = r0 * Math.sin(a0 + p0);
7939
        var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1;
7940
        if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) {
7941
          var h0 = (a0 + a1) / 2;
7942
          x2 = r0 * Math.cos(h0);
7943
          y2 = r0 * Math.sin(h0);
7944
          x3 = y3 = null;
7945
        }
7946
      } else {
7947
        x2 = y2 = 0;
7948
      }
7949
      if ((rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) {
7950
        cr = r0 < r1 ^ cw ? 0 : 1;
7951
        var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
7952
        if (x1 != null) {
7953
          var rc1 = Math.min(rc, (r1 - lc) / (kc + 1)), t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw);
7954
          if (rc === rc1) {
7955
            path.push("M", t30[0], "A", rc1, ",", rc1, " 0 0,", cr, " ", t30[1], "A", r1, ",", r1, " 0 ", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), ",", cw, " ", t12[1], "A", rc1, ",", rc1, " 0 0,", cr, " ", t12[0]);
7956
          } else {
7957
            path.push("M", t30[0], "A", rc1, ",", rc1, " 0 1,", cr, " ", t12[0]);
7958
          }
7959
        } else {
7960
          path.push("M", x0, ",", y0);
7961
        }
7962
        if (x3 != null) {
7963
          var rc0 = Math.min(rc, (r0 - lc) / (kc - 1)), t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw);
7964
          if (rc === rc0) {
7965
            path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t21[1], "A", r0, ",", r0, " 0 ", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), ",", 1 - cw, " ", t03[1], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]);
7966
          } else {
7967
            path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]);
7968
          }
7969
        } else {
7970
          path.push("L", x2, ",", y2);
7971
        }
7972
      } else {
7973
        path.push("M", x0, ",", y0);
7974
        if (x1 != null) path.push("A", r1, ",", r1, " 0 ", l1, ",", cw, " ", x1, ",", y1);
7975
        path.push("L", x2, ",", y2);
7976
        if (x3 != null) path.push("A", r0, ",", r0, " 0 ", l0, ",", 1 - cw, " ", x3, ",", y3);
7977
      }
7978
      path.push("Z");
7979
      return path.join("");
7980
    }
7981
    function circleSegment(r1, cw) {
7982
      return "M0," + r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + -r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + r1;
7983
    }
7984
    arc.innerRadius = function(v) {
7985
      if (!arguments.length) return innerRadius;
7986
      innerRadius = d3_functor(v);
7987
      return arc;
7988
    };
7989
    arc.outerRadius = function(v) {
7990
      if (!arguments.length) return outerRadius;
7991
      outerRadius = d3_functor(v);
7992
      return arc;
7993
    };
7994
    arc.cornerRadius = function(v) {
7995
      if (!arguments.length) return cornerRadius;
7996
      cornerRadius = d3_functor(v);
7997
      return arc;
7998
    };
7999
    arc.padRadius = function(v) {
8000
      if (!arguments.length) return padRadius;
8001
      padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v);
8002
      return arc;
8003
    };
8004
    arc.startAngle = function(v) {
8005
      if (!arguments.length) return startAngle;
8006
      startAngle = d3_functor(v);
8007
      return arc;
8008
    };
8009
    arc.endAngle = function(v) {
8010
      if (!arguments.length) return endAngle;
8011
      endAngle = d3_functor(v);
8012
      return arc;
8013
    };
8014
    arc.padAngle = function(v) {
8015
      if (!arguments.length) return padAngle;
8016
      padAngle = d3_functor(v);
8017
      return arc;
8018
    };
8019
    arc.centroid = function() {
8020
      var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - halfπ;
8021
      return [ Math.cos(a) * r, Math.sin(a) * r ];
8022
    };
8023
    return arc;
8024
  };
8025
  var d3_svg_arcAuto = "auto";
8026
  function d3_svg_arcInnerRadius(d) {
8027
    return d.innerRadius;
8028
  }
8029
  function d3_svg_arcOuterRadius(d) {
8030
    return d.outerRadius;
8031
  }
8032
  function d3_svg_arcStartAngle(d) {
8033
    return d.startAngle;
8034
  }
8035
  function d3_svg_arcEndAngle(d) {
8036
    return d.endAngle;
8037
  }
8038
  function d3_svg_arcPadAngle(d) {
8039
    return d && d.padAngle;
8040
  }
8041
  function d3_svg_arcSweep(x0, y0, x1, y1) {
8042
    return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1;
8043
  }
8044
  function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) {
8045
    var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(r * r * d2 - D * D), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3;
8046
    if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
8047
    return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ];
8048
  }
8049
  function d3_svg_line(projection) {
8050
    var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;
8051
    function line(data) {
8052
      var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y);
8053
      function segment() {
8054
        segments.push("M", interpolate(projection(points), tension));
8055
      }
8056
      while (++i < n) {
8057
        if (defined.call(this, d = data[i], i)) {
8058
          points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]);
8059
        } else if (points.length) {
8060
          segment();
8061
          points = [];
8062
        }
8063
      }
8064
      if (points.length) segment();
8065
      return segments.length ? segments.join("") : null;
8066
    }
8067
    line.x = function(_) {
8068
      if (!arguments.length) return x;
8069
      x = _;
8070
      return line;
8071
    };
8072
    line.y = function(_) {
8073
      if (!arguments.length) return y;
8074
      y = _;
8075
      return line;
8076
    };
8077
    line.defined = function(_) {
8078
      if (!arguments.length) return defined;
8079
      defined = _;
8080
      return line;
8081
    };
8082
    line.interpolate = function(_) {
8083
      if (!arguments.length) return interpolateKey;
8084
      if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
8085
      return line;
8086
    };
8087
    line.tension = function(_) {
8088
      if (!arguments.length) return tension;
8089
      tension = _;
8090
      return line;
8091
    };
8092
    return line;
8093
  }
8094
  d3.svg.line = function() {
8095
    return d3_svg_line(d3_identity);
8096
  };
8097
  var d3_svg_lineInterpolators = d3.map({
8098
    linear: d3_svg_lineLinear,
8099
    "linear-closed": d3_svg_lineLinearClosed,
8100
    step: d3_svg_lineStep,
8101
    "step-before": d3_svg_lineStepBefore,
8102
    "step-after": d3_svg_lineStepAfter,
8103
    basis: d3_svg_lineBasis,
8104
    "basis-open": d3_svg_lineBasisOpen,
8105
    "basis-closed": d3_svg_lineBasisClosed,
8106
    bundle: d3_svg_lineBundle,
8107
    cardinal: d3_svg_lineCardinal,
8108
    "cardinal-open": d3_svg_lineCardinalOpen,
8109
    "cardinal-closed": d3_svg_lineCardinalClosed,
8110
    monotone: d3_svg_lineMonotone
8111
  });
8112
  d3_svg_lineInterpolators.forEach(function(key, value) {
8113
    value.key = key;
8114
    value.closed = /-closed$/.test(key);
8115
  });
8116
  function d3_svg_lineLinear(points) {
8117
    return points.join("L");
8118
  }
8119
  function d3_svg_lineLinearClosed(points) {
8120
    return d3_svg_lineLinear(points) + "Z";
8121
  }
8122
  function d3_svg_lineStep(points) {
8123
    var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
8124
    while (++i < n) path.push("H", (p[0] + (p = points[i])[0]) / 2, "V", p[1]);
8125
    if (n > 1) path.push("H", p[0]);
8126
    return path.join("");
8127
  }
8128
  function d3_svg_lineStepBefore(points) {
8129
    var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
8130
    while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]);
8131
    return path.join("");
8132
  }
8133
  function d3_svg_lineStepAfter(points) {
8134
    var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
8135
    while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]);
8136
    return path.join("");
8137
  }
8138
  function d3_svg_lineCardinalOpen(points, tension) {
8139
    return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));
8140
  }
8141
  function d3_svg_lineCardinalClosed(points, tension) {
8142
    return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), 
8143
    points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));
8144
  }
8145
  function d3_svg_lineCardinal(points, tension) {
8146
    return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension));
8147
  }
8148
  function d3_svg_lineHermite(points, tangents) {
8149
    if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) {
8150
      return d3_svg_lineLinear(points);
8151
    }
8152
    var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1;
8153
    if (quad) {
8154
      path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1];
8155
      p0 = points[1];
8156
      pi = 2;
8157
    }
8158
    if (tangents.length > 1) {
8159
      t = tangents[1];
8160
      p = points[pi];
8161
      pi++;
8162
      path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
8163
      for (var i = 2; i < tangents.length; i++, pi++) {
8164
        p = points[pi];
8165
        t = tangents[i];
8166
        path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
8167
      }
8168
    }
8169
    if (quad) {
8170
      var lp = points[pi];
8171
      path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1];
8172
    }
8173
    return path;
8174
  }
8175
  function d3_svg_lineCardinalTangents(points, tension) {
8176
    var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length;
8177
    while (++i < n) {
8178
      p0 = p1;
8179
      p1 = p2;
8180
      p2 = points[i];
8181
      tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]);
8182
    }
8183
    return tangents;
8184
  }
8185
  function d3_svg_lineBasis(points) {
8186
    if (points.length < 3) return d3_svg_lineLinear(points);
8187
    var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, ",", y0, "L", d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];
8188
    points.push(points[n - 1]);
8189
    while (++i <= n) {
8190
      pi = points[i];
8191
      px.shift();
8192
      px.push(pi[0]);
8193
      py.shift();
8194
      py.push(pi[1]);
8195
      d3_svg_lineBasisBezier(path, px, py);
8196
    }
8197
    points.pop();
8198
    path.push("L", pi);
8199
    return path.join("");
8200
  }
8201
  function d3_svg_lineBasisOpen(points) {
8202
    if (points.length < 4) return d3_svg_lineLinear(points);
8203
    var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ];
8204
    while (++i < 3) {
8205
      pi = points[i];
8206
      px.push(pi[0]);
8207
      py.push(pi[1]);
8208
    }
8209
    path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));
8210
    --i;
8211
    while (++i < n) {
8212
      pi = points[i];
8213
      px.shift();
8214
      px.push(pi[0]);
8215
      py.shift();
8216
      py.push(pi[1]);
8217
      d3_svg_lineBasisBezier(path, px, py);
8218
    }
8219
    return path.join("");
8220
  }
8221
  function d3_svg_lineBasisClosed(points) {
8222
    var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = [];
8223
    while (++i < 4) {
8224
      pi = points[i % n];
8225
      px.push(pi[0]);
8226
      py.push(pi[1]);
8227
    }
8228
    path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];
8229
    --i;
8230
    while (++i < m) {
8231
      pi = points[i % n];
8232
      px.shift();
8233
      px.push(pi[0]);
8234
      py.shift();
8235
      py.push(pi[1]);
8236
      d3_svg_lineBasisBezier(path, px, py);
8237
    }
8238
    return path.join("");
8239
  }
8240
  function d3_svg_lineBundle(points, tension) {
8241
    var n = points.length - 1;
8242
    if (n) {
8243
      var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t;
8244
      while (++i <= n) {
8245
        p = points[i];
8246
        t = i / n;
8247
        p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
8248
        p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
8249
      }
8250
    }
8251
    return d3_svg_lineBasis(points);
8252
  }
8253
  function d3_svg_lineDot4(a, b) {
8254
    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
8255
  }
8256
  var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ];
8257
  function d3_svg_lineBasisBezier(path, x, y) {
8258
    path.push("C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y));
8259
  }
8260
  function d3_svg_lineSlope(p0, p1) {
8261
    return (p1[1] - p0[1]) / (p1[0] - p0[0]);
8262
  }
8263
  function d3_svg_lineFiniteDifferences(points) {
8264
    var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1);
8265
    while (++i < j) {
8266
      m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2;
8267
    }
8268
    m[i] = d;
8269
    return m;
8270
  }
8271
  function d3_svg_lineMonotoneTangents(points) {
8272
    var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1;
8273
    while (++i < j) {
8274
      d = d3_svg_lineSlope(points[i], points[i + 1]);
8275
      if (abs(d) < ε) {
8276
        m[i] = m[i + 1] = 0;
8277
      } else {
8278
        a = m[i] / d;
8279
        b = m[i + 1] / d;
8280
        s = a * a + b * b;
8281
        if (s > 9) {
8282
          s = d * 3 / Math.sqrt(s);
8283
          m[i] = s * a;
8284
          m[i + 1] = s * b;
8285
        }
8286
      }
8287
    }
8288
    i = -1;
8289
    while (++i <= j) {
8290
      s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));
8291
      tangents.push([ s || 0, m[i] * s || 0 ]);
8292
    }
8293
    return tangents;
8294
  }
8295
  function d3_svg_lineMonotone(points) {
8296
    return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));
8297
  }
8298
  d3.svg.line.radial = function() {
8299
    var line = d3_svg_line(d3_svg_lineRadial);
8300
    line.radius = line.x, delete line.x;
8301
    line.angle = line.y, delete line.y;
8302
    return line;
8303
  };
8304
  function d3_svg_lineRadial(points) {
8305
    var point, i = -1, n = points.length, r, a;
8306
    while (++i < n) {
8307
      point = points[i];
8308
      r = point[0];
8309
      a = point[1] - halfπ;
8310
      point[0] = r * Math.cos(a);
8311
      point[1] = r * Math.sin(a);
8312
    }
8313
    return points;
8314
  }
8315
  function d3_svg_area(projection) {
8316
    var x0 = d3_geom_pointX, x1 = d3_geom_pointX, y0 = 0, y1 = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7;
8317
    function area(data) {
8318
      var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() {
8319
        return x;
8320
      } : d3_functor(x1), fy1 = y0 === y1 ? function() {
8321
        return y;
8322
      } : d3_functor(y1), x, y;
8323
      function segment() {
8324
        segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z");
8325
      }
8326
      while (++i < n) {
8327
        if (defined.call(this, d = data[i], i)) {
8328
          points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]);
8329
          points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]);
8330
        } else if (points0.length) {
8331
          segment();
8332
          points0 = [];
8333
          points1 = [];
8334
        }
8335
      }
8336
      if (points0.length) segment();
8337
      return segments.length ? segments.join("") : null;
8338
    }
8339
    area.x = function(_) {
8340
      if (!arguments.length) return x1;
8341
      x0 = x1 = _;
8342
      return area;
8343
    };
8344
    area.x0 = function(_) {
8345
      if (!arguments.length) return x0;
8346
      x0 = _;
8347
      return area;
8348
    };
8349
    area.x1 = function(_) {
8350
      if (!arguments.length) return x1;
8351
      x1 = _;
8352
      return area;
8353
    };
8354
    area.y = function(_) {
8355
      if (!arguments.length) return y1;
8356
      y0 = y1 = _;
8357
      return area;
8358
    };
8359
    area.y0 = function(_) {
8360
      if (!arguments.length) return y0;
8361
      y0 = _;
8362
      return area;
8363
    };
8364
    area.y1 = function(_) {
8365
      if (!arguments.length) return y1;
8366
      y1 = _;
8367
      return area;
8368
    };
8369
    area.defined = function(_) {
8370
      if (!arguments.length) return defined;
8371
      defined = _;
8372
      return area;
8373
    };
8374
    area.interpolate = function(_) {
8375
      if (!arguments.length) return interpolateKey;
8376
      if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
8377
      interpolateReverse = interpolate.reverse || interpolate;
8378
      L = interpolate.closed ? "M" : "L";
8379
      return area;
8380
    };
8381
    area.tension = function(_) {
8382
      if (!arguments.length) return tension;
8383
      tension = _;
8384
      return area;
8385
    };
8386
    return area;
8387
  }
8388
  d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;
8389
  d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;
8390
  d3.svg.area = function() {
8391
    return d3_svg_area(d3_identity);
8392
  };
8393
  d3.svg.area.radial = function() {
8394
    var area = d3_svg_area(d3_svg_lineRadial);
8395
    area.radius = area.x, delete area.x;
8396
    area.innerRadius = area.x0, delete area.x0;
8397
    area.outerRadius = area.x1, delete area.x1;
8398
    area.angle = area.y, delete area.y;
8399
    area.startAngle = area.y0, delete area.y0;
8400
    area.endAngle = area.y1, delete area.y1;
8401
    return area;
8402
  };
8403
  d3.svg.chord = function() {
8404
    var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;
8405
    function chord(d, i) {
8406
      var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i);
8407
      return "M" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + "Z";
8408
    }
8409
    function subgroup(self, f, d, i) {
8410
      var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) - halfπ, a1 = endAngle.call(self, subgroup, i) - halfπ;
8411
      return {
8412
        r: r,
8413
        a0: a0,
8414
        a1: a1,
8415
        p0: [ r * Math.cos(a0), r * Math.sin(a0) ],
8416
        p1: [ r * Math.cos(a1), r * Math.sin(a1) ]
8417
      };
8418
    }
8419
    function equals(a, b) {
8420
      return a.a0 == b.a0 && a.a1 == b.a1;
8421
    }
8422
    function arc(r, p, a) {
8423
      return "A" + r + "," + r + " 0 " + +(a > π) + ",1 " + p;
8424
    }
8425
    function curve(r0, p0, r1, p1) {
8426
      return "Q 0,0 " + p1;
8427
    }
8428
    chord.radius = function(v) {
8429
      if (!arguments.length) return radius;
8430
      radius = d3_functor(v);
8431
      return chord;
8432
    };
8433
    chord.source = function(v) {
8434
      if (!arguments.length) return source;
8435
      source = d3_functor(v);
8436
      return chord;
8437
    };
8438
    chord.target = function(v) {
8439
      if (!arguments.length) return target;
8440
      target = d3_functor(v);
8441
      return chord;
8442
    };
8443
    chord.startAngle = function(v) {
8444
      if (!arguments.length) return startAngle;
8445
      startAngle = d3_functor(v);
8446
      return chord;
8447
    };
8448
    chord.endAngle = function(v) {
8449
      if (!arguments.length) return endAngle;
8450
      endAngle = d3_functor(v);
8451
      return chord;
8452
    };
8453
    return chord;
8454
  };
8455
  function d3_svg_chordRadius(d) {
8456
    return d.radius;
8457
  }
8458
  d3.svg.diagonal = function() {
8459
    var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection;
8460
    function diagonal(d, i) {
8461
      var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, {
8462
        x: p0.x,
8463
        y: m
8464
      }, {
8465
        x: p3.x,
8466
        y: m
8467
      }, p3 ];
8468
      p = p.map(projection);
8469
      return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3];
8470
    }
8471
    diagonal.source = function(x) {
8472
      if (!arguments.length) return source;
8473
      source = d3_functor(x);
8474
      return diagonal;
8475
    };
8476
    diagonal.target = function(x) {
8477
      if (!arguments.length) return target;
8478
      target = d3_functor(x);
8479
      return diagonal;
8480
    };
8481
    diagonal.projection = function(x) {
8482
      if (!arguments.length) return projection;
8483
      projection = x;
8484
      return diagonal;
8485
    };
8486
    return diagonal;
8487
  };
8488
  function d3_svg_diagonalProjection(d) {
8489
    return [ d.x, d.y ];
8490
  }
8491
  d3.svg.diagonal.radial = function() {
8492
    var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection;
8493
    diagonal.projection = function(x) {
8494
      return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection;
8495
    };
8496
    return diagonal;
8497
  };
8498
  function d3_svg_diagonalRadialProjection(projection) {
8499
    return function() {
8500
      var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ;
8501
      return [ r * Math.cos(a), r * Math.sin(a) ];
8502
    };
8503
  }
8504
  d3.svg.symbol = function() {
8505
    var type = d3_svg_symbolType, size = d3_svg_symbolSize;
8506
    function symbol(d, i) {
8507
      return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i));
8508
    }
8509
    symbol.type = function(x) {
8510
      if (!arguments.length) return type;
8511
      type = d3_functor(x);
8512
      return symbol;
8513
    };
8514
    symbol.size = function(x) {
8515
      if (!arguments.length) return size;
8516
      size = d3_functor(x);
8517
      return symbol;
8518
    };
8519
    return symbol;
8520
  };
8521
  function d3_svg_symbolSize() {
8522
    return 64;
8523
  }
8524
  function d3_svg_symbolType() {
8525
    return "circle";
8526
  }
8527
  function d3_svg_symbolCircle(size) {
8528
    var r = Math.sqrt(size / π);
8529
    return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z";
8530
  }
8531
  var d3_svg_symbols = d3.map({
8532
    circle: d3_svg_symbolCircle,
8533
    cross: function(size) {
8534
      var r = Math.sqrt(size / 5) / 2;
8535
      return "M" + -3 * r + "," + -r + "H" + -r + "V" + -3 * r + "H" + r + "V" + -r + "H" + 3 * r + "V" + r + "H" + r + "V" + 3 * r + "H" + -r + "V" + r + "H" + -3 * r + "Z";
8536
    },
8537
    diamond: function(size) {
8538
      var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30;
8539
      return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z";
8540
    },
8541
    square: function(size) {
8542
      var r = Math.sqrt(size) / 2;
8543
      return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z";
8544
    },
8545
    "triangle-down": function(size) {
8546
      var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;
8547
      return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z";
8548
    },
8549
    "triangle-up": function(size) {
8550
      var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;
8551
      return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z";
8552
    }
8553
  });
8554
  d3.svg.symbolTypes = d3_svg_symbols.keys();
8555
  var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);
8556
  function d3_transition(groups, namespace, id) {
8557
    d3_subclass(groups, d3_transitionPrototype);
8558
    groups.namespace = namespace;
8559
    groups.id = id;
8560
    return groups;
8561
  }
8562
  var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit;
8563
  d3_transitionPrototype.call = d3_selectionPrototype.call;
8564
  d3_transitionPrototype.empty = d3_selectionPrototype.empty;
8565
  d3_transitionPrototype.node = d3_selectionPrototype.node;
8566
  d3_transitionPrototype.size = d3_selectionPrototype.size;
8567
  d3.transition = function(selection) {
8568
    return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition();
8569
  };
8570
  d3.transition.prototype = d3_transitionPrototype;
8571
  d3_transitionPrototype.select = function(selector) {
8572
    var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node;
8573
    selector = d3_selection_selector(selector);
8574
    for (var j = -1, m = this.length; ++j < m; ) {
8575
      subgroups.push(subgroup = []);
8576
      for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8577
        if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) {
8578
          if ("__data__" in node) subnode.__data__ = node.__data__;
8579
          d3_transitionNode(subnode, i, ns, id, node[ns][id]);
8580
          subgroup.push(subnode);
8581
        } else {
8582
          subgroup.push(null);
8583
        }
8584
      }
8585
    }
8586
    return d3_transition(subgroups, ns, id);
8587
  };
8588
  d3_transitionPrototype.selectAll = function(selector) {
8589
    var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition;
8590
    selector = d3_selection_selectorAll(selector);
8591
    for (var j = -1, m = this.length; ++j < m; ) {
8592
      for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8593
        if (node = group[i]) {
8594
          transition = node[ns][id];
8595
          subnodes = selector.call(node, node.__data__, i, j);
8596
          subgroups.push(subgroup = []);
8597
          for (var k = -1, o = subnodes.length; ++k < o; ) {
8598
            if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition);
8599
            subgroup.push(subnode);
8600
          }
8601
        }
8602
      }
8603
    }
8604
    return d3_transition(subgroups, ns, id);
8605
  };
8606
  d3_transitionPrototype.filter = function(filter) {
8607
    var subgroups = [], subgroup, group, node;
8608
    if (typeof filter !== "function") filter = d3_selection_filter(filter);
8609
    for (var j = 0, m = this.length; j < m; j++) {
8610
      subgroups.push(subgroup = []);
8611
      for (var group = this[j], i = 0, n = group.length; i < n; i++) {
8612
        if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {
8613
          subgroup.push(node);
8614
        }
8615
      }
8616
    }
8617
    return d3_transition(subgroups, this.namespace, this.id);
8618
  };
8619
  d3_transitionPrototype.tween = function(name, tween) {
8620
    var id = this.id, ns = this.namespace;
8621
    if (arguments.length < 2) return this.node()[ns][id].tween.get(name);
8622
    return d3_selection_each(this, tween == null ? function(node) {
8623
      node[ns][id].tween.remove(name);
8624
    } : function(node) {
8625
      node[ns][id].tween.set(name, tween);
8626
    });
8627
  };
8628
  function d3_transition_tween(groups, name, value, tween) {
8629
    var id = groups.id, ns = groups.namespace;
8630
    return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) {
8631
      node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j)));
8632
    } : (value = tween(value), function(node) {
8633
      node[ns][id].tween.set(name, value);
8634
    }));
8635
  }
8636
  d3_transitionPrototype.attr = function(nameNS, value) {
8637
    if (arguments.length < 2) {
8638
      for (value in nameNS) this.attr(value, nameNS[value]);
8639
      return this;
8640
    }
8641
    var interpolate = nameNS == "transform" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS);
8642
    function attrNull() {
8643
      this.removeAttribute(name);
8644
    }
8645
    function attrNullNS() {
8646
      this.removeAttributeNS(name.space, name.local);
8647
    }
8648
    function attrTween(b) {
8649
      return b == null ? attrNull : (b += "", function() {
8650
        var a = this.getAttribute(name), i;
8651
        return a !== b && (i = interpolate(a, b), function(t) {
8652
          this.setAttribute(name, i(t));
8653
        });
8654
      });
8655
    }
8656
    function attrTweenNS(b) {
8657
      return b == null ? attrNullNS : (b += "", function() {
8658
        var a = this.getAttributeNS(name.space, name.local), i;
8659
        return a !== b && (i = interpolate(a, b), function(t) {
8660
          this.setAttributeNS(name.space, name.local, i(t));
8661
        });
8662
      });
8663
    }
8664
    return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween);
8665
  };
8666
  d3_transitionPrototype.attrTween = function(nameNS, tween) {
8667
    var name = d3.ns.qualify(nameNS);
8668
    function attrTween(d, i) {
8669
      var f = tween.call(this, d, i, this.getAttribute(name));
8670
      return f && function(t) {
8671
        this.setAttribute(name, f(t));
8672
      };
8673
    }
8674
    function attrTweenNS(d, i) {
8675
      var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));
8676
      return f && function(t) {
8677
        this.setAttributeNS(name.space, name.local, f(t));
8678
      };
8679
    }
8680
    return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween);
8681
  };
8682
  d3_transitionPrototype.style = function(name, value, priority) {
8683
    var n = arguments.length;
8684
    if (n < 3) {
8685
      if (typeof name !== "string") {
8686
        if (n < 2) value = "";
8687
        for (priority in name) this.style(priority, name[priority], value);
8688
        return this;
8689
      }
8690
      priority = "";
8691
    }
8692
    function styleNull() {
8693
      this.style.removeProperty(name);
8694
    }
8695
    function styleString(b) {
8696
      return b == null ? styleNull : (b += "", function() {
8697
        var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i;
8698
        return a !== b && (i = d3_interpolate(a, b), function(t) {
8699
          this.style.setProperty(name, i(t), priority);
8700
        });
8701
      });
8702
    }
8703
    return d3_transition_tween(this, "style." + name, value, styleString);
8704
  };
8705
  d3_transitionPrototype.styleTween = function(name, tween, priority) {
8706
    if (arguments.length < 3) priority = "";
8707
    function styleTween(d, i) {
8708
      var f = tween.call(this, d, i, d3_window.getComputedStyle(this, null).getPropertyValue(name));
8709
      return f && function(t) {
8710
        this.style.setProperty(name, f(t), priority);
8711
      };
8712
    }
8713
    return this.tween("style." + name, styleTween);
8714
  };
8715
  d3_transitionPrototype.text = function(value) {
8716
    return d3_transition_tween(this, "text", value, d3_transition_text);
8717
  };
8718
  function d3_transition_text(b) {
8719
    if (b == null) b = "";
8720
    return function() {
8721
      this.textContent = b;
8722
    };
8723
  }
8724
  d3_transitionPrototype.remove = function() {
8725
    var ns = this.namespace;
8726
    return this.each("end.transition", function() {
8727
      var p;
8728
      if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this);
8729
    });
8730
  };
8731
  d3_transitionPrototype.ease = function(value) {
8732
    var id = this.id, ns = this.namespace;
8733
    if (arguments.length < 1) return this.node()[ns][id].ease;
8734
    if (typeof value !== "function") value = d3.ease.apply(d3, arguments);
8735
    return d3_selection_each(this, function(node) {
8736
      node[ns][id].ease = value;
8737
    });
8738
  };
8739
  d3_transitionPrototype.delay = function(value) {
8740
    var id = this.id, ns = this.namespace;
8741
    if (arguments.length < 1) return this.node()[ns][id].delay;
8742
    return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8743
      node[ns][id].delay = +value.call(node, node.__data__, i, j);
8744
    } : (value = +value, function(node) {
8745
      node[ns][id].delay = value;
8746
    }));
8747
  };
8748
  d3_transitionPrototype.duration = function(value) {
8749
    var id = this.id, ns = this.namespace;
8750
    if (arguments.length < 1) return this.node()[ns][id].duration;
8751
    return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8752
      node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j));
8753
    } : (value = Math.max(1, value), function(node) {
8754
      node[ns][id].duration = value;
8755
    }));
8756
  };
8757
  d3_transitionPrototype.each = function(type, listener) {
8758
    var id = this.id, ns = this.namespace;
8759
    if (arguments.length < 2) {
8760
      var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;
8761
      d3_transitionInheritId = id;
8762
      d3_selection_each(this, function(node, i, j) {
8763
        d3_transitionInherit = node[ns][id];
8764
        type.call(node, node.__data__, i, j);
8765
      });
8766
      d3_transitionInherit = inherit;
8767
      d3_transitionInheritId = inheritId;
8768
    } else {
8769
      d3_selection_each(this, function(node) {
8770
        var transition = node[ns][id];
8771
        (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener);
8772
      });
8773
    }
8774
    return this;
8775
  };
8776
  d3_transitionPrototype.transition = function() {
8777
    var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition;
8778
    for (var j = 0, m = this.length; j < m; j++) {
8779
      subgroups.push(subgroup = []);
8780
      for (var group = this[j], i = 0, n = group.length; i < n; i++) {
8781
        if (node = group[i]) {
8782
          transition = node[ns][id0];
8783
          d3_transitionNode(node, i, ns, id1, {
8784
            time: transition.time,
8785
            ease: transition.ease,
8786
            delay: transition.delay + transition.duration,
8787
            duration: transition.duration
8788
          });
8789
        }
8790
        subgroup.push(node);
8791
      }
8792
    }
8793
    return d3_transition(subgroups, ns, id1);
8794
  };
8795
  function d3_transitionNamespace(name) {
8796
    return name == null ? "__transition__" : "__transition_" + name + "__";
8797
  }
8798
  function d3_transitionNode(node, i, namespace, id, inherit) {
8799
    var lock = node[namespace] || (node[namespace] = {
8800
      active: 0,
8801
      count: 0
8802
    }), transition = lock[id];
8803
    if (!transition) {
8804
      var time = inherit.time;
8805
      transition = lock[id] = {
8806
        tween: new d3_Map(),
8807
        time: time,
8808
        delay: inherit.delay,
8809
        duration: inherit.duration,
8810
        ease: inherit.ease
8811
      };
8812
      inherit = null;
8813
      ++lock.count;
8814
      d3.timer(function(elapsed) {
8815
        var d = node.__data__, delay = transition.delay, duration, ease, timer = d3_timer_active, tweened = [];
8816
        timer.t = delay + time;
8817
        if (delay <= elapsed) return start(elapsed - delay);
8818
        timer.c = start;
8819
        function start(elapsed) {
8820
          if (lock.active > id) return stop(false);
8821
          lock.active = id;
8822
          transition.event && transition.event.start.call(node, d, i);
8823
          transition.tween.forEach(function(key, value) {
8824
            if (value = value.call(node, d, i)) {
8825
              tweened.push(value);
8826
            }
8827
          });
8828
          ease = transition.ease;
8829
          duration = transition.duration;
8830
          d3.timer(function() {
8831
            timer.c = tick(elapsed || 1) ? d3_true : tick;
8832
            return 1;
8833
          }, 0, time);
8834
        }
8835
        function tick(elapsed) {
8836
          if (lock.active !== id) return stop(false);
8837
          var t = elapsed / duration, e = ease(t), n = tweened.length;
8838
          while (n > 0) {
8839
            tweened[--n].call(node, e);
8840
          }
8841
          if (t >= 1) return stop(true);
8842
        }
8843
        function stop(end) {
8844
          if (transition.event) transition.event[end ? "end" : "interrupt"].call(node, d, i);
8845
          if (--lock.count) delete lock[id]; else delete node[namespace];
8846
          return 1;
8847
        }
8848
      }, 0, time);
8849
    }
8850
  }
8851
  d3.svg.axis = function() {
8852
    var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_;
8853
    function axis(g) {
8854
      g.each(function() {
8855
        var g = d3.select(this);
8856
        var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy();
8857
        var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform;
8858
        var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), 
8859
        d3.transition(path));
8860
        tickEnter.append("line");
8861
        tickEnter.append("text");
8862
        var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"), sign = orient === "top" || orient === "left" ? -1 : 1, x1, x2, y1, y2;
8863
        if (orient === "bottom" || orient === "top") {
8864
          tickTransform = d3_svg_axisX, x1 = "x", y1 = "y", x2 = "x2", y2 = "y2";
8865
          text.attr("dy", sign < 0 ? "0em" : ".71em").style("text-anchor", "middle");
8866
          pathUpdate.attr("d", "M" + range[0] + "," + sign * outerTickSize + "V0H" + range[1] + "V" + sign * outerTickSize);
8867
        } else {
8868
          tickTransform = d3_svg_axisY, x1 = "y", y1 = "x", x2 = "y2", y2 = "x2";
8869
          text.attr("dy", ".32em").style("text-anchor", sign < 0 ? "end" : "start");
8870
          pathUpdate.attr("d", "M" + sign * outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + sign * outerTickSize);
8871
        }
8872
        lineEnter.attr(y2, sign * innerTickSize);
8873
        textEnter.attr(y1, sign * tickSpacing);
8874
        lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize);
8875
        textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing);
8876
        if (scale1.rangeBand) {
8877
          var x = scale1, dx = x.rangeBand() / 2;
8878
          scale0 = scale1 = function(d) {
8879
            return x(d) + dx;
8880
          };
8881
        } else if (scale0.rangeBand) {
8882
          scale0 = scale1;
8883
        } else {
8884
          tickExit.call(tickTransform, scale1, scale0);
8885
        }
8886
        tickEnter.call(tickTransform, scale0, scale1);
8887
        tickUpdate.call(tickTransform, scale1, scale1);
8888
      });
8889
    }
8890
    axis.scale = function(x) {
8891
      if (!arguments.length) return scale;
8892
      scale = x;
8893
      return axis;
8894
    };
8895
    axis.orient = function(x) {
8896
      if (!arguments.length) return orient;
8897
      orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient;
8898
      return axis;
8899
    };
8900
    axis.ticks = function() {
8901
      if (!arguments.length) return tickArguments_;
8902
      tickArguments_ = arguments;
8903
      return axis;
8904
    };
8905
    axis.tickValues = function(x) {
8906
      if (!arguments.length) return tickValues;
8907
      tickValues = x;
8908
      return axis;
8909
    };
8910
    axis.tickFormat = function(x) {
8911
      if (!arguments.length) return tickFormat_;
8912
      tickFormat_ = x;
8913
      return axis;
8914
    };
8915
    axis.tickSize = function(x) {
8916
      var n = arguments.length;
8917
      if (!n) return innerTickSize;
8918
      innerTickSize = +x;
8919
      outerTickSize = +arguments[n - 1];
8920
      return axis;
8921
    };
8922
    axis.innerTickSize = function(x) {
8923
      if (!arguments.length) return innerTickSize;
8924
      innerTickSize = +x;
8925
      return axis;
8926
    };
8927
    axis.outerTickSize = function(x) {
8928
      if (!arguments.length) return outerTickSize;
8929
      outerTickSize = +x;
8930
      return axis;
8931
    };
8932
    axis.tickPadding = function(x) {
8933
      if (!arguments.length) return tickPadding;
8934
      tickPadding = +x;
8935
      return axis;
8936
    };
8937
    axis.tickSubdivide = function() {
8938
      return arguments.length && axis;
8939
    };
8940
    return axis;
8941
  };
8942
  var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = {
8943
    top: 1,
8944
    right: 1,
8945
    bottom: 1,
8946
    left: 1
8947
  };
8948
  function d3_svg_axisX(selection, x0, x1) {
8949
    selection.attr("transform", function(d) {
8950
      var v0 = x0(d);
8951
      return "translate(" + (isFinite(v0) ? v0 : x1(d)) + ",0)";
8952
    });
8953
  }
8954
  function d3_svg_axisY(selection, y0, y1) {
8955
    selection.attr("transform", function(d) {
8956
      var v0 = y0(d);
8957
      return "translate(0," + (isFinite(v0) ? v0 : y1(d)) + ")";
8958
    });
8959
  }
8960
  d3.svg.brush = function() {
8961
    var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0];
8962
    function brush(g) {
8963
      g.each(function() {
8964
        var g = d3.select(this).style("pointer-events", "all").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart);
8965
        var background = g.selectAll(".background").data([ 0 ]);
8966
        background.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair");
8967
        g.selectAll(".extent").data([ 0 ]).enter().append("rect").attr("class", "extent").style("cursor", "move");
8968
        var resize = g.selectAll(".resize").data(resizes, d3_identity);
8969
        resize.exit().remove();
8970
        resize.enter().append("g").attr("class", function(d) {
8971
          return "resize " + d;
8972
        }).style("cursor", function(d) {
8973
          return d3_svg_brushCursor[d];
8974
        }).append("rect").attr("x", function(d) {
8975
          return /[ew]$/.test(d) ? -3 : null;
8976
        }).attr("y", function(d) {
8977
          return /^[ns]/.test(d) ? -3 : null;
8978
        }).attr("width", 6).attr("height", 6).style("visibility", "hidden");
8979
        resize.style("display", brush.empty() ? "none" : null);
8980
        var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range;
8981
        if (x) {
8982
          range = d3_scaleRange(x);
8983
          backgroundUpdate.attr("x", range[0]).attr("width", range[1] - range[0]);
8984
          redrawX(gUpdate);
8985
        }
8986
        if (y) {
8987
          range = d3_scaleRange(y);
8988
          backgroundUpdate.attr("y", range[0]).attr("height", range[1] - range[0]);
8989
          redrawY(gUpdate);
8990
        }
8991
        redraw(gUpdate);
8992
      });
8993
    }
8994
    brush.event = function(g) {
8995
      g.each(function() {
8996
        var event_ = event.of(this, arguments), extent1 = {
8997
          x: xExtent,
8998
          y: yExtent,
8999
          i: xExtentDomain,
9000
          j: yExtentDomain
9001
        }, extent0 = this.__chart__ || extent1;
9002
        this.__chart__ = extent1;
9003
        if (d3_transitionInheritId) {
9004
          d3.select(this).transition().each("start.brush", function() {
9005
            xExtentDomain = extent0.i;
9006
            yExtentDomain = extent0.j;
9007
            xExtent = extent0.x;
9008
            yExtent = extent0.y;
9009
            event_({
9010
              type: "brushstart"
9011
            });
9012
          }).tween("brush:brush", function() {
9013
            var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y);
9014
            xExtentDomain = yExtentDomain = null;
9015
            return function(t) {
9016
              xExtent = extent1.x = xi(t);
9017
              yExtent = extent1.y = yi(t);
9018
              event_({
9019
                type: "brush",
9020
                mode: "resize"
9021
              });
9022
            };
9023
          }).each("end.brush", function() {
9024
            xExtentDomain = extent1.i;
9025
            yExtentDomain = extent1.j;
9026
            event_({
9027
              type: "brush",
9028
              mode: "resize"
9029
            });
9030
            event_({
9031
              type: "brushend"
9032
            });
9033
          });
9034
        } else {
9035
          event_({
9036
            type: "brushstart"
9037
          });
9038
          event_({
9039
            type: "brush",
9040
            mode: "resize"
9041
          });
9042
          event_({
9043
            type: "brushend"
9044
          });
9045
        }
9046
      });
9047
    };
9048
    function redraw(g) {
9049
      g.selectAll(".resize").attr("transform", function(d) {
9050
        return "translate(" + xExtent[+/e$/.test(d)] + "," + yExtent[+/^s/.test(d)] + ")";
9051
      });
9052
    }
9053
    function redrawX(g) {
9054
      g.select(".extent").attr("x", xExtent[0]);
9055
      g.selectAll(".extent,.n>rect,.s>rect").attr("width", xExtent[1] - xExtent[0]);
9056
    }
9057
    function redrawY(g) {
9058
      g.select(".extent").attr("y", yExtent[0]);
9059
      g.selectAll(".extent,.e>rect,.w>rect").attr("height", yExtent[1] - yExtent[0]);
9060
    }
9061
    function brushstart() {
9062
      var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed("extent"), dragRestore = d3_event_dragSuppress(), center, origin = d3.mouse(target), offset;
9063
      var w = d3.select(d3_window).on("keydown.brush", keydown).on("keyup.brush", keyup);
9064
      if (d3.event.changedTouches) {
9065
        w.on("touchmove.brush", brushmove).on("touchend.brush", brushend);
9066
      } else {
9067
        w.on("mousemove.brush", brushmove).on("mouseup.brush", brushend);
9068
      }
9069
      g.interrupt().selectAll("*").interrupt();
9070
      if (dragging) {
9071
        origin[0] = xExtent[0] - origin[0];
9072
        origin[1] = yExtent[0] - origin[1];
9073
      } else if (resizing) {
9074
        var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing);
9075
        offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ];
9076
        origin[0] = xExtent[ex];
9077
        origin[1] = yExtent[ey];
9078
      } else if (d3.event.altKey) center = origin.slice();
9079
      g.style("pointer-events", "none").selectAll(".resize").style("display", null);
9080
      d3.select("body").style("cursor", eventTarget.style("cursor"));
9081
      event_({
9082
        type: "brushstart"
9083
      });
9084
      brushmove();
9085
      function keydown() {
9086
        if (d3.event.keyCode == 32) {
9087
          if (!dragging) {
9088
            center = null;
9089
            origin[0] -= xExtent[1];
9090
            origin[1] -= yExtent[1];
9091
            dragging = 2;
9092
          }
9093
          d3_eventPreventDefault();
9094
        }
9095
      }
9096
      function keyup() {
9097
        if (d3.event.keyCode == 32 && dragging == 2) {
9098
          origin[0] += xExtent[1];
9099
          origin[1] += yExtent[1];
9100
          dragging = 0;
9101
          d3_eventPreventDefault();
9102
        }
9103
      }
9104
      function brushmove() {
9105
        var point = d3.mouse(target), moved = false;
9106
        if (offset) {
9107
          point[0] += offset[0];
9108
          point[1] += offset[1];
9109
        }
9110
        if (!dragging) {
9111
          if (d3.event.altKey) {
9112
            if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ];
9113
            origin[0] = xExtent[+(point[0] < center[0])];
9114
            origin[1] = yExtent[+(point[1] < center[1])];
9115
          } else center = null;
9116
        }
9117
        if (resizingX && move1(point, x, 0)) {
9118
          redrawX(g);
9119
          moved = true;
9120
        }
9121
        if (resizingY && move1(point, y, 1)) {
9122
          redrawY(g);
9123
          moved = true;
9124
        }
9125
        if (moved) {
9126
          redraw(g);
9127
          event_({
9128
            type: "brush",
9129
            mode: dragging ? "move" : "resize"
9130
          });
9131
        }
9132
      }
9133
      function move1(point, scale, i) {
9134
        var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], extent = i ? yExtent : xExtent, size = extent[1] - extent[0], min, max;
9135
        if (dragging) {
9136
          r0 -= position;
9137
          r1 -= size + position;
9138
        }
9139
        min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i];
9140
        if (dragging) {
9141
          max = (min += position) + size;
9142
        } else {
9143
          if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min));
9144
          if (position < min) {
9145
            max = min;
9146
            min = position;
9147
          } else {
9148
            max = position;
9149
          }
9150
        }
9151
        if (extent[0] != min || extent[1] != max) {
9152
          if (i) yExtentDomain = null; else xExtentDomain = null;
9153
          extent[0] = min;
9154
          extent[1] = max;
9155
          return true;
9156
        }
9157
      }
9158
      function brushend() {
9159
        brushmove();
9160
        g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null);
9161
        d3.select("body").style("cursor", null);
9162
        w.on("mousemove.brush", null).on("mouseup.brush", null).on("touchmove.brush", null).on("touchend.brush", null).on("keydown.brush", null).on("keyup.brush", null);
9163
        dragRestore();
9164
        event_({
9165
          type: "brushend"
9166
        });
9167
      }
9168
    }
9169
    brush.x = function(z) {
9170
      if (!arguments.length) return x;
9171
      x = z;
9172
      resizes = d3_svg_brushResizes[!x << 1 | !y];
9173
      return brush;
9174
    };
9175
    brush.y = function(z) {
9176
      if (!arguments.length) return y;
9177
      y = z;
9178
      resizes = d3_svg_brushResizes[!x << 1 | !y];
9179
      return brush;
9180
    };
9181
    brush.clamp = function(z) {
9182
      if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null;
9183
      if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z;
9184
      return brush;
9185
    };
9186
    brush.extent = function(z) {
9187
      var x0, x1, y0, y1, t;
9188
      if (!arguments.length) {
9189
        if (x) {
9190
          if (xExtentDomain) {
9191
            x0 = xExtentDomain[0], x1 = xExtentDomain[1];
9192
          } else {
9193
            x0 = xExtent[0], x1 = xExtent[1];
9194
            if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);
9195
            if (x1 < x0) t = x0, x0 = x1, x1 = t;
9196
          }
9197
        }
9198
        if (y) {
9199
          if (yExtentDomain) {
9200
            y0 = yExtentDomain[0], y1 = yExtentDomain[1];
9201
          } else {
9202
            y0 = yExtent[0], y1 = yExtent[1];
9203
            if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);
9204
            if (y1 < y0) t = y0, y0 = y1, y1 = t;
9205
          }
9206
        }
9207
        return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ];
9208
      }
9209
      if (x) {
9210
        x0 = z[0], x1 = z[1];
9211
        if (y) x0 = x0[0], x1 = x1[0];
9212
        xExtentDomain = [ x0, x1 ];
9213
        if (x.invert) x0 = x(x0), x1 = x(x1);
9214
        if (x1 < x0) t = x0, x0 = x1, x1 = t;
9215
        if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ];
9216
      }
9217
      if (y) {
9218
        y0 = z[0], y1 = z[1];
9219
        if (x) y0 = y0[1], y1 = y1[1];
9220
        yExtentDomain = [ y0, y1 ];
9221
        if (y.invert) y0 = y(y0), y1 = y(y1);
9222
        if (y1 < y0) t = y0, y0 = y1, y1 = t;
9223
        if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ];
9224
      }
9225
      return brush;
9226
    };
9227
    brush.clear = function() {
9228
      if (!brush.empty()) {
9229
        xExtent = [ 0, 0 ], yExtent = [ 0, 0 ];
9230
        xExtentDomain = yExtentDomain = null;
9231
      }
9232
      return brush;
9233
    };
9234
    brush.empty = function() {
9235
      return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1];
9236
    };
9237
    return d3.rebind(brush, event, "on");
9238
  };
9239
  var d3_svg_brushCursor = {
9240
    n: "ns-resize",
9241
    e: "ew-resize",
9242
    s: "ns-resize",
9243
    w: "ew-resize",
9244
    nw: "nwse-resize",
9245
    ne: "nesw-resize",
9246
    se: "nwse-resize",
9247
    sw: "nesw-resize"
9248
  };
9249
  var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ];
9250
  var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat;
9251
  var d3_time_formatUtc = d3_time_format.utc;
9252
  var d3_time_formatIso = d3_time_formatUtc("%Y-%m-%dT%H:%M:%S.%LZ");
9253
  d3_time_format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso;
9254
  function d3_time_formatIsoNative(date) {
9255
    return date.toISOString();
9256
  }
9257
  d3_time_formatIsoNative.parse = function(string) {
9258
    var date = new Date(string);
9259
    return isNaN(date) ? null : date;
9260
  };
9261
  d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
9262
  d3_time.second = d3_time_interval(function(date) {
9263
    return new d3_date(Math.floor(date / 1e3) * 1e3);
9264
  }, function(date, offset) {
9265
    date.setTime(date.getTime() + Math.floor(offset) * 1e3);
9266
  }, function(date) {
9267
    return date.getSeconds();
9268
  });
9269
  d3_time.seconds = d3_time.second.range;
9270
  d3_time.seconds.utc = d3_time.second.utc.range;
9271
  d3_time.minute = d3_time_interval(function(date) {
9272
    return new d3_date(Math.floor(date / 6e4) * 6e4);
9273
  }, function(date, offset) {
9274
    date.setTime(date.getTime() + Math.floor(offset) * 6e4);
9275
  }, function(date) {
9276
    return date.getMinutes();
9277
  });
9278
  d3_time.minutes = d3_time.minute.range;
9279
  d3_time.minutes.utc = d3_time.minute.utc.range;
9280
  d3_time.hour = d3_time_interval(function(date) {
9281
    var timezone = date.getTimezoneOffset() / 60;
9282
    return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);
9283
  }, function(date, offset) {
9284
    date.setTime(date.getTime() + Math.floor(offset) * 36e5);
9285
  }, function(date) {
9286
    return date.getHours();
9287
  });
9288
  d3_time.hours = d3_time.hour.range;
9289
  d3_time.hours.utc = d3_time.hour.utc.range;
9290
  d3_time.month = d3_time_interval(function(date) {
9291
    date = d3_time.day(date);
9292
    date.setDate(1);
9293
    return date;
9294
  }, function(date, offset) {
9295
    date.setMonth(date.getMonth() + offset);
9296
  }, function(date) {
9297
    return date.getMonth();
9298
  });
9299
  d3_time.months = d3_time.month.range;
9300
  d3_time.months.utc = d3_time.month.utc.range;
9301
  function d3_time_scale(linear, methods, format) {
9302
    function scale(x) {
9303
      return linear(x);
9304
    }
9305
    scale.invert = function(x) {
9306
      return d3_time_scaleDate(linear.invert(x));
9307
    };
9308
    scale.domain = function(x) {
9309
      if (!arguments.length) return linear.domain().map(d3_time_scaleDate);
9310
      linear.domain(x);
9311
      return scale;
9312
    };
9313
    function tickMethod(extent, count) {
9314
      var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target);
9315
      return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) {
9316
        return d / 31536e6;
9317
      }), count)[2] ] : !i ? [ d3_time_scaleMilliseconds, d3_scale_linearTickRange(extent, count)[2] ] : methods[target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target ? i - 1 : i];
9318
    }
9319
    scale.nice = function(interval, skip) {
9320
      var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" && tickMethod(extent, interval);
9321
      if (method) interval = method[0], skip = method[1];
9322
      function skipped(date) {
9323
        return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length;
9324
      }
9325
      return scale.domain(d3_scale_nice(domain, skip > 1 ? {
9326
        floor: function(date) {
9327
          while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1);
9328
          return date;
9329
        },
9330
        ceil: function(date) {
9331
          while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1);
9332
          return date;
9333
        }
9334
      } : interval));
9335
    };
9336
    scale.ticks = function(interval, skip) {
9337
      var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" ? tickMethod(extent, interval) : !interval.range && [ {
9338
        range: interval
9339
      }, skip ];
9340
      if (method) interval = method[0], skip = method[1];
9341
      return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip);
9342
    };
9343
    scale.tickFormat = function() {
9344
      return format;
9345
    };
9346
    scale.copy = function() {
9347
      return d3_time_scale(linear.copy(), methods, format);
9348
    };
9349
    return d3_scale_linearRebind(scale, linear);
9350
  }
9351
  function d3_time_scaleDate(t) {
9352
    return new Date(t);
9353
  }
9354
  var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ];
9355
  var d3_time_scaleLocalMethods = [ [ d3_time.second, 1 ], [ d3_time.second, 5 ], [ d3_time.second, 15 ], [ d3_time.second, 30 ], [ d3_time.minute, 1 ], [ d3_time.minute, 5 ], [ d3_time.minute, 15 ], [ d3_time.minute, 30 ], [ d3_time.hour, 1 ], [ d3_time.hour, 3 ], [ d3_time.hour, 6 ], [ d3_time.hour, 12 ], [ d3_time.day, 1 ], [ d3_time.day, 2 ], [ d3_time.week, 1 ], [ d3_time.month, 1 ], [ d3_time.month, 3 ], [ d3_time.year, 1 ] ];
9356
  var d3_time_scaleLocalFormat = d3_time_format.multi([ [ ".%L", function(d) {
9357
    return d.getMilliseconds();
9358
  } ], [ ":%S", function(d) {
9359
    return d.getSeconds();
9360
  } ], [ "%I:%M", function(d) {
9361
    return d.getMinutes();
9362
  } ], [ "%I %p", function(d) {
9363
    return d.getHours();
9364
  } ], [ "%a %d", function(d) {
9365
    return d.getDay() && d.getDate() != 1;
9366
  } ], [ "%b %d", function(d) {
9367
    return d.getDate() != 1;
9368
  } ], [ "%B", function(d) {
9369
    return d.getMonth();
9370
  } ], [ "%Y", d3_true ] ]);
9371
  var d3_time_scaleMilliseconds = {
9372
    range: function(start, stop, step) {
9373
      return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate);
9374
    },
9375
    floor: d3_identity,
9376
    ceil: d3_identity
9377
  };
9378
  d3_time_scaleLocalMethods.year = d3_time.year;
9379
  d3_time.scale = function() {
9380
    return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);
9381
  };
9382
  var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) {
9383
    return [ m[0].utc, m[1] ];
9384
  });
9385
  var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ ".%L", function(d) {
9386
    return d.getUTCMilliseconds();
9387
  } ], [ ":%S", function(d) {
9388
    return d.getUTCSeconds();
9389
  } ], [ "%I:%M", function(d) {
9390
    return d.getUTCMinutes();
9391
  } ], [ "%I %p", function(d) {
9392
    return d.getUTCHours();
9393
  } ], [ "%a %d", function(d) {
9394
    return d.getUTCDay() && d.getUTCDate() != 1;
9395
  } ], [ "%b %d", function(d) {
9396
    return d.getUTCDate() != 1;
9397
  } ], [ "%B", function(d) {
9398
    return d.getUTCMonth();
9399
  } ], [ "%Y", d3_true ] ]);
9400
  d3_time_scaleUtcMethods.year = d3_time.year.utc;
9401
  d3_time.scale.utc = function() {
9402
    return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat);
9403
  };
9404
  d3.text = d3_xhrType(function(request) {
9405
    return request.responseText;
9406
  });
9407
  d3.json = function(url, callback) {
9408
    return d3_xhr(url, "application/json", d3_json, callback);
9409
  };
9410
  function d3_json(request) {
9411
    return JSON.parse(request.responseText);
9412
  }
9413
  d3.html = function(url, callback) {
9414
    return d3_xhr(url, "text/html", d3_html, callback);
9415
  };
9416
  function d3_html(request) {
9417
    var range = d3_document.createRange();
9418
    range.selectNode(d3_document.body);
9419
    return range.createContextualFragment(request.responseText);
9420
  }
9421
  d3.xml = d3_xhrType(function(request) {
9422
    return request.responseXML;
9423
  });
9424
  if (typeof define === "function" && define.amd) define(d3); else if (typeof module === "object" && module.exports) module.exports = d3;
9425
  this.d3 = d3;
9426
}();
(6-6/7)