browser/devtools/webaudioeditor/lib/d3.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial