artdaq_node_server  v1_01_01c
d3.js
1 !function() {
2  var d3 = {
3  version: "3.5.5"
4  };
5  var d3_arraySlice = [].slice, d3_array = function(list) {
6  return d3_arraySlice.call(list);
7  };
8  var d3_document = this.document;
9  function d3_documentElement(node) {
10  return node && (node.ownerDocument || node.document || node).documentElement;
11  }
12  function d3_window(node) {
13  return node && (node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView);
14  }
15  if (d3_document) {
16  try {
17  d3_array(d3_document.documentElement.childNodes)[0].nodeType;
18  } catch (e) {
19  d3_array = function(list) {
20  var i = list.length, array = new Array(i);
21  while (i--) array[i] = list[i];
22  return array;
23  };
24  }
25  }
26  if (!Date.now) Date.now = function() {
27  return +new Date();
28  };
29  if (d3_document) {
30  try {
31  d3_document.createElement("DIV").style.setProperty("opacity", 0, "");
32  } catch (error) {
33  var d3_element_prototype = this.Element.prototype, d3_element_setAttribute = d3_element_prototype.setAttribute, d3_element_setAttributeNS = d3_element_prototype.setAttributeNS, d3_style_prototype = this.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
34  d3_element_prototype.setAttribute = function(name, value) {
35  d3_element_setAttribute.call(this, name, value + "");
36  };
37  d3_element_prototype.setAttributeNS = function(space, local, value) {
38  d3_element_setAttributeNS.call(this, space, local, value + "");
39  };
40  d3_style_prototype.setProperty = function(name, value, priority) {
41  d3_style_setProperty.call(this, name, value + "", priority);
42  };
43  }
44  }
45  d3.ascending = d3_ascending;
46  function d3_ascending(a, b) {
47  return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
48  }
49  d3.descending = function(a, b) {
50  return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
51  };
52  d3.min = function(array, f) {
53  var i = -1, n = array.length, a, b;
54  if (arguments.length === 1) {
55  while (++i < n) if ((b = array[i]) != null && b >= b) {
56  a = b;
57  break;
58  }
59  while (++i < n) if ((b = array[i]) != null && a > b) a = b;
60  } else {
61  while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
62  a = b;
63  break;
64  }
65  while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
66  }
67  return a;
68  };
69  d3.max = function(array, f) {
70  var i = -1, n = array.length, a, b;
71  if (arguments.length === 1) {
72  while (++i < n) if ((b = array[i]) != null && b >= b) {
73  a = b;
74  break;
75  }
76  while (++i < n) if ((b = array[i]) != null && b > a) a = b;
77  } else {
78  while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
79  a = b;
80  break;
81  }
82  while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
83  }
84  return a;
85  };
86  d3.extent = function(array, f) {
87  var i = -1, n = array.length, a, b, c;
88  if (arguments.length === 1) {
89  while (++i < n) if ((b = array[i]) != null && b >= b) {
90  a = c = b;
91  break;
92  }
93  while (++i < n) if ((b = array[i]) != null) {
94  if (a > b) a = b;
95  if (c < b) c = b;
96  }
97  } else {
98  while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {
99  a = c = b;
100  break;
101  }
102  while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
103  if (a > b) a = b;
104  if (c < b) c = b;
105  }
106  }
107  return [ a, c ];
108  };
109  function d3_number(x) {
110  return x === null ? NaN : +x;
111  }
112  function d3_numeric(x) {
113  return !isNaN(x);
114  }
115  d3.sum = function(array, f) {
116  var s = 0, n = array.length, a, i = -1;
117  if (arguments.length === 1) {
118  while (++i < n) if (d3_numeric(a = +array[i])) s += a;
119  } else {
120  while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a;
121  }
122  return s;
123  };
124  d3.mean = function(array, f) {
125  var s = 0, n = array.length, a, i = -1, j = n;
126  if (arguments.length === 1) {
127  while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j;
128  } else {
129  while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j;
130  }
131  if (j) return s / j;
132  };
133  d3.quantile = function(values, p) {
134  var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;
135  return e ? v + e * (values[h] - v) : v;
136  };
137  d3.median = function(array, f) {
138  var numbers = [], n = array.length, a, i = -1;
139  if (arguments.length === 1) {
140  while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a);
141  } else {
142  while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a);
143  }
144  if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5);
145  };
146  d3.variance = function(array, f) {
147  var n = array.length, m = 0, a, d, s = 0, i = -1, j = 0;
148  if (arguments.length === 1) {
149  while (++i < n) {
150  if (d3_numeric(a = d3_number(array[i]))) {
151  d = a - m;
152  m += d / ++j;
153  s += d * (a - m);
154  }
155  }
156  } else {
157  while (++i < n) {
158  if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) {
159  d = a - m;
160  m += d / ++j;
161  s += d * (a - m);
162  }
163  }
164  }
165  if (j > 1) return s / (j - 1);
166  };
167  d3.deviation = function() {
168  var v = d3.variance.apply(this, arguments);
169  return v ? Math.sqrt(v) : v;
170  };
171  function d3_bisector(compare) {
172  return {
173  left: function(a, x, lo, hi) {
174  if (arguments.length < 3) lo = 0;
175  if (arguments.length < 4) hi = a.length;
176  while (lo < hi) {
177  var mid = lo + hi >>> 1;
178  if (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid;
179  }
180  return lo;
181  },
182  right: function(a, x, lo, hi) {
183  if (arguments.length < 3) lo = 0;
184  if (arguments.length < 4) hi = a.length;
185  while (lo < hi) {
186  var mid = lo + hi >>> 1;
187  if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1;
188  }
189  return lo;
190  }
191  };
192  }
193  var d3_bisect = d3_bisector(d3_ascending);
194  d3.bisectLeft = d3_bisect.left;
195  d3.bisect = d3.bisectRight = d3_bisect.right;
196  d3.bisector = function(f) {
197  return d3_bisector(f.length === 1 ? function(d, x) {
198  return d3_ascending(f(d), x);
199  } : f);
200  };
201  d3.shuffle = function(array, i0, i1) {
202  if ((m = arguments.length) < 3) {
203  i1 = array.length;
204  if (m < 2) i0 = 0;
205  }
206  var m = i1 - i0, t, i;
207  while (m) {
208  i = Math.random() * m-- | 0;
209  t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t;
210  }
211  return array;
212  };
213  d3.permute = function(array, indexes) {
214  var i = indexes.length, permutes = new Array(i);
215  while (i--) permutes[i] = array[indexes[i]];
216  return permutes;
217  };
218  d3.pairs = function(array) {
219  var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n);
220  while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ];
221  return pairs;
222  };
223  d3.zip = function() {
224  if (!(n = arguments.length)) return [];
225  for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) {
226  for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n; ) {
227  zip[j] = arguments[j][i];
228  }
229  }
230  return zips;
231  };
232  function d3_zipLength(d) {
233  return d.length;
234  }
235  d3.transpose = function(matrix) {
236  return d3.zip.apply(d3, matrix);
237  };
238  d3.keys = function(map) {
239  var keys = [];
240  for (var key in map) keys.push(key);
241  return keys;
242  };
243  d3.values = function(map) {
244  var values = [];
245  for (var key in map) values.push(map[key]);
246  return values;
247  };
248  d3.entries = function(map) {
249  var entries = [];
250  for (var key in map) entries.push({
251  key: key,
252  value: map[key]
253  });
254  return entries;
255  };
256  d3.merge = function(arrays) {
257  var n = arrays.length, m, i = -1, j = 0, merged, array;
258  while (++i < n) j += arrays[i].length;
259  merged = new Array(j);
260  while (--n >= 0) {
261  array = arrays[n];
262  m = array.length;
263  while (--m >= 0) {
264  merged[--j] = array[m];
265  }
266  }
267  return merged;
268  };
269  var abs = Math.abs;
270  d3.range = function(start, stop, step) {
271  if (arguments.length < 3) {
272  step = 1;
273  if (arguments.length < 2) {
274  stop = start;
275  start = 0;
276  }
277  }
278  if ((stop - start) / step === Infinity) throw new Error("infinite range");
279  var range = [], k = d3_range_integerScale(abs(step)), i = -1, j;
280  start *= k, stop *= k, step *= k;
281  if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k);
282  return range;
283  };
284  function d3_range_integerScale(x) {
285  var k = 1;
286  while (x * k % 1) k *= 10;
287  return k;
288  }
289  function d3_class(ctor, properties) {
290  for (var key in properties) {
291  Object.defineProperty(ctor.prototype, key, {
292  value: properties[key],
293  enumerable: false
294  });
295  }
296  }
297  d3.map = function(object, f) {
298  var map = new d3_Map();
299  if (object instanceof d3_Map) {
300  object.forEach(function(key, value) {
301  map.set(key, value);
302  });
303  } else if (Array.isArray(object)) {
304  var i = -1, n = object.length, o;
305  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);
306  } else {
307  for (var key in object) map.set(key, object[key]);
308  }
309  return map;
310  };
311  function d3_Map() {
312  this._ = Object.create(null);
313  }
314  var d3_map_proto = "__proto__", d3_map_zero = "\x00";
315  d3_class(d3_Map, {
316  has: d3_map_has,
317  get: function(key) {
318  return this._[d3_map_escape(key)];
319  },
320  set: function(key, value) {
321  return this._[d3_map_escape(key)] = value;
322  },
323  remove: d3_map_remove,
324  keys: d3_map_keys,
325  values: function() {
326  var values = [];
327  for (var key in this._) values.push(this._[key]);
328  return values;
329  },
330  entries: function() {
331  var entries = [];
332  for (var key in this._) entries.push({
333  key: d3_map_unescape(key),
334  value: this._[key]
335  });
336  return entries;
337  },
338  size: d3_map_size,
339  empty: d3_map_empty,
340  forEach: function(f) {
341  for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]);
342  }
343  });
344  function d3_map_escape(key) {
345  return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key;
346  }
347  function d3_map_unescape(key) {
348  return (key += "")[0] === d3_map_zero ? key.slice(1) : key;
349  }
350  function d3_map_has(key) {
351  return d3_map_escape(key) in this._;
352  }
353  function d3_map_remove(key) {
354  return (key = d3_map_escape(key)) in this._ && delete this._[key];
355  }
356  function d3_map_keys() {
357  var keys = [];
358  for (var key in this._) keys.push(d3_map_unescape(key));
359  return keys;
360  }
361  function d3_map_size() {
362  var size = 0;
363  for (var key in this._) ++size;
364  return size;
365  }
366  function d3_map_empty() {
367  for (var key in this._) return false;
368  return true;
369  }
370  d3.nest = function() {
371  var nest = {}, keys = [], sortKeys = [], sortValues, rollup;
372  function map(mapType, array, depth) {
373  if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array;
374  var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values;
375  while (++i < n) {
376  if (values = valuesByKey.get(keyValue = key(object = array[i]))) {
377  values.push(object);
378  } else {
379  valuesByKey.set(keyValue, [ object ]);
380  }
381  }
382  if (mapType) {
383  object = mapType();
384  setter = function(keyValue, values) {
385  object.set(keyValue, map(mapType, values, depth));
386  };
387  } else {
388  object = {};
389  setter = function(keyValue, values) {
390  object[keyValue] = map(mapType, values, depth);
391  };
392  }
393  valuesByKey.forEach(setter);
394  return object;
395  }
396  function entries(map, depth) {
397  if (depth >= keys.length) return map;
398  var array = [], sortKey = sortKeys[depth++];
399  map.forEach(function(key, keyMap) {
400  array.push({
401  key: key,
402  values: entries(keyMap, depth)
403  });
404  });
405  return sortKey ? array.sort(function(a, b) {
406  return sortKey(a.key, b.key);
407  }) : array;
408  }
409  nest.map = function(array, mapType) {
410  return map(mapType, array, 0);
411  };
412  nest.entries = function(array) {
413  return entries(map(d3.map, array, 0), 0);
414  };
415  nest.key = function(d) {
416  keys.push(d);
417  return nest;
418  };
419  nest.sortKeys = function(order) {
420  sortKeys[keys.length - 1] = order;
421  return nest;
422  };
423  nest.sortValues = function(order) {
424  sortValues = order;
425  return nest;
426  };
427  nest.rollup = function(f) {
428  rollup = f;
429  return nest;
430  };
431  return nest;
432  };
433  d3.set = function(array) {
434  var set = new d3_Set();
435  if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]);
436  return set;
437  };
438  function d3_Set() {
439  this._ = Object.create(null);
440  }
441  d3_class(d3_Set, {
442  has: d3_map_has,
443  add: function(key) {
444  this._[d3_map_escape(key += "")] = true;
445  return key;
446  },
447  remove: d3_map_remove,
448  values: d3_map_keys,
449  size: d3_map_size,
450  empty: d3_map_empty,
451  forEach: function(f) {
452  for (var key in this._) f.call(this, d3_map_unescape(key));
453  }
454  });
455  d3.behavior = {};
456  function d3_identity(d) {
457  return d;
458  }
459  d3.rebind = function(target, source) {
460  var i = 1, n = arguments.length, method;
461  while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);
462  return target;
463  };
464  function d3_rebind(target, source, method) {
465  return function() {
466  var value = method.apply(source, arguments);
467  return value === source ? target : value;
468  };
469  }
470  function d3_vendorSymbol(object, name) {
471  if (name in object) return name;
472  name = name.charAt(0).toUpperCase() + name.slice(1);
473  for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) {
474  var prefixName = d3_vendorPrefixes[i] + name;
475  if (prefixName in object) return prefixName;
476  }
477  }
478  var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ];
479  function d3_noop() {}
480  d3.dispatch = function() {
481  var dispatch = new d3_dispatch(), i = -1, n = arguments.length;
482  while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
483  return dispatch;
484  };
485  function d3_dispatch() {}
486  d3_dispatch.prototype.on = function(type, listener) {
487  var i = type.indexOf("."), name = "";
488  if (i >= 0) {
489  name = type.slice(i + 1);
490  type = type.slice(0, i);
491  }
492  if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener);
493  if (arguments.length === 2) {
494  if (listener == null) for (type in this) {
495  if (this.hasOwnProperty(type)) this[type].on(name, null);
496  }
497  return this;
498  }
499  };
500  function d3_dispatch_event(dispatch) {
501  var listeners = [], listenerByName = new d3_Map();
502  function event() {
503  var z = listeners, i = -1, n = z.length, l;
504  while (++i < n) if (l = z[i].on) l.apply(this, arguments);
505  return dispatch;
506  }
507  event.on = function(name, listener) {
508  var l = listenerByName.get(name), i;
509  if (arguments.length < 2) return l && l.on;
510  if (l) {
511  l.on = null;
512  listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));
513  listenerByName.remove(name);
514  }
515  if (listener) listeners.push(listenerByName.set(name, {
516  on: listener
517  }));
518  return dispatch;
519  };
520  return event;
521  }
522  d3.event = null;
523  function d3_eventPreventDefault() {
524  d3.event.preventDefault();
525  }
526  function d3_eventSource() {
527  var e = d3.event, s;
528  while (s = e.sourceEvent) e = s;
529  return e;
530  }
531  function d3_eventDispatch(target) {
532  var dispatch = new d3_dispatch(), i = 0, n = arguments.length;
533  while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
534  dispatch.of = function(thiz, argumentz) {
535  return function(e1) {
536  try {
537  var e0 = e1.sourceEvent = d3.event;
538  e1.target = target;
539  d3.event = e1;
540  dispatch[e1.type].apply(thiz, argumentz);
541  } finally {
542  d3.event = e0;
543  }
544  };
545  };
546  return dispatch;
547  }
548  d3.requote = function(s) {
549  return s.replace(d3_requote_re, "\\$&");
550  };
551  var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
552  var d3_subclass = {}.__proto__ ? function(object, prototype) {
553  object.__proto__ = prototype;
554  } : function(object, prototype) {
555  for (var property in prototype) object[property] = prototype[property];
556  };
557  function d3_selection(groups) {
558  d3_subclass(groups, d3_selectionPrototype);
559  return groups;
560  }
561  var d3_select = function(s, n) {
562  return n.querySelector(s);
563  }, d3_selectAll = function(s, n) {
564  return n.querySelectorAll(s);
565  }, d3_selectMatches = function(n, s) {
566  var d3_selectMatcher = n.matches || n[d3_vendorSymbol(n, "matchesSelector")];
567  d3_selectMatches = function(n, s) {
568  return d3_selectMatcher.call(n, s);
569  };
570  return d3_selectMatches(n, s);
571  };
572  if (typeof Sizzle === "function") {
573  d3_select = function(s, n) {
574  return Sizzle(s, n)[0] || null;
575  };
576  d3_selectAll = Sizzle;
577  d3_selectMatches = Sizzle.matchesSelector;
578  }
579  d3.selection = function() {
580  return d3.select(d3_document.documentElement);
581  };
582  var d3_selectionPrototype = d3.selection.prototype = [];
583  d3_selectionPrototype.select = function(selector) {
584  var subgroups = [], subgroup, subnode, group, node;
585  selector = d3_selection_selector(selector);
586  for (var j = -1, m = this.length; ++j < m; ) {
587  subgroups.push(subgroup = []);
588  subgroup.parentNode = (group = this[j]).parentNode;
589  for (var i = -1, n = group.length; ++i < n; ) {
590  if (node = group[i]) {
591  subgroup.push(subnode = selector.call(node, node.__data__, i, j));
592  if (subnode && "__data__" in node) subnode.__data__ = node.__data__;
593  } else {
594  subgroup.push(null);
595  }
596  }
597  }
598  return d3_selection(subgroups);
599  };
600  function d3_selection_selector(selector) {
601  return typeof selector === "function" ? selector : function() {
602  return d3_select(selector, this);
603  };
604  }
605  d3_selectionPrototype.selectAll = function(selector) {
606  var subgroups = [], subgroup, node;
607  selector = d3_selection_selectorAll(selector);
608  for (var j = -1, m = this.length; ++j < m; ) {
609  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
610  if (node = group[i]) {
611  subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j)));
612  subgroup.parentNode = node;
613  }
614  }
615  }
616  return d3_selection(subgroups);
617  };
618  function d3_selection_selectorAll(selector) {
619  return typeof selector === "function" ? selector : function() {
620  return d3_selectAll(selector, this);
621  };
622  }
623  var d3_nsPrefix = {
624  svg: "http://www.w3.org/2000/svg",
625  xhtml: "http://www.w3.org/1999/xhtml",
626  xlink: "http://www.w3.org/1999/xlink",
627  xml: "http://www.w3.org/XML/1998/namespace",
628  xmlns: "http://www.w3.org/2000/xmlns/"
629  };
630  d3.ns = {
631  prefix: d3_nsPrefix,
632  qualify: function(name) {
633  var i = name.indexOf(":"), prefix = name;
634  if (i >= 0) {
635  prefix = name.slice(0, i);
636  name = name.slice(i + 1);
637  }
638  return d3_nsPrefix.hasOwnProperty(prefix) ? {
639  space: d3_nsPrefix[prefix],
640  local: name
641  } : name;
642  }
643  };
644  d3_selectionPrototype.attr = function(name, value) {
645  if (arguments.length < 2) {
646  if (typeof name === "string") {
647  var node = this.node();
648  name = d3.ns.qualify(name);
649  return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name);
650  }
651  for (value in name) this.each(d3_selection_attr(value, name[value]));
652  return this;
653  }
654  return this.each(d3_selection_attr(name, value));
655  };
656  function d3_selection_attr(name, value) {
657  name = d3.ns.qualify(name);
658  function attrNull() {
659  this.removeAttribute(name);
660  }
661  function attrNullNS() {
662  this.removeAttributeNS(name.space, name.local);
663  }
664  function attrConstant() {
665  this.setAttribute(name, value);
666  }
667  function attrConstantNS() {
668  this.setAttributeNS(name.space, name.local, value);
669  }
670  function attrFunction() {
671  var x = value.apply(this, arguments);
672  if (x == null) this.removeAttribute(name); else this.setAttribute(name, x);
673  }
674  function attrFunctionNS() {
675  var x = value.apply(this, arguments);
676  if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x);
677  }
678  return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant;
679  }
680  function d3_collapse(s) {
681  return s.trim().replace(/\s+/g, " ");
682  }
683  d3_selectionPrototype.classed = function(name, value) {
684  if (arguments.length < 2) {
685  if (typeof name === "string") {
686  var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1;
687  if (value = node.classList) {
688  while (++i < n) if (!value.contains(name[i])) return false;
689  } else {
690  value = node.getAttribute("class");
691  while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false;
692  }
693  return true;
694  }
695  for (value in name) this.each(d3_selection_classed(value, name[value]));
696  return this;
697  }
698  return this.each(d3_selection_classed(name, value));
699  };
700  function d3_selection_classedRe(name) {
701  return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g");
702  }
703  function d3_selection_classes(name) {
704  return (name + "").trim().split(/^|\s+/);
705  }
706  function d3_selection_classed(name, value) {
707  name = d3_selection_classes(name).map(d3_selection_classedName);
708  var n = name.length;
709  function classedConstant() {
710  var i = -1;
711  while (++i < n) name[i](this, value);
712  }
713  function classedFunction() {
714  var i = -1, x = value.apply(this, arguments);
715  while (++i < n) name[i](this, x);
716  }
717  return typeof value === "function" ? classedFunction : classedConstant;
718  }
719  function d3_selection_classedName(name) {
720  var re = d3_selection_classedRe(name);
721  return function(node, value) {
722  if (c = node.classList) return value ? c.add(name) : c.remove(name);
723  var c = node.getAttribute("class") || "";
724  if (value) {
725  re.lastIndex = 0;
726  if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name));
727  } else {
728  node.setAttribute("class", d3_collapse(c.replace(re, " ")));
729  }
730  };
731  }
732  d3_selectionPrototype.style = function(name, value, priority) {
733  var n = arguments.length;
734  if (n < 3) {
735  if (typeof name !== "string") {
736  if (n < 2) value = "";
737  for (priority in name) this.each(d3_selection_style(priority, name[priority], value));
738  return this;
739  }
740  if (n < 2) {
741  var node = this.node();
742  return d3_window(node).getComputedStyle(node, null).getPropertyValue(name);
743  }
744  priority = "";
745  }
746  return this.each(d3_selection_style(name, value, priority));
747  };
748  function d3_selection_style(name, value, priority) {
749  function styleNull() {
750  this.style.removeProperty(name);
751  }
752  function styleConstant() {
753  this.style.setProperty(name, value, priority);
754  }
755  function styleFunction() {
756  var x = value.apply(this, arguments);
757  if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority);
758  }
759  return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant;
760  }
761  d3_selectionPrototype.property = function(name, value) {
762  if (arguments.length < 2) {
763  if (typeof name === "string") return this.node()[name];
764  for (value in name) this.each(d3_selection_property(value, name[value]));
765  return this;
766  }
767  return this.each(d3_selection_property(name, value));
768  };
769  function d3_selection_property(name, value) {
770  function propertyNull() {
771  delete this[name];
772  }
773  function propertyConstant() {
774  this[name] = value;
775  }
776  function propertyFunction() {
777  var x = value.apply(this, arguments);
778  if (x == null) delete this[name]; else this[name] = x;
779  }
780  return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant;
781  }
782  d3_selectionPrototype.text = function(value) {
783  return arguments.length ? this.each(typeof value === "function" ? function() {
784  var v = value.apply(this, arguments);
785  this.textContent = v == null ? "" : v;
786  } : value == null ? function() {
787  this.textContent = "";
788  } : function() {
789  this.textContent = value;
790  }) : this.node().textContent;
791  };
792  d3_selectionPrototype.html = function(value) {
793  return arguments.length ? this.each(typeof value === "function" ? function() {
794  var v = value.apply(this, arguments);
795  this.innerHTML = v == null ? "" : v;
796  } : value == null ? function() {
797  this.innerHTML = "";
798  } : function() {
799  this.innerHTML = value;
800  }) : this.node().innerHTML;
801  };
802  d3_selectionPrototype.append = function(name) {
803  name = d3_selection_creator(name);
804  return this.select(function() {
805  return this.appendChild(name.apply(this, arguments));
806  });
807  };
808  function d3_selection_creator(name) {
809  function create() {
810  var document = this.ownerDocument, namespace = this.namespaceURI;
811  return namespace ? document.createElementNS(namespace, name) : document.createElement(name);
812  }
813  function createNS() {
814  return this.ownerDocument.createElementNS(name.space, name.local);
815  }
816  return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? createNS : create;
817  }
818  d3_selectionPrototype.insert = function(name, before) {
819  name = d3_selection_creator(name);
820  before = d3_selection_selector(before);
821  return this.select(function() {
822  return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null);
823  });
824  };
825  d3_selectionPrototype.remove = function() {
826  return this.each(d3_selectionRemove);
827  };
828  function d3_selectionRemove() {
829  var parent = this.parentNode;
830  if (parent) parent.removeChild(this);
831  }
832  d3_selectionPrototype.data = function(value, key) {
833  var i = -1, n = this.length, group, node;
834  if (!arguments.length) {
835  value = new Array(n = (group = this[0]).length);
836  while (++i < n) {
837  if (node = group[i]) {
838  value[i] = node.__data__;
839  }
840  }
841  return value;
842  }
843  function bind(group, groupData) {
844  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;
845  if (key) {
846  var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue;
847  for (i = -1; ++i < n; ) {
848  if (nodeByKeyValue.has(keyValue = key.call(node = group[i], node.__data__, i))) {
849  exitNodes[i] = node;
850  } else {
851  nodeByKeyValue.set(keyValue, node);
852  }
853  keyValues[i] = keyValue;
854  }
855  for (i = -1; ++i < m; ) {
856  if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) {
857  enterNodes[i] = d3_selection_dataNode(nodeData);
858  } else if (node !== true) {
859  updateNodes[i] = node;
860  node.__data__ = nodeData;
861  }
862  nodeByKeyValue.set(keyValue, true);
863  }
864  for (i = -1; ++i < n; ) {
865  if (nodeByKeyValue.get(keyValues[i]) !== true) {
866  exitNodes[i] = group[i];
867  }
868  }
869  } else {
870  for (i = -1; ++i < n0; ) {
871  node = group[i];
872  nodeData = groupData[i];
873  if (node) {
874  node.__data__ = nodeData;
875  updateNodes[i] = node;
876  } else {
877  enterNodes[i] = d3_selection_dataNode(nodeData);
878  }
879  }
880  for (;i < m; ++i) {
881  enterNodes[i] = d3_selection_dataNode(groupData[i]);
882  }
883  for (;i < n; ++i) {
884  exitNodes[i] = group[i];
885  }
886  }
887  enterNodes.update = updateNodes;
888  enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode;
889  enter.push(enterNodes);
890  update.push(updateNodes);
891  exit.push(exitNodes);
892  }
893  var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]);
894  if (typeof value === "function") {
895  while (++i < n) {
896  bind(group = this[i], value.call(group, group.parentNode.__data__, i));
897  }
898  } else {
899  while (++i < n) {
900  bind(group = this[i], value);
901  }
902  }
903  update.enter = function() {
904  return enter;
905  };
906  update.exit = function() {
907  return exit;
908  };
909  return update;
910  };
911  function d3_selection_dataNode(data) {
912  return {
913  __data__: data
914  };
915  }
916  d3_selectionPrototype.datum = function(value) {
917  return arguments.length ? this.property("__data__", value) : this.property("__data__");
918  };
919  d3_selectionPrototype.filter = function(filter) {
920  var subgroups = [], subgroup, group, node;
921  if (typeof filter !== "function") filter = d3_selection_filter(filter);
922  for (var j = 0, m = this.length; j < m; j++) {
923  subgroups.push(subgroup = []);
924  subgroup.parentNode = (group = this[j]).parentNode;
925  for (var i = 0, n = group.length; i < n; i++) {
926  if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {
927  subgroup.push(node);
928  }
929  }
930  }
931  return d3_selection(subgroups);
932  };
933  function d3_selection_filter(selector) {
934  return function() {
935  return d3_selectMatches(this, selector);
936  };
937  }
938  d3_selectionPrototype.order = function() {
939  for (var j = -1, m = this.length; ++j < m; ) {
940  for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) {
941  if (node = group[i]) {
942  if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
943  next = node;
944  }
945  }
946  }
947  return this;
948  };
949  d3_selectionPrototype.sort = function(comparator) {
950  comparator = d3_selection_sortComparator.apply(this, arguments);
951  for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator);
952  return this.order();
953  };
954  function d3_selection_sortComparator(comparator) {
955  if (!arguments.length) comparator = d3_ascending;
956  return function(a, b) {
957  return a && b ? comparator(a.__data__, b.__data__) : !a - !b;
958  };
959  }
960  d3_selectionPrototype.each = function(callback) {
961  return d3_selection_each(this, function(node, i, j) {
962  callback.call(node, node.__data__, i, j);
963  });
964  };
965  function d3_selection_each(groups, callback) {
966  for (var j = 0, m = groups.length; j < m; j++) {
967  for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {
968  if (node = group[i]) callback(node, i, j);
969  }
970  }
971  return groups;
972  }
973  d3_selectionPrototype.call = function(callback) {
974  var args = d3_array(arguments);
975  callback.apply(args[0] = this, args);
976  return this;
977  };
978  d3_selectionPrototype.empty = function() {
979  return !this.node();
980  };
981  d3_selectionPrototype.node = function() {
982  for (var j = 0, m = this.length; j < m; j++) {
983  for (var group = this[j], i = 0, n = group.length; i < n; i++) {
984  var node = group[i];
985  if (node) return node;
986  }
987  }
988  return null;
989  };
990  d3_selectionPrototype.size = function() {
991  var n = 0;
992  d3_selection_each(this, function() {
993  ++n;
994  });
995  return n;
996  };
997  function d3_selection_enter(selection) {
998  d3_subclass(selection, d3_selection_enterPrototype);
999  return selection;
1000  }
1001  var d3_selection_enterPrototype = [];
1002  d3.selection.enter = d3_selection_enter;
1003  d3.selection.enter.prototype = d3_selection_enterPrototype;
1004  d3_selection_enterPrototype.append = d3_selectionPrototype.append;
1005  d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;
1006  d3_selection_enterPrototype.node = d3_selectionPrototype.node;
1007  d3_selection_enterPrototype.call = d3_selectionPrototype.call;
1008  d3_selection_enterPrototype.size = d3_selectionPrototype.size;
1009  d3_selection_enterPrototype.select = function(selector) {
1010  var subgroups = [], subgroup, subnode, upgroup, group, node;
1011  for (var j = -1, m = this.length; ++j < m; ) {
1012  upgroup = (group = this[j]).update;
1013  subgroups.push(subgroup = []);
1014  subgroup.parentNode = group.parentNode;
1015  for (var i = -1, n = group.length; ++i < n; ) {
1016  if (node = group[i]) {
1017  subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j));
1018  subnode.__data__ = node.__data__;
1019  } else {
1020  subgroup.push(null);
1021  }
1022  }
1023  }
1024  return d3_selection(subgroups);
1025  };
1026  d3_selection_enterPrototype.insert = function(name, before) {
1027  if (arguments.length < 2) before = d3_selection_enterInsertBefore(this);
1028  return d3_selectionPrototype.insert.call(this, name, before);
1029  };
1030  function d3_selection_enterInsertBefore(enter) {
1031  var i0, j0;
1032  return function(d, i, j) {
1033  var group = enter[j].update, n = group.length, node;
1034  if (j != j0) j0 = j, i0 = 0;
1035  if (i >= i0) i0 = i + 1;
1036  while (!(node = group[i0]) && ++i0 < n) ;
1037  return node;
1038  };
1039  }
1040  d3.select = function(node) {
1041  var group;
1042  if (typeof node === "string") {
1043  group = [ d3_select(node, d3_document) ];
1044  group.parentNode = d3_document.documentElement;
1045  } else {
1046  group = [ node ];
1047  group.parentNode = d3_documentElement(node);
1048  }
1049  return d3_selection([ group ]);
1050  };
1051  d3.selectAll = function(nodes) {
1052  var group;
1053  if (typeof nodes === "string") {
1054  group = d3_array(d3_selectAll(nodes, d3_document));
1055  group.parentNode = d3_document.documentElement;
1056  } else {
1057  group = nodes;
1058  group.parentNode = null;
1059  }
1060  return d3_selection([ group ]);
1061  };
1062  d3_selectionPrototype.on = function(type, listener, capture) {
1063  var n = arguments.length;
1064  if (n < 3) {
1065  if (typeof type !== "string") {
1066  if (n < 2) listener = false;
1067  for (capture in type) this.each(d3_selection_on(capture, type[capture], listener));
1068  return this;
1069  }
1070  if (n < 2) return (n = this.node()["__on" + type]) && n._;
1071  capture = false;
1072  }
1073  return this.each(d3_selection_on(type, listener, capture));
1074  };
1075  function d3_selection_on(type, listener, capture) {
1076  var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener;
1077  if (i > 0) type = type.slice(0, i);
1078  var filter = d3_selection_onFilters.get(type);
1079  if (filter) type = filter, wrap = d3_selection_onFilter;
1080  function onRemove() {
1081  var l = this[name];
1082  if (l) {
1083  this.removeEventListener(type, l, l.$);
1084  delete this[name];
1085  }
1086  }
1087  function onAdd() {
1088  var l = wrap(listener, d3_array(arguments));
1089  onRemove.call(this);
1090  this.addEventListener(type, this[name] = l, l.$ = capture);
1091  l._ = listener;
1092  }
1093  function removeAll() {
1094  var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match;
1095  for (var name in this) {
1096  if (match = name.match(re)) {
1097  var l = this[name];
1098  this.removeEventListener(match[1], l, l.$);
1099  delete this[name];
1100  }
1101  }
1102  }
1103  return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll;
1104  }
1105  var d3_selection_onFilters = d3.map({
1106  mouseenter: "mouseover",
1107  mouseleave: "mouseout"
1108  });
1109  if (d3_document) {
1110  d3_selection_onFilters.forEach(function(k) {
1111  if ("on" + k in d3_document) d3_selection_onFilters.remove(k);
1112  });
1113  }
1114  function d3_selection_onListener(listener, argumentz) {
1115  return function(e) {
1116  var o = d3.event;
1117  d3.event = e;
1118  argumentz[0] = this.__data__;
1119  try {
1120  listener.apply(this, argumentz);
1121  } finally {
1122  d3.event = o;
1123  }
1124  };
1125  }
1126  function d3_selection_onFilter(listener, argumentz) {
1127  var l = d3_selection_onListener(listener, argumentz);
1128  return function(e) {
1129  var target = this, related = e.relatedTarget;
1130  if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) {
1131  l.call(target, e);
1132  }
1133  };
1134  }
1135  var d3_event_dragSelect, d3_event_dragId = 0;
1136  function d3_event_dragSuppress(node) {
1137  var name = ".dragsuppress-" + ++d3_event_dragId, click = "click" + name, w = d3.select(d3_window(node)).on("touchmove" + name, d3_eventPreventDefault).on("dragstart" + name, d3_eventPreventDefault).on("selectstart" + name, d3_eventPreventDefault);
1138  if (d3_event_dragSelect == null) {
1139  d3_event_dragSelect = "onselectstart" in node ? false : d3_vendorSymbol(node.style, "userSelect");
1140  }
1141  if (d3_event_dragSelect) {
1142  var style = d3_documentElement(node).style, select = style[d3_event_dragSelect];
1143  style[d3_event_dragSelect] = "none";
1144  }
1145  return function(suppressClick) {
1146  w.on(name, null);
1147  if (d3_event_dragSelect) style[d3_event_dragSelect] = select;
1148  if (suppressClick) {
1149  var off = function() {
1150  w.on(click, null);
1151  };
1152  w.on(click, function() {
1153  d3_eventPreventDefault();
1154  off();
1155  }, true);
1156  setTimeout(off, 0);
1157  }
1158  };
1159  }
1160  d3.mouse = function(container) {
1161  return d3_mousePoint(container, d3_eventSource());
1162  };
1163  var d3_mouse_bug44083 = this.navigator && /WebKit/.test(this.navigator.userAgent) ? -1 : 0;
1164  function d3_mousePoint(container, e) {
1165  if (e.changedTouches) e = e.changedTouches[0];
1166  var svg = container.ownerSVGElement || container;
1167  if (svg.createSVGPoint) {
1168  var point = svg.createSVGPoint();
1169  if (d3_mouse_bug44083 < 0) {
1170  var window = d3_window(container);
1171  if (window.scrollX || window.scrollY) {
1172  svg = d3.select("body").append("svg").style({
1173  position: "absolute",
1174  top: 0,
1175  left: 0,
1176  margin: 0,
1177  padding: 0,
1178  border: "none"
1179  }, "important");
1180  var ctm = svg[0][0].getScreenCTM();
1181  d3_mouse_bug44083 = !(ctm.f || ctm.e);
1182  svg.remove();
1183  }
1184  }
1185  if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX,
1186  point.y = e.clientY;
1187  point = point.matrixTransform(container.getScreenCTM().inverse());
1188  return [ point.x, point.y ];
1189  }
1190  var rect = container.getBoundingClientRect();
1191  return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];
1192  }
1193  d3.touch = function(container, touches, identifier) {
1194  if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches;
1195  if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) {
1196  if ((touch = touches[i]).identifier === identifier) {
1197  return d3_mousePoint(container, touch);
1198  }
1199  }
1200  };
1201  d3.behavior.drag = function() {
1202  var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_window, "mousemove", "mouseup"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_identity, "touchmove", "touchend");
1203  function drag() {
1204  this.on("mousedown.drag", mousedown).on("touchstart.drag", touchstart);
1205  }
1206  function dragstart(id, position, subject, move, end) {
1207  return function() {
1208  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(target)).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(target), position0 = position(parent, dragId);
1209  if (origin) {
1210  dragOffset = origin.apply(that, arguments);
1211  dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ];
1212  } else {
1213  dragOffset = [ 0, 0 ];
1214  }
1215  dispatch({
1216  type: "dragstart"
1217  });
1218  function moved() {
1219  var position1 = position(parent, dragId), dx, dy;
1220  if (!position1) return;
1221  dx = position1[0] - position0[0];
1222  dy = position1[1] - position0[1];
1223  dragged |= dx | dy;
1224  position0 = position1;
1225  dispatch({
1226  type: "drag",
1227  x: position1[0] + dragOffset[0],
1228  y: position1[1] + dragOffset[1],
1229  dx: dx,
1230  dy: dy
1231  });
1232  }
1233  function ended() {
1234  if (!position(parent, dragId)) return;
1235  dragSubject.on(move + dragName, null).on(end + dragName, null);
1236  dragRestore(dragged && d3.event.target === target);
1237  dispatch({
1238  type: "dragend"
1239  });
1240  }
1241  };
1242  }
1243  drag.origin = function(x) {
1244  if (!arguments.length) return origin;
1245  origin = x;
1246  return drag;
1247  };
1248  return d3.rebind(drag, event, "on");
1249  };
1250  function d3_behavior_dragTouchId() {
1251  return d3.event.changedTouches[0].identifier;
1252  }
1253  d3.touches = function(container, touches) {
1254  if (arguments.length < 2) touches = d3_eventSource().touches;
1255  return touches ? d3_array(touches).map(function(touch) {
1256  var point = d3_mousePoint(container, touch);
1257  point.identifier = touch.identifier;
1258  return point;
1259  }) : [];
1260  };
1261  var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;
1262  function d3_sgn(x) {
1263  return x > 0 ? 1 : x < 0 ? -1 : 0;
1264  }
1265  function d3_cross2d(a, b, c) {
1266  return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
1267  }
1268  function d3_acos(x) {
1269  return x > 1 ? 0 : x < -1 ? π : Math.acos(x);
1270  }
1271  function d3_asin(x) {
1272  return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x);
1273  }
1274  function d3_sinh(x) {
1275  return ((x = Math.exp(x)) - 1 / x) / 2;
1276  }
1277  function d3_cosh(x) {
1278  return ((x = Math.exp(x)) + 1 / x) / 2;
1279  }
1280  function d3_tanh(x) {
1281  return ((x = Math.exp(2 * x)) - 1) / (x + 1);
1282  }
1283  function d3_haversin(x) {
1284  return (x = Math.sin(x / 2)) * x;
1285  }
1286  var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4;
1287  d3.interpolateZoom = function(p0, p1) {
1288  var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2];
1289  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)) / ρ;
1290  function interpolate(t) {
1291  var s = t * S;
1292  if (dr) {
1293  var coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0));
1294  return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ];
1295  }
1296  return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * s) ];
1297  }
1298  interpolate.duration = S * 1e3;
1299  return interpolate;
1300  };
1301  d3.behavior.zoom = function() {
1302  var view = {
1303  x: 0,
1304  y: 0,
1305  k: 1
1306  }, 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;
1307  if (!d3_behavior_zoomWheel) {
1308  d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() {
1309  return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1);
1310  }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() {
1311  return d3.event.wheelDelta;
1312  }, "mousewheel") : (d3_behavior_zoomDelta = function() {
1313  return -d3.event.detail;
1314  }, "MozMousePixelScroll");
1315  }
1316  function zoom(g) {
1317  g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted);
1318  }
1319  zoom.event = function(g) {
1320  g.each(function() {
1321  var dispatch = event.of(this, arguments), view1 = view;
1322  if (d3_transitionInheritId) {
1323  d3.select(this).transition().each("start.zoom", function() {
1324  view = this.__chart__ || {
1325  x: 0,
1326  y: 0,
1327  k: 1
1328  };
1329  zoomstarted(dispatch);
1330  }).tween("zoom:zoom", function() {
1331  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 ]);
1332  return function(t) {
1333  var l = i(t), k = dx / l[2];
1334  this.__chart__ = view = {
1335  x: cx - l[0] * k,
1336  y: cy - l[1] * k,
1337  k: k
1338  };
1339  zoomed(dispatch);
1340  };
1341  }).each("interrupt.zoom", function() {
1342  zoomended(dispatch);
1343  }).each("end.zoom", function() {
1344  zoomended(dispatch);
1345  });
1346  } else {
1347  this.__chart__ = view;
1348  zoomstarted(dispatch);
1349  zoomed(dispatch);
1350  zoomended(dispatch);
1351  }
1352  });
1353  };
1354  zoom.translate = function(_) {
1355  if (!arguments.length) return [ view.x, view.y ];
1356  view = {
1357  x: +_[0],
1358  y: +_[1],
1359  k: view.k
1360  };
1361  rescale();
1362  return zoom;
1363  };
1364  zoom.scale = function(_) {
1365  if (!arguments.length) return view.k;
1366  view = {
1367  x: view.x,
1368  y: view.y,
1369  k: +_
1370  };
1371  rescale();
1372  return zoom;
1373  };
1374  zoom.scaleExtent = function(_) {
1375  if (!arguments.length) return scaleExtent;
1376  scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ];
1377  return zoom;
1378  };
1379  zoom.center = function(_) {
1380  if (!arguments.length) return center;
1381  center = _ && [ +_[0], +_[1] ];
1382  return zoom;
1383  };
1384  zoom.size = function(_) {
1385  if (!arguments.length) return size;
1386  size = _ && [ +_[0], +_[1] ];
1387  return zoom;
1388  };
1389  zoom.duration = function(_) {
1390  if (!arguments.length) return duration;
1391  duration = +_;
1392  return zoom;
1393  };
1394  zoom.x = function(z) {
1395  if (!arguments.length) return x1;
1396  x1 = z;
1397  x0 = z.copy();
1398  view = {
1399  x: 0,
1400  y: 0,
1401  k: 1
1402  };
1403  return zoom;
1404  };
1405  zoom.y = function(z) {
1406  if (!arguments.length) return y1;
1407  y1 = z;
1408  y0 = z.copy();
1409  view = {
1410  x: 0,
1411  y: 0,
1412  k: 1
1413  };
1414  return zoom;
1415  };
1416  function location(p) {
1417  return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ];
1418  }
1419  function point(l) {
1420  return [ l[0] * view.k + view.x, l[1] * view.k + view.y ];
1421  }
1422  function scaleTo(s) {
1423  view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));
1424  }
1425  function translateTo(p, l) {
1426  l = point(l);
1427  view.x += p[0] - l[0];
1428  view.y += p[1] - l[1];
1429  }
1430  function zoomTo(that, p, l, k) {
1431  that.__chart__ = {
1432  x: view.x,
1433  y: view.y,
1434  k: view.k
1435  };
1436  scaleTo(Math.pow(2, k));
1437  translateTo(center0 = p, l);
1438  that = d3.select(that);
1439  if (duration > 0) that = that.transition().duration(duration);
1440  that.call(zoom.event);
1441  }
1442  function rescale() {
1443  if (x1) x1.domain(x0.range().map(function(x) {
1444  return (x - view.x) / view.k;
1445  }).map(x0.invert));
1446  if (y1) y1.domain(y0.range().map(function(y) {
1447  return (y - view.y) / view.k;
1448  }).map(y0.invert));
1449  }
1450  function zoomstarted(dispatch) {
1451  if (!zooming++) dispatch({
1452  type: "zoomstart"
1453  });
1454  }
1455  function zoomed(dispatch) {
1456  rescale();
1457  dispatch({
1458  type: "zoom",
1459  scale: view.k,
1460  translate: [ view.x, view.y ]
1461  });
1462  }
1463  function zoomended(dispatch) {
1464  if (!--zooming) dispatch({
1465  type: "zoomend"
1466  });
1467  center0 = null;
1468  }
1469  function mousedowned() {
1470  var that = this, target = d3.event.target, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(that);
1471  d3_selection_interrupt.call(that);
1472  zoomstarted(dispatch);
1473  function moved() {
1474  dragged = 1;
1475  translateTo(d3.mouse(that), location0);
1476  zoomed(dispatch);
1477  }
1478  function ended() {
1479  subject.on(mousemove, null).on(mouseup, null);
1480  dragRestore(dragged && d3.event.target === target);
1481  zoomended(dispatch);
1482  }
1483  }
1484  function touchstarted() {
1485  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(that);
1486  started();
1487  zoomstarted(dispatch);
1488  subject.on(mousedown, null).on(touchstart, started);
1489  function relocate() {
1490  var touches = d3.touches(that);
1491  scale0 = view.k;
1492  touches.forEach(function(t) {
1493  if (t.identifier in locations0) locations0[t.identifier] = location(t);
1494  });
1495  return touches;
1496  }
1497  function started() {
1498  var target = d3.event.target;
1499  d3.select(target).on(touchmove, moved).on(touchend, ended);
1500  targets.push(target);
1501  var changed = d3.event.changedTouches;
1502  for (var i = 0, n = changed.length; i < n; ++i) {
1503  locations0[changed[i].identifier] = null;
1504  }
1505  var touches = relocate(), now = Date.now();
1506  if (touches.length === 1) {
1507  if (now - touchtime < 500) {
1508  var p = touches[0];
1509  zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1);
1510  d3_eventPreventDefault();
1511  }
1512  touchtime = now;
1513  } else if (touches.length > 1) {
1514  var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1];
1515  distance0 = dx * dx + dy * dy;
1516  }
1517  }
1518  function moved() {
1519  var touches = d3.touches(that), p0, l0, p1, l1;
1520  d3_selection_interrupt.call(that);
1521  for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {
1522  p1 = touches[i];
1523  if (l1 = locations0[p1.identifier]) {
1524  if (l0) break;
1525  p0 = p1, l0 = l1;
1526  }
1527  }
1528  if (l1) {
1529  var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0);
1530  p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];
1531  l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];
1532  scaleTo(scale1 * scale0);
1533  }
1534  touchtime = null;
1535  translateTo(p0, l0);
1536  zoomed(dispatch);
1537  }
1538  function ended() {
1539  if (d3.event.touches.length) {
1540  var changed = d3.event.changedTouches;
1541  for (var i = 0, n = changed.length; i < n; ++i) {
1542  delete locations0[changed[i].identifier];
1543  }
1544  for (var identifier in locations0) {
1545  return void relocate();
1546  }
1547  }
1548  d3.selectAll(targets).on(zoomName, null);
1549  subject.on(mousedown, mousedowned).on(touchstart, touchstarted);
1550  dragRestore();
1551  zoomended(dispatch);
1552  }
1553  }
1554  function mousewheeled() {
1555  var dispatch = event.of(this, arguments);
1556  if (mousewheelTimer) clearTimeout(mousewheelTimer); else translate0 = location(center0 = center || d3.mouse(this)),
1557  d3_selection_interrupt.call(this), zoomstarted(dispatch);
1558  mousewheelTimer = setTimeout(function() {
1559  mousewheelTimer = null;
1560  zoomended(dispatch);
1561  }, 50);
1562  d3_eventPreventDefault();
1563  scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k);
1564  translateTo(center0, translate0);
1565  zoomed(dispatch);
1566  }
1567  function dblclicked() {
1568  var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2;
1569  zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1);
1570  }
1571  return d3.rebind(zoom, event, "on");
1572  };
1573  var d3_behavior_zoomInfinity = [ 0, Infinity ], d3_behavior_zoomDelta, d3_behavior_zoomWheel;
1574  d3.color = d3_color;
1575  function d3_color() {}
1576  d3_color.prototype.toString = function() {
1577  return this.rgb() + "";
1578  };
1579  d3.hsl = d3_hsl;
1580  function d3_hsl(h, s, l) {
1581  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);
1582  }
1583  var d3_hslPrototype = d3_hsl.prototype = new d3_color();
1584  d3_hslPrototype.brighter = function(k) {
1585  k = Math.pow(.7, arguments.length ? k : 1);
1586  return new d3_hsl(this.h, this.s, this.l / k);
1587  };
1588  d3_hslPrototype.darker = function(k) {
1589  k = Math.pow(.7, arguments.length ? k : 1);
1590  return new d3_hsl(this.h, this.s, k * this.l);
1591  };
1592  d3_hslPrototype.rgb = function() {
1593  return d3_hsl_rgb(this.h, this.s, this.l);
1594  };
1595  function d3_hsl_rgb(h, s, l) {
1596  var m1, m2;
1597  h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h;
1598  s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s;
1599  l = l < 0 ? 0 : l > 1 ? 1 : l;
1600  m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
1601  m1 = 2 * l - m2;
1602  function v(h) {
1603  if (h > 360) h -= 360; else if (h < 0) h += 360;
1604  if (h < 60) return m1 + (m2 - m1) * h / 60;
1605  if (h < 180) return m2;
1606  if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
1607  return m1;
1608  }
1609  function vv(h) {
1610  return Math.round(v(h) * 255);
1611  }
1612  return new d3_rgb(vv(h + 120), vv(h), vv(h - 120));
1613  }
1614  d3.hcl = d3_hcl;
1615  function d3_hcl(h, c, l) {
1616  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);
1617  }
1618  var d3_hclPrototype = d3_hcl.prototype = new d3_color();
1619  d3_hclPrototype.brighter = function(k) {
1620  return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));
1621  };
1622  d3_hclPrototype.darker = function(k) {
1623  return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));
1624  };
1625  d3_hclPrototype.rgb = function() {
1626  return d3_hcl_lab(this.h, this.c, this.l).rgb();
1627  };
1628  function d3_hcl_lab(h, c, l) {
1629  if (isNaN(h)) h = 0;
1630  if (isNaN(c)) c = 0;
1631  return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);
1632  }
1633  d3.lab = d3_lab;
1634  function d3_lab(l, a, b) {
1635  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);
1636  }
1637  var d3_lab_K = 18;
1638  var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;
1639  var d3_labPrototype = d3_lab.prototype = new d3_color();
1640  d3_labPrototype.brighter = function(k) {
1641  return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1642  };
1643  d3_labPrototype.darker = function(k) {
1644  return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
1645  };
1646  d3_labPrototype.rgb = function() {
1647  return d3_lab_rgb(this.l, this.a, this.b);
1648  };
1649  function d3_lab_rgb(l, a, b) {
1650  var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200;
1651  x = d3_lab_xyz(x) * d3_lab_X;
1652  y = d3_lab_xyz(y) * d3_lab_Y;
1653  z = d3_lab_xyz(z) * d3_lab_Z;
1654  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));
1655  }
1656  function d3_lab_hcl(l, a, b) {
1657  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);
1658  }
1659  function d3_lab_xyz(x) {
1660  return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;
1661  }
1662  function d3_xyz_lab(x) {
1663  return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;
1664  }
1665  function d3_xyz_rgb(r) {
1666  return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055));
1667  }
1668  d3.rgb = d3_rgb;
1669  function d3_rgb(r, g, b) {
1670  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);
1671  }
1672  function d3_rgbNumber(value) {
1673  return new d3_rgb(value >> 16, value >> 8 & 255, value & 255);
1674  }
1675  function d3_rgbString(value) {
1676  return d3_rgbNumber(value) + "";
1677  }
1678  var d3_rgbPrototype = d3_rgb.prototype = new d3_color();
1679  d3_rgbPrototype.brighter = function(k) {
1680  k = Math.pow(.7, arguments.length ? k : 1);
1681  var r = this.r, g = this.g, b = this.b, i = 30;
1682  if (!r && !g && !b) return new d3_rgb(i, i, i);
1683  if (r && r < i) r = i;
1684  if (g && g < i) g = i;
1685  if (b && b < i) b = i;
1686  return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k));
1687  };
1688  d3_rgbPrototype.darker = function(k) {
1689  k = Math.pow(.7, arguments.length ? k : 1);
1690  return new d3_rgb(k * this.r, k * this.g, k * this.b);
1691  };
1692  d3_rgbPrototype.hsl = function() {
1693  return d3_rgb_hsl(this.r, this.g, this.b);
1694  };
1695  d3_rgbPrototype.toString = function() {
1696  return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);
1697  };
1698  function d3_rgb_hex(v) {
1699  return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);
1700  }
1701  function d3_rgb_parse(format, rgb, hsl) {
1702  var r = 0, g = 0, b = 0, m1, m2, color;
1703  m1 = /([a-z]+)\((.*)\)/i.exec(format);
1704  if (m1) {
1705  m2 = m1[2].split(",");
1706  switch (m1[1]) {
1707  case "hsl":
1708  {
1709  return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100);
1710  }
1711 
1712  case "rgb":
1713  {
1714  return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2]));
1715  }
1716  }
1717  }
1718  if (color = d3_rgb_names.get(format.toLowerCase())) {
1719  return rgb(color.r, color.g, color.b);
1720  }
1721  if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) {
1722  if (format.length === 4) {
1723  r = (color & 3840) >> 4;
1724  r = r >> 4 | r;
1725  g = color & 240;
1726  g = g >> 4 | g;
1727  b = color & 15;
1728  b = b << 4 | b;
1729  } else if (format.length === 7) {
1730  r = (color & 16711680) >> 16;
1731  g = (color & 65280) >> 8;
1732  b = color & 255;
1733  }
1734  }
1735  return rgb(r, g, b);
1736  }
1737  function d3_rgb_hsl(r, g, b) {
1738  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;
1739  if (d) {
1740  s = l < .5 ? d / (max + min) : d / (2 - max - min);
1741  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;
1742  h *= 60;
1743  } else {
1744  h = NaN;
1745  s = l > 0 && l < 1 ? 0 : h;
1746  }
1747  return new d3_hsl(h, s, l);
1748  }
1749  function d3_rgb_lab(r, g, b) {
1750  r = d3_rgb_xyz(r);
1751  g = d3_rgb_xyz(g);
1752  b = d3_rgb_xyz(b);
1753  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);
1754  return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z));
1755  }
1756  function d3_rgb_xyz(r) {
1757  return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4);
1758  }
1759  function d3_rgb_parseNumber(c) {
1760  var f = parseFloat(c);
1761  return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f;
1762  }
1763  var d3_rgb_names = d3.map({
1764  aliceblue: 15792383,
1765  antiquewhite: 16444375,
1766  aqua: 65535,
1767  aquamarine: 8388564,
1768  azure: 15794175,
1769  beige: 16119260,
1770  bisque: 16770244,
1771  black: 0,
1772  blanchedalmond: 16772045,
1773  blue: 255,
1774  blueviolet: 9055202,
1775  brown: 10824234,
1776  burlywood: 14596231,
1777  cadetblue: 6266528,
1778  chartreuse: 8388352,
1779  chocolate: 13789470,
1780  coral: 16744272,
1781  cornflowerblue: 6591981,
1782  cornsilk: 16775388,
1783  crimson: 14423100,
1784  cyan: 65535,
1785  darkblue: 139,
1786  darkcyan: 35723,
1787  darkgoldenrod: 12092939,
1788  darkgray: 11119017,
1789  darkgreen: 25600,
1790  darkgrey: 11119017,
1791  darkkhaki: 12433259,
1792  darkmagenta: 9109643,
1793  darkolivegreen: 5597999,
1794  darkorange: 16747520,
1795  darkorchid: 10040012,
1796  darkred: 9109504,
1797  darksalmon: 15308410,
1798  darkseagreen: 9419919,
1799  darkslateblue: 4734347,
1800  darkslategray: 3100495,
1801  darkslategrey: 3100495,
1802  darkturquoise: 52945,
1803  darkviolet: 9699539,
1804  deeppink: 16716947,
1805  deepskyblue: 49151,
1806  dimgray: 6908265,
1807  dimgrey: 6908265,
1808  dodgerblue: 2003199,
1809  firebrick: 11674146,
1810  floralwhite: 16775920,
1811  forestgreen: 2263842,
1812  fuchsia: 16711935,
1813  gainsboro: 14474460,
1814  ghostwhite: 16316671,
1815  gold: 16766720,
1816  goldenrod: 14329120,
1817  gray: 8421504,
1818  green: 32768,
1819  greenyellow: 11403055,
1820  grey: 8421504,
1821  honeydew: 15794160,
1822  hotpink: 16738740,
1823  indianred: 13458524,
1824  indigo: 4915330,
1825  ivory: 16777200,
1826  khaki: 15787660,
1827  lavender: 15132410,
1828  lavenderblush: 16773365,
1829  lawngreen: 8190976,
1830  lemonchiffon: 16775885,
1831  lightblue: 11393254,
1832  lightcoral: 15761536,
1833  lightcyan: 14745599,
1834  lightgoldenrodyellow: 16448210,
1835  lightgray: 13882323,
1836  lightgreen: 9498256,
1837  lightgrey: 13882323,
1838  lightpink: 16758465,
1839  lightsalmon: 16752762,
1840  lightseagreen: 2142890,
1841  lightskyblue: 8900346,
1842  lightslategray: 7833753,
1843  lightslategrey: 7833753,
1844  lightsteelblue: 11584734,
1845  lightyellow: 16777184,
1846  lime: 65280,
1847  limegreen: 3329330,
1848  linen: 16445670,
1849  magenta: 16711935,
1850  maroon: 8388608,
1851  mediumaquamarine: 6737322,
1852  mediumblue: 205,
1853  mediumorchid: 12211667,
1854  mediumpurple: 9662683,
1855  mediumseagreen: 3978097,
1856  mediumslateblue: 8087790,
1857  mediumspringgreen: 64154,
1858  mediumturquoise: 4772300,
1859  mediumvioletred: 13047173,
1860  midnightblue: 1644912,
1861  mintcream: 16121850,
1862  mistyrose: 16770273,
1863  moccasin: 16770229,
1864  navajowhite: 16768685,
1865  navy: 128,
1866  oldlace: 16643558,
1867  olive: 8421376,
1868  olivedrab: 7048739,
1869  orange: 16753920,
1870  orangered: 16729344,
1871  orchid: 14315734,
1872  palegoldenrod: 15657130,
1873  palegreen: 10025880,
1874  paleturquoise: 11529966,
1875  palevioletred: 14381203,
1876  papayawhip: 16773077,
1877  peachpuff: 16767673,
1878  peru: 13468991,
1879  pink: 16761035,
1880  plum: 14524637,
1881  powderblue: 11591910,
1882  purple: 8388736,
1883  rebeccapurple: 6697881,
1884  red: 16711680,
1885  rosybrown: 12357519,
1886  royalblue: 4286945,
1887  saddlebrown: 9127187,
1888  salmon: 16416882,
1889  sandybrown: 16032864,
1890  seagreen: 3050327,
1891  seashell: 16774638,
1892  sienna: 10506797,
1893  silver: 12632256,
1894  skyblue: 8900331,
1895  slateblue: 6970061,
1896  slategray: 7372944,
1897  slategrey: 7372944,
1898  snow: 16775930,
1899  springgreen: 65407,
1900  steelblue: 4620980,
1901  tan: 13808780,
1902  teal: 32896,
1903  thistle: 14204888,
1904  tomato: 16737095,
1905  turquoise: 4251856,
1906  violet: 15631086,
1907  wheat: 16113331,
1908  white: 16777215,
1909  whitesmoke: 16119285,
1910  yellow: 16776960,
1911  yellowgreen: 10145074
1912  });
1913  d3_rgb_names.forEach(function(key, value) {
1914  d3_rgb_names.set(key, d3_rgbNumber(value));
1915  });
1916  function d3_functor(v) {
1917  return typeof v === "function" ? v : function() {
1918  return v;
1919  };
1920  }
1921  d3.functor = d3_functor;
1922  d3.xhr = d3_xhrType(d3_identity);
1923  function d3_xhrType(response) {
1924  return function(url, mimeType, callback) {
1925  if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType,
1926  mimeType = null;
1927  return d3_xhr(url, mimeType, response, callback);
1928  };
1929  }
1930  function d3_xhr(url, mimeType, response, callback) {
1931  var xhr = {}, dispatch = d3.dispatch("beforesend", "progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null;
1932  if (this.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest();
1933  "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {
1934  request.readyState > 3 && respond();
1935  };
1936  function respond() {
1937  var status = request.status, result;
1938  if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) {
1939  try {
1940  result = response.call(xhr, request);
1941  } catch (e) {
1942  dispatch.error.call(xhr, e);
1943  return;
1944  }
1945  dispatch.load.call(xhr, result);
1946  } else {
1947  dispatch.error.call(xhr, request);
1948  }
1949  }
1950  request.onprogress = function(event) {
1951  var o = d3.event;
1952  d3.event = event;
1953  try {
1954  dispatch.progress.call(xhr, request);
1955  } finally {
1956  d3.event = o;
1957  }
1958  };
1959  xhr.header = function(name, value) {
1960  name = (name + "").toLowerCase();
1961  if (arguments.length < 2) return headers[name];
1962  if (value == null) delete headers[name]; else headers[name] = value + "";
1963  return xhr;
1964  };
1965  xhr.mimeType = function(value) {
1966  if (!arguments.length) return mimeType;
1967  mimeType = value == null ? null : value + "";
1968  return xhr;
1969  };
1970  xhr.responseType = function(value) {
1971  if (!arguments.length) return responseType;
1972  responseType = value;
1973  return xhr;
1974  };
1975  xhr.response = function(value) {
1976  response = value;
1977  return xhr;
1978  };
1979  [ "get", "post" ].forEach(function(method) {
1980  xhr[method] = function() {
1981  return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments)));
1982  };
1983  });
1984  xhr.send = function(method, data, callback) {
1985  if (arguments.length === 2 && typeof data === "function") callback = data, data = null;
1986  request.open(method, url, true);
1987  if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*";
1988  if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]);
1989  if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType);
1990  if (responseType != null) request.responseType = responseType;
1991  if (callback != null) xhr.on("error", callback).on("load", function(request) {
1992  callback(null, request);
1993  });
1994  dispatch.beforesend.call(xhr, request);
1995  request.send(data == null ? null : data);
1996  return xhr;
1997  };
1998  xhr.abort = function() {
1999  request.abort();
2000  return xhr;
2001  };
2002  d3.rebind(xhr, dispatch, "on");
2003  return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback));
2004  }
2005  function d3_xhr_fixCallback(callback) {
2006  return callback.length === 1 ? function(error, request) {
2007  callback(error == null ? request : null);
2008  } : callback;
2009  }
2010  function d3_xhrHasResponse(request) {
2011  var type = request.responseType;
2012  return type && type !== "text" ? request.response : request.responseText;
2013  }
2014  d3.dsv = function(delimiter, mimeType) {
2015  var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0);
2016  function dsv(url, row, callback) {
2017  if (arguments.length < 3) callback = row, row = null;
2018  var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback);
2019  xhr.row = function(_) {
2020  return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row;
2021  };
2022  return xhr;
2023  }
2024  function response(request) {
2025  return dsv.parse(request.responseText);
2026  }
2027  function typedResponse(f) {
2028  return function(request) {
2029  return dsv.parse(request.responseText, f);
2030  };
2031  }
2032  dsv.parse = function(text, f) {
2033  var o;
2034  return dsv.parseRows(text, function(row, i) {
2035  if (o) return o(row, i - 1);
2036  var a = new Function("d", "return {" + row.map(function(name, i) {
2037  return JSON.stringify(name) + ": d[" + i + "]";
2038  }).join(",") + "}");
2039  o = f ? function(row, i) {
2040  return f(a(row), i);
2041  } : a;
2042  });
2043  };
2044  dsv.parseRows = function(text, f) {
2045  var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol;
2046  function token() {
2047  if (I >= N) return EOF;
2048  if (eol) return eol = false, EOL;
2049  var j = I;
2050  if (text.charCodeAt(j) === 34) {
2051  var i = j;
2052  while (i++ < N) {
2053  if (text.charCodeAt(i) === 34) {
2054  if (text.charCodeAt(i + 1) !== 34) break;
2055  ++i;
2056  }
2057  }
2058  I = i + 2;
2059  var c = text.charCodeAt(i + 1);
2060  if (c === 13) {
2061  eol = true;
2062  if (text.charCodeAt(i + 2) === 10) ++I;
2063  } else if (c === 10) {
2064  eol = true;
2065  }
2066  return text.slice(j + 1, i).replace(/""/g, '"');
2067  }
2068  while (I < N) {
2069  var c = text.charCodeAt(I++), k = 1;
2070  if (c === 10) eol = true; else if (c === 13) {
2071  eol = true;
2072  if (text.charCodeAt(I) === 10) ++I, ++k;
2073  } else if (c !== delimiterCode) continue;
2074  return text.slice(j, I - k);
2075  }
2076  return text.slice(j);
2077  }
2078  while ((t = token()) !== EOF) {
2079  var a = [];
2080  while (t !== EOL && t !== EOF) {
2081  a.push(t);
2082  t = token();
2083  }
2084  if (f && (a = f(a, n++)) == null) continue;
2085  rows.push(a);
2086  }
2087  return rows;
2088  };
2089  dsv.format = function(rows) {
2090  if (Array.isArray(rows[0])) return dsv.formatRows(rows);
2091  var fieldSet = new d3_Set(), fields = [];
2092  rows.forEach(function(row) {
2093  for (var field in row) {
2094  if (!fieldSet.has(field)) {
2095  fields.push(fieldSet.add(field));
2096  }
2097  }
2098  });
2099  return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) {
2100  return fields.map(function(field) {
2101  return formatValue(row[field]);
2102  }).join(delimiter);
2103  })).join("\n");
2104  };
2105  dsv.formatRows = function(rows) {
2106  return rows.map(formatRow).join("\n");
2107  };
2108  function formatRow(row) {
2109  return row.map(formatValue).join(delimiter);
2110  }
2111  function formatValue(text) {
2112  return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text;
2113  }
2114  return dsv;
2115  };
2116  d3.csv = d3.dsv(",", "text/csv");
2117  d3.tsv = d3.dsv(" ", "text/tab-separated-values");
2118  var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_active, d3_timer_frame = this[d3_vendorSymbol(this, "requestAnimationFrame")] || function(callback) {
2119  setTimeout(callback, 17);
2120  };
2121  d3.timer = function(callback, delay, then) {
2122  var n = arguments.length;
2123  if (n < 2) delay = 0;
2124  if (n < 3) then = Date.now();
2125  var time = then + delay, timer = {
2126  c: callback,
2127  t: time,
2128  f: false,
2129  n: null
2130  };
2131  if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer;
2132  d3_timer_queueTail = timer;
2133  if (!d3_timer_interval) {
2134  d3_timer_timeout = clearTimeout(d3_timer_timeout);
2135  d3_timer_interval = 1;
2136  d3_timer_frame(d3_timer_step);
2137  }
2138  };
2139  function d3_timer_step() {
2140  var now = d3_timer_mark(), delay = d3_timer_sweep() - now;
2141  if (delay > 24) {
2142  if (isFinite(delay)) {
2143  clearTimeout(d3_timer_timeout);
2144  d3_timer_timeout = setTimeout(d3_timer_step, delay);
2145  }
2146  d3_timer_interval = 0;
2147  } else {
2148  d3_timer_interval = 1;
2149  d3_timer_frame(d3_timer_step);
2150  }
2151  }
2152  d3.timer.flush = function() {
2153  d3_timer_mark();
2154  d3_timer_sweep();
2155  };
2156  function d3_timer_mark() {
2157  var now = Date.now();
2158  d3_timer_active = d3_timer_queueHead;
2159  while (d3_timer_active) {
2160  if (now >= d3_timer_active.t) d3_timer_active.f = d3_timer_active.c(now - d3_timer_active.t);
2161  d3_timer_active = d3_timer_active.n;
2162  }
2163  return now;
2164  }
2165  function d3_timer_sweep() {
2166  var t0, t1 = d3_timer_queueHead, time = Infinity;
2167  while (t1) {
2168  if (t1.f) {
2169  t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n;
2170  } else {
2171  if (t1.t < time) time = t1.t;
2172  t1 = (t0 = t1).n;
2173  }
2174  }
2175  d3_timer_queueTail = t0;
2176  return time;
2177  }
2178  function d3_format_precision(x, p) {
2179  return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1);
2180  }
2181  d3.round = function(x, n) {
2182  return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);
2183  };
2184  var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix);
2185  d3.formatPrefix = function(value, precision) {
2186  var i = 0;
2187  if (value) {
2188  if (value < 0) value *= -1;
2189  if (precision) value = d3.round(value, d3_format_precision(value, precision));
2190  i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
2191  i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3));
2192  }
2193  return d3_formatPrefixes[8 + i / 3];
2194  };
2195  function d3_formatPrefix(d, i) {
2196  var k = Math.pow(10, abs(8 - i) * 3);
2197  return {
2198  scale: i > 8 ? function(d) {
2199  return d / k;
2200  } : function(d) {
2201  return d * k;
2202  },
2203  symbol: d
2204  };
2205  }
2206  function d3_locale_numberFormat(locale) {
2207  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) {
2208  var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0;
2209  while (i > 0 && g > 0) {
2210  if (length + g + 1 > width) g = Math.max(1, width - length);
2211  t.push(value.substring(i -= g, i + g));
2212  if ((length += g + 1) > width) break;
2213  g = locale_grouping[j = (j + 1) % locale_grouping.length];
2214  }
2215  return t.reverse().join(locale_thousands);
2216  } : d3_identity;
2217  return function(specifier) {
2218  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;
2219  if (precision) precision = +precision.substring(1);
2220  if (zfill || fill === "0" && align === "=") {
2221  zfill = fill = "0";
2222  align = "=";
2223  }
2224  switch (type) {
2225  case "n":
2226  comma = true;
2227  type = "g";
2228  break;
2229 
2230  case "%":
2231  scale = 100;
2232  suffix = "%";
2233  type = "f";
2234  break;
2235 
2236  case "p":
2237  scale = 100;
2238  suffix = "%";
2239  type = "r";
2240  break;
2241 
2242  case "b":
2243  case "o":
2244  case "x":
2245  case "X":
2246  if (symbol === "#") prefix = "0" + type.toLowerCase();
2247 
2248  case "c":
2249  exponent = false;
2250 
2251  case "d":
2252  integer = true;
2253  precision = 0;
2254  break;
2255 
2256  case "s":
2257  scale = -1;
2258  type = "r";
2259  break;
2260  }
2261  if (symbol === "$") prefix = locale_currency[0], suffix = locale_currency[1];
2262  if (type == "r" && !precision) type = "g";
2263  if (precision != null) {
2264  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));
2265  }
2266  type = d3_format_types.get(type) || d3_format_typeDefault;
2267  var zcomma = zfill && comma;
2268  return function(value) {
2269  var fullSuffix = suffix;
2270  if (integer && value % 1) return "";
2271  var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign === "-" ? "" : sign;
2272  if (scale < 0) {
2273  var unit = d3.formatPrefix(value, precision);
2274  value = unit.scale(value);
2275  fullSuffix = unit.symbol + suffix;
2276  } else {
2277  value *= scale;
2278  }
2279  value = type(value, precision);
2280  var i = value.lastIndexOf("."), before, after;
2281  if (i < 0) {
2282  var j = exponent ? value.lastIndexOf("e") : -1;
2283  if (j < 0) before = value, after = ""; else before = value.substring(0, j), after = value.substring(j);
2284  } else {
2285  before = value.substring(0, i);
2286  after = locale_decimal + value.substring(i + 1);
2287  }
2288  if (!zfill && comma) before = formatGroup(before, Infinity);
2289  var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : "";
2290  if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity);
2291  negative += prefix;
2292  value = before + after;
2293  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;
2294  };
2295  };
2296  }
2297  var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i;
2298  var d3_format_types = d3.map({
2299  b: function(x) {
2300  return x.toString(2);
2301  },
2302  c: function(x) {
2303  return String.fromCharCode(x);
2304  },
2305  o: function(x) {
2306  return x.toString(8);
2307  },
2308  x: function(x) {
2309  return x.toString(16);
2310  },
2311  X: function(x) {
2312  return x.toString(16).toUpperCase();
2313  },
2314  g: function(x, p) {
2315  return x.toPrecision(p);
2316  },
2317  e: function(x, p) {
2318  return x.toExponential(p);
2319  },
2320  f: function(x, p) {
2321  return x.toFixed(p);
2322  },
2323  r: function(x, p) {
2324  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))));
2325  }
2326  });
2327  function d3_format_typeDefault(x) {
2328  return x + "";
2329  }
2330  var d3_time = d3.time = {}, d3_date = Date;
2331  function d3_date_utc() {
2332  this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]);
2333  }
2334  d3_date_utc.prototype = {
2335  getDate: function() {
2336  return this._.getUTCDate();
2337  },
2338  getDay: function() {
2339  return this._.getUTCDay();
2340  },
2341  getFullYear: function() {
2342  return this._.getUTCFullYear();
2343  },
2344  getHours: function() {
2345  return this._.getUTCHours();
2346  },
2347  getMilliseconds: function() {
2348  return this._.getUTCMilliseconds();
2349  },
2350  getMinutes: function() {
2351  return this._.getUTCMinutes();
2352  },
2353  getMonth: function() {
2354  return this._.getUTCMonth();
2355  },
2356  getSeconds: function() {
2357  return this._.getUTCSeconds();
2358  },
2359  getTime: function() {
2360  return this._.getTime();
2361  },
2362  getTimezoneOffset: function() {
2363  return 0;
2364  },
2365  valueOf: function() {
2366  return this._.valueOf();
2367  },
2368  setDate: function() {
2369  d3_time_prototype.setUTCDate.apply(this._, arguments);
2370  },
2371  setDay: function() {
2372  d3_time_prototype.setUTCDay.apply(this._, arguments);
2373  },
2374  setFullYear: function() {
2375  d3_time_prototype.setUTCFullYear.apply(this._, arguments);
2376  },
2377  setHours: function() {
2378  d3_time_prototype.setUTCHours.apply(this._, arguments);
2379  },
2380  setMilliseconds: function() {
2381  d3_time_prototype.setUTCMilliseconds.apply(this._, arguments);
2382  },
2383  setMinutes: function() {
2384  d3_time_prototype.setUTCMinutes.apply(this._, arguments);
2385  },
2386  setMonth: function() {
2387  d3_time_prototype.setUTCMonth.apply(this._, arguments);
2388  },
2389  setSeconds: function() {
2390  d3_time_prototype.setUTCSeconds.apply(this._, arguments);
2391  },
2392  setTime: function() {
2393  d3_time_prototype.setTime.apply(this._, arguments);
2394  }
2395  };
2396  var d3_time_prototype = Date.prototype;
2397  function d3_time_interval(local, step, number) {
2398  function round(date) {
2399  var d0 = local(date), d1 = offset(d0, 1);
2400  return date - d0 < d1 - date ? d0 : d1;
2401  }
2402  function ceil(date) {
2403  step(date = local(new d3_date(date - 1)), 1);
2404  return date;
2405  }
2406  function offset(date, k) {
2407  step(date = new d3_date(+date), k);
2408  return date;
2409  }
2410  function range(t0, t1, dt) {
2411  var time = ceil(t0), times = [];
2412  if (dt > 1) {
2413  while (time < t1) {
2414  if (!(number(time) % dt)) times.push(new Date(+time));
2415  step(time, 1);
2416  }
2417  } else {
2418  while (time < t1) times.push(new Date(+time)), step(time, 1);
2419  }
2420  return times;
2421  }
2422  function range_utc(t0, t1, dt) {
2423  try {
2424  d3_date = d3_date_utc;
2425  var utc = new d3_date_utc();
2426  utc._ = t0;
2427  return range(utc, t1, dt);
2428  } finally {
2429  d3_date = Date;
2430  }
2431  }
2432  local.floor = local;
2433  local.round = round;
2434  local.ceil = ceil;
2435  local.offset = offset;
2436  local.range = range;
2437  var utc = local.utc = d3_time_interval_utc(local);
2438  utc.floor = utc;
2439  utc.round = d3_time_interval_utc(round);
2440  utc.ceil = d3_time_interval_utc(ceil);
2441  utc.offset = d3_time_interval_utc(offset);
2442  utc.range = range_utc;
2443  return local;
2444  }
2445  function d3_time_interval_utc(method) {
2446  return function(date, k) {
2447  try {
2448  d3_date = d3_date_utc;
2449  var utc = new d3_date_utc();
2450  utc._ = date;
2451  return method(utc, k)._;
2452  } finally {
2453  d3_date = Date;
2454  }
2455  };
2456  }
2457  d3_time.year = d3_time_interval(function(date) {
2458  date = d3_time.day(date);
2459  date.setMonth(0, 1);
2460  return date;
2461  }, function(date, offset) {
2462  date.setFullYear(date.getFullYear() + offset);
2463  }, function(date) {
2464  return date.getFullYear();
2465  });
2466  d3_time.years = d3_time.year.range;
2467  d3_time.years.utc = d3_time.year.utc.range;
2468  d3_time.day = d3_time_interval(function(date) {
2469  var day = new d3_date(2e3, 0);
2470  day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
2471  return day;
2472  }, function(date, offset) {
2473  date.setDate(date.getDate() + offset);
2474  }, function(date) {
2475  return date.getDate() - 1;
2476  });
2477  d3_time.days = d3_time.day.range;
2478  d3_time.days.utc = d3_time.day.utc.range;
2479  d3_time.dayOfYear = function(date) {
2480  var year = d3_time.year(date);
2481  return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5);
2482  };
2483  [ "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" ].forEach(function(day, i) {
2484  i = 7 - i;
2485  var interval = d3_time[day] = d3_time_interval(function(date) {
2486  (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);
2487  return date;
2488  }, function(date, offset) {
2489  date.setDate(date.getDate() + Math.floor(offset) * 7);
2490  }, function(date) {
2491  var day = d3_time.year(date).getDay();
2492  return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);
2493  });
2494  d3_time[day + "s"] = interval.range;
2495  d3_time[day + "s"].utc = interval.utc.range;
2496  d3_time[day + "OfYear"] = function(date) {
2497  var day = d3_time.year(date).getDay();
2498  return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7);
2499  };
2500  });
2501  d3_time.week = d3_time.sunday;
2502  d3_time.weeks = d3_time.sunday.range;
2503  d3_time.weeks.utc = d3_time.sunday.utc.range;
2504  d3_time.weekOfYear = d3_time.sundayOfYear;
2505  function d3_locale_timeFormat(locale) {
2506  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;
2507  function d3_time_format(template) {
2508  var n = template.length;
2509  function format(date) {
2510  var string = [], i = -1, j = 0, c, p, f;
2511  while (++i < n) {
2512  if (template.charCodeAt(i) === 37) {
2513  string.push(template.slice(j, i));
2514  if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i);
2515  if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p);
2516  string.push(c);
2517  j = i + 1;
2518  }
2519  }
2520  string.push(template.slice(j, i));
2521  return string.join("");
2522  }
2523  format.parse = function(string) {
2524  var d = {
2525  y: 1900,
2526  m: 0,
2527  d: 1,
2528  H: 0,
2529  M: 0,
2530  S: 0,
2531  L: 0,
2532  Z: null
2533  }, i = d3_time_parse(d, template, string, 0);
2534  if (i != string.length) return null;
2535  if ("p" in d) d.H = d.H % 12 + d.p * 12;
2536  var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)();
2537  if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("w" in d && ("W" in d || "U" in d)) {
2538  date.setFullYear(d.y, 0, 1);
2539  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);
2540  } else date.setFullYear(d.y, d.m, d.d);
2541  date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L);
2542  return localZ ? date._ : date;
2543  };
2544  format.toString = function() {
2545  return template;
2546  };
2547  return format;
2548  }
2549  function d3_time_parse(date, template, string, j) {
2550  var c, p, t, i = 0, n = template.length, m = string.length;
2551  while (i < n) {
2552  if (j >= m) return -1;
2553  c = template.charCodeAt(i++);
2554  if (c === 37) {
2555  t = template.charAt(i++);
2556  p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t];
2557  if (!p || (j = p(date, string, j)) < 0) return -1;
2558  } else if (c != string.charCodeAt(j++)) {
2559  return -1;
2560  }
2561  }
2562  return j;
2563  }
2564  d3_time_format.utc = function(template) {
2565  var local = d3_time_format(template);
2566  function format(date) {
2567  try {
2568  d3_date = d3_date_utc;
2569  var utc = new d3_date();
2570  utc._ = date;
2571  return local(utc);
2572  } finally {
2573  d3_date = Date;
2574  }
2575  }
2576  format.parse = function(string) {
2577  try {
2578  d3_date = d3_date_utc;
2579  var date = local.parse(string);
2580  return date && date._;
2581  } finally {
2582  d3_date = Date;
2583  }
2584  };
2585  format.toString = local.toString;
2586  return format;
2587  };
2588  d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti;
2589  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);
2590  locale_periods.forEach(function(p, i) {
2591  d3_time_periodLookup.set(p.toLowerCase(), i);
2592  });
2593  var d3_time_formats = {
2594  a: function(d) {
2595  return locale_shortDays[d.getDay()];
2596  },
2597  A: function(d) {
2598  return locale_days[d.getDay()];
2599  },
2600  b: function(d) {
2601  return locale_shortMonths[d.getMonth()];
2602  },
2603  B: function(d) {
2604  return locale_months[d.getMonth()];
2605  },
2606  c: d3_time_format(locale_dateTime),
2607  d: function(d, p) {
2608  return d3_time_formatPad(d.getDate(), p, 2);
2609  },
2610  e: function(d, p) {
2611  return d3_time_formatPad(d.getDate(), p, 2);
2612  },
2613  H: function(d, p) {
2614  return d3_time_formatPad(d.getHours(), p, 2);
2615  },
2616  I: function(d, p) {
2617  return d3_time_formatPad(d.getHours() % 12 || 12, p, 2);
2618  },
2619  j: function(d, p) {
2620  return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3);
2621  },
2622  L: function(d, p) {
2623  return d3_time_formatPad(d.getMilliseconds(), p, 3);
2624  },
2625  m: function(d, p) {
2626  return d3_time_formatPad(d.getMonth() + 1, p, 2);
2627  },
2628  M: function(d, p) {
2629  return d3_time_formatPad(d.getMinutes(), p, 2);
2630  },
2631  p: function(d) {
2632  return locale_periods[+(d.getHours() >= 12)];
2633  },
2634  S: function(d, p) {
2635  return d3_time_formatPad(d.getSeconds(), p, 2);
2636  },
2637  U: function(d, p) {
2638  return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2);
2639  },
2640  w: function(d) {
2641  return d.getDay();
2642  },
2643  W: function(d, p) {
2644  return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2);
2645  },
2646  x: d3_time_format(locale_date),
2647  X: d3_time_format(locale_time),
2648  y: function(d, p) {
2649  return d3_time_formatPad(d.getFullYear() % 100, p, 2);
2650  },
2651  Y: function(d, p) {
2652  return d3_time_formatPad(d.getFullYear() % 1e4, p, 4);
2653  },
2654  Z: d3_time_zone,
2655  "%": function() {
2656  return "%";
2657  }
2658  };
2659  var d3_time_parsers = {
2660  a: d3_time_parseWeekdayAbbrev,
2661  A: d3_time_parseWeekday,
2662  b: d3_time_parseMonthAbbrev,
2663  B: d3_time_parseMonth,
2664  c: d3_time_parseLocaleFull,
2665  d: d3_time_parseDay,
2666  e: d3_time_parseDay,
2667  H: d3_time_parseHour24,
2668  I: d3_time_parseHour24,
2669  j: d3_time_parseDayOfYear,
2670  L: d3_time_parseMilliseconds,
2671  m: d3_time_parseMonthNumber,
2672  M: d3_time_parseMinutes,
2673  p: d3_time_parseAmPm,
2674  S: d3_time_parseSeconds,
2675  U: d3_time_parseWeekNumberSunday,
2676  w: d3_time_parseWeekdayNumber,
2677  W: d3_time_parseWeekNumberMonday,
2678  x: d3_time_parseLocaleDate,
2679  X: d3_time_parseLocaleTime,
2680  y: d3_time_parseYear,
2681  Y: d3_time_parseFullYear,
2682  Z: d3_time_parseZone,
2683  "%": d3_time_parseLiteralPercent
2684  };
2685  function d3_time_parseWeekdayAbbrev(date, string, i) {
2686  d3_time_dayAbbrevRe.lastIndex = 0;
2687  var n = d3_time_dayAbbrevRe.exec(string.slice(i));
2688  return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2689  }
2690  function d3_time_parseWeekday(date, string, i) {
2691  d3_time_dayRe.lastIndex = 0;
2692  var n = d3_time_dayRe.exec(string.slice(i));
2693  return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2694  }
2695  function d3_time_parseMonthAbbrev(date, string, i) {
2696  d3_time_monthAbbrevRe.lastIndex = 0;
2697  var n = d3_time_monthAbbrevRe.exec(string.slice(i));
2698  return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2699  }
2700  function d3_time_parseMonth(date, string, i) {
2701  d3_time_monthRe.lastIndex = 0;
2702  var n = d3_time_monthRe.exec(string.slice(i));
2703  return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;
2704  }
2705  function d3_time_parseLocaleFull(date, string, i) {
2706  return d3_time_parse(date, d3_time_formats.c.toString(), string, i);
2707  }
2708  function d3_time_parseLocaleDate(date, string, i) {
2709  return d3_time_parse(date, d3_time_formats.x.toString(), string, i);
2710  }
2711  function d3_time_parseLocaleTime(date, string, i) {
2712  return d3_time_parse(date, d3_time_formats.X.toString(), string, i);
2713  }
2714  function d3_time_parseAmPm(date, string, i) {
2715  var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase());
2716  return n == null ? -1 : (date.p = n, i);
2717  }
2718  return d3_time_format;
2719  }
2720  var d3_time_formatPads = {
2721  "-": "",
2722  _: " ",
2723  "0": "0"
2724  }, d3_time_numberRe = /^\s*\d+/, d3_time_percentRe = /^%/;
2725  function d3_time_formatPad(value, fill, width) {
2726  var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length;
2727  return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
2728  }
2729  function d3_time_formatRe(names) {
2730  return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i");
2731  }
2732  function d3_time_formatLookup(names) {
2733  var map = new d3_Map(), i = -1, n = names.length;
2734  while (++i < n) map.set(names[i].toLowerCase(), i);
2735  return map;
2736  }
2737  function d3_time_parseWeekdayNumber(date, string, i) {
2738  d3_time_numberRe.lastIndex = 0;
2739  var n = d3_time_numberRe.exec(string.slice(i, i + 1));
2740  return n ? (date.w = +n[0], i + n[0].length) : -1;
2741  }
2742  function d3_time_parseWeekNumberSunday(date, string, i) {
2743  d3_time_numberRe.lastIndex = 0;
2744  var n = d3_time_numberRe.exec(string.slice(i));
2745  return n ? (date.U = +n[0], i + n[0].length) : -1;
2746  }
2747  function d3_time_parseWeekNumberMonday(date, string, i) {
2748  d3_time_numberRe.lastIndex = 0;
2749  var n = d3_time_numberRe.exec(string.slice(i));
2750  return n ? (date.W = +n[0], i + n[0].length) : -1;
2751  }
2752  function d3_time_parseFullYear(date, string, i) {
2753  d3_time_numberRe.lastIndex = 0;
2754  var n = d3_time_numberRe.exec(string.slice(i, i + 4));
2755  return n ? (date.y = +n[0], i + n[0].length) : -1;
2756  }
2757  function d3_time_parseYear(date, string, i) {
2758  d3_time_numberRe.lastIndex = 0;
2759  var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2760  return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;
2761  }
2762  function d3_time_parseZone(date, string, i) {
2763  return /^[+-]\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string,
2764  i + 5) : -1;
2765  }
2766  function d3_time_expandYear(d) {
2767  return d + (d > 68 ? 1900 : 2e3);
2768  }
2769  function d3_time_parseMonthNumber(date, string, i) {
2770  d3_time_numberRe.lastIndex = 0;
2771  var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2772  return n ? (date.m = n[0] - 1, i + n[0].length) : -1;
2773  }
2774  function d3_time_parseDay(date, string, i) {
2775  d3_time_numberRe.lastIndex = 0;
2776  var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2777  return n ? (date.d = +n[0], i + n[0].length) : -1;
2778  }
2779  function d3_time_parseDayOfYear(date, string, i) {
2780  d3_time_numberRe.lastIndex = 0;
2781  var n = d3_time_numberRe.exec(string.slice(i, i + 3));
2782  return n ? (date.j = +n[0], i + n[0].length) : -1;
2783  }
2784  function d3_time_parseHour24(date, string, i) {
2785  d3_time_numberRe.lastIndex = 0;
2786  var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2787  return n ? (date.H = +n[0], i + n[0].length) : -1;
2788  }
2789  function d3_time_parseMinutes(date, string, i) {
2790  d3_time_numberRe.lastIndex = 0;
2791  var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2792  return n ? (date.M = +n[0], i + n[0].length) : -1;
2793  }
2794  function d3_time_parseSeconds(date, string, i) {
2795  d3_time_numberRe.lastIndex = 0;
2796  var n = d3_time_numberRe.exec(string.slice(i, i + 2));
2797  return n ? (date.S = +n[0], i + n[0].length) : -1;
2798  }
2799  function d3_time_parseMilliseconds(date, string, i) {
2800  d3_time_numberRe.lastIndex = 0;
2801  var n = d3_time_numberRe.exec(string.slice(i, i + 3));
2802  return n ? (date.L = +n[0], i + n[0].length) : -1;
2803  }
2804  function d3_time_zone(d) {
2805  var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = abs(z) / 60 | 0, zm = abs(z) % 60;
2806  return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2);
2807  }
2808  function d3_time_parseLiteralPercent(date, string, i) {
2809  d3_time_percentRe.lastIndex = 0;
2810  var n = d3_time_percentRe.exec(string.slice(i, i + 1));
2811  return n ? i + n[0].length : -1;
2812  }
2813  function d3_time_formatMulti(formats) {
2814  var n = formats.length, i = -1;
2815  while (++i < n) formats[i][0] = this(formats[i][0]);
2816  return function(date) {
2817  var i = 0, f = formats[i];
2818  while (!f[1](date)) f = formats[++i];
2819  return f[0](date);
2820  };
2821  }
2822  d3.locale = function(locale) {
2823  return {
2824  numberFormat: d3_locale_numberFormat(locale),
2825  timeFormat: d3_locale_timeFormat(locale)
2826  };
2827  };
2828  var d3_locale_enUS = d3.locale({
2829  decimal: ".",
2830  thousands: ",",
2831  grouping: [ 3 ],
2832  currency: [ "$", "" ],
2833  dateTime: "%a %b %e %X %Y",
2834  date: "%m/%d/%Y",
2835  time: "%H:%M:%S",
2836  periods: [ "AM", "PM" ],
2837  days: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
2838  shortDays: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
2839  months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
2840  shortMonths: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]
2841  });
2842  d3.format = d3_locale_enUS.numberFormat;
2843  d3.geo = {};
2844  function d3_adder() {}
2845  d3_adder.prototype = {
2846  s: 0,
2847  t: 0,
2848  add: function(y) {
2849  d3_adderSum(y, this.t, d3_adderTemp);
2850  d3_adderSum(d3_adderTemp.s, this.s, this);
2851  if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t;
2852  },
2853  reset: function() {
2854  this.s = this.t = 0;
2855  },
2856  valueOf: function() {
2857  return this.s;
2858  }
2859  };
2860  var d3_adderTemp = new d3_adder();
2861  function d3_adderSum(a, b, o) {
2862  var x = o.s = a + b, bv = x - a, av = x - bv;
2863  o.t = a - av + (b - bv);
2864  }
2865  d3.geo.stream = function(object, listener) {
2866  if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) {
2867  d3_geo_streamObjectType[object.type](object, listener);
2868  } else {
2869  d3_geo_streamGeometry(object, listener);
2870  }
2871  };
2872  function d3_geo_streamGeometry(geometry, listener) {
2873  if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {
2874  d3_geo_streamGeometryType[geometry.type](geometry, listener);
2875  }
2876  }
2877  var d3_geo_streamObjectType = {
2878  Feature: function(feature, listener) {
2879  d3_geo_streamGeometry(feature.geometry, listener);
2880  },
2881  FeatureCollection: function(object, listener) {
2882  var features = object.features, i = -1, n = features.length;
2883  while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener);
2884  }
2885  };
2886  var d3_geo_streamGeometryType = {
2887  Sphere: function(object, listener) {
2888  listener.sphere();
2889  },
2890  Point: function(object, listener) {
2891  object = object.coordinates;
2892  listener.point(object[0], object[1], object[2]);
2893  },
2894  MultiPoint: function(object, listener) {
2895  var coordinates = object.coordinates, i = -1, n = coordinates.length;
2896  while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]);
2897  },
2898  LineString: function(object, listener) {
2899  d3_geo_streamLine(object.coordinates, listener, 0);
2900  },
2901  MultiLineString: function(object, listener) {
2902  var coordinates = object.coordinates, i = -1, n = coordinates.length;
2903  while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0);
2904  },
2905  Polygon: function(object, listener) {
2906  d3_geo_streamPolygon(object.coordinates, listener);
2907  },
2908  MultiPolygon: function(object, listener) {
2909  var coordinates = object.coordinates, i = -1, n = coordinates.length;
2910  while (++i < n) d3_geo_streamPolygon(coordinates[i], listener);
2911  },
2912  GeometryCollection: function(object, listener) {
2913  var geometries = object.geometries, i = -1, n = geometries.length;
2914  while (++i < n) d3_geo_streamGeometry(geometries[i], listener);
2915  }
2916  };
2917  function d3_geo_streamLine(coordinates, listener, closed) {
2918  var i = -1, n = coordinates.length - closed, coordinate;
2919  listener.lineStart();
2920  while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]);
2921  listener.lineEnd();
2922  }
2923  function d3_geo_streamPolygon(coordinates, listener) {
2924  var i = -1, n = coordinates.length;
2925  listener.polygonStart();
2926  while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1);
2927  listener.polygonEnd();
2928  }
2929  d3.geo.area = function(object) {
2930  d3_geo_areaSum = 0;
2931  d3.geo.stream(object, d3_geo_area);
2932  return d3_geo_areaSum;
2933  };
2934  var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder();
2935  var d3_geo_area = {
2936  sphere: function() {
2937  d3_geo_areaSum += 4 * π;
2938  },
2939  point: d3_noop,
2940  lineStart: d3_noop,
2941  lineEnd: d3_noop,
2942  polygonStart: function() {
2943  d3_geo_areaRingSum.reset();
2944  d3_geo_area.lineStart = d3_geo_areaRingStart;
2945  },
2946  polygonEnd: function() {
2947  var area = 2 * d3_geo_areaRingSum;
2948  d3_geo_areaSum += area < 0 ? 4 * π + area : area;
2949  d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop;
2950  }
2951  };
2952  function d3_geo_areaRingStart() {
2953  var λ00, φ00, λ0, cosφ0, sinφ0;
2954  d3_geo_area.point = function(λ, φ) {
2955  d3_geo_area.point = nextPoint;
2956  λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4),
2957  sinφ0 = Math.sin(φ);
2958  };
2959  function nextPoint(λ, φ) {
2960  λ *= d3_radians;
2961  φ = φ * d3_radians / 2 + π / 4;
2962  var dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(adλ), v = k * sdλ * Math.sin(adλ);
2963  d3_geo_areaRingSum.add(Math.atan2(v, u));
2964  λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ;
2965  }
2966  d3_geo_area.lineEnd = function() {
2967  nextPoint(λ00, φ00);
2968  };
2969  }
2970  function d3_geo_cartesian(spherical) {
2971  var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ);
2972  return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ];
2973  }
2974  function d3_geo_cartesianDot(a, b) {
2975  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
2976  }
2977  function d3_geo_cartesianCross(a, b) {
2978  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] ];
2979  }
2980  function d3_geo_cartesianAdd(a, b) {
2981  a[0] += b[0];
2982  a[1] += b[1];
2983  a[2] += b[2];
2984  }
2985  function d3_geo_cartesianScale(vector, k) {
2986  return [ vector[0] * k, vector[1] * k, vector[2] * k ];
2987  }
2988  function d3_geo_cartesianNormalize(d) {
2989  var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
2990  d[0] /= l;
2991  d[1] /= l;
2992  d[2] /= l;
2993  }
2994  function d3_geo_spherical(cartesian) {
2995  return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ];
2996  }
2997  function d3_geo_sphericalEqual(a, b) {
2998  return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε;
2999  }
3000  d3.geo.bounds = function() {
3001  var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range;
3002  var bound = {
3003  point: point,
3004  lineStart: lineStart,
3005  lineEnd: lineEnd,
3006  polygonStart: function() {
3007  bound.point = ringPoint;
3008  bound.lineStart = ringStart;
3009  bound.lineEnd = ringEnd;
3010  dλSum = 0;
3011  d3_geo_area.polygonStart();
3012  },
3013  polygonEnd: function() {
3014  d3_geo_area.polygonEnd();
3015  bound.point = point;
3016  bound.lineStart = lineStart;
3017  bound.lineEnd = lineEnd;
3018  if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90;
3019  range[0] = λ0, range[1] = λ1;
3020  }
3021  };
3022  function point(λ, φ) {
3023  ranges.push(range = [ λ0 = λ, λ1 = λ ]);
3024  if (φ < φ0) φ0 = φ;
3025  if (φ > φ1) φ1 = φ;
3026  }
3027  function linePoint(λ, φ) {
3028  var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]);
3029  if (p0) {
3030  var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal);
3031  d3_geo_cartesianNormalize(inflection);
3032  inflection = d3_geo_spherical(inflection);
3033  var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs(dλ) > 180;
3034  if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) {
3035  var φi = inflection[1] * d3_degrees;
3036  if (φi > φ1) φ1 = φi;
3037  } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) {
3038  var φi = -inflection[1] * d3_degrees;
3039  if (φi < φ0) φ0 = φi;
3040  } else {
3041  if (φ < φ0) φ0 = φ;
3042  if (φ > φ1) φ1 = φ;
3043  }
3044  if (antimeridian) {
3045  if (λ < λ_) {
3046  if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;
3047  } else {
3048  if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;
3049  }
3050  } else {
3051  if (λ1 >= λ0) {
3052  if (λ < λ0) λ0 = λ;
3053  if (λ > λ1) λ1 = λ;
3054  } else {
3055  if (λ > λ_) {
3056  if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;
3057  } else {
3058  if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;
3059  }
3060  }
3061  }
3062  } else {
3063  point(λ, φ);
3064  }
3065  p0 = p, λ_ = λ;
3066  }
3067  function lineStart() {
3068  bound.point = linePoint;
3069  }
3070  function lineEnd() {
3071  range[0] = λ0, range[1] = λ1;
3072  bound.point = point;
3073  p0 = null;
3074  }
3075  function ringPoint(λ, φ) {
3076  if (p0) {
3077  var dλ = λ - λ_;
3078  dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ;
3079  } else λ__ = λ, φ__ = φ;
3080  d3_geo_area.point(λ, φ);
3081  linePoint(λ, φ);
3082  }
3083  function ringStart() {
3084  d3_geo_area.lineStart();
3085  }
3086  function ringEnd() {
3087  ringPoint(λ__, φ__);
3088  d3_geo_area.lineEnd();
3089  if (abs(dλSum) > ε) λ0 = -(λ1 = 180);
3090  range[0] = λ0, range[1] = λ1;
3091  p0 = null;
3092  }
3093  function angle(λ0, λ1) {
3094  return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1;
3095  }
3096  function compareRanges(a, b) {
3097  return a[0] - b[0];
3098  }
3099  function withinRange(x, range) {
3100  return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;
3101  }
3102  return function(feature) {
3103  φ1 = λ1 = -(λ0 = φ0 = Infinity);
3104  ranges = [];
3105  d3.geo.stream(feature, bound);
3106  var n = ranges.length;
3107  if (n) {
3108  ranges.sort(compareRanges);
3109  for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) {
3110  b = ranges[i];
3111  if (withinRange(b[0], a) || withinRange(b[1], a)) {
3112  if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];
3113  if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];
3114  } else {
3115  merged.push(a = b);
3116  }
3117  }
3118  var best = -Infinity, dλ;
3119  for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) {
3120  b = merged[i];
3121  if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1];
3122  }
3123  }
3124  ranges = range = null;
3125  return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ];
3126  };
3127  }();
3128  d3.geo.centroid = function(object) {
3129  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;
3130  d3.geo.stream(object, d3_geo_centroid);
3131  var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z;
3132  if (m < ε2) {
3133  x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1;
3134  if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0;
3135  m = x * x + y * y + z * z;
3136  if (m < ε2) return [ NaN, NaN ];
3137  }
3138  return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ];
3139  };
3140  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;
3141  var d3_geo_centroid = {
3142  sphere: d3_noop,
3143  point: d3_geo_centroidPoint,
3144  lineStart: d3_geo_centroidLineStart,
3145  lineEnd: d3_geo_centroidLineEnd,
3146  polygonStart: function() {
3147  d3_geo_centroid.lineStart = d3_geo_centroidRingStart;
3148  },
3149  polygonEnd: function() {
3150  d3_geo_centroid.lineStart = d3_geo_centroidLineStart;
3151  }
3152  };
3153  function d3_geo_centroidPoint(λ, φ) {
3154  λ *= d3_radians;
3155  var cosφ = Math.cos(φ *= d3_radians);
3156  d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ));
3157  }
3158  function d3_geo_centroidPointXYZ(x, y, z) {
3159  ++d3_geo_centroidW0;
3160  d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0;
3161  d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0;
3162  d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0;
3163  }
3164  function d3_geo_centroidLineStart() {
3165  var x0, y0, z0;
3166  d3_geo_centroid.point = function(λ, φ) {
3167  λ *= d3_radians;
3168  var cosφ = Math.cos(φ *= d3_radians);
3169  x0 = cosφ * Math.cos(λ);
3170  y0 = cosφ * Math.sin(λ);
3171  z0 = Math.sin(φ);
3172  d3_geo_centroid.point = nextPoint;
3173  d3_geo_centroidPointXYZ(x0, y0, z0);
3174  };
3175  function nextPoint(λ, φ) {
3176  λ *= d3_radians;
3177  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);
3178  d3_geo_centroidW1 += w;
3179  d3_geo_centroidX1 += w * (x0 + (x0 = x));
3180  d3_geo_centroidY1 += w * (y0 + (y0 = y));
3181  d3_geo_centroidZ1 += w * (z0 + (z0 = z));
3182  d3_geo_centroidPointXYZ(x0, y0, z0);
3183  }
3184  }
3185  function d3_geo_centroidLineEnd() {
3186  d3_geo_centroid.point = d3_geo_centroidPoint;
3187  }
3188  function d3_geo_centroidRingStart() {
3189  var λ00, φ00, x0, y0, z0;
3190  d3_geo_centroid.point = function(λ, φ) {
3191  λ00 = λ, φ00 = φ;
3192  d3_geo_centroid.point = nextPoint;
3193  λ *= d3_radians;
3194  var cosφ = Math.cos(φ *= d3_radians);
3195  x0 = cosφ * Math.cos(λ);
3196  y0 = cosφ * Math.sin(λ);
3197  z0 = Math.sin(φ);
3198  d3_geo_centroidPointXYZ(x0, y0, z0);
3199  };
3200  d3_geo_centroid.lineEnd = function() {
3201  nextPoint(λ00, φ00);
3202  d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd;
3203  d3_geo_centroid.point = d3_geo_centroidPoint;
3204  };
3205  function nextPoint(λ, φ) {
3206  λ *= d3_radians;
3207  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);
3208  d3_geo_centroidX2 += v * cx;
3209  d3_geo_centroidY2 += v * cy;
3210  d3_geo_centroidZ2 += v * cz;
3211  d3_geo_centroidW1 += w;
3212  d3_geo_centroidX1 += w * (x0 + (x0 = x));
3213  d3_geo_centroidY1 += w * (y0 + (y0 = y));
3214  d3_geo_centroidZ1 += w * (z0 + (z0 = z));
3215  d3_geo_centroidPointXYZ(x0, y0, z0);
3216  }
3217  }
3218  function d3_geo_compose(a, b) {
3219  function compose(x, y) {
3220  return x = a(x, y), b(x[0], x[1]);
3221  }
3222  if (a.invert && b.invert) compose.invert = function(x, y) {
3223  return x = b.invert(x, y), x && a.invert(x[0], x[1]);
3224  };
3225  return compose;
3226  }
3227  function d3_true() {
3228  return true;
3229  }
3230  function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) {
3231  var subject = [], clip = [];
3232  segments.forEach(function(segment) {
3233  if ((n = segment.length - 1) <= 0) return;
3234  var n, p0 = segment[0], p1 = segment[n];
3235  if (d3_geo_sphericalEqual(p0, p1)) {
3236  listener.lineStart();
3237  for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]);
3238  listener.lineEnd();
3239  return;
3240  }
3241  var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false);
3242  a.o = b;
3243  subject.push(a);
3244  clip.push(b);
3245  a = new d3_geo_clipPolygonIntersection(p1, segment, null, false);
3246  b = new d3_geo_clipPolygonIntersection(p1, null, a, true);
3247  a.o = b;
3248  subject.push(a);
3249  clip.push(b);
3250  });
3251  clip.sort(compare);
3252  d3_geo_clipPolygonLinkCircular(subject);
3253  d3_geo_clipPolygonLinkCircular(clip);
3254  if (!subject.length) return;
3255  for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) {
3256  clip[i].e = entry = !entry;
3257  }
3258  var start = subject[0], points, point;
3259  while (1) {
3260  var current = start, isSubject = true;
3261  while (current.v) if ((current = current.n) === start) return;
3262  points = current.z;
3263  listener.lineStart();
3264  do {
3265  current.v = current.o.v = true;
3266  if (current.e) {
3267  if (isSubject) {
3268  for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]);
3269  } else {
3270  interpolate(current.x, current.n.x, 1, listener);
3271  }
3272  current = current.n;
3273  } else {
3274  if (isSubject) {
3275  points = current.p.z;
3276  for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]);
3277  } else {
3278  interpolate(current.x, current.p.x, -1, listener);
3279  }
3280  current = current.p;
3281  }
3282  current = current.o;
3283  points = current.z;
3284  isSubject = !isSubject;
3285  } while (!current.v);
3286  listener.lineEnd();
3287  }
3288  }
3289  function d3_geo_clipPolygonLinkCircular(array) {
3290  if (!(n = array.length)) return;
3291  var n, i = 0, a = array[0], b;
3292  while (++i < n) {
3293  a.n = b = array[i];
3294  b.p = a;
3295  a = b;
3296  }
3297  a.n = b = array[0];
3298  b.p = a;
3299  }
3300  function d3_geo_clipPolygonIntersection(point, points, other, entry) {
3301  this.x = point;
3302  this.z = points;
3303  this.o = other;
3304  this.e = entry;
3305  this.v = false;
3306  this.n = this.p = null;
3307  }
3308  function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) {
3309  return function(rotate, listener) {
3310  var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]);
3311  var clip = {
3312  point: point,
3313  lineStart: lineStart,
3314  lineEnd: lineEnd,
3315  polygonStart: function() {
3316  clip.point = pointRing;
3317  clip.lineStart = ringStart;
3318  clip.lineEnd = ringEnd;
3319  segments = [];
3320  polygon = [];
3321  },
3322  polygonEnd: function() {
3323  clip.point = point;
3324  clip.lineStart = lineStart;
3325  clip.lineEnd = lineEnd;
3326  segments = d3.merge(segments);
3327  var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon);
3328  if (segments.length) {
3329  if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3330  d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener);
3331  } else if (clipStartInside) {
3332  if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3333  listener.lineStart();
3334  interpolate(null, null, 1, listener);
3335  listener.lineEnd();
3336  }
3337  if (polygonStarted) listener.polygonEnd(), polygonStarted = false;
3338  segments = polygon = null;
3339  },
3340  sphere: function() {
3341  listener.polygonStart();
3342  listener.lineStart();
3343  interpolate(null, null, 1, listener);
3344  listener.lineEnd();
3345  listener.polygonEnd();
3346  }
3347  };
3348  function point(λ, φ) {
3349  var point = rotate(λ, φ);
3350  if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ);
3351  }
3352  function pointLine(λ, φ) {
3353  var point = rotate(λ, φ);
3354  line.point(point[0], point[1]);
3355  }
3356  function lineStart() {
3357  clip.point = pointLine;
3358  line.lineStart();
3359  }
3360  function lineEnd() {
3361  clip.point = point;
3362  line.lineEnd();
3363  }
3364  var segments;
3365  var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring;
3366  function pointRing(λ, φ) {
3367  ring.push([ λ, φ ]);
3368  var point = rotate(λ, φ);
3369  ringListener.point(point[0], point[1]);
3370  }
3371  function ringStart() {
3372  ringListener.lineStart();
3373  ring = [];
3374  }
3375  function ringEnd() {
3376  pointRing(ring[0][0], ring[0][1]);
3377  ringListener.lineEnd();
3378  var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length;
3379  ring.pop();
3380  polygon.push(ring);
3381  ring = null;
3382  if (!n) return;
3383  if (clean & 1) {
3384  segment = ringSegments[0];
3385  var n = segment.length - 1, i = -1, point;
3386  if (n > 0) {
3387  if (!polygonStarted) listener.polygonStart(), polygonStarted = true;
3388  listener.lineStart();
3389  while (++i < n) listener.point((point = segment[i])[0], point[1]);
3390  listener.lineEnd();
3391  }
3392  return;
3393  }
3394  if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
3395  segments.push(ringSegments.filter(d3_geo_clipSegmentLength1));
3396  }
3397  return clip;
3398  };
3399  }
3400  function d3_geo_clipSegmentLength1(segment) {
3401  return segment.length > 1;
3402  }
3403  function d3_geo_clipBufferListener() {
3404  var lines = [], line;
3405  return {
3406  lineStart: function() {
3407  lines.push(line = []);
3408  },
3409  point: function(λ, φ) {
3410  line.push([ λ, φ ]);
3411  },
3412  lineEnd: d3_noop,
3413  buffer: function() {
3414  var buffer = lines;
3415  lines = [];
3416  line = null;
3417  return buffer;
3418  },
3419  rejoin: function() {
3420  if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
3421  }
3422  };
3423  }
3424  function d3_geo_clipSort(a, b) {
3425  return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]);
3426  }
3427  var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]);
3428  function d3_geo_clipAntimeridianLine(listener) {
3429  var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean;
3430  return {
3431  lineStart: function() {
3432  listener.lineStart();
3433  clean = 1;
3434  },
3435  point: function(λ1, φ1) {
3436  var sλ1 = λ1 > 0 ? π : -π, dλ = abs(λ1 - λ0);
3437  if (abs(dλ - π) < ε) {
3438  listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ);
3439  listener.point(sλ0, φ0);
3440  listener.lineEnd();
3441  listener.lineStart();
3442  listener.point(sλ1, φ0);
3443  listener.point(λ1, φ0);
3444  clean = 0;
3445  } else if (sλ0 !== sλ1 && dλ >= π) {
3446  if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε;
3447  if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε;
3448  φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1);
3449  listener.point(sλ0, φ0);
3450  listener.lineEnd();
3451  listener.lineStart();
3452  listener.point(sλ1, φ0);
3453  clean = 0;
3454  }
3455  listener.point(λ0 = λ1, φ0 = φ1);
3456  sλ0 = sλ1;
3457  },
3458  lineEnd: function() {
3459  listener.lineEnd();
3460  λ0 = φ0 = NaN;
3461  },
3462  clean: function() {
3463  return 2 - clean;
3464  }
3465  };
3466  }
3467  function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) {
3468  var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1);
3469  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;
3470  }
3471  function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) {
3472  var φ;
3473  if (from == null) {
3474  φ = direction * halfπ;
3475  listener.point(-π, φ);
3476  listener.point(0, φ);
3477  listener.point(π, φ);
3478  listener.point(π, 0);
3479  listener.point(π, -φ);
3480  listener.point(0, -φ);
3481  listener.point(-π, -φ);
3482  listener.point(-π, 0);
3483  listener.point(-π, φ);
3484  } else if (abs(from[0] - to[0]) > ε) {
3485  var s = from[0] < to[0] ? π : -π;
3486  φ = direction * s / 2;
3487  listener.point(-s, φ);
3488  listener.point(0, φ);
3489  listener.point(s, φ);
3490  } else {
3491  listener.point(to[0], to[1]);
3492  }
3493  }
3494  function d3_geo_pointInPolygon(point, polygon) {
3495  var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0;
3496  d3_geo_areaRingSum.reset();
3497  for (var i = 0, n = polygon.length; i < n; ++i) {
3498  var ring = polygon[i], m = ring.length;
3499  if (!m) continue;
3500  var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1;
3501  while (true) {
3502  if (j === m) j = 0;
3503  point = ring[j];
3504  var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ;
3505  d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ)));
3506  polarAngle += antimeridian ? dλ + sdλ * τ : dλ;
3507  if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) {
3508  var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point));
3509  d3_geo_cartesianNormalize(arc);
3510  var intersection = d3_geo_cartesianCross(meridianNormal, arc);
3511  d3_geo_cartesianNormalize(intersection);
3512  var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]);
3513  if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) {
3514  winding += antimeridian ^ dλ >= 0 ? 1 : -1;
3515  }
3516  }
3517  if (!j++) break;
3518  λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point;
3519  }
3520  }
3521  return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1;
3522  }
3523  function d3_geo_clipCircle(radius) {
3524  var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians);
3525  return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]);
3526  function visible(λ, φ) {
3527  return Math.cos(λ) * Math.cos(φ) > cr;
3528  }
3529  function clipLine(listener) {
3530  var point0, c0, v0, v00, clean;
3531  return {
3532  lineStart: function() {
3533  v00 = v0 = false;
3534  clean = 1;
3535  },
3536  point: function(λ, φ) {
3537  var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0;
3538  if (!point0 && (v00 = v0 = v)) listener.lineStart();
3539  if (v !== v0) {
3540  point2 = intersect(point0, point1);
3541  if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) {
3542  point1[0] += ε;
3543  point1[1] += ε;
3544  v = visible(point1[0], point1[1]);
3545  }
3546  }
3547  if (v !== v0) {
3548  clean = 0;
3549  if (v) {
3550  listener.lineStart();
3551  point2 = intersect(point1, point0);
3552  listener.point(point2[0], point2[1]);
3553  } else {
3554  point2 = intersect(point0, point1);
3555  listener.point(point2[0], point2[1]);
3556  listener.lineEnd();
3557  }
3558  point0 = point2;
3559  } else if (notHemisphere && point0 && smallRadius ^ v) {
3560  var t;
3561  if (!(c & c0) && (t = intersect(point1, point0, true))) {
3562  clean = 0;
3563  if (smallRadius) {
3564  listener.lineStart();
3565  listener.point(t[0][0], t[0][1]);
3566  listener.point(t[1][0], t[1][1]);
3567  listener.lineEnd();
3568  } else {
3569  listener.point(t[1][0], t[1][1]);
3570  listener.lineEnd();
3571  listener.lineStart();
3572  listener.point(t[0][0], t[0][1]);
3573  }
3574  }
3575  }
3576  if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) {
3577  listener.point(point1[0], point1[1]);
3578  }
3579  point0 = point1, v0 = v, c0 = c;
3580  },
3581  lineEnd: function() {
3582  if (v0) listener.lineEnd();
3583  point0 = null;
3584  },
3585  clean: function() {
3586  return clean | (v00 && v0) << 1;
3587  }
3588  };
3589  }
3590  function intersect(a, b, two) {
3591  var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b);
3592  var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;
3593  if (!determinant) return !two && a;
3594  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);
3595  d3_geo_cartesianAdd(A, B);
3596  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);
3597  if (t2 < 0) return;
3598  var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu);
3599  d3_geo_cartesianAdd(q, A);
3600  q = d3_geo_spherical(q);
3601  if (!two) return q;
3602  var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z;
3603  if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z;
3604  var δλ = λ1 - λ0, polar = abs(δλ - π) < ε, meridian = polar || δλ < ε;
3605  if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z;
3606  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)) {
3607  var q1 = d3_geo_cartesianScale(u, (-w + t) / uu);
3608  d3_geo_cartesianAdd(q1, A);
3609  return [ q, d3_geo_spherical(q1) ];
3610  }
3611  }
3612  function code(λ, φ) {
3613  var r = smallRadius ? radius : π - radius, code = 0;
3614  if (λ < -r) code |= 1; else if (λ > r) code |= 2;
3615  if (φ < -r) code |= 4; else if (φ > r) code |= 8;
3616  return code;
3617  }
3618  }
3619  function d3_geom_clipLine(x0, y0, x1, y1) {
3620  return function(line) {
3621  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;
3622  r = x0 - ax;
3623  if (!dx && r > 0) return;
3624  r /= dx;
3625  if (dx < 0) {
3626  if (r < t0) return;
3627  if (r < t1) t1 = r;
3628  } else if (dx > 0) {
3629  if (r > t1) return;
3630  if (r > t0) t0 = r;
3631  }
3632  r = x1 - ax;
3633  if (!dx && r < 0) return;
3634  r /= dx;
3635  if (dx < 0) {
3636  if (r > t1) return;
3637  if (r > t0) t0 = r;
3638  } else if (dx > 0) {
3639  if (r < t0) return;
3640  if (r < t1) t1 = r;
3641  }
3642  r = y0 - ay;
3643  if (!dy && r > 0) return;
3644  r /= dy;
3645  if (dy < 0) {
3646  if (r < t0) return;
3647  if (r < t1) t1 = r;
3648  } else if (dy > 0) {
3649  if (r > t1) return;
3650  if (r > t0) t0 = r;
3651  }
3652  r = y1 - ay;
3653  if (!dy && r < 0) return;
3654  r /= dy;
3655  if (dy < 0) {
3656  if (r > t1) return;
3657  if (r > t0) t0 = r;
3658  } else if (dy > 0) {
3659  if (r < t0) return;
3660  if (r < t1) t1 = r;
3661  }
3662  if (t0 > 0) line.a = {
3663  x: ax + t0 * dx,
3664  y: ay + t0 * dy
3665  };
3666  if (t1 < 1) line.b = {
3667  x: ax + t1 * dx,
3668  y: ay + t1 * dy
3669  };
3670  return line;
3671  };
3672  }
3673  var d3_geo_clipExtentMAX = 1e9;
3674  d3.geo.clipExtent = function() {
3675  var x0, y0, x1, y1, stream, clip, clipExtent = {
3676  stream: function(output) {
3677  if (stream) stream.valid = false;
3678  stream = clip(output);
3679  stream.valid = true;
3680  return stream;
3681  },
3682  extent: function(_) {
3683  if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];
3684  clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]);
3685  if (stream) stream.valid = false, stream = null;
3686  return clipExtent;
3687  }
3688  };
3689  return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]);
3690  };
3691  function d3_geo_clipExtent(x0, y0, x1, y1) {
3692  return function(listener) {
3693  var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring;
3694  var clip = {
3695  point: point,
3696  lineStart: lineStart,
3697  lineEnd: lineEnd,
3698  polygonStart: function() {
3699  listener = bufferListener;
3700  segments = [];
3701  polygon = [];
3702  clean = true;
3703  },
3704  polygonEnd: function() {
3705  listener = listener_;
3706  segments = d3.merge(segments);
3707  var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length;
3708  if (inside || visible) {
3709  listener.polygonStart();
3710  if (inside) {
3711  listener.lineStart();
3712  interpolate(null, null, 1, listener);
3713  listener.lineEnd();
3714  }
3715  if (visible) {
3716  d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener);
3717  }
3718  listener.polygonEnd();
3719  }
3720  segments = polygon = ring = null;
3721  }
3722  };
3723  function insidePolygon(p) {
3724  var wn = 0, n = polygon.length, y = p[1];
3725  for (var i = 0; i < n; ++i) {
3726  for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {
3727  b = v[j];
3728  if (a[1] <= y) {
3729  if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn;
3730  } else {
3731  if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn;
3732  }
3733  a = b;
3734  }
3735  }
3736  return wn !== 0;
3737  }
3738  function interpolate(from, to, direction, listener) {
3739  var a = 0, a1 = 0;
3740  if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) {
3741  do {
3742  listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);
3743  } while ((a = (a + direction + 4) % 4) !== a1);
3744  } else {
3745  listener.point(to[0], to[1]);
3746  }
3747  }
3748  function pointVisible(x, y) {
3749  return x0 <= x && x <= x1 && y0 <= y && y <= y1;
3750  }
3751  function point(x, y) {
3752  if (pointVisible(x, y)) listener.point(x, y);
3753  }
3754  var x__, y__, v__, x_, y_, v_, first, clean;
3755  function lineStart() {
3756  clip.point = linePoint;
3757  if (polygon) polygon.push(ring = []);
3758  first = true;
3759  v_ = false;
3760  x_ = y_ = NaN;
3761  }
3762  function lineEnd() {
3763  if (segments) {
3764  linePoint(x__, y__);
3765  if (v__ && v_) bufferListener.rejoin();
3766  segments.push(bufferListener.buffer());
3767  }
3768  clip.point = point;
3769  if (v_) listener.lineEnd();
3770  }
3771  function linePoint(x, y) {
3772  x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x));
3773  y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y));
3774  var v = pointVisible(x, y);
3775  if (polygon) ring.push([ x, y ]);
3776  if (first) {
3777  x__ = x, y__ = y, v__ = v;
3778  first = false;
3779  if (v) {
3780  listener.lineStart();
3781  listener.point(x, y);
3782  }
3783  } else {
3784  if (v && v_) listener.point(x, y); else {
3785  var l = {
3786  a: {
3787  x: x_,
3788  y: y_
3789  },
3790  b: {
3791  x: x,
3792  y: y
3793  }
3794  };
3795  if (clipLine(l)) {
3796  if (!v_) {
3797  listener.lineStart();
3798  listener.point(l.a.x, l.a.y);
3799  }
3800  listener.point(l.b.x, l.b.y);
3801  if (!v) listener.lineEnd();
3802  clean = false;
3803  } else if (v) {
3804  listener.lineStart();
3805  listener.point(x, y);
3806  clean = false;
3807  }
3808  }
3809  }
3810  x_ = x, y_ = y, v_ = v;
3811  }
3812  return clip;
3813  };
3814  function corner(p, direction) {
3815  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;
3816  }
3817  function compare(a, b) {
3818  return comparePoints(a.x, b.x);
3819  }
3820  function comparePoints(a, b) {
3821  var ca = corner(a, 1), cb = corner(b, 1);
3822  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];
3823  }
3824  }
3825  function d3_geo_conic(projectAt) {
3826  var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1);
3827  p.parallels = function(_) {
3828  if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ];
3829  return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180);
3830  };
3831  return p;
3832  }
3833  function d3_geo_conicEqualArea(φ0, φ1) {
3834  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;
3835  function forward(λ, φ) {
3836  var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n;
3837  return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ];
3838  }
3839  forward.invert = function(x, y) {
3840  var ρ0_y = ρ0 - y;
3841  return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ];
3842  };
3843  return forward;
3844  }
3845  (d3.geo.conicEqualArea = function() {
3846  return d3_geo_conic(d3_geo_conicEqualArea);
3847  }).raw = d3_geo_conicEqualArea;
3848  d3.geo.albers = function() {
3849  return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070);
3850  };
3851  d3.geo.albersUsa = function() {
3852  var lower48 = d3.geo.albers();
3853  var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]);
3854  var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]);
3855  var point, pointStream = {
3856  point: function(x, y) {
3857  point = [ x, y ];
3858  }
3859  }, lower48Point, alaskaPoint, hawaiiPoint;
3860  function albersUsa(coordinates) {
3861  var x = coordinates[0], y = coordinates[1];
3862  point = null;
3863  (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y);
3864  return point;
3865  }
3866  albersUsa.invert = function(coordinates) {
3867  var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k;
3868  return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates);
3869  };
3870  albersUsa.stream = function(stream) {
3871  var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream);
3872  return {
3873  point: function(x, y) {
3874  lower48Stream.point(x, y);
3875  alaskaStream.point(x, y);
3876  hawaiiStream.point(x, y);
3877  },
3878  sphere: function() {
3879  lower48Stream.sphere();
3880  alaskaStream.sphere();
3881  hawaiiStream.sphere();
3882  },
3883  lineStart: function() {
3884  lower48Stream.lineStart();
3885  alaskaStream.lineStart();
3886  hawaiiStream.lineStart();
3887  },
3888  lineEnd: function() {
3889  lower48Stream.lineEnd();
3890  alaskaStream.lineEnd();
3891  hawaiiStream.lineEnd();
3892  },
3893  polygonStart: function() {
3894  lower48Stream.polygonStart();
3895  alaskaStream.polygonStart();
3896  hawaiiStream.polygonStart();
3897  },
3898  polygonEnd: function() {
3899  lower48Stream.polygonEnd();
3900  alaskaStream.polygonEnd();
3901  hawaiiStream.polygonEnd();
3902  }
3903  };
3904  };
3905  albersUsa.precision = function(_) {
3906  if (!arguments.length) return lower48.precision();
3907  lower48.precision(_);
3908  alaska.precision(_);
3909  hawaii.precision(_);
3910  return albersUsa;
3911  };
3912  albersUsa.scale = function(_) {
3913  if (!arguments.length) return lower48.scale();
3914  lower48.scale(_);
3915  alaska.scale(_ * .35);
3916  hawaii.scale(_);
3917  return albersUsa.translate(lower48.translate());
3918  };
3919  albersUsa.translate = function(_) {
3920  if (!arguments.length) return lower48.translate();
3921  var k = lower48.scale(), x = +_[0], y = +_[1];
3922  lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point;
3923  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;
3924  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;
3925  return albersUsa;
3926  };
3927  return albersUsa.scale(1070);
3928  };
3929  var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = {
3930  point: d3_noop,
3931  lineStart: d3_noop,
3932  lineEnd: d3_noop,
3933  polygonStart: function() {
3934  d3_geo_pathAreaPolygon = 0;
3935  d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart;
3936  },
3937  polygonEnd: function() {
3938  d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop;
3939  d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2);
3940  }
3941  };
3942  function d3_geo_pathAreaRingStart() {
3943  var x00, y00, x0, y0;
3944  d3_geo_pathArea.point = function(x, y) {
3945  d3_geo_pathArea.point = nextPoint;
3946  x00 = x0 = x, y00 = y0 = y;
3947  };
3948  function nextPoint(x, y) {
3949  d3_geo_pathAreaPolygon += y0 * x - x0 * y;
3950  x0 = x, y0 = y;
3951  }
3952  d3_geo_pathArea.lineEnd = function() {
3953  nextPoint(x00, y00);
3954  };
3955  }
3956  var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1;
3957  var d3_geo_pathBounds = {
3958  point: d3_geo_pathBoundsPoint,
3959  lineStart: d3_noop,
3960  lineEnd: d3_noop,
3961  polygonStart: d3_noop,
3962  polygonEnd: d3_noop
3963  };
3964  function d3_geo_pathBoundsPoint(x, y) {
3965  if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x;
3966  if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x;
3967  if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y;
3968  if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y;
3969  }
3970  function d3_geo_pathBuffer() {
3971  var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = [];
3972  var stream = {
3973  point: point,
3974  lineStart: function() {
3975  stream.point = pointLineStart;
3976  },
3977  lineEnd: lineEnd,
3978  polygonStart: function() {
3979  stream.lineEnd = lineEndPolygon;
3980  },
3981  polygonEnd: function() {
3982  stream.lineEnd = lineEnd;
3983  stream.point = point;
3984  },
3985  pointRadius: function(_) {
3986  pointCircle = d3_geo_pathBufferCircle(_);
3987  return stream;
3988  },
3989  result: function() {
3990  if (buffer.length) {
3991  var result = buffer.join("");
3992  buffer = [];
3993  return result;
3994  }
3995  }
3996  };
3997  function point(x, y) {
3998  buffer.push("M", x, ",", y, pointCircle);
3999  }
4000  function pointLineStart(x, y) {
4001  buffer.push("M", x, ",", y);
4002  stream.point = pointLine;
4003  }
4004  function pointLine(x, y) {
4005  buffer.push("L", x, ",", y);
4006  }
4007  function lineEnd() {
4008  stream.point = point;
4009  }
4010  function lineEndPolygon() {
4011  buffer.push("Z");
4012  }
4013  return stream;
4014  }
4015  function d3_geo_pathBufferCircle(radius) {
4016  return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z";
4017  }
4018  var d3_geo_pathCentroid = {
4019  point: d3_geo_pathCentroidPoint,
4020  lineStart: d3_geo_pathCentroidLineStart,
4021  lineEnd: d3_geo_pathCentroidLineEnd,
4022  polygonStart: function() {
4023  d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart;
4024  },
4025  polygonEnd: function() {
4026  d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;
4027  d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart;
4028  d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd;
4029  }
4030  };
4031  function d3_geo_pathCentroidPoint(x, y) {
4032  d3_geo_centroidX0 += x;
4033  d3_geo_centroidY0 += y;
4034  ++d3_geo_centroidZ0;
4035  }
4036  function d3_geo_pathCentroidLineStart() {
4037  var x0, y0;
4038  d3_geo_pathCentroid.point = function(x, y) {
4039  d3_geo_pathCentroid.point = nextPoint;
4040  d3_geo_pathCentroidPoint(x0 = x, y0 = y);
4041  };
4042  function nextPoint(x, y) {
4043  var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);
4044  d3_geo_centroidX1 += z * (x0 + x) / 2;
4045  d3_geo_centroidY1 += z * (y0 + y) / 2;
4046  d3_geo_centroidZ1 += z;
4047  d3_geo_pathCentroidPoint(x0 = x, y0 = y);
4048  }
4049  }
4050  function d3_geo_pathCentroidLineEnd() {
4051  d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;
4052  }
4053  function d3_geo_pathCentroidRingStart() {
4054  var x00, y00, x0, y0;
4055  d3_geo_pathCentroid.point = function(x, y) {
4056  d3_geo_pathCentroid.point = nextPoint;
4057  d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y);
4058  };
4059  function nextPoint(x, y) {
4060  var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);
4061  d3_geo_centroidX1 += z * (x0 + x) / 2;
4062  d3_geo_centroidY1 += z * (y0 + y) / 2;
4063  d3_geo_centroidZ1 += z;
4064  z = y0 * x - x0 * y;
4065  d3_geo_centroidX2 += z * (x0 + x);
4066  d3_geo_centroidY2 += z * (y0 + y);
4067  d3_geo_centroidZ2 += z * 3;
4068  d3_geo_pathCentroidPoint(x0 = x, y0 = y);
4069  }
4070  d3_geo_pathCentroid.lineEnd = function() {
4071  nextPoint(x00, y00);
4072  };
4073  }
4074  function d3_geo_pathContext(context) {
4075  var pointRadius = 4.5;
4076  var stream = {
4077  point: point,
4078  lineStart: function() {
4079  stream.point = pointLineStart;
4080  },
4081  lineEnd: lineEnd,
4082  polygonStart: function() {
4083  stream.lineEnd = lineEndPolygon;
4084  },
4085  polygonEnd: function() {
4086  stream.lineEnd = lineEnd;
4087  stream.point = point;
4088  },
4089  pointRadius: function(_) {
4090  pointRadius = _;
4091  return stream;
4092  },
4093  result: d3_noop
4094  };
4095  function point(x, y) {
4096  context.moveTo(x + pointRadius, y);
4097  context.arc(x, y, pointRadius, 0, τ);
4098  }
4099  function pointLineStart(x, y) {
4100  context.moveTo(x, y);
4101  stream.point = pointLine;
4102  }
4103  function pointLine(x, y) {
4104  context.lineTo(x, y);
4105  }
4106  function lineEnd() {
4107  stream.point = point;
4108  }
4109  function lineEndPolygon() {
4110  context.closePath();
4111  }
4112  return stream;
4113  }
4114  function d3_geo_resample(project) {
4115  var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16;
4116  function resample(stream) {
4117  return (maxDepth ? resampleRecursive : resampleNone)(stream);
4118  }
4119  function resampleNone(stream) {
4120  return d3_geo_transformPoint(stream, function(x, y) {
4121  x = project(x, y);
4122  stream.point(x[0], x[1]);
4123  });
4124  }
4125  function resampleRecursive(stream) {
4126  var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0;
4127  var resample = {
4128  point: point,
4129  lineStart: lineStart,
4130  lineEnd: lineEnd,
4131  polygonStart: function() {
4132  stream.polygonStart();
4133  resample.lineStart = ringStart;
4134  },
4135  polygonEnd: function() {
4136  stream.polygonEnd();
4137  resample.lineStart = lineStart;
4138  }
4139  };
4140  function point(x, y) {
4141  x = project(x, y);
4142  stream.point(x[0], x[1]);
4143  }
4144  function lineStart() {
4145  x0 = NaN;
4146  resample.point = linePoint;
4147  stream.lineStart();
4148  }
4149  function linePoint(λ, φ) {
4150  var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ);
4151  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);
4152  stream.point(x0, y0);
4153  }
4154  function lineEnd() {
4155  resample.point = point;
4156  stream.lineEnd();
4157  }
4158  function ringStart() {
4159  lineStart();
4160  resample.point = ringPoint;
4161  resample.lineEnd = ringEnd;
4162  }
4163  function ringPoint(λ, φ) {
4164  linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;
4165  resample.point = linePoint;
4166  }
4167  function ringEnd() {
4168  resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream);
4169  resample.lineEnd = lineEnd;
4170  lineEnd();
4171  }
4172  return resample;
4173  }
4174  function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) {
4175  var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;
4176  if (d2 > 4 * δ2 && depth--) {
4177  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;
4178  if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
4179  resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream);
4180  stream.point(x2, y2);
4181  resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream);
4182  }
4183  }
4184  }
4185  resample.precision = function(_) {
4186  if (!arguments.length) return Math.sqrt(δ2);
4187  maxDepth = (δ2 = _ * _) > 0 && 16;
4188  return resample;
4189  };
4190  return resample;
4191  }
4192  d3.geo.path = function() {
4193  var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream;
4194  function path(object) {
4195  if (object) {
4196  if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
4197  if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream);
4198  d3.geo.stream(object, cacheStream);
4199  }
4200  return contextStream.result();
4201  }
4202  path.area = function(object) {
4203  d3_geo_pathAreaSum = 0;
4204  d3.geo.stream(object, projectStream(d3_geo_pathArea));
4205  return d3_geo_pathAreaSum;
4206  };
4207  path.centroid = function(object) {
4208  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;
4209  d3.geo.stream(object, projectStream(d3_geo_pathCentroid));
4210  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 ];
4211  };
4212  path.bounds = function(object) {
4213  d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity);
4214  d3.geo.stream(object, projectStream(d3_geo_pathBounds));
4215  return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ];
4216  };
4217  path.projection = function(_) {
4218  if (!arguments.length) return projection;
4219  projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity;
4220  return reset();
4221  };
4222  path.context = function(_) {
4223  if (!arguments.length) return context;
4224  contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_);
4225  if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius);
4226  return reset();
4227  };
4228  path.pointRadius = function(_) {
4229  if (!arguments.length) return pointRadius;
4230  pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_);
4231  return path;
4232  };
4233  function reset() {
4234  cacheStream = null;
4235  return path;
4236  }
4237  return path.projection(d3.geo.albersUsa()).context(null);
4238  };
4239  function d3_geo_pathProjectStream(project) {
4240  var resample = d3_geo_resample(function(x, y) {
4241  return project([ x * d3_degrees, y * d3_degrees ]);
4242  });
4243  return function(stream) {
4244  return d3_geo_projectionRadians(resample(stream));
4245  };
4246  }
4247  d3.geo.transform = function(methods) {
4248  return {
4249  stream: function(stream) {
4250  var transform = new d3_geo_transform(stream);
4251  for (var k in methods) transform[k] = methods[k];
4252  return transform;
4253  }
4254  };
4255  };
4256  function d3_geo_transform(stream) {
4257  this.stream = stream;
4258  }
4259  d3_geo_transform.prototype = {
4260  point: function(x, y) {
4261  this.stream.point(x, y);
4262  },
4263  sphere: function() {
4264  this.stream.sphere();
4265  },
4266  lineStart: function() {
4267  this.stream.lineStart();
4268  },
4269  lineEnd: function() {
4270  this.stream.lineEnd();
4271  },
4272  polygonStart: function() {
4273  this.stream.polygonStart();
4274  },
4275  polygonEnd: function() {
4276  this.stream.polygonEnd();
4277  }
4278  };
4279  function d3_geo_transformPoint(stream, point) {
4280  return {
4281  point: point,
4282  sphere: function() {
4283  stream.sphere();
4284  },
4285  lineStart: function() {
4286  stream.lineStart();
4287  },
4288  lineEnd: function() {
4289  stream.lineEnd();
4290  },
4291  polygonStart: function() {
4292  stream.polygonStart();
4293  },
4294  polygonEnd: function() {
4295  stream.polygonEnd();
4296  }
4297  };
4298  }
4299  d3.geo.projection = d3_geo_projection;
4300  d3.geo.projectionMutator = d3_geo_projectionMutator;
4301  function d3_geo_projection(project) {
4302  return d3_geo_projectionMutator(function() {
4303  return project;
4304  })();
4305  }
4306  function d3_geo_projectionMutator(projectAt) {
4307  var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) {
4308  x = project(x, y);
4309  return [ x[0] * k + δx, δy - x[1] * k ];
4310  }), 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;
4311  function projection(point) {
4312  point = projectRotate(point[0] * d3_radians, point[1] * d3_radians);
4313  return [ point[0] * k + δx, δy - point[1] * k ];
4314  }
4315  function invert(point) {
4316  point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k);
4317  return point && [ point[0] * d3_degrees, point[1] * d3_degrees ];
4318  }
4319  projection.stream = function(output) {
4320  if (stream) stream.valid = false;
4321  stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output))));
4322  stream.valid = true;
4323  return stream;
4324  };
4325  projection.clipAngle = function(_) {
4326  if (!arguments.length) return clipAngle;
4327  preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians);
4328  return invalidate();
4329  };
4330  projection.clipExtent = function(_) {
4331  if (!arguments.length) return clipExtent;
4332  clipExtent = _;
4333  postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity;
4334  return invalidate();
4335  };
4336  projection.scale = function(_) {
4337  if (!arguments.length) return k;
4338  k = +_;
4339  return reset();
4340  };
4341  projection.translate = function(_) {
4342  if (!arguments.length) return [ x, y ];
4343  x = +_[0];
4344  y = +_[1];
4345  return reset();
4346  };
4347  projection.center = function(_) {
4348  if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ];
4349  λ = _[0] % 360 * d3_radians;
4350  φ = _[1] % 360 * d3_radians;
4351  return reset();
4352  };
4353  projection.rotate = function(_) {
4354  if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ];
4355  δλ = _[0] % 360 * d3_radians;
4356  δφ = _[1] % 360 * d3_radians;
4357  δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0;
4358  return reset();
4359  };
4360  d3.rebind(projection, projectResample, "precision");
4361  function reset() {
4362  projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project);
4363  var center = project(λ, φ);
4364  δx = x - center[0] * k;
4365  δy = y + center[1] * k;
4366  return invalidate();
4367  }
4368  function invalidate() {
4369  if (stream) stream.valid = false, stream = null;
4370  return projection;
4371  }
4372  return function() {
4373  project = projectAt.apply(this, arguments);
4374  projection.invert = project.invert && invert;
4375  return reset();
4376  };
4377  }
4378  function d3_geo_projectionRadians(stream) {
4379  return d3_geo_transformPoint(stream, function(x, y) {
4380  stream.point(x * d3_radians, y * d3_radians);
4381  });
4382  }
4383  function d3_geo_equirectangular(λ, φ) {
4384  return [ λ, φ ];
4385  }
4386  (d3.geo.equirectangular = function() {
4387  return d3_geo_projection(d3_geo_equirectangular);
4388  }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular;
4389  d3.geo.rotation = function(rotate) {
4390  rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0);
4391  function forward(coordinates) {
4392  coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
4393  return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
4394  }
4395  forward.invert = function(coordinates) {
4396  coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians);
4397  return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;
4398  };
4399  return forward;
4400  };
4401  function d3_geo_identityRotation(λ, φ) {
4402  return [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];
4403  }
4404  d3_geo_identityRotation.invert = d3_geo_equirectangular;
4405  function d3_geo_rotation(δλ, δφ, δγ) {
4406  return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_identityRotation;
4407  }
4408  function d3_geo_forwardRotationλ(δλ) {
4409  return function(λ, φ) {
4410  return λ += δλ, [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];
4411  };
4412  }
4413  function d3_geo_rotationλ(δλ) {
4414  var rotation = d3_geo_forwardRotationλ(δλ);
4415  rotation.invert = d3_geo_forwardRotationλ(-δλ);
4416  return rotation;
4417  }
4418  function d3_geo_rotationφγ(δφ, δγ) {
4419  var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ);
4420  function rotation(λ, φ) {
4421  var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ;
4422  return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ];
4423  }
4424  rotation.invert = function(λ, φ) {
4425  var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ;
4426  return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ];
4427  };
4428  return rotation;
4429  }
4430  d3.geo.circle = function() {
4431  var origin = [ 0, 0 ], angle, precision = 6, interpolate;
4432  function circle() {
4433  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 = [];
4434  interpolate(null, null, 1, {
4435  point: function(x, y) {
4436  ring.push(x = rotate(x, y));
4437  x[0] *= d3_degrees, x[1] *= d3_degrees;
4438  }
4439  });
4440  return {
4441  type: "Polygon",
4442  coordinates: [ ring ]
4443  };
4444  }
4445  circle.origin = function(x) {
4446  if (!arguments.length) return origin;
4447  origin = x;
4448  return circle;
4449  };
4450  circle.angle = function(x) {
4451  if (!arguments.length) return angle;
4452  interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians);
4453  return circle;
4454  };
4455  circle.precision = function(_) {
4456  if (!arguments.length) return precision;
4457  interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians);
4458  return circle;
4459  };
4460  return circle.angle(90);
4461  };
4462  function d3_geo_circleInterpolate(radius, precision) {
4463  var cr = Math.cos(radius), sr = Math.sin(radius);
4464  return function(from, to, direction, listener) {
4465  var step = direction * precision;
4466  if (from != null) {
4467  from = d3_geo_circleAngle(cr, from);
4468  to = d3_geo_circleAngle(cr, to);
4469  if (direction > 0 ? from < to : from > to) from += direction * τ;
4470  } else {
4471  from = radius + direction * τ;
4472  to = radius - .5 * step;
4473  }
4474  for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) {
4475  listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]);
4476  }
4477  };
4478  }
4479  function d3_geo_circleAngle(cr, point) {
4480  var a = d3_geo_cartesian(point);
4481  a[0] -= cr;
4482  d3_geo_cartesianNormalize(a);
4483  var angle = d3_acos(-a[1]);
4484  return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI);
4485  }
4486  d3.geo.distance = function(a, b) {
4487  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;
4488  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Δλ);
4489  };
4490  d3.geo.graticule = function() {
4491  var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5;
4492  function graticule() {
4493  return {
4494  type: "MultiLineString",
4495  coordinates: lines()
4496  };
4497  }
4498  function lines() {
4499  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) {
4500  return abs(x % DX) > ε;
4501  }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) {
4502  return abs(y % DY) > ε;
4503  }).map(y));
4504  }
4505  graticule.lines = function() {
4506  return lines().map(function(coordinates) {
4507  return {
4508  type: "LineString",
4509  coordinates: coordinates
4510  };
4511  });
4512  };
4513  graticule.outline = function() {
4514  return {
4515  type: "Polygon",
4516  coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ]
4517  };
4518  };
4519  graticule.extent = function(_) {
4520  if (!arguments.length) return graticule.minorExtent();
4521  return graticule.majorExtent(_).minorExtent(_);
4522  };
4523  graticule.majorExtent = function(_) {
4524  if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ];
4525  X0 = +_[0][0], X1 = +_[1][0];
4526  Y0 = +_[0][1], Y1 = +_[1][1];
4527  if (X0 > X1) _ = X0, X0 = X1, X1 = _;
4528  if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;
4529  return graticule.precision(precision);
4530  };
4531  graticule.minorExtent = function(_) {
4532  if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];
4533  x0 = +_[0][0], x1 = +_[1][0];
4534  y0 = +_[0][1], y1 = +_[1][1];
4535  if (x0 > x1) _ = x0, x0 = x1, x1 = _;
4536  if (y0 > y1) _ = y0, y0 = y1, y1 = _;
4537  return graticule.precision(precision);
4538  };
4539  graticule.step = function(_) {
4540  if (!arguments.length) return graticule.minorStep();
4541  return graticule.majorStep(_).minorStep(_);
4542  };
4543  graticule.majorStep = function(_) {
4544  if (!arguments.length) return [ DX, DY ];
4545  DX = +_[0], DY = +_[1];
4546  return graticule;
4547  };
4548  graticule.minorStep = function(_) {
4549  if (!arguments.length) return [ dx, dy ];
4550  dx = +_[0], dy = +_[1];
4551  return graticule;
4552  };
4553  graticule.precision = function(_) {
4554  if (!arguments.length) return precision;
4555  precision = +_;
4556  x = d3_geo_graticuleX(y0, y1, 90);
4557  y = d3_geo_graticuleY(x0, x1, precision);
4558  X = d3_geo_graticuleX(Y0, Y1, 90);
4559  Y = d3_geo_graticuleY(X0, X1, precision);
4560  return graticule;
4561  };
4562  return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]);
4563  };
4564  function d3_geo_graticuleX(y0, y1, dy) {
4565  var y = d3.range(y0, y1 - ε, dy).concat(y1);
4566  return function(x) {
4567  return y.map(function(y) {
4568  return [ x, y ];
4569  });
4570  };
4571  }
4572  function d3_geo_graticuleY(x0, x1, dx) {
4573  var x = d3.range(x0, x1 - ε, dx).concat(x1);
4574  return function(y) {
4575  return x.map(function(x) {
4576  return [ x, y ];
4577  });
4578  };
4579  }
4580  function d3_source(d) {
4581  return d.source;
4582  }
4583  function d3_target(d) {
4584  return d.target;
4585  }
4586  d3.geo.greatArc = function() {
4587  var source = d3_source, source_, target = d3_target, target_;
4588  function greatArc() {
4589  return {
4590  type: "LineString",
4591  coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ]
4592  };
4593  }
4594  greatArc.distance = function() {
4595  return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments));
4596  };
4597  greatArc.source = function(_) {
4598  if (!arguments.length) return source;
4599  source = _, source_ = typeof _ === "function" ? null : _;
4600  return greatArc;
4601  };
4602  greatArc.target = function(_) {
4603  if (!arguments.length) return target;
4604  target = _, target_ = typeof _ === "function" ? null : _;
4605  return greatArc;
4606  };
4607  greatArc.precision = function() {
4608  return arguments.length ? greatArc : 0;
4609  };
4610  return greatArc;
4611  };
4612  d3.geo.interpolate = function(source, target) {
4613  return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians);
4614  };
4615  function d3_geo_interpolate(x0, y0, x1, y1) {
4616  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);
4617  var interpolate = d ? function(t) {
4618  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;
4619  return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ];
4620  } : function() {
4621  return [ x0 * d3_degrees, y0 * d3_degrees ];
4622  };
4623  interpolate.distance = d;
4624  return interpolate;
4625  }
4626  d3.geo.length = function(object) {
4627  d3_geo_lengthSum = 0;
4628  d3.geo.stream(object, d3_geo_length);
4629  return d3_geo_lengthSum;
4630  };
4631  var d3_geo_lengthSum;
4632  var d3_geo_length = {
4633  sphere: d3_noop,
4634  point: d3_noop,
4635  lineStart: d3_geo_lengthLineStart,
4636  lineEnd: d3_noop,
4637  polygonStart: d3_noop,
4638  polygonEnd: d3_noop
4639  };
4640  function d3_geo_lengthLineStart() {
4641  var λ0, sinφ0, cosφ0;
4642  d3_geo_length.point = function(λ, φ) {
4643  λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ);
4644  d3_geo_length.point = nextPoint;
4645  };
4646  d3_geo_length.lineEnd = function() {
4647  d3_geo_length.point = d3_geo_length.lineEnd = d3_noop;
4648  };
4649  function nextPoint(λ, φ) {
4650  var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t);
4651  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Δλ);
4652  λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ;
4653  }
4654  }
4655  function d3_geo_azimuthal(scale, angle) {
4656  function azimuthal(λ, φ) {
4657  var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ);
4658  return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ];
4659  }
4660  azimuthal.invert = function(x, y) {
4661  var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c);
4662  return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ];
4663  };
4664  return azimuthal;
4665  }
4666  var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) {
4667  return Math.sqrt(2 / (1 + cosλcosφ));
4668  }, function(ρ) {
4669  return 2 * Math.asin(ρ / 2);
4670  });
4671  (d3.geo.azimuthalEqualArea = function() {
4672  return d3_geo_projection(d3_geo_azimuthalEqualArea);
4673  }).raw = d3_geo_azimuthalEqualArea;
4674  var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) {
4675  var c = Math.acos(cosλcosφ);
4676  return c && c / Math.sin(c);
4677  }, d3_identity);
4678  (d3.geo.azimuthalEquidistant = function() {
4679  return d3_geo_projection(d3_geo_azimuthalEquidistant);
4680  }).raw = d3_geo_azimuthalEquidistant;
4681  function d3_geo_conicConformal(φ0, φ1) {
4682  var cosφ0 = Math.cos(φ0), t = function(φ) {
4683  return Math.tan(π / 4 + φ / 2);
4684  }, 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;
4685  if (!n) return d3_geo_mercator;
4686  function forward(λ, φ) {
4687  if (F > 0) {
4688  if (φ < -halfπ + ε) φ = -halfπ + ε;
4689  } else {
4690  if (φ > halfπ - ε) φ = halfπ - ε;
4691  }
4692  var ρ = F / Math.pow(t(φ), n);
4693  return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ];
4694  }
4695  forward.invert = function(x, y) {
4696  var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y);
4697  return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ ];
4698  };
4699  return forward;
4700  }
4701  (d3.geo.conicConformal = function() {
4702  return d3_geo_conic(d3_geo_conicConformal);
4703  }).raw = d3_geo_conicConformal;
4704  function d3_geo_conicEquidistant(φ0, φ1) {
4705  var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0;
4706  if (abs(n) < ε) return d3_geo_equirectangular;
4707  function forward(λ, φ) {
4708  var ρ = G - φ;
4709  return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ];
4710  }
4711  forward.invert = function(x, y) {
4712  var ρ0_y = G - y;
4713  return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ];
4714  };
4715  return forward;
4716  }
4717  (d3.geo.conicEquidistant = function() {
4718  return d3_geo_conic(d3_geo_conicEquidistant);
4719  }).raw = d3_geo_conicEquidistant;
4720  var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) {
4721  return 1 / cosλcosφ;
4722  }, Math.atan);
4723  (d3.geo.gnomonic = function() {
4724  return d3_geo_projection(d3_geo_gnomonic);
4725  }).raw = d3_geo_gnomonic;
4726  function d3_geo_mercator(λ, φ) {
4727  return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ];
4728  }
4729  d3_geo_mercator.invert = function(x, y) {
4730  return [ x, 2 * Math.atan(Math.exp(y)) - halfπ ];
4731  };
4732  function d3_geo_mercatorProjection(project) {
4733  var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto;
4734  m.scale = function() {
4735  var v = scale.apply(m, arguments);
4736  return v === m ? clipAuto ? m.clipExtent(null) : m : v;
4737  };
4738  m.translate = function() {
4739  var v = translate.apply(m, arguments);
4740  return v === m ? clipAuto ? m.clipExtent(null) : m : v;
4741  };
4742  m.clipExtent = function(_) {
4743  var v = clipExtent.apply(m, arguments);
4744  if (v === m) {
4745  if (clipAuto = _ == null) {
4746  var k = π * scale(), t = translate();
4747  clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]);
4748  }
4749  } else if (clipAuto) {
4750  v = null;
4751  }
4752  return v;
4753  };
4754  return m.clipExtent(null);
4755  }
4756  (d3.geo.mercator = function() {
4757  return d3_geo_mercatorProjection(d3_geo_mercator);
4758  }).raw = d3_geo_mercator;
4759  var d3_geo_orthographic = d3_geo_azimuthal(function() {
4760  return 1;
4761  }, Math.asin);
4762  (d3.geo.orthographic = function() {
4763  return d3_geo_projection(d3_geo_orthographic);
4764  }).raw = d3_geo_orthographic;
4765  var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) {
4766  return 1 / (1 + cosλcosφ);
4767  }, function(ρ) {
4768  return 2 * Math.atan(ρ);
4769  });
4770  (d3.geo.stereographic = function() {
4771  return d3_geo_projection(d3_geo_stereographic);
4772  }).raw = d3_geo_stereographic;
4773  function d3_geo_transverseMercator(λ, φ) {
4774  return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ];
4775  }
4776  d3_geo_transverseMercator.invert = function(x, y) {
4777  return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ];
4778  };
4779  (d3.geo.transverseMercator = function() {
4780  var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate;
4781  projection.center = function(_) {
4782  return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]);
4783  };
4784  projection.rotate = function(_) {
4785  return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(),
4786  [ _[0], _[1], _[2] - 90 ]);
4787  };
4788  return rotate([ 0, 0, 90 ]);
4789  }).raw = d3_geo_transverseMercator;
4790  d3.geom = {};
4791  function d3_geom_pointX(d) {
4792  return d[0];
4793  }
4794  function d3_geom_pointY(d) {
4795  return d[1];
4796  }
4797  d3.geom.hull = function(vertices) {
4798  var x = d3_geom_pointX, y = d3_geom_pointY;
4799  if (arguments.length) return hull(vertices);
4800  function hull(data) {
4801  if (data.length < 3) return [];
4802  var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = [];
4803  for (i = 0; i < n; i++) {
4804  points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]);
4805  }
4806  points.sort(d3_geom_hullOrder);
4807  for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]);
4808  var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints);
4809  var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = [];
4810  for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]);
4811  for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]);
4812  return polygon;
4813  }
4814  hull.x = function(_) {
4815  return arguments.length ? (x = _, hull) : x;
4816  };
4817  hull.y = function(_) {
4818  return arguments.length ? (y = _, hull) : y;
4819  };
4820  return hull;
4821  };
4822  function d3_geom_hullUpper(points) {
4823  var n = points.length, hull = [ 0, 1 ], hs = 2;
4824  for (var i = 2; i < n; i++) {
4825  while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs;
4826  hull[hs++] = i;
4827  }
4828  return hull.slice(0, hs);
4829  }
4830  function d3_geom_hullOrder(a, b) {
4831  return a[0] - b[0] || a[1] - b[1];
4832  }
4833  d3.geom.polygon = function(coordinates) {
4834  d3_subclass(coordinates, d3_geom_polygonPrototype);
4835  return coordinates;
4836  };
4837  var d3_geom_polygonPrototype = d3.geom.polygon.prototype = [];
4838  d3_geom_polygonPrototype.area = function() {
4839  var i = -1, n = this.length, a, b = this[n - 1], area = 0;
4840  while (++i < n) {
4841  a = b;
4842  b = this[i];
4843  area += a[1] * b[0] - a[0] * b[1];
4844  }
4845  return area * .5;
4846  };
4847  d3_geom_polygonPrototype.centroid = function(k) {
4848  var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c;
4849  if (!arguments.length) k = -1 / (6 * this.area());
4850  while (++i < n) {
4851  a = b;
4852  b = this[i];
4853  c = a[0] * b[1] - b[0] * a[1];
4854  x += (a[0] + b[0]) * c;
4855  y += (a[1] + b[1]) * c;
4856  }
4857  return [ x * k, y * k ];
4858  };
4859  d3_geom_polygonPrototype.clip = function(subject) {
4860  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;
4861  while (++i < n) {
4862  input = subject.slice();
4863  subject.length = 0;
4864  b = this[i];
4865  c = input[(m = input.length - closed) - 1];
4866  j = -1;
4867  while (++j < m) {
4868  d = input[j];
4869  if (d3_geom_polygonInside(d, a, b)) {
4870  if (!d3_geom_polygonInside(c, a, b)) {
4871  subject.push(d3_geom_polygonIntersect(c, d, a, b));
4872  }
4873  subject.push(d);
4874  } else if (d3_geom_polygonInside(c, a, b)) {
4875  subject.push(d3_geom_polygonIntersect(c, d, a, b));
4876  }
4877  c = d;
4878  }
4879  if (closed) subject.push(subject[0]);
4880  a = b;
4881  }
4882  return subject;
4883  };
4884  function d3_geom_polygonInside(p, a, b) {
4885  return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);
4886  }
4887  function d3_geom_polygonIntersect(c, d, a, b) {
4888  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);
4889  return [ x1 + ua * x21, y1 + ua * y21 ];
4890  }
4891  function d3_geom_polygonClosed(coordinates) {
4892  var a = coordinates[0], b = coordinates[coordinates.length - 1];
4893  return !(a[0] - b[0] || a[1] - b[1]);
4894  }
4895  var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = [];
4896  function d3_geom_voronoiBeach() {
4897  d3_geom_voronoiRedBlackNode(this);
4898  this.edge = this.site = this.circle = null;
4899  }
4900  function d3_geom_voronoiCreateBeach(site) {
4901  var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach();
4902  beach.site = site;
4903  return beach;
4904  }
4905  function d3_geom_voronoiDetachBeach(beach) {
4906  d3_geom_voronoiDetachCircle(beach);
4907  d3_geom_voronoiBeaches.remove(beach);
4908  d3_geom_voronoiBeachPool.push(beach);
4909  d3_geom_voronoiRedBlackNode(beach);
4910  }
4911  function d3_geom_voronoiRemoveBeach(beach) {
4912  var circle = beach.circle, x = circle.x, y = circle.cy, vertex = {
4913  x: x,
4914  y: y
4915  }, previous = beach.P, next = beach.N, disappearing = [ beach ];
4916  d3_geom_voronoiDetachBeach(beach);
4917  var lArc = previous;
4918  while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) {
4919  previous = lArc.P;
4920  disappearing.unshift(lArc);
4921  d3_geom_voronoiDetachBeach(lArc);
4922  lArc = previous;
4923  }
4924  disappearing.unshift(lArc);
4925  d3_geom_voronoiDetachCircle(lArc);
4926  var rArc = next;
4927  while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) {
4928  next = rArc.N;
4929  disappearing.push(rArc);
4930  d3_geom_voronoiDetachBeach(rArc);
4931  rArc = next;
4932  }
4933  disappearing.push(rArc);
4934  d3_geom_voronoiDetachCircle(rArc);
4935  var nArcs = disappearing.length, iArc;
4936  for (iArc = 1; iArc < nArcs; ++iArc) {
4937  rArc = disappearing[iArc];
4938  lArc = disappearing[iArc - 1];
4939  d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);
4940  }
4941  lArc = disappearing[0];
4942  rArc = disappearing[nArcs - 1];
4943  rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex);
4944  d3_geom_voronoiAttachCircle(lArc);
4945  d3_geom_voronoiAttachCircle(rArc);
4946  }
4947  function d3_geom_voronoiAddBeach(site) {
4948  var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._;
4949  while (node) {
4950  dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x;
4951  if (dxl > ε) node = node.L; else {
4952  dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix);
4953  if (dxr > ε) {
4954  if (!node.R) {
4955  lArc = node;
4956  break;
4957  }
4958  node = node.R;
4959  } else {
4960  if (dxl > -ε) {
4961  lArc = node.P;
4962  rArc = node;
4963  } else if (dxr > -ε) {
4964  lArc = node;
4965  rArc = node.N;
4966  } else {
4967  lArc = rArc = node;
4968  }
4969  break;
4970  }
4971  }
4972  }
4973  var newArc = d3_geom_voronoiCreateBeach(site);
4974  d3_geom_voronoiBeaches.insert(lArc, newArc);
4975  if (!lArc && !rArc) return;
4976  if (lArc === rArc) {
4977  d3_geom_voronoiDetachCircle(lArc);
4978  rArc = d3_geom_voronoiCreateBeach(lArc.site);
4979  d3_geom_voronoiBeaches.insert(newArc, rArc);
4980  newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);
4981  d3_geom_voronoiAttachCircle(lArc);
4982  d3_geom_voronoiAttachCircle(rArc);
4983  return;
4984  }
4985  if (!rArc) {
4986  newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);
4987  return;
4988  }
4989  d3_geom_voronoiDetachCircle(lArc);
4990  d3_geom_voronoiDetachCircle(rArc);
4991  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 = {
4992  x: (cy * hb - by * hc) / d + ax,
4993  y: (bx * hc - cx * hb) / d + ay
4994  };
4995  d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex);
4996  newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex);
4997  rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex);
4998  d3_geom_voronoiAttachCircle(lArc);
4999  d3_geom_voronoiAttachCircle(rArc);
5000  }
5001  function d3_geom_voronoiLeftBreakPoint(arc, directrix) {
5002  var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix;
5003  if (!pby2) return rfocx;
5004  var lArc = arc.P;
5005  if (!lArc) return -Infinity;
5006  site = lArc.site;
5007  var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix;
5008  if (!plby2) return lfocx;
5009  var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2;
5010  if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;
5011  return (rfocx + lfocx) / 2;
5012  }
5013  function d3_geom_voronoiRightBreakPoint(arc, directrix) {
5014  var rArc = arc.N;
5015  if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix);
5016  var site = arc.site;
5017  return site.y === directrix ? site.x : Infinity;
5018  }
5019  function d3_geom_voronoiCell(site) {
5020  this.site = site;
5021  this.edges = [];
5022  }
5023  d3_geom_voronoiCell.prototype.prepare = function() {
5024  var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge;
5025  while (iHalfEdge--) {
5026  edge = halfEdges[iHalfEdge].edge;
5027  if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1);
5028  }
5029  halfEdges.sort(d3_geom_voronoiHalfEdgeOrder);
5030  return halfEdges.length;
5031  };
5032  function d3_geom_voronoiCloseCells(extent) {
5033  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;
5034  while (iCell--) {
5035  cell = cells[iCell];
5036  if (!cell || !cell.prepare()) continue;
5037  halfEdges = cell.edges;
5038  nHalfEdges = halfEdges.length;
5039  iHalfEdge = 0;
5040  while (iHalfEdge < nHalfEdges) {
5041  end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y;
5042  start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y;
5043  if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) {
5044  halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? {
5045  x: x0,
5046  y: abs(x2 - x0) < ε ? y2 : y1
5047  } : abs(y3 - y1) < ε && x1 - x3 > ε ? {
5048  x: abs(y2 - y1) < ε ? x2 : x1,
5049  y: y1
5050  } : abs(x3 - x1) < ε && y3 - y0 > ε ? {
5051  x: x1,
5052  y: abs(x2 - x1) < ε ? y2 : y0
5053  } : abs(y3 - y0) < ε && x3 - x0 > ε ? {
5054  x: abs(y2 - y0) < ε ? x2 : x0,
5055  y: y0
5056  } : null), cell.site, null));
5057  ++nHalfEdges;
5058  }
5059  }
5060  }
5061  }
5062  function d3_geom_voronoiHalfEdgeOrder(a, b) {
5063  return b.angle - a.angle;
5064  }
5065  function d3_geom_voronoiCircle() {
5066  d3_geom_voronoiRedBlackNode(this);
5067  this.x = this.y = this.arc = this.site = this.cy = null;
5068  }
5069  function d3_geom_voronoiAttachCircle(arc) {
5070  var lArc = arc.P, rArc = arc.N;
5071  if (!lArc || !rArc) return;
5072  var lSite = lArc.site, cSite = arc.site, rSite = rArc.site;
5073  if (lSite === rSite) return;
5074  var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by;
5075  var d = 2 * (ax * cy - ay * cx);
5076  if (d >= -ε2) return;
5077  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;
5078  var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle();
5079  circle.arc = arc;
5080  circle.site = cSite;
5081  circle.x = x + bx;
5082  circle.y = cy + Math.sqrt(x * x + y * y);
5083  circle.cy = cy;
5084  arc.circle = circle;
5085  var before = null, node = d3_geom_voronoiCircles._;
5086  while (node) {
5087  if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) {
5088  if (node.L) node = node.L; else {
5089  before = node.P;
5090  break;
5091  }
5092  } else {
5093  if (node.R) node = node.R; else {
5094  before = node;
5095  break;
5096  }
5097  }
5098  }
5099  d3_geom_voronoiCircles.insert(before, circle);
5100  if (!before) d3_geom_voronoiFirstCircle = circle;
5101  }
5102  function d3_geom_voronoiDetachCircle(arc) {
5103  var circle = arc.circle;
5104  if (circle) {
5105  if (!circle.P) d3_geom_voronoiFirstCircle = circle.N;
5106  d3_geom_voronoiCircles.remove(circle);
5107  d3_geom_voronoiCirclePool.push(circle);
5108  d3_geom_voronoiRedBlackNode(circle);
5109  arc.circle = null;
5110  }
5111  }
5112  function d3_geom_voronoiClipEdges(extent) {
5113  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;
5114  while (i--) {
5115  e = edges[i];
5116  if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) {
5117  e.a = e.b = null;
5118  edges.splice(i, 1);
5119  }
5120  }
5121  }
5122  function d3_geom_voronoiConnectEdge(edge, extent) {
5123  var vb = edge.b;
5124  if (vb) return true;
5125  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;
5126  if (ry === ly) {
5127  if (fx < x0 || fx >= x1) return;
5128  if (lx > rx) {
5129  if (!va) va = {
5130  x: fx,
5131  y: y0
5132  }; else if (va.y >= y1) return;
5133  vb = {
5134  x: fx,
5135  y: y1
5136  };
5137  } else {
5138  if (!va) va = {
5139  x: fx,
5140  y: y1
5141  }; else if (va.y < y0) return;
5142  vb = {
5143  x: fx,
5144  y: y0
5145  };
5146  }
5147  } else {
5148  fm = (lx - rx) / (ry - ly);
5149  fb = fy - fm * fx;
5150  if (fm < -1 || fm > 1) {
5151  if (lx > rx) {
5152  if (!va) va = {
5153  x: (y0 - fb) / fm,
5154  y: y0
5155  }; else if (va.y >= y1) return;
5156  vb = {
5157  x: (y1 - fb) / fm,
5158  y: y1
5159  };
5160  } else {
5161  if (!va) va = {
5162  x: (y1 - fb) / fm,
5163  y: y1
5164  }; else if (va.y < y0) return;
5165  vb = {
5166  x: (y0 - fb) / fm,
5167  y: y0
5168  };
5169  }
5170  } else {
5171  if (ly < ry) {
5172  if (!va) va = {
5173  x: x0,
5174  y: fm * x0 + fb
5175  }; else if (va.x >= x1) return;
5176  vb = {
5177  x: x1,
5178  y: fm * x1 + fb
5179  };
5180  } else {
5181  if (!va) va = {
5182  x: x1,
5183  y: fm * x1 + fb
5184  }; else if (va.x < x0) return;
5185  vb = {
5186  x: x0,
5187  y: fm * x0 + fb
5188  };
5189  }
5190  }
5191  }
5192  edge.a = va;
5193  edge.b = vb;
5194  return true;
5195  }
5196  function d3_geom_voronoiEdge(lSite, rSite) {
5197  this.l = lSite;
5198  this.r = rSite;
5199  this.a = this.b = null;
5200  }
5201  function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) {
5202  var edge = new d3_geom_voronoiEdge(lSite, rSite);
5203  d3_geom_voronoiEdges.push(edge);
5204  if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va);
5205  if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb);
5206  d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite));
5207  d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite));
5208  return edge;
5209  }
5210  function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) {
5211  var edge = new d3_geom_voronoiEdge(lSite, null);
5212  edge.a = va;
5213  edge.b = vb;
5214  d3_geom_voronoiEdges.push(edge);
5215  return edge;
5216  }
5217  function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) {
5218  if (!edge.a && !edge.b) {
5219  edge.a = vertex;
5220  edge.l = lSite;
5221  edge.r = rSite;
5222  } else if (edge.l === rSite) {
5223  edge.b = vertex;
5224  } else {
5225  edge.a = vertex;
5226  }
5227  }
5228  function d3_geom_voronoiHalfEdge(edge, lSite, rSite) {
5229  var va = edge.a, vb = edge.b;
5230  this.edge = edge;
5231  this.site = lSite;
5232  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);
5233  }
5234  d3_geom_voronoiHalfEdge.prototype = {
5235  start: function() {
5236  return this.edge.l === this.site ? this.edge.a : this.edge.b;
5237  },
5238  end: function() {
5239  return this.edge.l === this.site ? this.edge.b : this.edge.a;
5240  }
5241  };
5242  function d3_geom_voronoiRedBlackTree() {
5243  this._ = null;
5244  }
5245  function d3_geom_voronoiRedBlackNode(node) {
5246  node.U = node.C = node.L = node.R = node.P = node.N = null;
5247  }
5248  d3_geom_voronoiRedBlackTree.prototype = {
5249  insert: function(after, node) {
5250  var parent, grandpa, uncle;
5251  if (after) {
5252  node.P = after;
5253  node.N = after.N;
5254  if (after.N) after.N.P = node;
5255  after.N = node;
5256  if (after.R) {
5257  after = after.R;
5258  while (after.L) after = after.L;
5259  after.L = node;
5260  } else {
5261  after.R = node;
5262  }
5263  parent = after;
5264  } else if (this._) {
5265  after = d3_geom_voronoiRedBlackFirst(this._);
5266  node.P = null;
5267  node.N = after;
5268  after.P = after.L = node;
5269  parent = after;
5270  } else {
5271  node.P = node.N = null;
5272  this._ = node;
5273  parent = null;
5274  }
5275  node.L = node.R = null;
5276  node.U = parent;
5277  node.C = true;
5278  after = node;
5279  while (parent && parent.C) {
5280  grandpa = parent.U;
5281  if (parent === grandpa.L) {
5282  uncle = grandpa.R;
5283  if (uncle && uncle.C) {
5284  parent.C = uncle.C = false;
5285  grandpa.C = true;
5286  after = grandpa;
5287  } else {
5288  if (after === parent.R) {
5289  d3_geom_voronoiRedBlackRotateLeft(this, parent);
5290  after = parent;
5291  parent = after.U;
5292  }
5293  parent.C = false;
5294  grandpa.C = true;
5295  d3_geom_voronoiRedBlackRotateRight(this, grandpa);
5296  }
5297  } else {
5298  uncle = grandpa.L;
5299  if (uncle && uncle.C) {
5300  parent.C = uncle.C = false;
5301  grandpa.C = true;
5302  after = grandpa;
5303  } else {
5304  if (after === parent.L) {
5305  d3_geom_voronoiRedBlackRotateRight(this, parent);
5306  after = parent;
5307  parent = after.U;
5308  }
5309  parent.C = false;
5310  grandpa.C = true;
5311  d3_geom_voronoiRedBlackRotateLeft(this, grandpa);
5312  }
5313  }
5314  parent = after.U;
5315  }
5316  this._.C = false;
5317  },
5318  remove: function(node) {
5319  if (node.N) node.N.P = node.P;
5320  if (node.P) node.P.N = node.N;
5321  node.N = node.P = null;
5322  var parent = node.U, sibling, left = node.L, right = node.R, next, red;
5323  if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right);
5324  if (parent) {
5325  if (parent.L === node) parent.L = next; else parent.R = next;
5326  } else {
5327  this._ = next;
5328  }
5329  if (left && right) {
5330  red = next.C;
5331  next.C = node.C;
5332  next.L = left;
5333  left.U = next;
5334  if (next !== right) {
5335  parent = next.U;
5336  next.U = node.U;
5337  node = next.R;
5338  parent.L = node;
5339  next.R = right;
5340  right.U = next;
5341  } else {
5342  next.U = parent;
5343  parent = next;
5344  node = next.R;
5345  }
5346  } else {
5347  red = node.C;
5348  node = next;
5349  }
5350  if (node) node.U = parent;
5351  if (red) return;
5352  if (node && node.C) {
5353  node.C = false;
5354  return;
5355  }
5356  do {
5357  if (node === this._) break;
5358  if (node === parent.L) {
5359  sibling = parent.R;
5360  if (sibling.C) {
5361  sibling.C = false;
5362  parent.C = true;
5363  d3_geom_voronoiRedBlackRotateLeft(this, parent);
5364  sibling = parent.R;
5365  }
5366  if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
5367  if (!sibling.R || !sibling.R.C) {
5368  sibling.L.C = false;
5369  sibling.C = true;
5370  d3_geom_voronoiRedBlackRotateRight(this, sibling);
5371  sibling = parent.R;
5372  }
5373  sibling.C = parent.C;
5374  parent.C = sibling.R.C = false;
5375  d3_geom_voronoiRedBlackRotateLeft(this, parent);
5376  node = this._;
5377  break;
5378  }
5379  } else {
5380  sibling = parent.L;
5381  if (sibling.C) {
5382  sibling.C = false;
5383  parent.C = true;
5384  d3_geom_voronoiRedBlackRotateRight(this, parent);
5385  sibling = parent.L;
5386  }
5387  if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {
5388  if (!sibling.L || !sibling.L.C) {
5389  sibling.R.C = false;
5390  sibling.C = true;
5391  d3_geom_voronoiRedBlackRotateLeft(this, sibling);
5392  sibling = parent.L;
5393  }
5394  sibling.C = parent.C;
5395  parent.C = sibling.L.C = false;
5396  d3_geom_voronoiRedBlackRotateRight(this, parent);
5397  node = this._;
5398  break;
5399  }
5400  }
5401  sibling.C = true;
5402  node = parent;
5403  parent = parent.U;
5404  } while (!node.C);
5405  if (node) node.C = false;
5406  }
5407  };
5408  function d3_geom_voronoiRedBlackRotateLeft(tree, node) {
5409  var p = node, q = node.R, parent = p.U;
5410  if (parent) {
5411  if (parent.L === p) parent.L = q; else parent.R = q;
5412  } else {
5413  tree._ = q;
5414  }
5415  q.U = parent;
5416  p.U = q;
5417  p.R = q.L;
5418  if (p.R) p.R.U = p;
5419  q.L = p;
5420  }
5421  function d3_geom_voronoiRedBlackRotateRight(tree, node) {
5422  var p = node, q = node.L, parent = p.U;
5423  if (parent) {
5424  if (parent.L === p) parent.L = q; else parent.R = q;
5425  } else {
5426  tree._ = q;
5427  }
5428  q.U = parent;
5429  p.U = q;
5430  p.L = q.R;
5431  if (p.L) p.L.U = p;
5432  q.R = p;
5433  }
5434  function d3_geom_voronoiRedBlackFirst(node) {
5435  while (node.L) node = node.L;
5436  return node;
5437  }
5438  function d3_geom_voronoi(sites, bbox) {
5439  var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle;
5440  d3_geom_voronoiEdges = [];
5441  d3_geom_voronoiCells = new Array(sites.length);
5442  d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree();
5443  d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree();
5444  while (true) {
5445  circle = d3_geom_voronoiFirstCircle;
5446  if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) {
5447  if (site.x !== x0 || site.y !== y0) {
5448  d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site);
5449  d3_geom_voronoiAddBeach(site);
5450  x0 = site.x, y0 = site.y;
5451  }
5452  site = sites.pop();
5453  } else if (circle) {
5454  d3_geom_voronoiRemoveBeach(circle.arc);
5455  } else {
5456  break;
5457  }
5458  }
5459  if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox);
5460  var diagram = {
5461  cells: d3_geom_voronoiCells,
5462  edges: d3_geom_voronoiEdges
5463  };
5464  d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null;
5465  return diagram;
5466  }
5467  function d3_geom_voronoiVertexOrder(a, b) {
5468  return b.y - a.y || b.x - a.x;
5469  }
5470  d3.geom.voronoi = function(points) {
5471  var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent;
5472  if (points) return voronoi(points);
5473  function voronoi(data) {
5474  var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1];
5475  d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) {
5476  var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) {
5477  var s = e.start();
5478  return [ s.x, s.y ];
5479  }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : [];
5480  polygon.point = data[i];
5481  });
5482  return polygons;
5483  }
5484  function sites(data) {
5485  return data.map(function(d, i) {
5486  return {
5487  x: Math.round(fx(d, i) / ε) * ε,
5488  y: Math.round(fy(d, i) / ε) * ε,
5489  i: i
5490  };
5491  });
5492  }
5493  voronoi.links = function(data) {
5494  return d3_geom_voronoi(sites(data)).edges.filter(function(edge) {
5495  return edge.l && edge.r;
5496  }).map(function(edge) {
5497  return {
5498  source: data[edge.l.i],
5499  target: data[edge.r.i]
5500  };
5501  });
5502  };
5503  voronoi.triangles = function(data) {
5504  var triangles = [];
5505  d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) {
5506  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;
5507  while (++j < m) {
5508  e0 = e1;
5509  s0 = s1;
5510  e1 = edges[j].edge;
5511  s1 = e1.l === site ? e1.r : e1.l;
5512  if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) {
5513  triangles.push([ data[i], data[s0.i], data[s1.i] ]);
5514  }
5515  }
5516  });
5517  return triangles;
5518  };
5519  voronoi.x = function(_) {
5520  return arguments.length ? (fx = d3_functor(x = _), voronoi) : x;
5521  };
5522  voronoi.y = function(_) {
5523  return arguments.length ? (fy = d3_functor(y = _), voronoi) : y;
5524  };
5525  voronoi.clipExtent = function(_) {
5526  if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent;
5527  clipExtent = _ == null ? d3_geom_voronoiClipExtent : _;
5528  return voronoi;
5529  };
5530  voronoi.size = function(_) {
5531  if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1];
5532  return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]);
5533  };
5534  return voronoi;
5535  };
5536  var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ];
5537  function d3_geom_voronoiTriangleArea(a, b, c) {
5538  return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y);
5539  }
5540  d3.geom.delaunay = function(vertices) {
5541  return d3.geom.voronoi().triangles(vertices);
5542  };
5543  d3.geom.quadtree = function(points, x1, y1, x2, y2) {
5544  var x = d3_geom_pointX, y = d3_geom_pointY, compat;
5545  if (compat = arguments.length) {
5546  x = d3_geom_quadtreeCompatX;
5547  y = d3_geom_quadtreeCompatY;
5548  if (compat === 3) {
5549  y2 = y1;
5550  x2 = x1;
5551  y1 = x1 = 0;
5552  }
5553  return quadtree(points);
5554  }
5555  function quadtree(data) {
5556  var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_;
5557  if (x1 != null) {
5558  x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2;
5559  } else {
5560  x2_ = y2_ = -(x1_ = y1_ = Infinity);
5561  xs = [], ys = [];
5562  n = data.length;
5563  if (compat) for (i = 0; i < n; ++i) {
5564  d = data[i];
5565  if (d.x < x1_) x1_ = d.x;
5566  if (d.y < y1_) y1_ = d.y;
5567  if (d.x > x2_) x2_ = d.x;
5568  if (d.y > y2_) y2_ = d.y;
5569  xs.push(d.x);
5570  ys.push(d.y);
5571  } else for (i = 0; i < n; ++i) {
5572  var x_ = +fx(d = data[i], i), y_ = +fy(d, i);
5573  if (x_ < x1_) x1_ = x_;
5574  if (y_ < y1_) y1_ = y_;
5575  if (x_ > x2_) x2_ = x_;
5576  if (y_ > y2_) y2_ = y_;
5577  xs.push(x_);
5578  ys.push(y_);
5579  }
5580  }
5581  var dx = x2_ - x1_, dy = y2_ - y1_;
5582  if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy;
5583  function insert(n, d, x, y, x1, y1, x2, y2) {
5584  if (isNaN(x) || isNaN(y)) return;
5585  if (n.leaf) {
5586  var nx = n.x, ny = n.y;
5587  if (nx != null) {
5588  if (abs(nx - x) + abs(ny - y) < .01) {
5589  insertChild(n, d, x, y, x1, y1, x2, y2);
5590  } else {
5591  var nPoint = n.point;
5592  n.x = n.y = n.point = null;
5593  insertChild(n, nPoint, nx, ny, x1, y1, x2, y2);
5594  insertChild(n, d, x, y, x1, y1, x2, y2);
5595  }
5596  } else {
5597  n.x = x, n.y = y, n.point = d;
5598  }
5599  } else {
5600  insertChild(n, d, x, y, x1, y1, x2, y2);
5601  }
5602  }
5603  function insertChild(n, d, x, y, x1, y1, x2, y2) {
5604  var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right;
5605  n.leaf = false;
5606  n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());
5607  if (right) x1 = xm; else x2 = xm;
5608  if (below) y1 = ym; else y2 = ym;
5609  insert(n, d, x, y, x1, y1, x2, y2);
5610  }
5611  var root = d3_geom_quadtreeNode();
5612  root.add = function(d) {
5613  insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_);
5614  };
5615  root.visit = function(f) {
5616  d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_);
5617  };
5618  root.find = function(point) {
5619  return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_);
5620  };
5621  i = -1;
5622  if (x1 == null) {
5623  while (++i < n) {
5624  insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_);
5625  }
5626  --i;
5627  } else data.forEach(root.add);
5628  xs = ys = data = d = null;
5629  return root;
5630  }
5631  quadtree.x = function(_) {
5632  return arguments.length ? (x = _, quadtree) : x;
5633  };
5634  quadtree.y = function(_) {
5635  return arguments.length ? (y = _, quadtree) : y;
5636  };
5637  quadtree.extent = function(_) {
5638  if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ];
5639  if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0],
5640  y2 = +_[1][1];
5641  return quadtree;
5642  };
5643  quadtree.size = function(_) {
5644  if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ];
5645  if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1];
5646  return quadtree;
5647  };
5648  return quadtree;
5649  };
5650  function d3_geom_quadtreeCompatX(d) {
5651  return d.x;
5652  }
5653  function d3_geom_quadtreeCompatY(d) {
5654  return d.y;
5655  }
5656  function d3_geom_quadtreeNode() {
5657  return {
5658  leaf: true,
5659  nodes: [],
5660  point: null,
5661  x: null,
5662  y: null
5663  };
5664  }
5665  function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {
5666  if (!f(node, x1, y1, x2, y2)) {
5667  var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes;
5668  if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);
5669  if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);
5670  if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);
5671  if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
5672  }
5673  }
5674  function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) {
5675  var minDistance2 = Infinity, closestPoint;
5676  (function find(node, x1, y1, x2, y2) {
5677  if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return;
5678  if (point = node.point) {
5679  var point, dx = x - node.x, dy = y - node.y, distance2 = dx * dx + dy * dy;
5680  if (distance2 < minDistance2) {
5681  var distance = Math.sqrt(minDistance2 = distance2);
5682  x0 = x - distance, y0 = y - distance;
5683  x3 = x + distance, y3 = y + distance;
5684  closestPoint = point;
5685  }
5686  }
5687  var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym;
5688  for (var i = below << 1 | right, j = i + 4; i < j; ++i) {
5689  if (node = children[i & 3]) switch (i & 3) {
5690  case 0:
5691  find(node, x1, y1, xm, ym);
5692  break;
5693 
5694  case 1:
5695  find(node, xm, y1, x2, ym);
5696  break;
5697 
5698  case 2:
5699  find(node, x1, ym, xm, y2);
5700  break;
5701 
5702  case 3:
5703  find(node, xm, ym, x2, y2);
5704  break;
5705  }
5706  }
5707  })(root, x0, y0, x3, y3);
5708  return closestPoint;
5709  }
5710  d3.interpolateRgb = d3_interpolateRgb;
5711  function d3_interpolateRgb(a, b) {
5712  a = d3.rgb(a);
5713  b = d3.rgb(b);
5714  var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab;
5715  return function(t) {
5716  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));
5717  };
5718  }
5719  d3.interpolateObject = d3_interpolateObject;
5720  function d3_interpolateObject(a, b) {
5721  var i = {}, c = {}, k;
5722  for (k in a) {
5723  if (k in b) {
5724  i[k] = d3_interpolate(a[k], b[k]);
5725  } else {
5726  c[k] = a[k];
5727  }
5728  }
5729  for (k in b) {
5730  if (!(k in a)) {
5731  c[k] = b[k];
5732  }
5733  }
5734  return function(t) {
5735  for (k in i) c[k] = i[k](t);
5736  return c;
5737  };
5738  }
5739  d3.interpolateNumber = d3_interpolateNumber;
5740  function d3_interpolateNumber(a, b) {
5741  a = +a, b = +b;
5742  return function(t) {
5743  return a * (1 - t) + b * t;
5744  };
5745  }
5746  d3.interpolateString = d3_interpolateString;
5747  function d3_interpolateString(a, b) {
5748  var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = [];
5749  a = a + "", b = b + "";
5750  while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) {
5751  if ((bs = bm.index) > bi) {
5752  bs = b.slice(bi, bs);
5753  if (s[i]) s[i] += bs; else s[++i] = bs;
5754  }
5755  if ((am = am[0]) === (bm = bm[0])) {
5756  if (s[i]) s[i] += bm; else s[++i] = bm;
5757  } else {
5758  s[++i] = null;
5759  q.push({
5760  i: i,
5761  x: d3_interpolateNumber(am, bm)
5762  });
5763  }
5764  bi = d3_interpolate_numberB.lastIndex;
5765  }
5766  if (bi < b.length) {
5767  bs = b.slice(bi);
5768  if (s[i]) s[i] += bs; else s[++i] = bs;
5769  }
5770  return s.length < 2 ? q[0] ? (b = q[0].x, function(t) {
5771  return b(t) + "";
5772  }) : function() {
5773  return b;
5774  } : (b = q.length, function(t) {
5775  for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
5776  return s.join("");
5777  });
5778  }
5779  var d3_interpolate_numberA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, "g");
5780  d3.interpolate = d3_interpolate;
5781  function d3_interpolate(a, b) {
5782  var i = d3.interpolators.length, f;
5783  while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ;
5784  return f;
5785  }
5786  d3.interpolators = [ function(a, b) {
5787  var t = typeof b;
5788  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);
5789  } ];
5790  d3.interpolateArray = d3_interpolateArray;
5791  function d3_interpolateArray(a, b) {
5792  var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i;
5793  for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i]));
5794  for (;i < na; ++i) c[i] = a[i];
5795  for (;i < nb; ++i) c[i] = b[i];
5796  return function(t) {
5797  for (i = 0; i < n0; ++i) c[i] = x[i](t);
5798  return c;
5799  };
5800  }
5801  var d3_ease_default = function() {
5802  return d3_identity;
5803  };
5804  var d3_ease = d3.map({
5805  linear: d3_ease_default,
5806  poly: d3_ease_poly,
5807  quad: function() {
5808  return d3_ease_quad;
5809  },
5810  cubic: function() {
5811  return d3_ease_cubic;
5812  },
5813  sin: function() {
5814  return d3_ease_sin;
5815  },
5816  exp: function() {
5817  return d3_ease_exp;
5818  },
5819  circle: function() {
5820  return d3_ease_circle;
5821  },
5822  elastic: d3_ease_elastic,
5823  back: d3_ease_back,
5824  bounce: function() {
5825  return d3_ease_bounce;
5826  }
5827  });
5828  var d3_ease_mode = d3.map({
5829  "in": d3_identity,
5830  out: d3_ease_reverse,
5831  "in-out": d3_ease_reflect,
5832  "out-in": function(f) {
5833  return d3_ease_reflect(d3_ease_reverse(f));
5834  }
5835  });
5836  d3.ease = function(name) {
5837  var i = name.indexOf("-"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : "in";
5838  t = d3_ease.get(t) || d3_ease_default;
5839  m = d3_ease_mode.get(m) || d3_identity;
5840  return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1))));
5841  };
5842  function d3_ease_clamp(f) {
5843  return function(t) {
5844  return t <= 0 ? 0 : t >= 1 ? 1 : f(t);
5845  };
5846  }
5847  function d3_ease_reverse(f) {
5848  return function(t) {
5849  return 1 - f(1 - t);
5850  };
5851  }
5852  function d3_ease_reflect(f) {
5853  return function(t) {
5854  return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t));
5855  };
5856  }
5857  function d3_ease_quad(t) {
5858  return t * t;
5859  }
5860  function d3_ease_cubic(t) {
5861  return t * t * t;
5862  }
5863  function d3_ease_cubicInOut(t) {
5864  if (t <= 0) return 0;
5865  if (t >= 1) return 1;
5866  var t2 = t * t, t3 = t2 * t;
5867  return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75);
5868  }
5869  function d3_ease_poly(e) {
5870  return function(t) {
5871  return Math.pow(t, e);
5872  };
5873  }
5874  function d3_ease_sin(t) {
5875  return 1 - Math.cos(t * halfπ);
5876  }
5877  function d3_ease_exp(t) {
5878  return Math.pow(2, 10 * (t - 1));
5879  }
5880  function d3_ease_circle(t) {
5881  return 1 - Math.sqrt(1 - t * t);
5882  }
5883  function d3_ease_elastic(a, p) {
5884  var s;
5885  if (arguments.length < 2) p = .45;
5886  if (arguments.length) s = p / τ * Math.asin(1 / a); else a = 1, s = p / 4;
5887  return function(t) {
5888  return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p);
5889  };
5890  }
5891  function d3_ease_back(s) {
5892  if (!s) s = 1.70158;
5893  return function(t) {
5894  return t * t * ((s + 1) * t - s);
5895  };
5896  }
5897  function d3_ease_bounce(t) {
5898  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;
5899  }
5900  d3.interpolateHcl = d3_interpolateHcl;
5901  function d3_interpolateHcl(a, b) {
5902  a = d3.hcl(a);
5903  b = d3.hcl(b);
5904  var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al;
5905  if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac;
5906  if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
5907  return function(t) {
5908  return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + "";
5909  };
5910  }
5911  d3.interpolateHsl = d3_interpolateHsl;
5912  function d3_interpolateHsl(a, b) {
5913  a = d3.hsl(a);
5914  b = d3.hsl(b);
5915  var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al;
5916  if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as;
5917  if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
5918  return function(t) {
5919  return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + "";
5920  };
5921  }
5922  d3.interpolateLab = d3_interpolateLab;
5923  function d3_interpolateLab(a, b) {
5924  a = d3.lab(a);
5925  b = d3.lab(b);
5926  var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab;
5927  return function(t) {
5928  return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + "";
5929  };
5930  }
5931  d3.interpolateRound = d3_interpolateRound;
5932  function d3_interpolateRound(a, b) {
5933  b -= a;
5934  return function(t) {
5935  return Math.round(a + b * t);
5936  };
5937  }
5938  d3.transform = function(string) {
5939  var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
5940  return (d3.transform = function(string) {
5941  if (string != null) {
5942  g.setAttribute("transform", string);
5943  var t = g.transform.baseVal.consolidate();
5944  }
5945  return new d3_transform(t ? t.matrix : d3_transformIdentity);
5946  })(string);
5947  };
5948  function d3_transform(m) {
5949  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;
5950  if (r0[0] * r1[1] < r1[0] * r0[1]) {
5951  r0[0] *= -1;
5952  r0[1] *= -1;
5953  kx *= -1;
5954  kz *= -1;
5955  }
5956  this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees;
5957  this.translate = [ m.e, m.f ];
5958  this.scale = [ kx, ky ];
5959  this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0;
5960  }
5961  d3_transform.prototype.toString = function() {
5962  return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")";
5963  };
5964  function d3_transformDot(a, b) {
5965  return a[0] * b[0] + a[1] * b[1];
5966  }
5967  function d3_transformNormalize(a) {
5968  var k = Math.sqrt(d3_transformDot(a, a));
5969  if (k) {
5970  a[0] /= k;
5971  a[1] /= k;
5972  }
5973  return k;
5974  }
5975  function d3_transformCombine(a, b, k) {
5976  a[0] += k * b[0];
5977  a[1] += k * b[1];
5978  return a;
5979  }
5980  var d3_transformIdentity = {
5981  a: 1,
5982  b: 0,
5983  c: 0,
5984  d: 1,
5985  e: 0,
5986  f: 0
5987  };
5988  d3.interpolateTransform = d3_interpolateTransform;
5989  function d3_interpolateTransform(a, b) {
5990  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;
5991  if (ta[0] != tb[0] || ta[1] != tb[1]) {
5992  s.push("translate(", null, ",", null, ")");
5993  q.push({
5994  i: 1,
5995  x: d3_interpolateNumber(ta[0], tb[0])
5996  }, {
5997  i: 3,
5998  x: d3_interpolateNumber(ta[1], tb[1])
5999  });
6000  } else if (tb[0] || tb[1]) {
6001  s.push("translate(" + tb + ")");
6002  } else {
6003  s.push("");
6004  }
6005  if (ra != rb) {
6006  if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360;
6007  q.push({
6008  i: s.push(s.pop() + "rotate(", null, ")") - 2,
6009  x: d3_interpolateNumber(ra, rb)
6010  });
6011  } else if (rb) {
6012  s.push(s.pop() + "rotate(" + rb + ")");
6013  }
6014  if (wa != wb) {
6015  q.push({
6016  i: s.push(s.pop() + "skewX(", null, ")") - 2,
6017  x: d3_interpolateNumber(wa, wb)
6018  });
6019  } else if (wb) {
6020  s.push(s.pop() + "skewX(" + wb + ")");
6021  }
6022  if (ka[0] != kb[0] || ka[1] != kb[1]) {
6023  n = s.push(s.pop() + "scale(", null, ",", null, ")");
6024  q.push({
6025  i: n - 4,
6026  x: d3_interpolateNumber(ka[0], kb[0])
6027  }, {
6028  i: n - 2,
6029  x: d3_interpolateNumber(ka[1], kb[1])
6030  });
6031  } else if (kb[0] != 1 || kb[1] != 1) {
6032  s.push(s.pop() + "scale(" + kb + ")");
6033  }
6034  n = q.length;
6035  return function(t) {
6036  var i = -1, o;
6037  while (++i < n) s[(o = q[i]).i] = o.x(t);
6038  return s.join("");
6039  };
6040  }
6041  function d3_uninterpolateNumber(a, b) {
6042  b = (b -= a = +a) || 1 / b;
6043  return function(x) {
6044  return (x - a) / b;
6045  };
6046  }
6047  function d3_uninterpolateClamp(a, b) {
6048  b = (b -= a = +a) || 1 / b;
6049  return function(x) {
6050  return Math.max(0, Math.min(1, (x - a) / b));
6051  };
6052  }
6053  d3.layout = {};
6054  d3.layout.bundle = function() {
6055  return function(links) {
6056  var paths = [], i = -1, n = links.length;
6057  while (++i < n) paths.push(d3_layout_bundlePath(links[i]));
6058  return paths;
6059  };
6060  };
6061  function d3_layout_bundlePath(link) {
6062  var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ];
6063  while (start !== lca) {
6064  start = start.parent;
6065  points.push(start);
6066  }
6067  var k = points.length;
6068  while (end !== lca) {
6069  points.splice(k, 0, end);
6070  end = end.parent;
6071  }
6072  return points;
6073  }
6074  function d3_layout_bundleAncestors(node) {
6075  var ancestors = [], parent = node.parent;
6076  while (parent != null) {
6077  ancestors.push(node);
6078  node = parent;
6079  parent = parent.parent;
6080  }
6081  ancestors.push(node);
6082  return ancestors;
6083  }
6084  function d3_layout_bundleLeastCommonAncestor(a, b) {
6085  if (a === b) return a;
6086  var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null;
6087  while (aNode === bNode) {
6088  sharedNode = aNode;
6089  aNode = aNodes.pop();
6090  bNode = bNodes.pop();
6091  }
6092  return sharedNode;
6093  }
6094  d3.layout.chord = function() {
6095  var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;
6096  function relayout() {
6097  var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j;
6098  chords = [];
6099  groups = [];
6100  k = 0, i = -1;
6101  while (++i < n) {
6102  x = 0, j = -1;
6103  while (++j < n) {
6104  x += matrix[i][j];
6105  }
6106  groupSums.push(x);
6107  subgroupIndex.push(d3.range(n));
6108  k += x;
6109  }
6110  if (sortGroups) {
6111  groupIndex.sort(function(a, b) {
6112  return sortGroups(groupSums[a], groupSums[b]);
6113  });
6114  }
6115  if (sortSubgroups) {
6116  subgroupIndex.forEach(function(d, i) {
6117  d.sort(function(a, b) {
6118  return sortSubgroups(matrix[i][a], matrix[i][b]);
6119  });
6120  });
6121  }
6122  k = (τ - padding * n) / k;
6123  x = 0, i = -1;
6124  while (++i < n) {
6125  x0 = x, j = -1;
6126  while (++j < n) {
6127  var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;
6128  subgroups[di + "-" + dj] = {
6129  index: di,
6130  subindex: dj,
6131  startAngle: a0,
6132  endAngle: a1,
6133  value: v
6134  };
6135  }
6136  groups[di] = {
6137  index: di,
6138  startAngle: x0,
6139  endAngle: x,
6140  value: (x - x0) / k
6141  };
6142  x += padding;
6143  }
6144  i = -1;
6145  while (++i < n) {
6146  j = i - 1;
6147  while (++j < n) {
6148  var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i];
6149  if (source.value || target.value) {
6150  chords.push(source.value < target.value ? {
6151  source: target,
6152  target: source
6153  } : {
6154  source: source,
6155  target: target
6156  });
6157  }
6158  }
6159  }
6160  if (sortChords) resort();
6161  }
6162  function resort() {
6163  chords.sort(function(a, b) {
6164  return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2);
6165  });
6166  }
6167  chord.matrix = function(x) {
6168  if (!arguments.length) return matrix;
6169  n = (matrix = x) && matrix.length;
6170  chords = groups = null;
6171  return chord;
6172  };
6173  chord.padding = function(x) {
6174  if (!arguments.length) return padding;
6175  padding = x;
6176  chords = groups = null;
6177  return chord;
6178  };
6179  chord.sortGroups = function(x) {
6180  if (!arguments.length) return sortGroups;
6181  sortGroups = x;
6182  chords = groups = null;
6183  return chord;
6184  };
6185  chord.sortSubgroups = function(x) {
6186  if (!arguments.length) return sortSubgroups;
6187  sortSubgroups = x;
6188  chords = null;
6189  return chord;
6190  };
6191  chord.sortChords = function(x) {
6192  if (!arguments.length) return sortChords;
6193  sortChords = x;
6194  if (chords) resort();
6195  return chord;
6196  };
6197  chord.chords = function() {
6198  if (!chords) relayout();
6199  return chords;
6200  };
6201  chord.groups = function() {
6202  if (!groups) relayout();
6203  return groups;
6204  };
6205  return chord;
6206  };
6207  d3.layout.force = function() {
6208  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;
6209  function repulse(node) {
6210  return function(quad, x1, _, x2) {
6211  if (quad.point !== node) {
6212  var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy;
6213  if (dw * dw / theta2 < dn) {
6214  if (dn < chargeDistance2) {
6215  var k = quad.charge / dn;
6216  node.px -= dx * k;
6217  node.py -= dy * k;
6218  }
6219  return true;
6220  }
6221  if (quad.point && dn && dn < chargeDistance2) {
6222  var k = quad.pointCharge / dn;
6223  node.px -= dx * k;
6224  node.py -= dy * k;
6225  }
6226  }
6227  return !quad.charge;
6228  };
6229  }
6230  force.tick = function() {
6231  if ((alpha *= .99) < .005) {
6232  event.end({
6233  type: "end",
6234  alpha: alpha = 0
6235  });
6236  return true;
6237  }
6238  var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y;
6239  for (i = 0; i < m; ++i) {
6240  o = links[i];
6241  s = o.source;
6242  t = o.target;
6243  x = t.x - s.x;
6244  y = t.y - s.y;
6245  if (l = x * x + y * y) {
6246  l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;
6247  x *= l;
6248  y *= l;
6249  t.x -= x * (k = s.weight / (t.weight + s.weight));
6250  t.y -= y * k;
6251  s.x += x * (k = 1 - k);
6252  s.y += y * k;
6253  }
6254  }
6255  if (k = alpha * gravity) {
6256  x = size[0] / 2;
6257  y = size[1] / 2;
6258  i = -1;
6259  if (k) while (++i < n) {
6260  o = nodes[i];
6261  o.x += (x - o.x) * k;
6262  o.y += (y - o.y) * k;
6263  }
6264  }
6265  if (charge) {
6266  d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges);
6267  i = -1;
6268  while (++i < n) {
6269  if (!(o = nodes[i]).fixed) {
6270  q.visit(repulse(o));
6271  }
6272  }
6273  }
6274  i = -1;
6275  while (++i < n) {
6276  o = nodes[i];
6277  if (o.fixed) {
6278  o.x = o.px;
6279  o.y = o.py;
6280  } else {
6281  o.x -= (o.px - (o.px = o.x)) * friction;
6282  o.y -= (o.py - (o.py = o.y)) * friction;
6283  }
6284  }
6285  event.tick({
6286  type: "tick",
6287  alpha: alpha
6288  });
6289  };
6290  force.nodes = function(x) {
6291  if (!arguments.length) return nodes;
6292  nodes = x;
6293  return force;
6294  };
6295  force.links = function(x) {
6296  if (!arguments.length) return links;
6297  links = x;
6298  return force;
6299  };
6300  force.size = function(x) {
6301  if (!arguments.length) return size;
6302  size = x;
6303  return force;
6304  };
6305  force.linkDistance = function(x) {
6306  if (!arguments.length) return linkDistance;
6307  linkDistance = typeof x === "function" ? x : +x;
6308  return force;
6309  };
6310  force.distance = force.linkDistance;
6311  force.linkStrength = function(x) {
6312  if (!arguments.length) return linkStrength;
6313  linkStrength = typeof x === "function" ? x : +x;
6314  return force;
6315  };
6316  force.friction = function(x) {
6317  if (!arguments.length) return friction;
6318  friction = +x;
6319  return force;
6320  };
6321  force.charge = function(x) {
6322  if (!arguments.length) return charge;
6323  charge = typeof x === "function" ? x : +x;
6324  return force;
6325  };
6326  force.chargeDistance = function(x) {
6327  if (!arguments.length) return Math.sqrt(chargeDistance2);
6328  chargeDistance2 = x * x;
6329  return force;
6330  };
6331  force.gravity = function(x) {
6332  if (!arguments.length) return gravity;
6333  gravity = +x;
6334  return force;
6335  };
6336  force.theta = function(x) {
6337  if (!arguments.length) return Math.sqrt(theta2);
6338  theta2 = x * x;
6339  return force;
6340  };
6341  force.alpha = function(x) {
6342  if (!arguments.length) return alpha;
6343  x = +x;
6344  if (alpha) {
6345  if (x > 0) alpha = x; else alpha = 0;
6346  } else if (x > 0) {
6347  event.start({
6348  type: "start",
6349  alpha: alpha = x
6350  });
6351  d3.timer(force.tick);
6352  }
6353  return force;
6354  };
6355  force.start = function() {
6356  var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o;
6357  for (i = 0; i < n; ++i) {
6358  (o = nodes[i]).index = i;
6359  o.weight = 0;
6360  }
6361  for (i = 0; i < m; ++i) {
6362  o = links[i];
6363  if (typeof o.source == "number") o.source = nodes[o.source];
6364  if (typeof o.target == "number") o.target = nodes[o.target];
6365  ++o.source.weight;
6366  ++o.target.weight;
6367  }
6368  for (i = 0; i < n; ++i) {
6369  o = nodes[i];
6370  if (isNaN(o.x)) o.x = position("x", w);
6371  if (isNaN(o.y)) o.y = position("y", h);
6372  if (isNaN(o.px)) o.px = o.x;
6373  if (isNaN(o.py)) o.py = o.y;
6374  }
6375  distances = [];
6376  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;
6377  strengths = [];
6378  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;
6379  charges = [];
6380  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;
6381  function position(dimension, size) {
6382  if (!neighbors) {
6383  neighbors = new Array(n);
6384  for (j = 0; j < n; ++j) {
6385  neighbors[j] = [];
6386  }
6387  for (j = 0; j < m; ++j) {
6388  var o = links[j];
6389  neighbors[o.source.index].push(o.target);
6390  neighbors[o.target.index].push(o.source);
6391  }
6392  }
6393  var candidates = neighbors[i], j = -1, l = candidates.length, x;
6394  while (++j < l) if (!isNaN(x = candidates[j][dimension])) return x;
6395  return Math.random() * size;
6396  }
6397  return force.resume();
6398  };
6399  force.resume = function() {
6400  return force.alpha(.1);
6401  };
6402  force.stop = function() {
6403  return force.alpha(0);
6404  };
6405  force.drag = function() {
6406  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);
6407  if (!arguments.length) return drag;
6408  this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag);
6409  };
6410  function dragmove(d) {
6411  d.px = d3.event.x, d.py = d3.event.y;
6412  force.resume();
6413  }
6414  return d3.rebind(force, event, "on");
6415  };
6416  function d3_layout_forceDragstart(d) {
6417  d.fixed |= 2;
6418  }
6419  function d3_layout_forceDragend(d) {
6420  d.fixed &= ~6;
6421  }
6422  function d3_layout_forceMouseover(d) {
6423  d.fixed |= 4;
6424  d.px = d.x, d.py = d.y;
6425  }
6426  function d3_layout_forceMouseout(d) {
6427  d.fixed &= ~4;
6428  }
6429  function d3_layout_forceAccumulate(quad, alpha, charges) {
6430  var cx = 0, cy = 0;
6431  quad.charge = 0;
6432  if (!quad.leaf) {
6433  var nodes = quad.nodes, n = nodes.length, i = -1, c;
6434  while (++i < n) {
6435  c = nodes[i];
6436  if (c == null) continue;
6437  d3_layout_forceAccumulate(c, alpha, charges);
6438  quad.charge += c.charge;
6439  cx += c.charge * c.cx;
6440  cy += c.charge * c.cy;
6441  }
6442  }
6443  if (quad.point) {
6444  if (!quad.leaf) {
6445  quad.point.x += Math.random() - .5;
6446  quad.point.y += Math.random() - .5;
6447  }
6448  var k = alpha * charges[quad.point.index];
6449  quad.charge += quad.pointCharge = k;
6450  cx += k * quad.point.x;
6451  cy += k * quad.point.y;
6452  }
6453  quad.cx = cx / quad.charge;
6454  quad.cy = cy / quad.charge;
6455  }
6456  var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity;
6457  d3.layout.hierarchy = function() {
6458  var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue;
6459  function hierarchy(root) {
6460  var stack = [ root ], nodes = [], node;
6461  root.depth = 0;
6462  while ((node = stack.pop()) != null) {
6463  nodes.push(node);
6464  if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) {
6465  var n, childs, child;
6466  while (--n >= 0) {
6467  stack.push(child = childs[n]);
6468  child.parent = node;
6469  child.depth = node.depth + 1;
6470  }
6471  if (value) node.value = 0;
6472  node.children = childs;
6473  } else {
6474  if (value) node.value = +value.call(hierarchy, node, node.depth) || 0;
6475  delete node.children;
6476  }
6477  }
6478  d3_layout_hierarchyVisitAfter(root, function(node) {
6479  var childs, parent;
6480  if (sort && (childs = node.children)) childs.sort(sort);
6481  if (value && (parent = node.parent)) parent.value += node.value;
6482  });
6483  return nodes;
6484  }
6485  hierarchy.sort = function(x) {
6486  if (!arguments.length) return sort;
6487  sort = x;
6488  return hierarchy;
6489  };
6490  hierarchy.children = function(x) {
6491  if (!arguments.length) return children;
6492  children = x;
6493  return hierarchy;
6494  };
6495  hierarchy.value = function(x) {
6496  if (!arguments.length) return value;
6497  value = x;
6498  return hierarchy;
6499  };
6500  hierarchy.revalue = function(root) {
6501  if (value) {
6502  d3_layout_hierarchyVisitBefore(root, function(node) {
6503  if (node.children) node.value = 0;
6504  });
6505  d3_layout_hierarchyVisitAfter(root, function(node) {
6506  var parent;
6507  if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;
6508  if (parent = node.parent) parent.value += node.value;
6509  });
6510  }
6511  return root;
6512  };
6513  return hierarchy;
6514  };
6515  function d3_layout_hierarchyRebind(object, hierarchy) {
6516  d3.rebind(object, hierarchy, "sort", "children", "value");
6517  object.nodes = object;
6518  object.links = d3_layout_hierarchyLinks;
6519  return object;
6520  }
6521  function d3_layout_hierarchyVisitBefore(node, callback) {
6522  var nodes = [ node ];
6523  while ((node = nodes.pop()) != null) {
6524  callback(node);
6525  if ((children = node.children) && (n = children.length)) {
6526  var n, children;
6527  while (--n >= 0) nodes.push(children[n]);
6528  }
6529  }
6530  }
6531  function d3_layout_hierarchyVisitAfter(node, callback) {
6532  var nodes = [ node ], nodes2 = [];
6533  while ((node = nodes.pop()) != null) {
6534  nodes2.push(node);
6535  if ((children = node.children) && (n = children.length)) {
6536  var i = -1, n, children;
6537  while (++i < n) nodes.push(children[i]);
6538  }
6539  }
6540  while ((node = nodes2.pop()) != null) {
6541  callback(node);
6542  }
6543  }
6544  function d3_layout_hierarchyChildren(d) {
6545  return d.children;
6546  }
6547  function d3_layout_hierarchyValue(d) {
6548  return d.value;
6549  }
6550  function d3_layout_hierarchySort(a, b) {
6551  return b.value - a.value;
6552  }
6553  function d3_layout_hierarchyLinks(nodes) {
6554  return d3.merge(nodes.map(function(parent) {
6555  return (parent.children || []).map(function(child) {
6556  return {
6557  source: parent,
6558  target: child
6559  };
6560  });
6561  }));
6562  }
6563  d3.layout.partition = function() {
6564  var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ];
6565  function position(node, x, dx, dy) {
6566  var children = node.children;
6567  node.x = x;
6568  node.y = node.depth * dy;
6569  node.dx = dx;
6570  node.dy = dy;
6571  if (children && (n = children.length)) {
6572  var i = -1, n, c, d;
6573  dx = node.value ? dx / node.value : 0;
6574  while (++i < n) {
6575  position(c = children[i], x, d = c.value * dx, dy);
6576  x += d;
6577  }
6578  }
6579  }
6580  function depth(node) {
6581  var children = node.children, d = 0;
6582  if (children && (n = children.length)) {
6583  var i = -1, n;
6584  while (++i < n) d = Math.max(d, depth(children[i]));
6585  }
6586  return 1 + d;
6587  }
6588  function partition(d, i) {
6589  var nodes = hierarchy.call(this, d, i);
6590  position(nodes[0], 0, size[0], size[1] / depth(nodes[0]));
6591  return nodes;
6592  }
6593  partition.size = function(x) {
6594  if (!arguments.length) return size;
6595  size = x;
6596  return partition;
6597  };
6598  return d3_layout_hierarchyRebind(partition, hierarchy);
6599  };
6600  d3.layout.pie = function() {
6601  var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0;
6602  function pie(data) {
6603  var n = data.length, values = data.map(function(d, i) {
6604  return +value.call(pie, d, i);
6605  }), 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;
6606  if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {
6607  return values[j] - values[i];
6608  } : function(i, j) {
6609  return sort(data[i], data[j]);
6610  });
6611  index.forEach(function(i) {
6612  arcs[i] = {
6613  data: data[i],
6614  value: v = values[i],
6615  startAngle: a,
6616  endAngle: a += v * k + pa,
6617  padAngle: p
6618  };
6619  });
6620  return arcs;
6621  }
6622  pie.value = function(_) {
6623  if (!arguments.length) return value;
6624  value = _;
6625  return pie;
6626  };
6627  pie.sort = function(_) {
6628  if (!arguments.length) return sort;
6629  sort = _;
6630  return pie;
6631  };
6632  pie.startAngle = function(_) {
6633  if (!arguments.length) return startAngle;
6634  startAngle = _;
6635  return pie;
6636  };
6637  pie.endAngle = function(_) {
6638  if (!arguments.length) return endAngle;
6639  endAngle = _;
6640  return pie;
6641  };
6642  pie.padAngle = function(_) {
6643  if (!arguments.length) return padAngle;
6644  padAngle = _;
6645  return pie;
6646  };
6647  return pie;
6648  };
6649  var d3_layout_pieSortByValue = {};
6650  d3.layout.stack = function() {
6651  var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY;
6652  function stack(data, index) {
6653  if (!(n = data.length)) return data;
6654  var series = data.map(function(d, i) {
6655  return values.call(stack, d, i);
6656  });
6657  var points = series.map(function(d) {
6658  return d.map(function(v, i) {
6659  return [ x.call(stack, v, i), y.call(stack, v, i) ];
6660  });
6661  });
6662  var orders = order.call(stack, points, index);
6663  series = d3.permute(series, orders);
6664  points = d3.permute(points, orders);
6665  var offsets = offset.call(stack, points, index);
6666  var m = series[0].length, n, i, j, o;
6667  for (j = 0; j < m; ++j) {
6668  out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);
6669  for (i = 1; i < n; ++i) {
6670  out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]);
6671  }
6672  }
6673  return data;
6674  }
6675  stack.values = function(x) {
6676  if (!arguments.length) return values;
6677  values = x;
6678  return stack;
6679  };
6680  stack.order = function(x) {
6681  if (!arguments.length) return order;
6682  order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault;
6683  return stack;
6684  };
6685  stack.offset = function(x) {
6686  if (!arguments.length) return offset;
6687  offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero;
6688  return stack;
6689  };
6690  stack.x = function(z) {
6691  if (!arguments.length) return x;
6692  x = z;
6693  return stack;
6694  };
6695  stack.y = function(z) {
6696  if (!arguments.length) return y;
6697  y = z;
6698  return stack;
6699  };
6700  stack.out = function(z) {
6701  if (!arguments.length) return out;
6702  out = z;
6703  return stack;
6704  };
6705  return stack;
6706  };
6707  function d3_layout_stackX(d) {
6708  return d.x;
6709  }
6710  function d3_layout_stackY(d) {
6711  return d.y;
6712  }
6713  function d3_layout_stackOut(d, y0, y) {
6714  d.y0 = y0;
6715  d.y = y;
6716  }
6717  var d3_layout_stackOrders = d3.map({
6718  "inside-out": function(data) {
6719  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) {
6720  return max[a] - max[b];
6721  }), top = 0, bottom = 0, tops = [], bottoms = [];
6722  for (i = 0; i < n; ++i) {
6723  j = index[i];
6724  if (top < bottom) {
6725  top += sums[j];
6726  tops.push(j);
6727  } else {
6728  bottom += sums[j];
6729  bottoms.push(j);
6730  }
6731  }
6732  return bottoms.reverse().concat(tops);
6733  },
6734  reverse: function(data) {
6735  return d3.range(data.length).reverse();
6736  },
6737  "default": d3_layout_stackOrderDefault
6738  });
6739  var d3_layout_stackOffsets = d3.map({
6740  silhouette: function(data) {
6741  var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = [];
6742  for (j = 0; j < m; ++j) {
6743  for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
6744  if (o > max) max = o;
6745  sums.push(o);
6746  }
6747  for (j = 0; j < m; ++j) {
6748  y0[j] = (max - sums[j]) / 2;
6749  }
6750  return y0;
6751  },
6752  wiggle: function(data) {
6753  var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = [];
6754  y0[0] = o = o0 = 0;
6755  for (j = 1; j < m; ++j) {
6756  for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1];
6757  for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) {
6758  for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) {
6759  s3 += (data[k][j][1] - data[k][j - 1][1]) / dx;
6760  }
6761  s2 += s3 * data[i][j][1];
6762  }
6763  y0[j] = o -= s1 ? s2 / s1 * dx : 0;
6764  if (o < o0) o0 = o;
6765  }
6766  for (j = 0; j < m; ++j) y0[j] -= o0;
6767  return y0;
6768  },
6769  expand: function(data) {
6770  var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = [];
6771  for (j = 0; j < m; ++j) {
6772  for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
6773  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;
6774  }
6775  for (j = 0; j < m; ++j) y0[j] = 0;
6776  return y0;
6777  },
6778  zero: d3_layout_stackOffsetZero
6779  });
6780  function d3_layout_stackOrderDefault(data) {
6781  return d3.range(data.length);
6782  }
6783  function d3_layout_stackOffsetZero(data) {
6784  var j = -1, m = data[0].length, y0 = [];
6785  while (++j < m) y0[j] = 0;
6786  return y0;
6787  }
6788  function d3_layout_stackMaxIndex(array) {
6789  var i = 1, j = 0, v = array[0][1], k, n = array.length;
6790  for (;i < n; ++i) {
6791  if ((k = array[i][1]) > v) {
6792  j = i;
6793  v = k;
6794  }
6795  }
6796  return j;
6797  }
6798  function d3_layout_stackReduceSum(d) {
6799  return d.reduce(d3_layout_stackSum, 0);
6800  }
6801  function d3_layout_stackSum(p, d) {
6802  return p + d[1];
6803  }
6804  d3.layout.histogram = function() {
6805  var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges;
6806  function histogram(data, i) {
6807  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;
6808  while (++i < m) {
6809  bin = bins[i] = [];
6810  bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);
6811  bin.y = 0;
6812  }
6813  if (m > 0) {
6814  i = -1;
6815  while (++i < n) {
6816  x = values[i];
6817  if (x >= range[0] && x <= range[1]) {
6818  bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
6819  bin.y += k;
6820  bin.push(data[i]);
6821  }
6822  }
6823  }
6824  return bins;
6825  }
6826  histogram.value = function(x) {
6827  if (!arguments.length) return valuer;
6828  valuer = x;
6829  return histogram;
6830  };
6831  histogram.range = function(x) {
6832  if (!arguments.length) return ranger;
6833  ranger = d3_functor(x);
6834  return histogram;
6835  };
6836  histogram.bins = function(x) {
6837  if (!arguments.length) return binner;
6838  binner = typeof x === "number" ? function(range) {
6839  return d3_layout_histogramBinFixed(range, x);
6840  } : d3_functor(x);
6841  return histogram;
6842  };
6843  histogram.frequency = function(x) {
6844  if (!arguments.length) return frequency;
6845  frequency = !!x;
6846  return histogram;
6847  };
6848  return histogram;
6849  };
6850  function d3_layout_histogramBinSturges(range, values) {
6851  return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));
6852  }
6853  function d3_layout_histogramBinFixed(range, n) {
6854  var x = -1, b = +range[0], m = (range[1] - b) / n, f = [];
6855  while (++x <= n) f[x] = m * x + b;
6856  return f;
6857  }
6858  function d3_layout_histogramRange(values) {
6859  return [ d3.min(values), d3.max(values) ];
6860  }
6861  d3.layout.pack = function() {
6862  var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius;
6863  function pack(d, i) {
6864  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() {
6865  return radius;
6866  };
6867  root.x = root.y = 0;
6868  d3_layout_hierarchyVisitAfter(root, function(d) {
6869  d.r = +r(d.value);
6870  });
6871  d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
6872  if (padding) {
6873  var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2;
6874  d3_layout_hierarchyVisitAfter(root, function(d) {
6875  d.r += dr;
6876  });
6877  d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);
6878  d3_layout_hierarchyVisitAfter(root, function(d) {
6879  d.r -= dr;
6880  });
6881  }
6882  d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h));
6883  return nodes;
6884  }
6885  pack.size = function(_) {
6886  if (!arguments.length) return size;
6887  size = _;
6888  return pack;
6889  };
6890  pack.radius = function(_) {
6891  if (!arguments.length) return radius;
6892  radius = _ == null || typeof _ === "function" ? _ : +_;
6893  return pack;
6894  };
6895  pack.padding = function(_) {
6896  if (!arguments.length) return padding;
6897  padding = +_;
6898  return pack;
6899  };
6900  return d3_layout_hierarchyRebind(pack, hierarchy);
6901  };
6902  function d3_layout_packSort(a, b) {
6903  return a.value - b.value;
6904  }
6905  function d3_layout_packInsert(a, b) {
6906  var c = a._pack_next;
6907  a._pack_next = b;
6908  b._pack_prev = a;
6909  b._pack_next = c;
6910  c._pack_prev = b;
6911  }
6912  function d3_layout_packSplice(a, b) {
6913  a._pack_next = b;
6914  b._pack_prev = a;
6915  }
6916  function d3_layout_packIntersects(a, b) {
6917  var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r;
6918  return .999 * dr * dr > dx * dx + dy * dy;
6919  }
6920  function d3_layout_packSiblings(node) {
6921  if (!(nodes = node.children) || !(n = nodes.length)) return;
6922  var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n;
6923  function bound(node) {
6924  xMin = Math.min(node.x - node.r, xMin);
6925  xMax = Math.max(node.x + node.r, xMax);
6926  yMin = Math.min(node.y - node.r, yMin);
6927  yMax = Math.max(node.y + node.r, yMax);
6928  }
6929  nodes.forEach(d3_layout_packLink);
6930  a = nodes[0];
6931  a.x = -a.r;
6932  a.y = 0;
6933  bound(a);
6934  if (n > 1) {
6935  b = nodes[1];
6936  b.x = b.r;
6937  b.y = 0;
6938  bound(b);
6939  if (n > 2) {
6940  c = nodes[2];
6941  d3_layout_packPlace(a, b, c);
6942  bound(c);
6943  d3_layout_packInsert(a, c);
6944  a._pack_prev = c;
6945  d3_layout_packInsert(c, b);
6946  b = a._pack_next;
6947  for (i = 3; i < n; i++) {
6948  d3_layout_packPlace(a, b, c = nodes[i]);
6949  var isect = 0, s1 = 1, s2 = 1;
6950  for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {
6951  if (d3_layout_packIntersects(j, c)) {
6952  isect = 1;
6953  break;
6954  }
6955  }
6956  if (isect == 1) {
6957  for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {
6958  if (d3_layout_packIntersects(k, c)) {
6959  break;
6960  }
6961  }
6962  }
6963  if (isect) {
6964  if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b);
6965  i--;
6966  } else {
6967  d3_layout_packInsert(a, c);
6968  b = c;
6969  bound(c);
6970  }
6971  }
6972  }
6973  }
6974  var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0;
6975  for (i = 0; i < n; i++) {
6976  c = nodes[i];
6977  c.x -= cx;
6978  c.y -= cy;
6979  cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y));
6980  }
6981  node.r = cr;
6982  nodes.forEach(d3_layout_packUnlink);
6983  }
6984  function d3_layout_packLink(node) {
6985  node._pack_next = node._pack_prev = node;
6986  }
6987  function d3_layout_packUnlink(node) {
6988  delete node._pack_next;
6989  delete node._pack_prev;
6990  }
6991  function d3_layout_packTransform(node, x, y, k) {
6992  var children = node.children;
6993  node.x = x += k * node.x;
6994  node.y = y += k * node.y;
6995  node.r *= k;
6996  if (children) {
6997  var i = -1, n = children.length;
6998  while (++i < n) d3_layout_packTransform(children[i], x, y, k);
6999  }
7000  }
7001  function d3_layout_packPlace(a, b, c) {
7002  var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y;
7003  if (db && (dx || dy)) {
7004  var da = b.r + c.r, dc = dx * dx + dy * dy;
7005  da *= da;
7006  db *= db;
7007  var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc);
7008  c.x = a.x + x * dx + y * dy;
7009  c.y = a.y + x * dy - y * dx;
7010  } else {
7011  c.x = a.x + db;
7012  c.y = a.y;
7013  }
7014  }
7015  d3.layout.tree = function() {
7016  var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null;
7017  function tree(d, i) {
7018  var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0);
7019  d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z;
7020  d3_layout_hierarchyVisitBefore(root1, secondWalk);
7021  if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else {
7022  var left = root0, right = root0, bottom = root0;
7023  d3_layout_hierarchyVisitBefore(root0, function(node) {
7024  if (node.x < left.x) left = node;
7025  if (node.x > right.x) right = node;
7026  if (node.depth > bottom.depth) bottom = node;
7027  });
7028  var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1);
7029  d3_layout_hierarchyVisitBefore(root0, function(node) {
7030  node.x = (node.x + tx) * kx;
7031  node.y = node.depth * ky;
7032  });
7033  }
7034  return nodes;
7035  }
7036  function wrapTree(root0) {
7037  var root1 = {
7038  A: null,
7039  children: [ root0 ]
7040  }, queue = [ root1 ], node1;
7041  while ((node1 = queue.pop()) != null) {
7042  for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) {
7043  queue.push((children[i] = child = {
7044  _: children[i],
7045  parent: node1,
7046  children: (child = children[i].children) && child.slice() || [],
7047  A: null,
7048  a: null,
7049  z: 0,
7050  m: 0,
7051  c: 0,
7052  s: 0,
7053  t: null,
7054  i: i
7055  }).a = child);
7056  }
7057  }
7058  return root1.children[0];
7059  }
7060  function firstWalk(v) {
7061  var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;
7062  if (children.length) {
7063  d3_layout_treeShift(v);
7064  var midpoint = (children[0].z + children[children.length - 1].z) / 2;
7065  if (w) {
7066  v.z = w.z + separation(v._, w._);
7067  v.m = v.z - midpoint;
7068  } else {
7069  v.z = midpoint;
7070  }
7071  } else if (w) {
7072  v.z = w.z + separation(v._, w._);
7073  }
7074  v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
7075  }
7076  function secondWalk(v) {
7077  v._.x = v.z + v.parent.m;
7078  v.m += v.parent.m;
7079  }
7080  function apportion(v, w, ancestor) {
7081  if (w) {
7082  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;
7083  while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
7084  vom = d3_layout_treeLeft(vom);
7085  vop = d3_layout_treeRight(vop);
7086  vop.a = v;
7087  shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
7088  if (shift > 0) {
7089  d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift);
7090  sip += shift;
7091  sop += shift;
7092  }
7093  sim += vim.m;
7094  sip += vip.m;
7095  som += vom.m;
7096  sop += vop.m;
7097  }
7098  if (vim && !d3_layout_treeRight(vop)) {
7099  vop.t = vim;
7100  vop.m += sim - sop;
7101  }
7102  if (vip && !d3_layout_treeLeft(vom)) {
7103  vom.t = vip;
7104  vom.m += sip - som;
7105  ancestor = v;
7106  }
7107  }
7108  return ancestor;
7109  }
7110  function sizeNode(node) {
7111  node.x *= size[0];
7112  node.y = node.depth * size[1];
7113  }
7114  tree.separation = function(x) {
7115  if (!arguments.length) return separation;
7116  separation = x;
7117  return tree;
7118  };
7119  tree.size = function(x) {
7120  if (!arguments.length) return nodeSize ? null : size;
7121  nodeSize = (size = x) == null ? sizeNode : null;
7122  return tree;
7123  };
7124  tree.nodeSize = function(x) {
7125  if (!arguments.length) return nodeSize ? size : null;
7126  nodeSize = (size = x) == null ? null : sizeNode;
7127  return tree;
7128  };
7129  return d3_layout_hierarchyRebind(tree, hierarchy);
7130  };
7131  function d3_layout_treeSeparation(a, b) {
7132  return a.parent == b.parent ? 1 : 2;
7133  }
7134  function d3_layout_treeLeft(v) {
7135  var children = v.children;
7136  return children.length ? children[0] : v.t;
7137  }
7138  function d3_layout_treeRight(v) {
7139  var children = v.children, n;
7140  return (n = children.length) ? children[n - 1] : v.t;
7141  }
7142  function d3_layout_treeMove(wm, wp, shift) {
7143  var change = shift / (wp.i - wm.i);
7144  wp.c -= change;
7145  wp.s += shift;
7146  wm.c += change;
7147  wp.z += shift;
7148  wp.m += shift;
7149  }
7150  function d3_layout_treeShift(v) {
7151  var shift = 0, change = 0, children = v.children, i = children.length, w;
7152  while (--i >= 0) {
7153  w = children[i];
7154  w.z += shift;
7155  w.m += shift;
7156  shift += w.s + (change += w.c);
7157  }
7158  }
7159  function d3_layout_treeAncestor(vim, v, ancestor) {
7160  return vim.a.parent === v.parent ? vim.a : ancestor;
7161  }
7162  d3.layout.cluster = function() {
7163  var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;
7164  function cluster(d, i) {
7165  var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0;
7166  d3_layout_hierarchyVisitAfter(root, function(node) {
7167  var children = node.children;
7168  if (children && children.length) {
7169  node.x = d3_layout_clusterX(children);
7170  node.y = d3_layout_clusterY(children);
7171  } else {
7172  node.x = previousNode ? x += separation(node, previousNode) : 0;
7173  node.y = 0;
7174  previousNode = node;
7175  }
7176  });
7177  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;
7178  d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) {
7179  node.x = (node.x - root.x) * size[0];
7180  node.y = (root.y - node.y) * size[1];
7181  } : function(node) {
7182  node.x = (node.x - x0) / (x1 - x0) * size[0];
7183  node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];
7184  });
7185  return nodes;
7186  }
7187  cluster.separation = function(x) {
7188  if (!arguments.length) return separation;
7189  separation = x;
7190  return cluster;
7191  };
7192  cluster.size = function(x) {
7193  if (!arguments.length) return nodeSize ? null : size;
7194  nodeSize = (size = x) == null;
7195  return cluster;
7196  };
7197  cluster.nodeSize = function(x) {
7198  if (!arguments.length) return nodeSize ? size : null;
7199  nodeSize = (size = x) != null;
7200  return cluster;
7201  };
7202  return d3_layout_hierarchyRebind(cluster, hierarchy);
7203  };
7204  function d3_layout_clusterY(children) {
7205  return 1 + d3.max(children, function(child) {
7206  return child.y;
7207  });
7208  }
7209  function d3_layout_clusterX(children) {
7210  return children.reduce(function(x, child) {
7211  return x + child.x;
7212  }, 0) / children.length;
7213  }
7214  function d3_layout_clusterLeft(node) {
7215  var children = node.children;
7216  return children && children.length ? d3_layout_clusterLeft(children[0]) : node;
7217  }
7218  function d3_layout_clusterRight(node) {
7219  var children = node.children, n;
7220  return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;
7221  }
7222  d3.layout.treemap = function() {
7223  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));
7224  function scale(children, k) {
7225  var i = -1, n = children.length, child, area;
7226  while (++i < n) {
7227  area = (child = children[i]).value * (k < 0 ? 0 : k);
7228  child.area = isNaN(area) || area <= 0 ? 0 : area;
7229  }
7230  }
7231  function squarify(node) {
7232  var children = node.children;
7233  if (children && children.length) {
7234  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;
7235  scale(remaining, rect.dx * rect.dy / node.value);
7236  row.area = 0;
7237  while ((n = remaining.length) > 0) {
7238  row.push(child = remaining[n - 1]);
7239  row.area += child.area;
7240  if (mode !== "squarify" || (score = worst(row, u)) <= best) {
7241  remaining.pop();
7242  best = score;
7243  } else {
7244  row.area -= row.pop().area;
7245  position(row, u, rect, false);
7246  u = Math.min(rect.dx, rect.dy);
7247  row.length = row.area = 0;
7248  best = Infinity;
7249  }
7250  }
7251  if (row.length) {
7252  position(row, u, rect, true);
7253  row.length = row.area = 0;
7254  }
7255  children.forEach(squarify);
7256  }
7257  }
7258  function stickify(node) {
7259  var children = node.children;
7260  if (children && children.length) {
7261  var rect = pad(node), remaining = children.slice(), child, row = [];
7262  scale(remaining, rect.dx * rect.dy / node.value);
7263  row.area = 0;
7264  while (child = remaining.pop()) {
7265  row.push(child);
7266  row.area += child.area;
7267  if (child.z != null) {
7268  position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length);
7269  row.length = row.area = 0;
7270  }
7271  }
7272  children.forEach(stickify);
7273  }
7274  }
7275  function worst(row, u) {
7276  var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length;
7277  while (++i < n) {
7278  if (!(r = row[i].area)) continue;
7279  if (r < rmin) rmin = r;
7280  if (r > rmax) rmax = r;
7281  }
7282  s *= s;
7283  u *= u;
7284  return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity;
7285  }
7286  function position(row, u, rect, flush) {
7287  var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o;
7288  if (u == rect.dx) {
7289  if (flush || v > rect.dy) v = rect.dy;
7290  while (++i < n) {
7291  o = row[i];
7292  o.x = x;
7293  o.y = y;
7294  o.dy = v;
7295  x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0);
7296  }
7297  o.z = true;
7298  o.dx += rect.x + rect.dx - x;
7299  rect.y += v;
7300  rect.dy -= v;
7301  } else {
7302  if (flush || v > rect.dx) v = rect.dx;
7303  while (++i < n) {
7304  o = row[i];
7305  o.x = x;
7306  o.y = y;
7307  o.dx = v;
7308  y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0);
7309  }
7310  o.z = false;
7311  o.dy += rect.y + rect.dy - y;
7312  rect.x += v;
7313  rect.dx -= v;
7314  }
7315  }
7316  function treemap(d) {
7317  var nodes = stickies || hierarchy(d), root = nodes[0];
7318  root.x = 0;
7319  root.y = 0;
7320  root.dx = size[0];
7321  root.dy = size[1];
7322  if (stickies) hierarchy.revalue(root);
7323  scale([ root ], root.dx * root.dy / root.value);
7324  (stickies ? stickify : squarify)(root);
7325  if (sticky) stickies = nodes;
7326  return nodes;
7327  }
7328  treemap.size = function(x) {
7329  if (!arguments.length) return size;
7330  size = x;
7331  return treemap;
7332  };
7333  treemap.padding = function(x) {
7334  if (!arguments.length) return padding;
7335  function padFunction(node) {
7336  var p = x.call(treemap, node, node.depth);
7337  return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p);
7338  }
7339  function padConstant(node) {
7340  return d3_layout_treemapPad(node, x);
7341  }
7342  var type;
7343  pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ],
7344  padConstant) : padConstant;
7345  return treemap;
7346  };
7347  treemap.round = function(x) {
7348  if (!arguments.length) return round != Number;
7349  round = x ? Math.round : Number;
7350  return treemap;
7351  };
7352  treemap.sticky = function(x) {
7353  if (!arguments.length) return sticky;
7354  sticky = x;
7355  stickies = null;
7356  return treemap;
7357  };
7358  treemap.ratio = function(x) {
7359  if (!arguments.length) return ratio;
7360  ratio = x;
7361  return treemap;
7362  };
7363  treemap.mode = function(x) {
7364  if (!arguments.length) return mode;
7365  mode = x + "";
7366  return treemap;
7367  };
7368  return d3_layout_hierarchyRebind(treemap, hierarchy);
7369  };
7370  function d3_layout_treemapPadNull(node) {
7371  return {
7372  x: node.x,
7373  y: node.y,
7374  dx: node.dx,
7375  dy: node.dy
7376  };
7377  }
7378  function d3_layout_treemapPad(node, padding) {
7379  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];
7380  if (dx < 0) {
7381  x += dx / 2;
7382  dx = 0;
7383  }
7384  if (dy < 0) {
7385  y += dy / 2;
7386  dy = 0;
7387  }
7388  return {
7389  x: x,
7390  y: y,
7391  dx: dx,
7392  dy: dy
7393  };
7394  }
7395  d3.random = {
7396  normal: function(µ, σ) {
7397  var n = arguments.length;
7398  if (n < 2) σ = 1;
7399  if (n < 1) µ = 0;
7400  return function() {
7401  var x, y, r;
7402  do {
7403  x = Math.random() * 2 - 1;
7404  y = Math.random() * 2 - 1;
7405  r = x * x + y * y;
7406  } while (!r || r > 1);
7407  return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r);
7408  };
7409  },
7410  logNormal: function() {
7411  var random = d3.random.normal.apply(d3, arguments);
7412  return function() {
7413  return Math.exp(random());
7414  };
7415  },
7416  bates: function(m) {
7417  var random = d3.random.irwinHall(m);
7418  return function() {
7419  return random() / m;
7420  };
7421  },
7422  irwinHall: function(m) {
7423  return function() {
7424  for (var s = 0, j = 0; j < m; j++) s += Math.random();
7425  return s;
7426  };
7427  }
7428  };
7429  d3.scale = {};
7430  function d3_scaleExtent(domain) {
7431  var start = domain[0], stop = domain[domain.length - 1];
7432  return start < stop ? [ start, stop ] : [ stop, start ];
7433  }
7434  function d3_scaleRange(scale) {
7435  return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());
7436  }
7437  function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {
7438  var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]);
7439  return function(x) {
7440  return i(u(x));
7441  };
7442  }
7443  function d3_scale_nice(domain, nice) {
7444  var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx;
7445  if (x1 < x0) {
7446  dx = i0, i0 = i1, i1 = dx;
7447  dx = x0, x0 = x1, x1 = dx;
7448  }
7449  domain[i0] = nice.floor(x0);
7450  domain[i1] = nice.ceil(x1);
7451  return domain;
7452  }
7453  function d3_scale_niceStep(step) {
7454  return step ? {
7455  floor: function(x) {
7456  return Math.floor(x / step) * step;
7457  },
7458  ceil: function(x) {
7459  return Math.ceil(x / step) * step;
7460  }
7461  } : d3_scale_niceIdentity;
7462  }
7463  var d3_scale_niceIdentity = {
7464  floor: d3_identity,
7465  ceil: d3_identity
7466  };
7467  function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
7468  var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1;
7469  if (domain[k] < domain[0]) {
7470  domain = domain.slice().reverse();
7471  range = range.slice().reverse();
7472  }
7473  while (++j <= k) {
7474  u.push(uninterpolate(domain[j - 1], domain[j]));
7475  i.push(interpolate(range[j - 1], range[j]));
7476  }
7477  return function(x) {
7478  var j = d3.bisect(domain, x, 1, k) - 1;
7479  return i[j](u[j](x));
7480  };
7481  }
7482  d3.scale.linear = function() {
7483  return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false);
7484  };
7485  function d3_scale_linear(domain, range, interpolate, clamp) {
7486  var output, input;
7487  function rescale() {
7488  var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
7489  output = linear(domain, range, uninterpolate, interpolate);
7490  input = linear(range, domain, uninterpolate, d3_interpolate);
7491  return scale;
7492  }
7493  function scale(x) {
7494  return output(x);
7495  }
7496  scale.invert = function(y) {
7497  return input(y);
7498  };
7499  scale.domain = function(x) {
7500  if (!arguments.length) return domain;
7501  domain = x.map(Number);
7502  return rescale();
7503  };
7504  scale.range = function(x) {
7505  if (!arguments.length) return range;
7506  range = x;
7507  return rescale();
7508  };
7509  scale.rangeRound = function(x) {
7510  return scale.range(x).interpolate(d3_interpolateRound);
7511  };
7512  scale.clamp = function(x) {
7513  if (!arguments.length) return clamp;
7514  clamp = x;
7515  return rescale();
7516  };
7517  scale.interpolate = function(x) {
7518  if (!arguments.length) return interpolate;
7519  interpolate = x;
7520  return rescale();
7521  };
7522  scale.ticks = function(m) {
7523  return d3_scale_linearTicks(domain, m);
7524  };
7525  scale.tickFormat = function(m, format) {
7526  return d3_scale_linearTickFormat(domain, m, format);
7527  };
7528  scale.nice = function(m) {
7529  d3_scale_linearNice(domain, m);
7530  return rescale();
7531  };
7532  scale.copy = function() {
7533  return d3_scale_linear(domain, range, interpolate, clamp);
7534  };
7535  return rescale();
7536  }
7537  function d3_scale_linearRebind(scale, linear) {
7538  return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
7539  }
7540  function d3_scale_linearNice(domain, m) {
7541  return d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));
7542  }
7543  function d3_scale_linearTickRange(domain, m) {
7544  if (m == null) m = 10;
7545  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;
7546  if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2;
7547  extent[0] = Math.ceil(extent[0] / step) * step;
7548  extent[1] = Math.floor(extent[1] / step) * step + step * .5;
7549  extent[2] = step;
7550  return extent;
7551  }
7552  function d3_scale_linearTicks(domain, m) {
7553  return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));
7554  }
7555  function d3_scale_linearTickFormat(domain, m, format) {
7556  var range = d3_scale_linearTickRange(domain, m);
7557  if (format) {
7558  var match = d3_format_re.exec(format);
7559  match.shift();
7560  if (match[8] === "s") {
7561  var prefix = d3.formatPrefix(Math.max(abs(range[0]), abs(range[1])));
7562  if (!match[7]) match[7] = "." + d3_scale_linearPrecision(prefix.scale(range[2]));
7563  match[8] = "f";
7564  format = d3.format(match.join(""));
7565  return function(d) {
7566  return format(prefix.scale(d)) + prefix.symbol;
7567  };
7568  }
7569  if (!match[7]) match[7] = "." + d3_scale_linearFormatPrecision(match[8], range);
7570  format = match.join("");
7571  } else {
7572  format = ",." + d3_scale_linearPrecision(range[2]) + "f";
7573  }
7574  return d3.format(format);
7575  }
7576  var d3_scale_linearFormatSignificant = {
7577  s: 1,
7578  g: 1,
7579  p: 1,
7580  r: 1,
7581  e: 1
7582  };
7583  function d3_scale_linearPrecision(value) {
7584  return -Math.floor(Math.log(value) / Math.LN10 + .01);
7585  }
7586  function d3_scale_linearFormatPrecision(type, range) {
7587  var p = d3_scale_linearPrecision(range[2]);
7588  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;
7589  }
7590  d3.scale.log = function() {
7591  return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]);
7592  };
7593  function d3_scale_log(linear, base, positive, domain) {
7594  function log(x) {
7595  return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base);
7596  }
7597  function pow(x) {
7598  return positive ? Math.pow(base, x) : -Math.pow(base, -x);
7599  }
7600  function scale(x) {
7601  return linear(log(x));
7602  }
7603  scale.invert = function(x) {
7604  return pow(linear.invert(x));
7605  };
7606  scale.domain = function(x) {
7607  if (!arguments.length) return domain;
7608  positive = x[0] >= 0;
7609  linear.domain((domain = x.map(Number)).map(log));
7610  return scale;
7611  };
7612  scale.base = function(_) {
7613  if (!arguments.length) return base;
7614  base = +_;
7615  linear.domain(domain.map(log));
7616  return scale;
7617  };
7618  scale.nice = function() {
7619  var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative);
7620  linear.domain(niced);
7621  domain = niced.map(pow);
7622  return scale;
7623  };
7624  scale.ticks = function() {
7625  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;
7626  if (isFinite(j - i)) {
7627  if (positive) {
7628  for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k);
7629  ticks.push(pow(i));
7630  } else {
7631  ticks.push(pow(i));
7632  for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k);
7633  }
7634  for (i = 0; ticks[i] < u; i++) {}
7635  for (j = ticks.length; ticks[j - 1] > v; j--) {}
7636  ticks = ticks.slice(i, j);
7637  }
7638  return ticks;
7639  };
7640  scale.tickFormat = function(n, format) {
7641  if (!arguments.length) return d3_scale_logFormat;
7642  if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format);
7643  var k = Math.max(.1, n / scale.ticks().length), f = positive ? (e = 1e-12, Math.ceil) : (e = -1e-12,
7644  Math.floor), e;
7645  return function(d) {
7646  return d / pow(f(log(d) + e)) <= k ? format(d) : "";
7647  };
7648  };
7649  scale.copy = function() {
7650  return d3_scale_log(linear.copy(), base, positive, domain);
7651  };
7652  return d3_scale_linearRebind(scale, linear);
7653  }
7654  var d3_scale_logFormat = d3.format(".0e"), d3_scale_logNiceNegative = {
7655  floor: function(x) {
7656  return -Math.ceil(-x);
7657  },
7658  ceil: function(x) {
7659  return -Math.floor(-x);
7660  }
7661  };
7662  d3.scale.pow = function() {
7663  return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]);
7664  };
7665  function d3_scale_pow(linear, exponent, domain) {
7666  var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent);
7667  function scale(x) {
7668  return linear(powp(x));
7669  }
7670  scale.invert = function(x) {
7671  return powb(linear.invert(x));
7672  };
7673  scale.domain = function(x) {
7674  if (!arguments.length) return domain;
7675  linear.domain((domain = x.map(Number)).map(powp));
7676  return scale;
7677  };
7678  scale.ticks = function(m) {
7679  return d3_scale_linearTicks(domain, m);
7680  };
7681  scale.tickFormat = function(m, format) {
7682  return d3_scale_linearTickFormat(domain, m, format);
7683  };
7684  scale.nice = function(m) {
7685  return scale.domain(d3_scale_linearNice(domain, m));
7686  };
7687  scale.exponent = function(x) {
7688  if (!arguments.length) return exponent;
7689  powp = d3_scale_powPow(exponent = x);
7690  powb = d3_scale_powPow(1 / exponent);
7691  linear.domain(domain.map(powp));
7692  return scale;
7693  };
7694  scale.copy = function() {
7695  return d3_scale_pow(linear.copy(), exponent, domain);
7696  };
7697  return d3_scale_linearRebind(scale, linear);
7698  }
7699  function d3_scale_powPow(e) {
7700  return function(x) {
7701  return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);
7702  };
7703  }
7704  d3.scale.sqrt = function() {
7705  return d3.scale.pow().exponent(.5);
7706  };
7707  d3.scale.ordinal = function() {
7708  return d3_scale_ordinal([], {
7709  t: "range",
7710  a: [ [] ]
7711  });
7712  };
7713  function d3_scale_ordinal(domain, ranger) {
7714  var index, range, rangeBand;
7715  function scale(x) {
7716  return range[((index.get(x) || (ranger.t === "range" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length];
7717  }
7718  function steps(start, step) {
7719  return d3.range(domain.length).map(function(i) {
7720  return start + step * i;
7721  });
7722  }
7723  scale.domain = function(x) {
7724  if (!arguments.length) return domain;
7725  domain = [];
7726  index = new d3_Map();
7727  var i = -1, n = x.length, xi;
7728  while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));
7729  return scale[ranger.t].apply(scale, ranger.a);
7730  };
7731  scale.range = function(x) {
7732  if (!arguments.length) return range;
7733  range = x;
7734  rangeBand = 0;
7735  ranger = {
7736  t: "range",
7737  a: arguments
7738  };
7739  return scale;
7740  };
7741  scale.rangePoints = function(x, padding) {
7742  if (arguments.length < 2) padding = 0;
7743  var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2,
7744  0) : (stop - start) / (domain.length - 1 + padding);
7745  range = steps(start + step * padding / 2, step);
7746  rangeBand = 0;
7747  ranger = {
7748  t: "rangePoints",
7749  a: arguments
7750  };
7751  return scale;
7752  };
7753  scale.rangeRoundPoints = function(x, padding) {
7754  if (arguments.length < 2) padding = 0;
7755  var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2),
7756  0) : (stop - start) / (domain.length - 1 + padding) | 0;
7757  range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step);
7758  rangeBand = 0;
7759  ranger = {
7760  t: "rangeRoundPoints",
7761  a: arguments
7762  };
7763  return scale;
7764  };
7765  scale.rangeBands = function(x, padding, outerPadding) {
7766  if (arguments.length < 2) padding = 0;
7767  if (arguments.length < 3) outerPadding = padding;
7768  var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding);
7769  range = steps(start + step * outerPadding, step);
7770  if (reverse) range.reverse();
7771  rangeBand = step * (1 - padding);
7772  ranger = {
7773  t: "rangeBands",
7774  a: arguments
7775  };
7776  return scale;
7777  };
7778  scale.rangeRoundBands = function(x, padding, outerPadding) {
7779  if (arguments.length < 2) padding = 0;
7780  if (arguments.length < 3) outerPadding = padding;
7781  var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding));
7782  range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step);
7783  if (reverse) range.reverse();
7784  rangeBand = Math.round(step * (1 - padding));
7785  ranger = {
7786  t: "rangeRoundBands",
7787  a: arguments
7788  };
7789  return scale;
7790  };
7791  scale.rangeBand = function() {
7792  return rangeBand;
7793  };
7794  scale.rangeExtent = function() {
7795  return d3_scaleExtent(ranger.a[0]);
7796  };
7797  scale.copy = function() {
7798  return d3_scale_ordinal(domain, ranger);
7799  };
7800  return scale.domain(domain);
7801  }
7802  d3.scale.category10 = function() {
7803  return d3.scale.ordinal().range(d3_category10);
7804  };
7805  d3.scale.category20 = function() {
7806  return d3.scale.ordinal().range(d3_category20);
7807  };
7808  d3.scale.category20b = function() {
7809  return d3.scale.ordinal().range(d3_category20b);
7810  };
7811  d3.scale.category20c = function() {
7812  return d3.scale.ordinal().range(d3_category20c);
7813  };
7814  var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString);
7815  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);
7816  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);
7817  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);
7818  d3.scale.quantile = function() {
7819  return d3_scale_quantile([], []);
7820  };
7821  function d3_scale_quantile(domain, range) {
7822  var thresholds;
7823  function rescale() {
7824  var k = 0, q = range.length;
7825  thresholds = [];
7826  while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);
7827  return scale;
7828  }
7829  function scale(x) {
7830  if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)];
7831  }
7832  scale.domain = function(x) {
7833  if (!arguments.length) return domain;
7834  domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending);
7835  return rescale();
7836  };
7837  scale.range = function(x) {
7838  if (!arguments.length) return range;
7839  range = x;
7840  return rescale();
7841  };
7842  scale.quantiles = function() {
7843  return thresholds;
7844  };
7845  scale.invertExtent = function(y) {
7846  y = range.indexOf(y);
7847  return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ];
7848  };
7849  scale.copy = function() {
7850  return d3_scale_quantile(domain, range);
7851  };
7852  return rescale();
7853  }
7854  d3.scale.quantize = function() {
7855  return d3_scale_quantize(0, 1, [ 0, 1 ]);
7856  };
7857  function d3_scale_quantize(x0, x1, range) {
7858  var kx, i;
7859  function scale(x) {
7860  return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];
7861  }
7862  function rescale() {
7863  kx = range.length / (x1 - x0);
7864  i = range.length - 1;
7865  return scale;
7866  }
7867  scale.domain = function(x) {
7868  if (!arguments.length) return [ x0, x1 ];
7869  x0 = +x[0];
7870  x1 = +x[x.length - 1];
7871  return rescale();
7872  };
7873  scale.range = function(x) {
7874  if (!arguments.length) return range;
7875  range = x;
7876  return rescale();
7877  };
7878  scale.invertExtent = function(y) {
7879  y = range.indexOf(y);
7880  y = y < 0 ? NaN : y / kx + x0;
7881  return [ y, y + 1 / kx ];
7882  };
7883  scale.copy = function() {
7884  return d3_scale_quantize(x0, x1, range);
7885  };
7886  return rescale();
7887  }
7888  d3.scale.threshold = function() {
7889  return d3_scale_threshold([ .5 ], [ 0, 1 ]);
7890  };
7891  function d3_scale_threshold(domain, range) {
7892  function scale(x) {
7893  if (x <= x) return range[d3.bisect(domain, x)];
7894  }
7895  scale.domain = function(_) {
7896  if (!arguments.length) return domain;
7897  domain = _;
7898  return scale;
7899  };
7900  scale.range = function(_) {
7901  if (!arguments.length) return range;
7902  range = _;
7903  return scale;
7904  };
7905  scale.invertExtent = function(y) {
7906  y = range.indexOf(y);
7907  return [ domain[y - 1], domain[y] ];
7908  };
7909  scale.copy = function() {
7910  return d3_scale_threshold(domain, range);
7911  };
7912  return scale;
7913  }
7914  d3.scale.identity = function() {
7915  return d3_scale_identity([ 0, 1 ]);
7916  };
7917  function d3_scale_identity(domain) {
7918  function identity(x) {
7919  return +x;
7920  }
7921  identity.invert = identity;
7922  identity.domain = identity.range = function(x) {
7923  if (!arguments.length) return domain;
7924  domain = x.map(identity);
7925  return identity;
7926  };
7927  identity.ticks = function(m) {
7928  return d3_scale_linearTicks(domain, m);
7929  };
7930  identity.tickFormat = function(m, format) {
7931  return d3_scale_linearTickFormat(domain, m, format);
7932  };
7933  identity.copy = function() {
7934  return d3_scale_identity(domain);
7935  };
7936  return identity;
7937  }
7938  d3.svg = {};
7939  function d3_zero() {
7940  return 0;
7941  }
7942  d3.svg.arc = function() {
7943  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;
7944  function arc() {
7945  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;
7946  if (r1 < r0) rc = r1, r1 = r0, r0 = rc;
7947  if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : "") + "Z";
7948  var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = [];
7949  if (ap = (+padAngle.apply(this, arguments) || 0) / 2) {
7950  rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments);
7951  if (!cw) p1 *= -1;
7952  if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap));
7953  if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap));
7954  }
7955  if (r1) {
7956  x0 = r1 * Math.cos(a0 + p1);
7957  y0 = r1 * Math.sin(a0 + p1);
7958  x1 = r1 * Math.cos(a1 - p1);
7959  y1 = r1 * Math.sin(a1 - p1);
7960  var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1;
7961  if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) {
7962  var h1 = (a0 + a1) / 2;
7963  x0 = r1 * Math.cos(h1);
7964  y0 = r1 * Math.sin(h1);
7965  x1 = y1 = null;
7966  }
7967  } else {
7968  x0 = y0 = 0;
7969  }
7970  if (r0) {
7971  x2 = r0 * Math.cos(a1 - p0);
7972  y2 = r0 * Math.sin(a1 - p0);
7973  x3 = r0 * Math.cos(a0 + p0);
7974  y3 = r0 * Math.sin(a0 + p0);
7975  var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1;
7976  if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) {
7977  var h0 = (a0 + a1) / 2;
7978  x2 = r0 * Math.cos(h0);
7979  y2 = r0 * Math.sin(h0);
7980  x3 = y3 = null;
7981  }
7982  } else {
7983  x2 = y2 = 0;
7984  }
7985  if ((rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) {
7986  cr = r0 < r1 ^ cw ? 0 : 1;
7987  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]);
7988  if (x1 != null) {
7989  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);
7990  if (rc === rc1) {
7991  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]);
7992  } else {
7993  path.push("M", t30[0], "A", rc1, ",", rc1, " 0 1,", cr, " ", t12[0]);
7994  }
7995  } else {
7996  path.push("M", x0, ",", y0);
7997  }
7998  if (x3 != null) {
7999  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);
8000  if (rc === rc0) {
8001  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]);
8002  } else {
8003  path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]);
8004  }
8005  } else {
8006  path.push("L", x2, ",", y2);
8007  }
8008  } else {
8009  path.push("M", x0, ",", y0);
8010  if (x1 != null) path.push("A", r1, ",", r1, " 0 ", l1, ",", cw, " ", x1, ",", y1);
8011  path.push("L", x2, ",", y2);
8012  if (x3 != null) path.push("A", r0, ",", r0, " 0 ", l0, ",", 1 - cw, " ", x3, ",", y3);
8013  }
8014  path.push("Z");
8015  return path.join("");
8016  }
8017  function circleSegment(r1, cw) {
8018  return "M0," + r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + -r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + r1;
8019  }
8020  arc.innerRadius = function(v) {
8021  if (!arguments.length) return innerRadius;
8022  innerRadius = d3_functor(v);
8023  return arc;
8024  };
8025  arc.outerRadius = function(v) {
8026  if (!arguments.length) return outerRadius;
8027  outerRadius = d3_functor(v);
8028  return arc;
8029  };
8030  arc.cornerRadius = function(v) {
8031  if (!arguments.length) return cornerRadius;
8032  cornerRadius = d3_functor(v);
8033  return arc;
8034  };
8035  arc.padRadius = function(v) {
8036  if (!arguments.length) return padRadius;
8037  padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v);
8038  return arc;
8039  };
8040  arc.startAngle = function(v) {
8041  if (!arguments.length) return startAngle;
8042  startAngle = d3_functor(v);
8043  return arc;
8044  };
8045  arc.endAngle = function(v) {
8046  if (!arguments.length) return endAngle;
8047  endAngle = d3_functor(v);
8048  return arc;
8049  };
8050  arc.padAngle = function(v) {
8051  if (!arguments.length) return padAngle;
8052  padAngle = d3_functor(v);
8053  return arc;
8054  };
8055  arc.centroid = function() {
8056  var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - halfπ;
8057  return [ Math.cos(a) * r, Math.sin(a) * r ];
8058  };
8059  return arc;
8060  };
8061  var d3_svg_arcAuto = "auto";
8062  function d3_svg_arcInnerRadius(d) {
8063  return d.innerRadius;
8064  }
8065  function d3_svg_arcOuterRadius(d) {
8066  return d.outerRadius;
8067  }
8068  function d3_svg_arcStartAngle(d) {
8069  return d.startAngle;
8070  }
8071  function d3_svg_arcEndAngle(d) {
8072  return d.endAngle;
8073  }
8074  function d3_svg_arcPadAngle(d) {
8075  return d && d.padAngle;
8076  }
8077  function d3_svg_arcSweep(x0, y0, x1, y1) {
8078  return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1;
8079  }
8080  function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) {
8081  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;
8082  if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
8083  return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ];
8084  }
8085  function d3_svg_line(projection) {
8086  var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;
8087  function line(data) {
8088  var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y);
8089  function segment() {
8090  segments.push("M", interpolate(projection(points), tension));
8091  }
8092  while (++i < n) {
8093  if (defined.call(this, d = data[i], i)) {
8094  points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]);
8095  } else if (points.length) {
8096  segment();
8097  points = [];
8098  }
8099  }
8100  if (points.length) segment();
8101  return segments.length ? segments.join("") : null;
8102  }
8103  line.x = function(_) {
8104  if (!arguments.length) return x;
8105  x = _;
8106  return line;
8107  };
8108  line.y = function(_) {
8109  if (!arguments.length) return y;
8110  y = _;
8111  return line;
8112  };
8113  line.defined = function(_) {
8114  if (!arguments.length) return defined;
8115  defined = _;
8116  return line;
8117  };
8118  line.interpolate = function(_) {
8119  if (!arguments.length) return interpolateKey;
8120  if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
8121  return line;
8122  };
8123  line.tension = function(_) {
8124  if (!arguments.length) return tension;
8125  tension = _;
8126  return line;
8127  };
8128  return line;
8129  }
8130  d3.svg.line = function() {
8131  return d3_svg_line(d3_identity);
8132  };
8133  var d3_svg_lineInterpolators = d3.map({
8134  linear: d3_svg_lineLinear,
8135  "linear-closed": d3_svg_lineLinearClosed,
8136  step: d3_svg_lineStep,
8137  "step-before": d3_svg_lineStepBefore,
8138  "step-after": d3_svg_lineStepAfter,
8139  basis: d3_svg_lineBasis,
8140  "basis-open": d3_svg_lineBasisOpen,
8141  "basis-closed": d3_svg_lineBasisClosed,
8142  bundle: d3_svg_lineBundle,
8143  cardinal: d3_svg_lineCardinal,
8144  "cardinal-open": d3_svg_lineCardinalOpen,
8145  "cardinal-closed": d3_svg_lineCardinalClosed,
8146  monotone: d3_svg_lineMonotone
8147  });
8148  d3_svg_lineInterpolators.forEach(function(key, value) {
8149  value.key = key;
8150  value.closed = /-closed$/.test(key);
8151  });
8152  function d3_svg_lineLinear(points) {
8153  return points.join("L");
8154  }
8155  function d3_svg_lineLinearClosed(points) {
8156  return d3_svg_lineLinear(points) + "Z";
8157  }
8158  function d3_svg_lineStep(points) {
8159  var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
8160  while (++i < n) path.push("H", (p[0] + (p = points[i])[0]) / 2, "V", p[1]);
8161  if (n > 1) path.push("H", p[0]);
8162  return path.join("");
8163  }
8164  function d3_svg_lineStepBefore(points) {
8165  var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
8166  while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]);
8167  return path.join("");
8168  }
8169  function d3_svg_lineStepAfter(points) {
8170  var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
8171  while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]);
8172  return path.join("");
8173  }
8174  function d3_svg_lineCardinalOpen(points, tension) {
8175  return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));
8176  }
8177  function d3_svg_lineCardinalClosed(points, tension) {
8178  return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]),
8179  points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));
8180  }
8181  function d3_svg_lineCardinal(points, tension) {
8182  return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension));
8183  }
8184  function d3_svg_lineHermite(points, tangents) {
8185  if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) {
8186  return d3_svg_lineLinear(points);
8187  }
8188  var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1;
8189  if (quad) {
8190  path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1];
8191  p0 = points[1];
8192  pi = 2;
8193  }
8194  if (tangents.length > 1) {
8195  t = tangents[1];
8196  p = points[pi];
8197  pi++;
8198  path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
8199  for (var i = 2; i < tangents.length; i++, pi++) {
8200  p = points[pi];
8201  t = tangents[i];
8202  path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
8203  }
8204  }
8205  if (quad) {
8206  var lp = points[pi];
8207  path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1];
8208  }
8209  return path;
8210  }
8211  function d3_svg_lineCardinalTangents(points, tension) {
8212  var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length;
8213  while (++i < n) {
8214  p0 = p1;
8215  p1 = p2;
8216  p2 = points[i];
8217  tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]);
8218  }
8219  return tangents;
8220  }
8221  function d3_svg_lineBasis(points) {
8222  if (points.length < 3) return d3_svg_lineLinear(points);
8223  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) ];
8224  points.push(points[n - 1]);
8225  while (++i <= n) {
8226  pi = points[i];
8227  px.shift();
8228  px.push(pi[0]);
8229  py.shift();
8230  py.push(pi[1]);
8231  d3_svg_lineBasisBezier(path, px, py);
8232  }
8233  points.pop();
8234  path.push("L", pi);
8235  return path.join("");
8236  }
8237  function d3_svg_lineBasisOpen(points) {
8238  if (points.length < 4) return d3_svg_lineLinear(points);
8239  var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ];
8240  while (++i < 3) {
8241  pi = points[i];
8242  px.push(pi[0]);
8243  py.push(pi[1]);
8244  }
8245  path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));
8246  --i;
8247  while (++i < n) {
8248  pi = points[i];
8249  px.shift();
8250  px.push(pi[0]);
8251  py.shift();
8252  py.push(pi[1]);
8253  d3_svg_lineBasisBezier(path, px, py);
8254  }
8255  return path.join("");
8256  }
8257  function d3_svg_lineBasisClosed(points) {
8258  var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = [];
8259  while (++i < 4) {
8260  pi = points[i % n];
8261  px.push(pi[0]);
8262  py.push(pi[1]);
8263  }
8264  path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];
8265  --i;
8266  while (++i < m) {
8267  pi = points[i % n];
8268  px.shift();
8269  px.push(pi[0]);
8270  py.shift();
8271  py.push(pi[1]);
8272  d3_svg_lineBasisBezier(path, px, py);
8273  }
8274  return path.join("");
8275  }
8276  function d3_svg_lineBundle(points, tension) {
8277  var n = points.length - 1;
8278  if (n) {
8279  var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t;
8280  while (++i <= n) {
8281  p = points[i];
8282  t = i / n;
8283  p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
8284  p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
8285  }
8286  }
8287  return d3_svg_lineBasis(points);
8288  }
8289  function d3_svg_lineDot4(a, b) {
8290  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
8291  }
8292  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 ];
8293  function d3_svg_lineBasisBezier(path, x, y) {
8294  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));
8295  }
8296  function d3_svg_lineSlope(p0, p1) {
8297  return (p1[1] - p0[1]) / (p1[0] - p0[0]);
8298  }
8299  function d3_svg_lineFiniteDifferences(points) {
8300  var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1);
8301  while (++i < j) {
8302  m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2;
8303  }
8304  m[i] = d;
8305  return m;
8306  }
8307  function d3_svg_lineMonotoneTangents(points) {
8308  var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1;
8309  while (++i < j) {
8310  d = d3_svg_lineSlope(points[i], points[i + 1]);
8311  if (abs(d) < ε) {
8312  m[i] = m[i + 1] = 0;
8313  } else {
8314  a = m[i] / d;
8315  b = m[i + 1] / d;
8316  s = a * a + b * b;
8317  if (s > 9) {
8318  s = d * 3 / Math.sqrt(s);
8319  m[i] = s * a;
8320  m[i + 1] = s * b;
8321  }
8322  }
8323  }
8324  i = -1;
8325  while (++i <= j) {
8326  s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));
8327  tangents.push([ s || 0, m[i] * s || 0 ]);
8328  }
8329  return tangents;
8330  }
8331  function d3_svg_lineMonotone(points) {
8332  return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));
8333  }
8334  d3.svg.line.radial = function() {
8335  var line = d3_svg_line(d3_svg_lineRadial);
8336  line.radius = line.x, delete line.x;
8337  line.angle = line.y, delete line.y;
8338  return line;
8339  };
8340  function d3_svg_lineRadial(points) {
8341  var point, i = -1, n = points.length, r, a;
8342  while (++i < n) {
8343  point = points[i];
8344  r = point[0];
8345  a = point[1] - halfπ;
8346  point[0] = r * Math.cos(a);
8347  point[1] = r * Math.sin(a);
8348  }
8349  return points;
8350  }
8351  function d3_svg_area(projection) {
8352  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;
8353  function area(data) {
8354  var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() {
8355  return x;
8356  } : d3_functor(x1), fy1 = y0 === y1 ? function() {
8357  return y;
8358  } : d3_functor(y1), x, y;
8359  function segment() {
8360  segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z");
8361  }
8362  while (++i < n) {
8363  if (defined.call(this, d = data[i], i)) {
8364  points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]);
8365  points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]);
8366  } else if (points0.length) {
8367  segment();
8368  points0 = [];
8369  points1 = [];
8370  }
8371  }
8372  if (points0.length) segment();
8373  return segments.length ? segments.join("") : null;
8374  }
8375  area.x = function(_) {
8376  if (!arguments.length) return x1;
8377  x0 = x1 = _;
8378  return area;
8379  };
8380  area.x0 = function(_) {
8381  if (!arguments.length) return x0;
8382  x0 = _;
8383  return area;
8384  };
8385  area.x1 = function(_) {
8386  if (!arguments.length) return x1;
8387  x1 = _;
8388  return area;
8389  };
8390  area.y = function(_) {
8391  if (!arguments.length) return y1;
8392  y0 = y1 = _;
8393  return area;
8394  };
8395  area.y0 = function(_) {
8396  if (!arguments.length) return y0;
8397  y0 = _;
8398  return area;
8399  };
8400  area.y1 = function(_) {
8401  if (!arguments.length) return y1;
8402  y1 = _;
8403  return area;
8404  };
8405  area.defined = function(_) {
8406  if (!arguments.length) return defined;
8407  defined = _;
8408  return area;
8409  };
8410  area.interpolate = function(_) {
8411  if (!arguments.length) return interpolateKey;
8412  if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
8413  interpolateReverse = interpolate.reverse || interpolate;
8414  L = interpolate.closed ? "M" : "L";
8415  return area;
8416  };
8417  area.tension = function(_) {
8418  if (!arguments.length) return tension;
8419  tension = _;
8420  return area;
8421  };
8422  return area;
8423  }
8424  d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;
8425  d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;
8426  d3.svg.area = function() {
8427  return d3_svg_area(d3_identity);
8428  };
8429  d3.svg.area.radial = function() {
8430  var area = d3_svg_area(d3_svg_lineRadial);
8431  area.radius = area.x, delete area.x;
8432  area.innerRadius = area.x0, delete area.x0;
8433  area.outerRadius = area.x1, delete area.x1;
8434  area.angle = area.y, delete area.y;
8435  area.startAngle = area.y0, delete area.y0;
8436  area.endAngle = area.y1, delete area.y1;
8437  return area;
8438  };
8439  d3.svg.chord = function() {
8440  var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;
8441  function chord(d, i) {
8442  var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i);
8443  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";
8444  }
8445  function subgroup(self, f, d, i) {
8446  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π;
8447  return {
8448  r: r,
8449  a0: a0,
8450  a1: a1,
8451  p0: [ r * Math.cos(a0), r * Math.sin(a0) ],
8452  p1: [ r * Math.cos(a1), r * Math.sin(a1) ]
8453  };
8454  }
8455  function equals(a, b) {
8456  return a.a0 == b.a0 && a.a1 == b.a1;
8457  }
8458  function arc(r, p, a) {
8459  return "A" + r + "," + r + " 0 " + +(a > π) + ",1 " + p;
8460  }
8461  function curve(r0, p0, r1, p1) {
8462  return "Q 0,0 " + p1;
8463  }
8464  chord.radius = function(v) {
8465  if (!arguments.length) return radius;
8466  radius = d3_functor(v);
8467  return chord;
8468  };
8469  chord.source = function(v) {
8470  if (!arguments.length) return source;
8471  source = d3_functor(v);
8472  return chord;
8473  };
8474  chord.target = function(v) {
8475  if (!arguments.length) return target;
8476  target = d3_functor(v);
8477  return chord;
8478  };
8479  chord.startAngle = function(v) {
8480  if (!arguments.length) return startAngle;
8481  startAngle = d3_functor(v);
8482  return chord;
8483  };
8484  chord.endAngle = function(v) {
8485  if (!arguments.length) return endAngle;
8486  endAngle = d3_functor(v);
8487  return chord;
8488  };
8489  return chord;
8490  };
8491  function d3_svg_chordRadius(d) {
8492  return d.radius;
8493  }
8494  d3.svg.diagonal = function() {
8495  var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection;
8496  function diagonal(d, i) {
8497  var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, {
8498  x: p0.x,
8499  y: m
8500  }, {
8501  x: p3.x,
8502  y: m
8503  }, p3 ];
8504  p = p.map(projection);
8505  return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3];
8506  }
8507  diagonal.source = function(x) {
8508  if (!arguments.length) return source;
8509  source = d3_functor(x);
8510  return diagonal;
8511  };
8512  diagonal.target = function(x) {
8513  if (!arguments.length) return target;
8514  target = d3_functor(x);
8515  return diagonal;
8516  };
8517  diagonal.projection = function(x) {
8518  if (!arguments.length) return projection;
8519  projection = x;
8520  return diagonal;
8521  };
8522  return diagonal;
8523  };
8524  function d3_svg_diagonalProjection(d) {
8525  return [ d.x, d.y ];
8526  }
8527  d3.svg.diagonal.radial = function() {
8528  var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection;
8529  diagonal.projection = function(x) {
8530  return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection;
8531  };
8532  return diagonal;
8533  };
8534  function d3_svg_diagonalRadialProjection(projection) {
8535  return function() {
8536  var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ;
8537  return [ r * Math.cos(a), r * Math.sin(a) ];
8538  };
8539  }
8540  d3.svg.symbol = function() {
8541  var type = d3_svg_symbolType, size = d3_svg_symbolSize;
8542  function symbol(d, i) {
8543  return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i));
8544  }
8545  symbol.type = function(x) {
8546  if (!arguments.length) return type;
8547  type = d3_functor(x);
8548  return symbol;
8549  };
8550  symbol.size = function(x) {
8551  if (!arguments.length) return size;
8552  size = d3_functor(x);
8553  return symbol;
8554  };
8555  return symbol;
8556  };
8557  function d3_svg_symbolSize() {
8558  return 64;
8559  }
8560  function d3_svg_symbolType() {
8561  return "circle";
8562  }
8563  function d3_svg_symbolCircle(size) {
8564  var r = Math.sqrt(size / π);
8565  return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z";
8566  }
8567  var d3_svg_symbols = d3.map({
8568  circle: d3_svg_symbolCircle,
8569  cross: function(size) {
8570  var r = Math.sqrt(size / 5) / 2;
8571  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";
8572  },
8573  diamond: function(size) {
8574  var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30;
8575  return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z";
8576  },
8577  square: function(size) {
8578  var r = Math.sqrt(size) / 2;
8579  return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z";
8580  },
8581  "triangle-down": function(size) {
8582  var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;
8583  return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z";
8584  },
8585  "triangle-up": function(size) {
8586  var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;
8587  return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z";
8588  }
8589  });
8590  d3.svg.symbolTypes = d3_svg_symbols.keys();
8591  var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);
8592  d3_selectionPrototype.transition = function(name) {
8593  var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || {
8594  time: Date.now(),
8595  ease: d3_ease_cubicInOut,
8596  delay: 0,
8597  duration: 250
8598  };
8599  for (var j = -1, m = this.length; ++j < m; ) {
8600  subgroups.push(subgroup = []);
8601  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8602  if (node = group[i]) d3_transitionNode(node, i, ns, id, transition);
8603  subgroup.push(node);
8604  }
8605  }
8606  return d3_transition(subgroups, ns, id);
8607  };
8608  d3_selectionPrototype.interrupt = function(name) {
8609  return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name)));
8610  };
8611  var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace());
8612  function d3_selection_interruptNS(ns) {
8613  return function() {
8614  var lock, active;
8615  if ((lock = this[ns]) && (active = lock[lock.active])) {
8616  if (--lock.count) delete lock[lock.active]; else delete this[ns];
8617  lock.active += .5;
8618  active.event && active.event.interrupt.call(this, this.__data__, active.index);
8619  }
8620  };
8621  }
8622  function d3_transition(groups, ns, id) {
8623  d3_subclass(groups, d3_transitionPrototype);
8624  groups.namespace = ns;
8625  groups.id = id;
8626  return groups;
8627  }
8628  var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit;
8629  d3_transitionPrototype.call = d3_selectionPrototype.call;
8630  d3_transitionPrototype.empty = d3_selectionPrototype.empty;
8631  d3_transitionPrototype.node = d3_selectionPrototype.node;
8632  d3_transitionPrototype.size = d3_selectionPrototype.size;
8633  d3.transition = function(selection, name) {
8634  return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3.selection().transition(selection);
8635  };
8636  d3.transition.prototype = d3_transitionPrototype;
8637  d3_transitionPrototype.select = function(selector) {
8638  var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node;
8639  selector = d3_selection_selector(selector);
8640  for (var j = -1, m = this.length; ++j < m; ) {
8641  subgroups.push(subgroup = []);
8642  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8643  if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) {
8644  if ("__data__" in node) subnode.__data__ = node.__data__;
8645  d3_transitionNode(subnode, i, ns, id, node[ns][id]);
8646  subgroup.push(subnode);
8647  } else {
8648  subgroup.push(null);
8649  }
8650  }
8651  }
8652  return d3_transition(subgroups, ns, id);
8653  };
8654  d3_transitionPrototype.selectAll = function(selector) {
8655  var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition;
8656  selector = d3_selection_selectorAll(selector);
8657  for (var j = -1, m = this.length; ++j < m; ) {
8658  for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
8659  if (node = group[i]) {
8660  transition = node[ns][id];
8661  subnodes = selector.call(node, node.__data__, i, j);
8662  subgroups.push(subgroup = []);
8663  for (var k = -1, o = subnodes.length; ++k < o; ) {
8664  if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition);
8665  subgroup.push(subnode);
8666  }
8667  }
8668  }
8669  }
8670  return d3_transition(subgroups, ns, id);
8671  };
8672  d3_transitionPrototype.filter = function(filter) {
8673  var subgroups = [], subgroup, group, node;
8674  if (typeof filter !== "function") filter = d3_selection_filter(filter);
8675  for (var j = 0, m = this.length; j < m; j++) {
8676  subgroups.push(subgroup = []);
8677  for (var group = this[j], i = 0, n = group.length; i < n; i++) {
8678  if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {
8679  subgroup.push(node);
8680  }
8681  }
8682  }
8683  return d3_transition(subgroups, this.namespace, this.id);
8684  };
8685  d3_transitionPrototype.tween = function(name, tween) {
8686  var id = this.id, ns = this.namespace;
8687  if (arguments.length < 2) return this.node()[ns][id].tween.get(name);
8688  return d3_selection_each(this, tween == null ? function(node) {
8689  node[ns][id].tween.remove(name);
8690  } : function(node) {
8691  node[ns][id].tween.set(name, tween);
8692  });
8693  };
8694  function d3_transition_tween(groups, name, value, tween) {
8695  var id = groups.id, ns = groups.namespace;
8696  return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) {
8697  node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j)));
8698  } : (value = tween(value), function(node) {
8699  node[ns][id].tween.set(name, value);
8700  }));
8701  }
8702  d3_transitionPrototype.attr = function(nameNS, value) {
8703  if (arguments.length < 2) {
8704  for (value in nameNS) this.attr(value, nameNS[value]);
8705  return this;
8706  }
8707  var interpolate = nameNS == "transform" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS);
8708  function attrNull() {
8709  this.removeAttribute(name);
8710  }
8711  function attrNullNS() {
8712  this.removeAttributeNS(name.space, name.local);
8713  }
8714  function attrTween(b) {
8715  return b == null ? attrNull : (b += "", function() {
8716  var a = this.getAttribute(name), i;
8717  return a !== b && (i = interpolate(a, b), function(t) {
8718  this.setAttribute(name, i(t));
8719  });
8720  });
8721  }
8722  function attrTweenNS(b) {
8723  return b == null ? attrNullNS : (b += "", function() {
8724  var a = this.getAttributeNS(name.space, name.local), i;
8725  return a !== b && (i = interpolate(a, b), function(t) {
8726  this.setAttributeNS(name.space, name.local, i(t));
8727  });
8728  });
8729  }
8730  return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween);
8731  };
8732  d3_transitionPrototype.attrTween = function(nameNS, tween) {
8733  var name = d3.ns.qualify(nameNS);
8734  function attrTween(d, i) {
8735  var f = tween.call(this, d, i, this.getAttribute(name));
8736  return f && function(t) {
8737  this.setAttribute(name, f(t));
8738  };
8739  }
8740  function attrTweenNS(d, i) {
8741  var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));
8742  return f && function(t) {
8743  this.setAttributeNS(name.space, name.local, f(t));
8744  };
8745  }
8746  return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween);
8747  };
8748  d3_transitionPrototype.style = function(name, value, priority) {
8749  var n = arguments.length;
8750  if (n < 3) {
8751  if (typeof name !== "string") {
8752  if (n < 2) value = "";
8753  for (priority in name) this.style(priority, name[priority], value);
8754  return this;
8755  }
8756  priority = "";
8757  }
8758  function styleNull() {
8759  this.style.removeProperty(name);
8760  }
8761  function styleString(b) {
8762  return b == null ? styleNull : (b += "", function() {
8763  var a = d3_window(this).getComputedStyle(this, null).getPropertyValue(name), i;
8764  return a !== b && (i = d3_interpolate(a, b), function(t) {
8765  this.style.setProperty(name, i(t), priority);
8766  });
8767  });
8768  }
8769  return d3_transition_tween(this, "style." + name, value, styleString);
8770  };
8771  d3_transitionPrototype.styleTween = function(name, tween, priority) {
8772  if (arguments.length < 3) priority = "";
8773  function styleTween(d, i) {
8774  var f = tween.call(this, d, i, d3_window(this).getComputedStyle(this, null).getPropertyValue(name));
8775  return f && function(t) {
8776  this.style.setProperty(name, f(t), priority);
8777  };
8778  }
8779  return this.tween("style." + name, styleTween);
8780  };
8781  d3_transitionPrototype.text = function(value) {
8782  return d3_transition_tween(this, "text", value, d3_transition_text);
8783  };
8784  function d3_transition_text(b) {
8785  if (b == null) b = "";
8786  return function() {
8787  this.textContent = b;
8788  };
8789  }
8790  d3_transitionPrototype.remove = function() {
8791  var ns = this.namespace;
8792  return this.each("end.transition", function() {
8793  var p;
8794  if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this);
8795  });
8796  };
8797  d3_transitionPrototype.ease = function(value) {
8798  var id = this.id, ns = this.namespace;
8799  if (arguments.length < 1) return this.node()[ns][id].ease;
8800  if (typeof value !== "function") value = d3.ease.apply(d3, arguments);
8801  return d3_selection_each(this, function(node) {
8802  node[ns][id].ease = value;
8803  });
8804  };
8805  d3_transitionPrototype.delay = function(value) {
8806  var id = this.id, ns = this.namespace;
8807  if (arguments.length < 1) return this.node()[ns][id].delay;
8808  return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8809  node[ns][id].delay = +value.call(node, node.__data__, i, j);
8810  } : (value = +value, function(node) {
8811  node[ns][id].delay = value;
8812  }));
8813  };
8814  d3_transitionPrototype.duration = function(value) {
8815  var id = this.id, ns = this.namespace;
8816  if (arguments.length < 1) return this.node()[ns][id].duration;
8817  return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
8818  node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j));
8819  } : (value = Math.max(1, value), function(node) {
8820  node[ns][id].duration = value;
8821  }));
8822  };
8823  d3_transitionPrototype.each = function(type, listener) {
8824  var id = this.id, ns = this.namespace;
8825  if (arguments.length < 2) {
8826  var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;
8827  try {
8828  d3_transitionInheritId = id;
8829  d3_selection_each(this, function(node, i, j) {
8830  d3_transitionInherit = node[ns][id];
8831  type.call(node, node.__data__, i, j);
8832  });
8833  } finally {
8834  d3_transitionInherit = inherit;
8835  d3_transitionInheritId = inheritId;
8836  }
8837  } else {
8838  d3_selection_each(this, function(node) {
8839  var transition = node[ns][id];
8840  (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener);
8841  });
8842  }
8843  return this;
8844  };
8845  d3_transitionPrototype.transition = function() {
8846  var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition;
8847  for (var j = 0, m = this.length; j < m; j++) {
8848  subgroups.push(subgroup = []);
8849  for (var group = this[j], i = 0, n = group.length; i < n; i++) {
8850  if (node = group[i]) {
8851  transition = node[ns][id0];
8852  d3_transitionNode(node, i, ns, id1, {
8853  time: transition.time,
8854  ease: transition.ease,
8855  delay: transition.delay + transition.duration,
8856  duration: transition.duration
8857  });
8858  }
8859  subgroup.push(node);
8860  }
8861  }
8862  return d3_transition(subgroups, ns, id1);
8863  };
8864  function d3_transitionNamespace(name) {
8865  return name == null ? "__transition__" : "__transition_" + name + "__";
8866  }
8867  function d3_transitionNode(node, i, ns, id, inherit) {
8868  var lock = node[ns] || (node[ns] = {
8869  active: 0,
8870  count: 0
8871  }), transition = lock[id];
8872  if (!transition) {
8873  var time = inherit.time;
8874  transition = lock[id] = {
8875  tween: new d3_Map(),
8876  time: time,
8877  delay: inherit.delay,
8878  duration: inherit.duration,
8879  ease: inherit.ease,
8880  index: i
8881  };
8882  inherit = null;
8883  ++lock.count;
8884  d3.timer(function(elapsed) {
8885  var delay = transition.delay, duration, ease, timer = d3_timer_active, tweened = [];
8886  timer.t = delay + time;
8887  if (delay <= elapsed) return start(elapsed - delay);
8888  timer.c = start;
8889  function start(elapsed) {
8890  if (lock.active > id) return stop();
8891  var active = lock[lock.active];
8892  if (active) {
8893  --lock.count;
8894  delete lock[lock.active];
8895  active.event && active.event.interrupt.call(node, node.__data__, active.index);
8896  }
8897  lock.active = id;
8898  transition.event && transition.event.start.call(node, node.__data__, i);
8899  transition.tween.forEach(function(key, value) {
8900  if (value = value.call(node, node.__data__, i)) {
8901  tweened.push(value);
8902  }
8903  });
8904  ease = transition.ease;
8905  duration = transition.duration;
8906  d3.timer(function() {
8907  timer.c = tick(elapsed || 1) ? d3_true : tick;
8908  return 1;
8909  }, 0, time);
8910  }
8911  function tick(elapsed) {
8912  if (lock.active !== id) return 1;
8913  var t = elapsed / duration, e = ease(t), n = tweened.length;
8914  while (n > 0) {
8915  tweened[--n].call(node, e);
8916  }
8917  if (t >= 1) {
8918  transition.event && transition.event.end.call(node, node.__data__, i);
8919  return stop();
8920  }
8921  }
8922  function stop() {
8923  if (--lock.count) delete lock[id]; else delete node[ns];
8924  return 1;
8925  }
8926  }, 0, time);
8927  }
8928  }
8929  d3.svg.axis = function() {
8930  var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_;
8931  function axis(g) {
8932  g.each(function() {
8933  var g = d3.select(this);
8934  var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy();
8935  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;
8936  var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"),
8937  d3.transition(path));
8938  tickEnter.append("line");
8939  tickEnter.append("text");
8940  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;
8941  if (orient === "bottom" || orient === "top") {
8942  tickTransform = d3_svg_axisX, x1 = "x", y1 = "y", x2 = "x2", y2 = "y2";
8943  text.attr("dy", sign < 0 ? "0em" : ".71em").style("text-anchor", "middle");
8944  pathUpdate.attr("d", "M" + range[0] + "," + sign * outerTickSize + "V0H" + range[1] + "V" + sign * outerTickSize);
8945  } else {
8946  tickTransform = d3_svg_axisY, x1 = "y", y1 = "x", x2 = "y2", y2 = "x2";
8947  text.attr("dy", ".32em").style("text-anchor", sign < 0 ? "end" : "start");
8948  pathUpdate.attr("d", "M" + sign * outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + sign * outerTickSize);
8949  }
8950  lineEnter.attr(y2, sign * innerTickSize);
8951  textEnter.attr(y1, sign * tickSpacing);
8952  lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize);
8953  textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing);
8954  if (scale1.rangeBand) {
8955  var x = scale1, dx = x.rangeBand() / 2;
8956  scale0 = scale1 = function(d) {
8957  return x(d) + dx;
8958  };
8959  } else if (scale0.rangeBand) {
8960  scale0 = scale1;
8961  } else {
8962  tickExit.call(tickTransform, scale1, scale0);
8963  }
8964  tickEnter.call(tickTransform, scale0, scale1);
8965  tickUpdate.call(tickTransform, scale1, scale1);
8966  });
8967  }
8968  axis.scale = function(x) {
8969  if (!arguments.length) return scale;
8970  scale = x;
8971  return axis;
8972  };
8973  axis.orient = function(x) {
8974  if (!arguments.length) return orient;
8975  orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient;
8976  return axis;
8977  };
8978  axis.ticks = function() {
8979  if (!arguments.length) return tickArguments_;
8980  tickArguments_ = arguments;
8981  return axis;
8982  };
8983  axis.tickValues = function(x) {
8984  if (!arguments.length) return tickValues;
8985  tickValues = x;
8986  return axis;
8987  };
8988  axis.tickFormat = function(x) {
8989  if (!arguments.length) return tickFormat_;
8990  tickFormat_ = x;
8991  return axis;
8992  };
8993  axis.tickSize = function(x) {
8994  var n = arguments.length;
8995  if (!n) return innerTickSize;
8996  innerTickSize = +x;
8997  outerTickSize = +arguments[n - 1];
8998  return axis;
8999  };
9000  axis.innerTickSize = function(x) {
9001  if (!arguments.length) return innerTickSize;
9002  innerTickSize = +x;
9003  return axis;
9004  };
9005  axis.outerTickSize = function(x) {
9006  if (!arguments.length) return outerTickSize;
9007  outerTickSize = +x;
9008  return axis;
9009  };
9010  axis.tickPadding = function(x) {
9011  if (!arguments.length) return tickPadding;
9012  tickPadding = +x;
9013  return axis;
9014  };
9015  axis.tickSubdivide = function() {
9016  return arguments.length && axis;
9017  };
9018  return axis;
9019  };
9020  var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = {
9021  top: 1,
9022  right: 1,
9023  bottom: 1,
9024  left: 1
9025  };
9026  function d3_svg_axisX(selection, x0, x1) {
9027  selection.attr("transform", function(d) {
9028  var v0 = x0(d);
9029  return "translate(" + (isFinite(v0) ? v0 : x1(d)) + ",0)";
9030  });
9031  }
9032  function d3_svg_axisY(selection, y0, y1) {
9033  selection.attr("transform", function(d) {
9034  var v0 = y0(d);
9035  return "translate(0," + (isFinite(v0) ? v0 : y1(d)) + ")";
9036  });
9037  }
9038  d3.svg.brush = function() {
9039  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];
9040  function brush(g) {
9041  g.each(function() {
9042  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);
9043  var background = g.selectAll(".background").data([ 0 ]);
9044  background.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair");
9045  g.selectAll(".extent").data([ 0 ]).enter().append("rect").attr("class", "extent").style("cursor", "move");
9046  var resize = g.selectAll(".resize").data(resizes, d3_identity);
9047  resize.exit().remove();
9048  resize.enter().append("g").attr("class", function(d) {
9049  return "resize " + d;
9050  }).style("cursor", function(d) {
9051  return d3_svg_brushCursor[d];
9052  }).append("rect").attr("x", function(d) {
9053  return /[ew]$/.test(d) ? -3 : null;
9054  }).attr("y", function(d) {
9055  return /^[ns]/.test(d) ? -3 : null;
9056  }).attr("width", 6).attr("height", 6).style("visibility", "hidden");
9057  resize.style("display", brush.empty() ? "none" : null);
9058  var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range;
9059  if (x) {
9060  range = d3_scaleRange(x);
9061  backgroundUpdate.attr("x", range[0]).attr("width", range[1] - range[0]);
9062  redrawX(gUpdate);
9063  }
9064  if (y) {
9065  range = d3_scaleRange(y);
9066  backgroundUpdate.attr("y", range[0]).attr("height", range[1] - range[0]);
9067  redrawY(gUpdate);
9068  }
9069  redraw(gUpdate);
9070  });
9071  }
9072  brush.event = function(g) {
9073  g.each(function() {
9074  var event_ = event.of(this, arguments), extent1 = {
9075  x: xExtent,
9076  y: yExtent,
9077  i: xExtentDomain,
9078  j: yExtentDomain
9079  }, extent0 = this.__chart__ || extent1;
9080  this.__chart__ = extent1;
9081  if (d3_transitionInheritId) {
9082  d3.select(this).transition().each("start.brush", function() {
9083  xExtentDomain = extent0.i;
9084  yExtentDomain = extent0.j;
9085  xExtent = extent0.x;
9086  yExtent = extent0.y;
9087  event_({
9088  type: "brushstart"
9089  });
9090  }).tween("brush:brush", function() {
9091  var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y);
9092  xExtentDomain = yExtentDomain = null;
9093  return function(t) {
9094  xExtent = extent1.x = xi(t);
9095  yExtent = extent1.y = yi(t);
9096  event_({
9097  type: "brush",
9098  mode: "resize"
9099  });
9100  };
9101  }).each("end.brush", function() {
9102  xExtentDomain = extent1.i;
9103  yExtentDomain = extent1.j;
9104  event_({
9105  type: "brush",
9106  mode: "resize"
9107  });
9108  event_({
9109  type: "brushend"
9110  });
9111  });
9112  } else {
9113  event_({
9114  type: "brushstart"
9115  });
9116  event_({
9117  type: "brush",
9118  mode: "resize"
9119  });
9120  event_({
9121  type: "brushend"
9122  });
9123  }
9124  });
9125  };
9126  function redraw(g) {
9127  g.selectAll(".resize").attr("transform", function(d) {
9128  return "translate(" + xExtent[+/e$/.test(d)] + "," + yExtent[+/^s/.test(d)] + ")";
9129  });
9130  }
9131  function redrawX(g) {
9132  g.select(".extent").attr("x", xExtent[0]);
9133  g.selectAll(".extent,.n>rect,.s>rect").attr("width", xExtent[1] - xExtent[0]);
9134  }
9135  function redrawY(g) {
9136  g.select(".extent").attr("y", yExtent[0]);
9137  g.selectAll(".extent,.e>rect,.w>rect").attr("height", yExtent[1] - yExtent[0]);
9138  }
9139  function brushstart() {
9140  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(target), center, origin = d3.mouse(target), offset;
9141  var w = d3.select(d3_window(target)).on("keydown.brush", keydown).on("keyup.brush", keyup);
9142  if (d3.event.changedTouches) {
9143  w.on("touchmove.brush", brushmove).on("touchend.brush", brushend);
9144  } else {
9145  w.on("mousemove.brush", brushmove).on("mouseup.brush", brushend);
9146  }
9147  g.interrupt().selectAll("*").interrupt();
9148  if (dragging) {
9149  origin[0] = xExtent[0] - origin[0];
9150  origin[1] = yExtent[0] - origin[1];
9151  } else if (resizing) {
9152  var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing);
9153  offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ];
9154  origin[0] = xExtent[ex];
9155  origin[1] = yExtent[ey];
9156  } else if (d3.event.altKey) center = origin.slice();
9157  g.style("pointer-events", "none").selectAll(".resize").style("display", null);
9158  d3.select("body").style("cursor", eventTarget.style("cursor"));
9159  event_({
9160  type: "brushstart"
9161  });
9162  brushmove();
9163  function keydown() {
9164  if (d3.event.keyCode == 32) {
9165  if (!dragging) {
9166  center = null;
9167  origin[0] -= xExtent[1];
9168  origin[1] -= yExtent[1];
9169  dragging = 2;
9170  }
9171  d3_eventPreventDefault();
9172  }
9173  }
9174  function keyup() {
9175  if (d3.event.keyCode == 32 && dragging == 2) {
9176  origin[0] += xExtent[1];
9177  origin[1] += yExtent[1];
9178  dragging = 0;
9179  d3_eventPreventDefault();
9180  }
9181  }
9182  function brushmove() {
9183  var point = d3.mouse(target), moved = false;
9184  if (offset) {
9185  point[0] += offset[0];
9186  point[1] += offset[1];
9187  }
9188  if (!dragging) {
9189  if (d3.event.altKey) {
9190  if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ];
9191  origin[0] = xExtent[+(point[0] < center[0])];
9192  origin[1] = yExtent[+(point[1] < center[1])];
9193  } else center = null;
9194  }
9195  if (resizingX && move1(point, x, 0)) {
9196  redrawX(g);
9197  moved = true;
9198  }
9199  if (resizingY && move1(point, y, 1)) {
9200  redrawY(g);
9201  moved = true;
9202  }
9203  if (moved) {
9204  redraw(g);
9205  event_({
9206  type: "brush",
9207  mode: dragging ? "move" : "resize"
9208  });
9209  }
9210  }
9211  function move1(point, scale, i) {
9212  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;
9213  if (dragging) {
9214  r0 -= position;
9215  r1 -= size + position;
9216  }
9217  min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i];
9218  if (dragging) {
9219  max = (min += position) + size;
9220  } else {
9221  if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min));
9222  if (position < min) {
9223  max = min;
9224  min = position;
9225  } else {
9226  max = position;
9227  }
9228  }
9229  if (extent[0] != min || extent[1] != max) {
9230  if (i) yExtentDomain = null; else xExtentDomain = null;
9231  extent[0] = min;
9232  extent[1] = max;
9233  return true;
9234  }
9235  }
9236  function brushend() {
9237  brushmove();
9238  g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null);
9239  d3.select("body").style("cursor", null);
9240  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);
9241  dragRestore();
9242  event_({
9243  type: "brushend"
9244  });
9245  }
9246  }
9247  brush.x = function(z) {
9248  if (!arguments.length) return x;
9249  x = z;
9250  resizes = d3_svg_brushResizes[!x << 1 | !y];
9251  return brush;
9252  };
9253  brush.y = function(z) {
9254  if (!arguments.length) return y;
9255  y = z;
9256  resizes = d3_svg_brushResizes[!x << 1 | !y];
9257  return brush;
9258  };
9259  brush.clamp = function(z) {
9260  if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null;
9261  if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z;
9262  return brush;
9263  };
9264  brush.extent = function(z) {
9265  var x0, x1, y0, y1, t;
9266  if (!arguments.length) {
9267  if (x) {
9268  if (xExtentDomain) {
9269  x0 = xExtentDomain[0], x1 = xExtentDomain[1];
9270  } else {
9271  x0 = xExtent[0], x1 = xExtent[1];
9272  if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);
9273  if (x1 < x0) t = x0, x0 = x1, x1 = t;
9274  }
9275  }
9276  if (y) {
9277  if (yExtentDomain) {
9278  y0 = yExtentDomain[0], y1 = yExtentDomain[1];
9279  } else {
9280  y0 = yExtent[0], y1 = yExtent[1];
9281  if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);
9282  if (y1 < y0) t = y0, y0 = y1, y1 = t;
9283  }
9284  }
9285  return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ];
9286  }
9287  if (x) {
9288  x0 = z[0], x1 = z[1];
9289  if (y) x0 = x0[0], x1 = x1[0];
9290  xExtentDomain = [ x0, x1 ];
9291  if (x.invert) x0 = x(x0), x1 = x(x1);
9292  if (x1 < x0) t = x0, x0 = x1, x1 = t;
9293  if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ];
9294  }
9295  if (y) {
9296  y0 = z[0], y1 = z[1];
9297  if (x) y0 = y0[1], y1 = y1[1];
9298  yExtentDomain = [ y0, y1 ];
9299  if (y.invert) y0 = y(y0), y1 = y(y1);
9300  if (y1 < y0) t = y0, y0 = y1, y1 = t;
9301  if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ];
9302  }
9303  return brush;
9304  };
9305  brush.clear = function() {
9306  if (!brush.empty()) {
9307  xExtent = [ 0, 0 ], yExtent = [ 0, 0 ];
9308  xExtentDomain = yExtentDomain = null;
9309  }
9310  return brush;
9311  };
9312  brush.empty = function() {
9313  return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1];
9314  };
9315  return d3.rebind(brush, event, "on");
9316  };
9317  var d3_svg_brushCursor = {
9318  n: "ns-resize",
9319  e: "ew-resize",
9320  s: "ns-resize",
9321  w: "ew-resize",
9322  nw: "nwse-resize",
9323  ne: "nesw-resize",
9324  se: "nwse-resize",
9325  sw: "nesw-resize"
9326  };
9327  var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ];
9328  var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat;
9329  var d3_time_formatUtc = d3_time_format.utc;
9330  var d3_time_formatIso = d3_time_formatUtc("%Y-%m-%dT%H:%M:%S.%LZ");
9331  d3_time_format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso;
9332  function d3_time_formatIsoNative(date) {
9333  return date.toISOString();
9334  }
9335  d3_time_formatIsoNative.parse = function(string) {
9336  var date = new Date(string);
9337  return isNaN(date) ? null : date;
9338  };
9339  d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
9340  d3_time.second = d3_time_interval(function(date) {
9341  return new d3_date(Math.floor(date / 1e3) * 1e3);
9342  }, function(date, offset) {
9343  date.setTime(date.getTime() + Math.floor(offset) * 1e3);
9344  }, function(date) {
9345  return date.getSeconds();
9346  });
9347  d3_time.seconds = d3_time.second.range;
9348  d3_time.seconds.utc = d3_time.second.utc.range;
9349  d3_time.minute = d3_time_interval(function(date) {
9350  return new d3_date(Math.floor(date / 6e4) * 6e4);
9351  }, function(date, offset) {
9352  date.setTime(date.getTime() + Math.floor(offset) * 6e4);
9353  }, function(date) {
9354  return date.getMinutes();
9355  });
9356  d3_time.minutes = d3_time.minute.range;
9357  d3_time.minutes.utc = d3_time.minute.utc.range;
9358  d3_time.hour = d3_time_interval(function(date) {
9359  var timezone = date.getTimezoneOffset() / 60;
9360  return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);
9361  }, function(date, offset) {
9362  date.setTime(date.getTime() + Math.floor(offset) * 36e5);
9363  }, function(date) {
9364  return date.getHours();
9365  });
9366  d3_time.hours = d3_time.hour.range;
9367  d3_time.hours.utc = d3_time.hour.utc.range;
9368  d3_time.month = d3_time_interval(function(date) {
9369  date = d3_time.day(date);
9370  date.setDate(1);
9371  return date;
9372  }, function(date, offset) {
9373  date.setMonth(date.getMonth() + offset);
9374  }, function(date) {
9375  return date.getMonth();
9376  });
9377  d3_time.months = d3_time.month.range;
9378  d3_time.months.utc = d3_time.month.utc.range;
9379  function d3_time_scale(linear, methods, format) {
9380  function scale(x) {
9381  return linear(x);
9382  }
9383  scale.invert = function(x) {
9384  return d3_time_scaleDate(linear.invert(x));
9385  };
9386  scale.domain = function(x) {
9387  if (!arguments.length) return linear.domain().map(d3_time_scaleDate);
9388  linear.domain(x);
9389  return scale;
9390  };
9391  function tickMethod(extent, count) {
9392  var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target);
9393  return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) {
9394  return d / 31536e6;
9395  }), 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];
9396  }
9397  scale.nice = function(interval, skip) {
9398  var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" && tickMethod(extent, interval);
9399  if (method) interval = method[0], skip = method[1];
9400  function skipped(date) {
9401  return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length;
9402  }
9403  return scale.domain(d3_scale_nice(domain, skip > 1 ? {
9404  floor: function(date) {
9405  while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1);
9406  return date;
9407  },
9408  ceil: function(date) {
9409  while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1);
9410  return date;
9411  }
9412  } : interval));
9413  };
9414  scale.ticks = function(interval, skip) {
9415  var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" ? tickMethod(extent, interval) : !interval.range && [ {
9416  range: interval
9417  }, skip ];
9418  if (method) interval = method[0], skip = method[1];
9419  return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip);
9420  };
9421  scale.tickFormat = function() {
9422  return format;
9423  };
9424  scale.copy = function() {
9425  return d3_time_scale(linear.copy(), methods, format);
9426  };
9427  return d3_scale_linearRebind(scale, linear);
9428  }
9429  function d3_time_scaleDate(t) {
9430  return new Date(t);
9431  }
9432  var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ];
9433  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 ] ];
9434  var d3_time_scaleLocalFormat = d3_time_format.multi([ [ ".%L", function(d) {
9435  return d.getMilliseconds();
9436  } ], [ ":%S", function(d) {
9437  return d.getSeconds();
9438  } ], [ "%I:%M", function(d) {
9439  return d.getMinutes();
9440  } ], [ "%I %p", function(d) {
9441  return d.getHours();
9442  } ], [ "%a %d", function(d) {
9443  return d.getDay() && d.getDate() != 1;
9444  } ], [ "%b %d", function(d) {
9445  return d.getDate() != 1;
9446  } ], [ "%B", function(d) {
9447  return d.getMonth();
9448  } ], [ "%Y", d3_true ] ]);
9449  var d3_time_scaleMilliseconds = {
9450  range: function(start, stop, step) {
9451  return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate);
9452  },
9453  floor: d3_identity,
9454  ceil: d3_identity
9455  };
9456  d3_time_scaleLocalMethods.year = d3_time.year;
9457  d3_time.scale = function() {
9458  return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);
9459  };
9460  var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) {
9461  return [ m[0].utc, m[1] ];
9462  });
9463  var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ ".%L", function(d) {
9464  return d.getUTCMilliseconds();
9465  } ], [ ":%S", function(d) {
9466  return d.getUTCSeconds();
9467  } ], [ "%I:%M", function(d) {
9468  return d.getUTCMinutes();
9469  } ], [ "%I %p", function(d) {
9470  return d.getUTCHours();
9471  } ], [ "%a %d", function(d) {
9472  return d.getUTCDay() && d.getUTCDate() != 1;
9473  } ], [ "%b %d", function(d) {
9474  return d.getUTCDate() != 1;
9475  } ], [ "%B", function(d) {
9476  return d.getUTCMonth();
9477  } ], [ "%Y", d3_true ] ]);
9478  d3_time_scaleUtcMethods.year = d3_time.year.utc;
9479  d3_time.scale.utc = function() {
9480  return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat);
9481  };
9482  d3.text = d3_xhrType(function(request) {
9483  return request.responseText;
9484  });
9485  d3.json = function(url, callback) {
9486  return d3_xhr(url, "application/json", d3_json, callback);
9487  };
9488  function d3_json(request) {
9489  return JSON.parse(request.responseText);
9490  }
9491  d3.html = function(url, callback) {
9492  return d3_xhr(url, "text/html", d3_html, callback);
9493  };
9494  function d3_html(request) {
9495  var range = d3_document.createRange();
9496  range.selectNode(d3_document.body);
9497  return range.createContextualFragment(request.responseText);
9498  }
9499  d3.xml = d3_xhrType(function(request) {
9500  return request.responseXML;
9501  });
9502  if (typeof define === "function" && define.amd) define(d3); else if (typeof module === "object" && module.exports) module.exports = d3;
9503  this.d3 = d3;
9504 }();