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