flamegraph

Fork of flamegraph without J***S*****.
git clone git://git.laack.co/flamegraph.git
Log | Files | Refs | README

cpu-zoomable.html (460507B)


      1 <!DOCTYPE html>
      2 <html>
      3   <head>
      4     <!--
      5         NOTE: This HTML file was generated automatically by "stackvis share".
      6         Do not edit this file directly.
      7      -->
      8     <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
      9     <title>Flame graph</title>
     10     <style type="text/css">
     11         /*
     12  * icicle.css: styles for Icicle visualization
     13  */
     14 body {
     15 	font-family: sans-serif;
     16 	font-size: small;
     17 	padding-left: 20px;
     18 	padding-right: 20px;
     19 	color: #333333;
     20 }
     21 
     22 a {
     23 	color: #CC2900;
     24 }
     25 
     26 div#chart {
     27 	width: 100%;
     28 	margin-top: 20px;
     29 }
     30 
     31 rect.svBox {
     32 	stroke: #fff;
     33 }
     34 
     35 rect.svBox:hover {
     36 	cursor: pointer;
     37 }
     38 
     39 .svBoxLabel {
     40 	cursor: pointer;
     41 	fill: #333333;
     42 }
     43 
     44 div.svTooltip {
     45 	opacity: 0;
     46 	z-index: 2;
     47 	position: absolute;           
     48 	height: 3em;                 
     49 	white-space: nowrap;
     50 	padding-top: 8px;             
     51 	padding-left: 12px;
     52 	padding-right: 12px;
     53 	padding-bottom: 18px;
     54 	font-size: small;
     55 	background: #ffffee;   
     56 	border: 0px;
     57 	border-radius: 2px;           
     58 	pointer-events: none;  
     59 }
     60 
     61 div.svPopout {
     62 	position: absolute;
     63 	border-radius: 2px;
     64 	border: 2px #333333 solid;
     65 	padding: 6px;
     66 	background-color: #ffffff;
     67 	opacity: 0;
     68 	z-index: -1;
     69 	width: 50%;
     70 }
     71 
     72 .svXAxisLabel {
     73 	font-size: large;
     74 	font-weight: bold;
     75 	font-variant: small-caps;
     76 	text-align: center;
     77 	width: 100%;
     78 	letter-spacing: 0.3em;
     79 	margin-bottom: 20px;
     80 }
     81 
     82 .svYAxisLabel {
     83 	font-size: large;
     84 	font-weight: bold;
     85 	font-variant: small-caps;
     86 	text-align: center;
     87 	letter-spacing: 0.3em;
     88 	white-space: nowrap;
     89 }
     90 
     91     </style>
     92     <script type="text/javascript">
     93         /* BEGIN contents of d3.v2.js */
     94         (function(){if (!Date.now) Date.now = function() {
     95   return +new Date;
     96 };
     97 try {
     98   document.createElement("div").style.setProperty("opacity", 0, "");
     99 } catch (error) {
    100   var d3_style_prototype = CSSStyleDeclaration.prototype,
    101       d3_style_setProperty = d3_style_prototype.setProperty;
    102   d3_style_prototype.setProperty = function(name, value, priority) {
    103     d3_style_setProperty.call(this, name, value + "", priority);
    104   };
    105 }
    106 d3 = {version: "2.8.1"}; // semver
    107 function d3_class(ctor, properties) {
    108   try {
    109     for (var key in properties) {
    110       Object.defineProperty(ctor.prototype, key, {
    111         value: properties[key],
    112         enumerable: false
    113       });
    114     }
    115   } catch (e) {
    116     ctor.prototype = properties;
    117   }
    118 }
    119 var d3_array = d3_arraySlice; // conversion for NodeLists
    120 
    121 function d3_arrayCopy(pseudoarray) {
    122   var i = -1, n = pseudoarray.length, array = [];
    123   while (++i < n) array.push(pseudoarray[i]);
    124   return array;
    125 }
    126 
    127 function d3_arraySlice(pseudoarray) {
    128   return Array.prototype.slice.call(pseudoarray);
    129 }
    130 
    131 try {
    132   d3_array(document.documentElement.childNodes)[0].nodeType;
    133 } catch(e) {
    134   d3_array = d3_arrayCopy;
    135 }
    136 
    137 var d3_arraySubclass = [].__proto__?
    138 
    139 // Until ECMAScript supports array subclassing, prototype injection works well.
    140 function(array, prototype) {
    141   array.__proto__ = prototype;
    142 }:
    143 
    144 // And if your browser doesn't support __proto__, we'll use direct extension.
    145 function(array, prototype) {
    146   for (var property in prototype) array[property] = prototype[property];
    147 };
    148 d3.map = function(object) {
    149   var map = new d3_Map;
    150   for (var key in object) map.set(key, object[key]);
    151   return map;
    152 };
    153 
    154 function d3_Map() {}
    155 
    156 d3_class(d3_Map, {
    157   has: function(key) {
    158     return d3_map_prefix + key in this;
    159   },
    160   get: function(key) {
    161     return this[d3_map_prefix + key];
    162   },
    163   set: function(key, value) {
    164     return this[d3_map_prefix + key] = value;
    165   },
    166   remove: function(key) {
    167     key = d3_map_prefix + key;
    168     return key in this && delete this[key];
    169   },
    170   keys: function() {
    171     var keys = [];
    172     this.forEach(function(key) { keys.push(key); });
    173     return keys;
    174   },
    175   values: function() {
    176     var values = [];
    177     this.forEach(function(key, value) { values.push(value); });
    178     return values;
    179   },
    180   entries: function() {
    181     var entries = [];
    182     this.forEach(function(key, value) { entries.push({key: key, value: value}); });
    183     return entries;
    184   },
    185   forEach: function(f) {
    186     for (var key in this) {
    187       if (key.charCodeAt(0) === d3_map_prefixCode) {
    188         f.call(this, key.substring(1), this[key]);
    189       }
    190     }
    191   }
    192 });
    193 
    194 var d3_map_prefix = "\0", // prevent collision with built-ins
    195     d3_map_prefixCode = d3_map_prefix.charCodeAt(0);
    196 function d3_this() {
    197   return this;
    198 }
    199 d3.functor = function(v) {
    200   return typeof v === "function" ? v : function() { return v; };
    201 };
    202 // Copies a variable number of methods from source to target.
    203 d3.rebind = function(target, source) {
    204   var i = 1, n = arguments.length, method;
    205   while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);
    206   return target;
    207 };
    208 
    209 // Method is assumed to be a standard D3 getter-setter:
    210 // If passed with no arguments, gets the value.
    211 // If passed with arguments, sets the value and returns the target.
    212 function d3_rebind(target, source, method) {
    213   return function() {
    214     var value = method.apply(source, arguments);
    215     return arguments.length ? target : value;
    216   };
    217 }
    218 d3.ascending = function(a, b) {
    219   return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
    220 };
    221 d3.descending = function(a, b) {
    222   return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
    223 };
    224 d3.mean = function(array, f) {
    225   var n = array.length,
    226       a,
    227       m = 0,
    228       i = -1,
    229       j = 0;
    230   if (arguments.length === 1) {
    231     while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j;
    232   } else {
    233     while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j;
    234   }
    235   return j ? m : undefined;
    236 };
    237 d3.median = function(array, f) {
    238   if (arguments.length > 1) array = array.map(f);
    239   array = array.filter(d3_number);
    240   return array.length ? d3.quantile(array.sort(d3.ascending), .5) : undefined;
    241 };
    242 d3.min = function(array, f) {
    243   var i = -1,
    244       n = array.length,
    245       a,
    246       b;
    247   if (arguments.length === 1) {
    248     while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
    249     while (++i < n) if ((b = array[i]) != null && a > b) a = b;
    250   } else {
    251     while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
    252     while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
    253   }
    254   return a;
    255 };
    256 d3.max = function(array, f) {
    257   var i = -1,
    258       n = array.length,
    259       a,
    260       b;
    261   if (arguments.length === 1) {
    262     while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
    263     while (++i < n) if ((b = array[i]) != null && b > a) a = b;
    264   } else {
    265     while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
    266     while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
    267   }
    268   return a;
    269 };
    270 d3.extent = function(array, f) {
    271   var i = -1,
    272       n = array.length,
    273       a,
    274       b,
    275       c;
    276   if (arguments.length === 1) {
    277     while (++i < n && ((a = c = array[i]) == null || a != a)) a = c = undefined;
    278     while (++i < n) if ((b = array[i]) != null) {
    279       if (a > b) a = b;
    280       if (c < b) c = b;
    281     }
    282   } else {
    283     while (++i < n && ((a = c = f.call(array, array[i], i)) == null || a != a)) a = undefined;
    284     while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
    285       if (a > b) a = b;
    286       if (c < b) c = b;
    287     }
    288   }
    289   return [a, c];
    290 };
    291 d3.random = {
    292   normal: function(mean, deviation) {
    293     if (arguments.length < 2) deviation = 1;
    294     if (arguments.length < 1) mean = 0;
    295     return function() {
    296       var x, y, r;
    297       do {
    298         x = Math.random() * 2 - 1;
    299         y = Math.random() * 2 - 1;
    300         r = x * x + y * y;
    301       } while (!r || r > 1);
    302       return mean + deviation * x * Math.sqrt(-2 * Math.log(r) / r);
    303     };
    304   }
    305 };
    306 function d3_number(x) {
    307   return x != null && !isNaN(x);
    308 }
    309 d3.sum = function(array, f) {
    310   var s = 0,
    311       n = array.length,
    312       a,
    313       i = -1;
    314 
    315   if (arguments.length === 1) {
    316     while (++i < n) if (!isNaN(a = +array[i])) s += a;
    317   } else {
    318     while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a;
    319   }
    320 
    321   return s;
    322 };
    323 // R-7 per <http://en.wikipedia.org/wiki/Quantile>
    324 d3.quantile = function(values, p) {
    325   var H = (values.length - 1) * p + 1,
    326       h = Math.floor(H),
    327       v = values[h - 1],
    328       e = H - h;
    329   return e ? v + e * (values[h] - v) : v;
    330 };
    331 d3.transpose = function(matrix) {
    332   return d3.zip.apply(d3, matrix);
    333 };
    334 d3.zip = function() {
    335   if (!(n = arguments.length)) return [];
    336   for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m;) {
    337     for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n;) {
    338       zip[j] = arguments[j][i];
    339     }
    340   }
    341   return zips;
    342 };
    343 
    344 function d3_zipLength(d) {
    345   return d.length;
    346 }
    347 d3.bisector = function(f) {
    348   return {
    349     left: function(a, x, lo, hi) {
    350       if (arguments.length < 3) lo = 0;
    351       if (arguments.length < 4) hi = a.length;
    352       while (lo < hi) {
    353         var mid = lo + hi >> 1;
    354         if (f.call(a, a[mid], mid) < x) lo = mid + 1;
    355         else hi = mid;
    356       }
    357       return lo;
    358     },
    359     right: function(a, x, lo, hi) {
    360       if (arguments.length < 3) lo = 0;
    361       if (arguments.length < 4) hi = a.length;
    362       while (lo < hi) {
    363         var mid = lo + hi >> 1;
    364         if (x < f.call(a, a[mid], mid)) hi = mid;
    365         else lo = mid + 1;
    366       }
    367       return lo;
    368     }
    369   };
    370 };
    371 
    372 var d3_bisector = d3.bisector(function(d) { return d; });
    373 d3.bisectLeft = d3_bisector.left;
    374 d3.bisect = d3.bisectRight = d3_bisector.right;
    375 d3.first = function(array, f) {
    376   var i = 0,
    377       n = array.length,
    378       a = array[0],
    379       b;
    380   if (arguments.length === 1) f = d3.ascending;
    381   while (++i < n) {
    382     if (f.call(array, a, b = array[i]) > 0) {
    383       a = b;
    384     }
    385   }
    386   return a;
    387 };
    388 d3.last = function(array, f) {
    389   var i = 0,
    390       n = array.length,
    391       a = array[0],
    392       b;
    393   if (arguments.length === 1) f = d3.ascending;
    394   while (++i < n) {
    395     if (f.call(array, a, b = array[i]) <= 0) {
    396       a = b;
    397     }
    398   }
    399   return a;
    400 };
    401 d3.nest = function() {
    402   var nest = {},
    403       keys = [],
    404       sortKeys = [],
    405       sortValues,
    406       rollup;
    407 
    408   function map(array, depth) {
    409     if (depth >= keys.length) return rollup
    410         ? rollup.call(nest, array) : (sortValues
    411         ? array.sort(sortValues)
    412         : array);
    413 
    414     var i = -1,
    415         n = array.length,
    416         key = keys[depth++],
    417         keyValue,
    418         object,
    419         valuesByKey = new d3_Map,
    420         values,
    421         o = {};
    422 
    423     while (++i < n) {
    424       if (values = valuesByKey.get(keyValue = key(object = array[i]))) {
    425         values.push(object);
    426       } else {
    427         valuesByKey.set(keyValue, [object]);
    428       }
    429     }
    430 
    431     valuesByKey.forEach(function(keyValue) {
    432       o[keyValue] = map(valuesByKey.get(keyValue), depth);
    433     });
    434 
    435     return o;
    436   }
    437 
    438   function entries(map, depth) {
    439     if (depth >= keys.length) return map;
    440 
    441     var a = [],
    442         sortKey = sortKeys[depth++],
    443         key;
    444 
    445     for (key in map) {
    446       a.push({key: key, values: entries(map[key], depth)});
    447     }
    448 
    449     if (sortKey) a.sort(function(a, b) {
    450       return sortKey(a.key, b.key);
    451     });
    452 
    453     return a;
    454   }
    455 
    456   nest.map = function(array) {
    457     return map(array, 0);
    458   };
    459 
    460   nest.entries = function(array) {
    461     return entries(map(array, 0), 0);
    462   };
    463 
    464   nest.key = function(d) {
    465     keys.push(d);
    466     return nest;
    467   };
    468 
    469   // Specifies the order for the most-recently specified key.
    470   // Note: only applies to entries. Map keys are unordered!
    471   nest.sortKeys = function(order) {
    472     sortKeys[keys.length - 1] = order;
    473     return nest;
    474   };
    475 
    476   // Specifies the order for leaf values.
    477   // Applies to both maps and entries array.
    478   nest.sortValues = function(order) {
    479     sortValues = order;
    480     return nest;
    481   };
    482 
    483   nest.rollup = function(f) {
    484     rollup = f;
    485     return nest;
    486   };
    487 
    488   return nest;
    489 };
    490 d3.keys = function(map) {
    491   var keys = [];
    492   for (var key in map) keys.push(key);
    493   return keys;
    494 };
    495 d3.values = function(map) {
    496   var values = [];
    497   for (var key in map) values.push(map[key]);
    498   return values;
    499 };
    500 d3.entries = function(map) {
    501   var entries = [];
    502   for (var key in map) entries.push({key: key, value: map[key]});
    503   return entries;
    504 };
    505 d3.permute = function(array, indexes) {
    506   var permutes = [],
    507       i = -1,
    508       n = indexes.length;
    509   while (++i < n) permutes[i] = array[indexes[i]];
    510   return permutes;
    511 };
    512 d3.merge = function(arrays) {
    513   return Array.prototype.concat.apply([], arrays);
    514 };
    515 d3.split = function(array, f) {
    516   var arrays = [],
    517       values = [],
    518       value,
    519       i = -1,
    520       n = array.length;
    521   if (arguments.length < 2) f = d3_splitter;
    522   while (++i < n) {
    523     if (f.call(values, value = array[i], i)) {
    524       values = [];
    525     } else {
    526       if (!values.length) arrays.push(values);
    527       values.push(value);
    528     }
    529   }
    530   return arrays;
    531 };
    532 
    533 function d3_splitter(d) {
    534   return d == null;
    535 }
    536 function d3_collapse(s) {
    537   return s.replace(/(^\s+)|(\s+$)/g, "").replace(/\s+/g, " ");
    538 }
    539 d3.range = function(start, stop, step) {
    540   if (arguments.length < 3) {
    541     step = 1;
    542     if (arguments.length < 2) {
    543       stop = start;
    544       start = 0;
    545     }
    546   }
    547   if ((stop - start) / step === Infinity) throw new Error("infinite range");
    548   var range = [],
    549        k = d3_range_integerScale(Math.abs(step)),
    550        i = -1,
    551        j;
    552   start *= k, stop *= k, step *= k;
    553   if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k);
    554   else while ((j = start + step * ++i) < stop) range.push(j / k);
    555   return range;
    556 };
    557 
    558 function d3_range_integerScale(x) {
    559   var k = 1;
    560   while (x * k % 1) k *= 10;
    561   return k;
    562 }
    563 d3.requote = function(s) {
    564   return s.replace(d3_requote_re, "\\$&");
    565 };
    566 
    567 var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
    568 d3.round = function(x, n) {
    569   return n
    570       ? Math.round(x * (n = Math.pow(10, n))) / n
    571       : Math.round(x);
    572 };
    573 d3.xhr = function(url, mime, callback) {
    574   var req = new XMLHttpRequest;
    575   if (arguments.length < 3) callback = mime, mime = null;
    576   else if (mime && req.overrideMimeType) req.overrideMimeType(mime);
    577   req.open("GET", url, true);
    578   if (mime) req.setRequestHeader("Accept", mime);
    579   req.onreadystatechange = function() {
    580     if (req.readyState === 4) callback(req.status < 300 ? req : null);
    581   };
    582   req.send(null);
    583 };
    584 d3.text = function(url, mime, callback) {
    585   function ready(req) {
    586     callback(req && req.responseText);
    587   }
    588   if (arguments.length < 3) {
    589     callback = mime;
    590     mime = null;
    591   }
    592   d3.xhr(url, mime, ready);
    593 };
    594 d3.json = function(url, callback) {
    595   d3.text(url, "application/json", function(text) {
    596     callback(text ? JSON.parse(text) : null);
    597   });
    598 };
    599 d3.html = function(url, callback) {
    600   d3.text(url, "text/html", function(text) {
    601     if (text != null) { // Treat empty string as valid HTML.
    602       var range = document.createRange();
    603       range.selectNode(document.body);
    604       text = range.createContextualFragment(text);
    605     }
    606     callback(text);
    607   });
    608 };
    609 d3.xml = function(url, mime, callback) {
    610   function ready(req) {
    611     callback(req && req.responseXML);
    612   }
    613   if (arguments.length < 3) {
    614     callback = mime;
    615     mime = null;
    616   }
    617   d3.xhr(url, mime, ready);
    618 };
    619 var d3_nsPrefix = {
    620   svg: "http://www.w3.org/2000/svg",
    621   xhtml: "http://www.w3.org/1999/xhtml",
    622   xlink: "http://www.w3.org/1999/xlink",
    623   xml: "http://www.w3.org/XML/1998/namespace",
    624   xmlns: "http://www.w3.org/2000/xmlns/"
    625 };
    626 
    627 d3.ns = {
    628   prefix: d3_nsPrefix,
    629   qualify: function(name) {
    630     var i = name.indexOf(":"),
    631         prefix = name;
    632     if (i >= 0) {
    633       prefix = name.substring(0, i);
    634       name = name.substring(i + 1);
    635     }
    636     return d3_nsPrefix.hasOwnProperty(prefix)
    637         ? {space: d3_nsPrefix[prefix], local: name}
    638         : name;
    639   }
    640 };
    641 d3.dispatch = function() {
    642   var dispatch = new d3_dispatch,
    643       i = -1,
    644       n = arguments.length;
    645   while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
    646   return dispatch;
    647 };
    648 
    649 function d3_dispatch() {}
    650 
    651 d3_dispatch.prototype.on = function(type, listener) {
    652   var i = type.indexOf("."),
    653       name = "";
    654 
    655   // Extract optional namespace, e.g., "click.foo"
    656   if (i > 0) {
    657     name = type.substring(i + 1);
    658     type = type.substring(0, i);
    659   }
    660 
    661   return arguments.length < 2
    662       ? this[type].on(name)
    663       : this[type].on(name, listener);
    664 };
    665 
    666 function d3_dispatch_event(dispatch) {
    667   var listeners = [],
    668       listenerByName = new d3_Map;
    669 
    670   function event() {
    671     var z = listeners, // defensive reference
    672         i = -1,
    673         n = z.length,
    674         l;
    675     while (++i < n) if (l = z[i].on) l.apply(this, arguments);
    676     return dispatch;
    677   }
    678 
    679   event.on = function(name, listener) {
    680     var l = listenerByName.get(name),
    681         i;
    682 
    683     // return the current listener, if any
    684     if (arguments.length < 2) return l && l.on;
    685 
    686     // remove the old listener, if any (with copy-on-write)
    687     if (l) {
    688       l.on = null;
    689       listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));
    690       listenerByName.remove(name);
    691     }
    692 
    693     // add the new listener, if any
    694     if (listener) listeners.push(listenerByName.set(name, {on: listener}));
    695 
    696     return dispatch;
    697   };
    698 
    699   return event;
    700 }
    701 // TODO align
    702 d3.format = function(specifier) {
    703   var match = d3_format_re.exec(specifier),
    704       fill = match[1] || " ",
    705       sign = match[3] || "",
    706       zfill = match[5],
    707       width = +match[6],
    708       comma = match[7],
    709       precision = match[8],
    710       type = match[9],
    711       scale = 1,
    712       suffix = "",
    713       integer = false;
    714 
    715   if (precision) precision = +precision.substring(1);
    716 
    717   if (zfill) {
    718     fill = "0"; // TODO align = "=";
    719     if (comma) width -= Math.floor((width - 1) / 4);
    720   }
    721 
    722   switch (type) {
    723     case "n": comma = true; type = "g"; break;
    724     case "%": scale = 100; suffix = "%"; type = "f"; break;
    725     case "p": scale = 100; suffix = "%"; type = "r"; break;
    726     case "d": integer = true; precision = 0; break;
    727     case "s": scale = -1; type = "r"; break;
    728   }
    729 
    730   // If no precision is specified for r, fallback to general notation.
    731   if (type == "r" && !precision) type = "g";
    732 
    733   type = d3_format_types.get(type) || d3_format_typeDefault;
    734 
    735   return function(value) {
    736 
    737     // Return the empty string for floats formatted as ints.
    738     if (integer && (value % 1)) return "";
    739 
    740     // Convert negative to positive, and record the sign prefix.
    741     var negative = (value < 0) && (value = -value) ? "\u2212" : sign;
    742 
    743     // Apply the scale, computing it from the value's exponent for si format.
    744     if (scale < 0) {
    745       var prefix = d3.formatPrefix(value, precision);
    746       value *= prefix.scale;
    747       suffix = prefix.symbol;
    748     } else {
    749       value *= scale;
    750     }
    751 
    752     // Convert to the desired precision.
    753     value = type(value, precision);
    754 
    755     // If the fill character is 0, the sign and group is applied after the fill.
    756     if (zfill) {
    757       var length = value.length + negative.length;
    758       if (length < width) value = new Array(width - length + 1).join(fill) + value;
    759       if (comma) value = d3_format_group(value);
    760       value = negative + value;
    761     }
    762 
    763     // Otherwise (e.g., space-filling), the sign and group is applied before.
    764     else {
    765       if (comma) value = d3_format_group(value);
    766       value = negative + value;
    767       var length = value.length;
    768       if (length < width) value = new Array(width - length + 1).join(fill) + value;
    769     }
    770 
    771     return value + suffix;
    772   };
    773 };
    774 
    775 // [[fill]align][sign][#][0][width][,][.precision][type]
    776 var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/;
    777 
    778 var d3_format_types = d3.map({
    779   g: function(x, p) { return x.toPrecision(p); },
    780   e: function(x, p) { return x.toExponential(p); },
    781   f: function(x, p) { return x.toFixed(p); },
    782   r: function(x, p) { return d3.round(x, p = d3_format_precision(x, p)).toFixed(Math.max(0, Math.min(20, p))); }
    783 });
    784 
    785 function d3_format_precision(x, p) {
    786   return p - (x ? 1 + Math.floor(Math.log(x + Math.pow(10, 1 + Math.floor(Math.log(x) / Math.LN10) - p)) / Math.LN10) : 1);
    787 }
    788 
    789 function d3_format_typeDefault(x) {
    790   return x + "";
    791 }
    792 
    793 // Apply comma grouping for thousands.
    794 function d3_format_group(value) {
    795   var i = value.lastIndexOf("."),
    796       f = i >= 0 ? value.substring(i) : (i = value.length, ""),
    797       t = [];
    798   while (i > 0) t.push(value.substring(i -= 3, i + 3));
    799   return t.reverse().join(",") + f;
    800 }
    801 var d3_formatPrefixes = ["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(d3_formatPrefix);
    802 
    803 d3.formatPrefix = function(value, precision) {
    804   var i = 0;
    805   if (value) {
    806     if (value < 0) value *= -1;
    807     if (precision) value = d3.round(value, d3_format_precision(value, precision));
    808     i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
    809     i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3));
    810   }
    811   return d3_formatPrefixes[8 + i / 3];
    812 };
    813 
    814 function d3_formatPrefix(d, i) {
    815   return {
    816     scale: Math.pow(10, (8 - i) * 3),
    817     symbol: d
    818   };
    819 }
    820 
    821 /*
    822  * TERMS OF USE - EASING EQUATIONS
    823  *
    824  * Open source under the BSD License.
    825  *
    826  * Copyright 2001 Robert Penner
    827  * All rights reserved.
    828  *
    829  * Redistribution and use in source and binary forms, with or without
    830  * modification, are permitted provided that the following conditions are met:
    831  *
    832  * - Redistributions of source code must retain the above copyright notice, this
    833  *   list of conditions and the following disclaimer.
    834  *
    835  * - Redistributions in binary form must reproduce the above copyright notice,
    836  *   this list of conditions and the following disclaimer in the documentation
    837  *   and/or other materials provided with the distribution.
    838  *
    839  * - Neither the name of the author nor the names of contributors may be used to
    840  *   endorse or promote products derived from this software without specific
    841  *   prior written permission.
    842  *
    843  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    844  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    845  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    846  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    847  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    848  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    849  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    850  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    851  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    852  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    853  * POSSIBILITY OF SUCH DAMAGE.
    854  */
    855 
    856 var d3_ease_quad = d3_ease_poly(2),
    857     d3_ease_cubic = d3_ease_poly(3),
    858     d3_ease_default = function() { return d3_ease_identity; };
    859 
    860 var d3_ease = d3.map({
    861   linear: d3_ease_default,
    862   poly: d3_ease_poly,
    863   quad: function() { return d3_ease_quad; },
    864   cubic: function() { return d3_ease_cubic; },
    865   sin: function() { return d3_ease_sin; },
    866   exp: function() { return d3_ease_exp; },
    867   circle: function() { return d3_ease_circle; },
    868   elastic: d3_ease_elastic,
    869   back: d3_ease_back,
    870   bounce: function() { return d3_ease_bounce; }
    871 });
    872 
    873 var d3_ease_mode = d3.map({
    874   "in": d3_ease_identity,
    875   "out": d3_ease_reverse,
    876   "in-out": d3_ease_reflect,
    877   "out-in": function(f) { return d3_ease_reflect(d3_ease_reverse(f)); }
    878 });
    879 
    880 d3.ease = function(name) {
    881   var i = name.indexOf("-"),
    882       t = i >= 0 ? name.substring(0, i) : name,
    883       m = i >= 0 ? name.substring(i + 1) : "in";
    884   t = d3_ease.get(t) || d3_ease_default;
    885   m = d3_ease_mode.get(m) || d3_ease_identity;
    886   return d3_ease_clamp(m(t.apply(null, Array.prototype.slice.call(arguments, 1))));
    887 };
    888 
    889 function d3_ease_clamp(f) {
    890   return function(t) {
    891     return t <= 0 ? 0 : t >= 1 ? 1 : f(t);
    892   };
    893 }
    894 
    895 function d3_ease_reverse(f) {
    896   return function(t) {
    897     return 1 - f(1 - t);
    898   };
    899 }
    900 
    901 function d3_ease_reflect(f) {
    902   return function(t) {
    903     return .5 * (t < .5 ? f(2 * t) : (2 - f(2 - 2 * t)));
    904   };
    905 }
    906 
    907 function d3_ease_identity(t) {
    908   return t;
    909 }
    910 
    911 function d3_ease_poly(e) {
    912   return function(t) {
    913     return Math.pow(t, e);
    914   };
    915 }
    916 
    917 function d3_ease_sin(t) {
    918   return 1 - Math.cos(t * Math.PI / 2);
    919 }
    920 
    921 function d3_ease_exp(t) {
    922   return Math.pow(2, 10 * (t - 1));
    923 }
    924 
    925 function d3_ease_circle(t) {
    926   return 1 - Math.sqrt(1 - t * t);
    927 }
    928 
    929 function d3_ease_elastic(a, p) {
    930   var s;
    931   if (arguments.length < 2) p = 0.45;
    932   if (arguments.length < 1) { a = 1; s = p / 4; }
    933   else s = p / (2 * Math.PI) * Math.asin(1 / a);
    934   return function(t) {
    935     return 1 + a * Math.pow(2, 10 * -t) * Math.sin((t - s) * 2 * Math.PI / p);
    936   };
    937 }
    938 
    939 function d3_ease_back(s) {
    940   if (!s) s = 1.70158;
    941   return function(t) {
    942     return t * t * ((s + 1) * t - s);
    943   };
    944 }
    945 
    946 function d3_ease_bounce(t) {
    947   return t < 1 / 2.75 ? 7.5625 * t * t
    948       : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75
    949       : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375
    950       : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
    951 }
    952 d3.event = null;
    953 
    954 function d3_eventCancel() {
    955   d3.event.stopPropagation();
    956   d3.event.preventDefault();
    957 }
    958 
    959 function d3_eventSource() {
    960   var e = d3.event, s;
    961   while (s = e.sourceEvent) e = s;
    962   return e;
    963 }
    964 
    965 // Like d3.dispatch, but for custom events abstracting native UI events. These
    966 // events have a target component (such as a brush), a target element (such as
    967 // the svg:g element containing the brush) and the standard arguments `d` (the
    968 // target element's data) and `i` (the selection index of the target element).
    969 function d3_eventDispatch(target) {
    970   var dispatch = new d3_dispatch,
    971       i = 0,
    972       n = arguments.length;
    973 
    974   while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
    975 
    976   // Creates a dispatch context for the specified `thiz` (typically, the target
    977   // DOM element that received the source event) and `argumentz` (typically, the
    978   // data `d` and index `i` of the target element). The returned function can be
    979   // used to dispatch an event to any registered listeners; the function takes a
    980   // single argument as input, being the event to dispatch. The event must have
    981   // a "type" attribute which corresponds to a type registered in the
    982   // constructor. This context will automatically populate the "sourceEvent" and
    983   // "target" attributes of the event, as well as setting the `d3.event` global
    984   // for the duration of the notification.
    985   dispatch.of = function(thiz, argumentz) {
    986     return function(e1) {
    987       try {
    988         var e0 =
    989         e1.sourceEvent = d3.event;
    990         e1.target = target;
    991         d3.event = e1;
    992         dispatch[e1.type].apply(thiz, argumentz);
    993       } finally {
    994         d3.event = e0;
    995       }
    996     };
    997   };
    998 
    999   return dispatch;
   1000 }
   1001 d3.interpolate = function(a, b) {
   1002   var i = d3.interpolators.length, f;
   1003   while (--i >= 0 && !(f = d3.interpolators[i](a, b)));
   1004   return f;
   1005 };
   1006 
   1007 d3.interpolateNumber = function(a, b) {
   1008   b -= a;
   1009   return function(t) { return a + b * t; };
   1010 };
   1011 
   1012 d3.interpolateRound = function(a, b) {
   1013   b -= a;
   1014   return function(t) { return Math.round(a + b * t); };
   1015 };
   1016 
   1017 d3.interpolateString = function(a, b) {
   1018   var m, // current match
   1019       i, // current index
   1020       j, // current index (for coallescing)
   1021       s0 = 0, // start index of current string prefix
   1022       s1 = 0, // end index of current string prefix
   1023       s = [], // string constants and placeholders
   1024       q = [], // number interpolators
   1025       n, // q.length
   1026       o;
   1027 
   1028   // Reset our regular expression!
   1029   d3_interpolate_number.lastIndex = 0;
   1030 
   1031   // Find all numbers in b.
   1032   for (i = 0; m = d3_interpolate_number.exec(b); ++i) {
   1033     if (m.index) s.push(b.substring(s0, s1 = m.index));
   1034     q.push({i: s.length, x: m[0]});
   1035     s.push(null);
   1036     s0 = d3_interpolate_number.lastIndex;
   1037   }
   1038   if (s0 < b.length) s.push(b.substring(s0));
   1039 
   1040   // Find all numbers in a.
   1041   for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) {
   1042     o = q[i];
   1043     if (o.x == m[0]) { // The numbers match, so coallesce.
   1044       if (o.i) {
   1045         if (s[o.i + 1] == null) { // This match is followed by another number.
   1046           s[o.i - 1] += o.x;
   1047           s.splice(o.i, 1);
   1048           for (j = i + 1; j < n; ++j) q[j].i--;
   1049         } else { // This match is followed by a string, so coallesce twice.
   1050           s[o.i - 1] += o.x + s[o.i + 1];
   1051           s.splice(o.i, 2);
   1052           for (j = i + 1; j < n; ++j) q[j].i -= 2;
   1053         }
   1054       } else {
   1055           if (s[o.i + 1] == null) { // This match is followed by another number.
   1056           s[o.i] = o.x;
   1057         } else { // This match is followed by a string, so coallesce twice.
   1058           s[o.i] = o.x + s[o.i + 1];
   1059           s.splice(o.i + 1, 1);
   1060           for (j = i + 1; j < n; ++j) q[j].i--;
   1061         }
   1062       }
   1063       q.splice(i, 1);
   1064       n--;
   1065       i--;
   1066     } else {
   1067       o.x = d3.interpolateNumber(parseFloat(m[0]), parseFloat(o.x));
   1068     }
   1069   }
   1070 
   1071   // Remove any numbers in b not found in a.
   1072   while (i < n) {
   1073     o = q.pop();
   1074     if (s[o.i + 1] == null) { // This match is followed by another number.
   1075       s[o.i] = o.x;
   1076     } else { // This match is followed by a string, so coallesce twice.
   1077       s[o.i] = o.x + s[o.i + 1];
   1078       s.splice(o.i + 1, 1);
   1079     }
   1080     n--;
   1081   }
   1082 
   1083   // Special optimization for only a single match.
   1084   if (s.length === 1) {
   1085     return s[0] == null ? q[0].x : function() { return b; };
   1086   }
   1087 
   1088   // Otherwise, interpolate each of the numbers and rejoin the string.
   1089   return function(t) {
   1090     for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t);
   1091     return s.join("");
   1092   };
   1093 };
   1094 
   1095 d3.interpolateTransform = function(a, b) {
   1096   var s = [], // string constants and placeholders
   1097       q = [], // number interpolators
   1098       n,
   1099       A = d3.transform(a),
   1100       B = d3.transform(b),
   1101       ta = A.translate,
   1102       tb = B.translate,
   1103       ra = A.rotate,
   1104       rb = B.rotate,
   1105       wa = A.skew,
   1106       wb = B.skew,
   1107       ka = A.scale,
   1108       kb = B.scale;
   1109 
   1110   if (ta[0] != tb[0] || ta[1] != tb[1]) {
   1111     s.push("translate(", null, ",", null, ")");
   1112     q.push({i: 1, x: d3.interpolateNumber(ta[0], tb[0])}, {i: 3, x: d3.interpolateNumber(ta[1], tb[1])});
   1113   } else if (tb[0] || tb[1]) {
   1114     s.push("translate(" + tb + ")");
   1115   } else {
   1116     s.push("");
   1117   }
   1118 
   1119   if (ra != rb) {
   1120     q.push({i: s.push(s.pop() + "rotate(", null, ")") - 2, x: d3.interpolateNumber(ra, rb)});
   1121   } else if (rb) {
   1122     s.push(s.pop() + "rotate(" + rb + ")");
   1123   }
   1124 
   1125   if (wa != wb) {
   1126     q.push({i: s.push(s.pop() + "skewX(", null, ")") - 2, x: d3.interpolateNumber(wa, wb)});
   1127   } else if (wb) {
   1128     s.push(s.pop() + "skewX(" + wb + ")");
   1129   }
   1130 
   1131   if (ka[0] != kb[0] || ka[1] != kb[1]) {
   1132     n = s.push(s.pop() + "scale(", null, ",", null, ")");
   1133     q.push({i: n - 4, x: d3.interpolateNumber(ka[0], kb[0])}, {i: n - 2, x: d3.interpolateNumber(ka[1], kb[1])});
   1134   } else if (kb[0] != 1 || kb[1] != 1) {
   1135     s.push(s.pop() + "scale(" + kb + ")");
   1136   }
   1137 
   1138   n = q.length;
   1139   return function(t) {
   1140     var i = -1, o;
   1141     while (++i < n) s[(o = q[i]).i] = o.x(t);
   1142     return s.join("");
   1143   };
   1144 };
   1145 
   1146 d3.interpolateRgb = function(a, b) {
   1147   a = d3.rgb(a);
   1148   b = d3.rgb(b);
   1149   var ar = a.r,
   1150       ag = a.g,
   1151       ab = a.b,
   1152       br = b.r - ar,
   1153       bg = b.g - ag,
   1154       bb = b.b - ab;
   1155   return function(t) {
   1156     return "#"
   1157         + d3_rgb_hex(Math.round(ar + br * t))
   1158         + d3_rgb_hex(Math.round(ag + bg * t))
   1159         + d3_rgb_hex(Math.round(ab + bb * t));
   1160   };
   1161 };
   1162 
   1163 // interpolates HSL space, but outputs RGB string (for compatibility)
   1164 d3.interpolateHsl = function(a, b) {
   1165   a = d3.hsl(a);
   1166   b = d3.hsl(b);
   1167   var h0 = a.h,
   1168       s0 = a.s,
   1169       l0 = a.l,
   1170       h1 = b.h - h0,
   1171       s1 = b.s - s0,
   1172       l1 = b.l - l0;
   1173   return function(t) {
   1174     return d3_hsl_rgb(h0 + h1 * t, s0 + s1 * t, l0 + l1 * t).toString();
   1175   };
   1176 };
   1177 
   1178 d3.interpolateArray = function(a, b) {
   1179   var x = [],
   1180       c = [],
   1181       na = a.length,
   1182       nb = b.length,
   1183       n0 = Math.min(a.length, b.length),
   1184       i;
   1185   for (i = 0; i < n0; ++i) x.push(d3.interpolate(a[i], b[i]));
   1186   for (; i < na; ++i) c[i] = a[i];
   1187   for (; i < nb; ++i) c[i] = b[i];
   1188   return function(t) {
   1189     for (i = 0; i < n0; ++i) c[i] = x[i](t);
   1190     return c;
   1191   };
   1192 };
   1193 
   1194 d3.interpolateObject = function(a, b) {
   1195   var i = {},
   1196       c = {},
   1197       k;
   1198   for (k in a) {
   1199     if (k in b) {
   1200       i[k] = d3_interpolateByName(k)(a[k], b[k]);
   1201     } else {
   1202       c[k] = a[k];
   1203     }
   1204   }
   1205   for (k in b) {
   1206     if (!(k in a)) {
   1207       c[k] = b[k];
   1208     }
   1209   }
   1210   return function(t) {
   1211     for (k in i) c[k] = i[k](t);
   1212     return c;
   1213   };
   1214 }
   1215 
   1216 var d3_interpolate_number = /[-+]?(?:\d*\.?\d+)(?:[eE][-+]?\d+)?/g;
   1217 
   1218 function d3_interpolateByName(n) {
   1219   return n == "transform"
   1220       ? d3.interpolateTransform
   1221       : d3.interpolate;
   1222 }
   1223 
   1224 d3.interpolators = [
   1225   d3.interpolateObject,
   1226   function(a, b) { return (b instanceof Array) && d3.interpolateArray(a, b); },
   1227   function(a, b) { return (typeof a === "string" || typeof b === "string") && d3.interpolateString(a + "", b + ""); },
   1228   function(a, b) { return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Rgb || b instanceof d3_Hsl) && d3.interpolateRgb(a, b); },
   1229   function(a, b) { return !isNaN(a = +a) && !isNaN(b = +b) && d3.interpolateNumber(a, b); }
   1230 ];
   1231 function d3_uninterpolateNumber(a, b) {
   1232   b = b - (a = +a) ? 1 / (b - a) : 0;
   1233   return function(x) { return (x - a) * b; };
   1234 }
   1235 
   1236 function d3_uninterpolateClamp(a, b) {
   1237   b = b - (a = +a) ? 1 / (b - a) : 0;
   1238   return function(x) { return Math.max(0, Math.min(1, (x - a) * b)); };
   1239 }
   1240 d3.rgb = function(r, g, b) {
   1241   return arguments.length === 1
   1242       ? (r instanceof d3_Rgb ? d3_rgb(r.r, r.g, r.b)
   1243       : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb))
   1244       : d3_rgb(~~r, ~~g, ~~b);
   1245 };
   1246 
   1247 function d3_rgb(r, g, b) {
   1248   return new d3_Rgb(r, g, b);
   1249 }
   1250 
   1251 function d3_Rgb(r, g, b) {
   1252   this.r = r;
   1253   this.g = g;
   1254   this.b = b;
   1255 }
   1256 
   1257 d3_Rgb.prototype.brighter = function(k) {
   1258   k = Math.pow(0.7, arguments.length ? k : 1);
   1259   var r = this.r,
   1260       g = this.g,
   1261       b = this.b,
   1262       i = 30;
   1263   if (!r && !g && !b) return d3_rgb(i, i, i);
   1264   if (r && r < i) r = i;
   1265   if (g && g < i) g = i;
   1266   if (b && b < i) b = i;
   1267   return d3_rgb(
   1268       Math.min(255, Math.floor(r / k)),
   1269       Math.min(255, Math.floor(g / k)),
   1270       Math.min(255, Math.floor(b / k)));
   1271 };
   1272 
   1273 d3_Rgb.prototype.darker = function(k) {
   1274   k = Math.pow(0.7, arguments.length ? k : 1);
   1275   return d3_rgb(
   1276       Math.floor(k * this.r),
   1277       Math.floor(k * this.g),
   1278       Math.floor(k * this.b));
   1279 };
   1280 
   1281 d3_Rgb.prototype.hsl = function() {
   1282   return d3_rgb_hsl(this.r, this.g, this.b);
   1283 };
   1284 
   1285 d3_Rgb.prototype.toString = function() {
   1286   return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);
   1287 };
   1288 
   1289 function d3_rgb_hex(v) {
   1290   return v < 0x10
   1291       ? "0" + Math.max(0, v).toString(16)
   1292       : Math.min(255, v).toString(16);
   1293 }
   1294 
   1295 function d3_rgb_parse(format, rgb, hsl) {
   1296   var r = 0, // red channel; int in [0, 255]
   1297       g = 0, // green channel; int in [0, 255]
   1298       b = 0, // blue channel; int in [0, 255]
   1299       m1, // CSS color specification match
   1300       m2, // CSS color specification type (e.g., rgb)
   1301       name;
   1302 
   1303   /* Handle hsl, rgb. */
   1304   m1 = /([a-z]+)\((.*)\)/i.exec(format);
   1305   if (m1) {
   1306     m2 = m1[2].split(",");
   1307     switch (m1[1]) {
   1308       case "hsl": {
   1309         return hsl(
   1310           parseFloat(m2[0]), // degrees
   1311           parseFloat(m2[1]) / 100, // percentage
   1312           parseFloat(m2[2]) / 100 // percentage
   1313         );
   1314       }
   1315       case "rgb": {
   1316         return rgb(
   1317           d3_rgb_parseNumber(m2[0]),
   1318           d3_rgb_parseNumber(m2[1]),
   1319           d3_rgb_parseNumber(m2[2])
   1320         );
   1321       }
   1322     }
   1323   }
   1324 
   1325   /* Named colors. */
   1326   if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b);
   1327 
   1328   /* Hexadecimal colors: #rgb and #rrggbb. */
   1329   if (format != null && format.charAt(0) === "#") {
   1330     if (format.length === 4) {
   1331       r = format.charAt(1); r += r;
   1332       g = format.charAt(2); g += g;
   1333       b = format.charAt(3); b += b;
   1334     } else if (format.length === 7) {
   1335       r = format.substring(1, 3);
   1336       g = format.substring(3, 5);
   1337       b = format.substring(5, 7);
   1338     }
   1339     r = parseInt(r, 16);
   1340     g = parseInt(g, 16);
   1341     b = parseInt(b, 16);
   1342   }
   1343 
   1344   return rgb(r, g, b);
   1345 }
   1346 
   1347 function d3_rgb_hsl(r, g, b) {
   1348   var min = Math.min(r /= 255, g /= 255, b /= 255),
   1349       max = Math.max(r, g, b),
   1350       d = max - min,
   1351       h,
   1352       s,
   1353       l = (max + min) / 2;
   1354   if (d) {
   1355     s = l < .5 ? d / (max + min) : d / (2 - max - min);
   1356     if (r == max) h = (g - b) / d + (g < b ? 6 : 0);
   1357     else if (g == max) h = (b - r) / d + 2;
   1358     else h = (r - g) / d + 4;
   1359     h *= 60;
   1360   } else {
   1361     s = h = 0;
   1362   }
   1363   return d3_hsl(h, s, l);
   1364 }
   1365 
   1366 function d3_rgb_parseNumber(c) { // either integer or percentage
   1367   var f = parseFloat(c);
   1368   return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f;
   1369 }
   1370 
   1371 var d3_rgb_names = d3.map({
   1372   aliceblue: "#f0f8ff",
   1373   antiquewhite: "#faebd7",
   1374   aqua: "#00ffff",
   1375   aquamarine: "#7fffd4",
   1376   azure: "#f0ffff",
   1377   beige: "#f5f5dc",
   1378   bisque: "#ffe4c4",
   1379   black: "#000000",
   1380   blanchedalmond: "#ffebcd",
   1381   blue: "#0000ff",
   1382   blueviolet: "#8a2be2",
   1383   brown: "#a52a2a",
   1384   burlywood: "#deb887",
   1385   cadetblue: "#5f9ea0",
   1386   chartreuse: "#7fff00",
   1387   chocolate: "#d2691e",
   1388   coral: "#ff7f50",
   1389   cornflowerblue: "#6495ed",
   1390   cornsilk: "#fff8dc",
   1391   crimson: "#dc143c",
   1392   cyan: "#00ffff",
   1393   darkblue: "#00008b",
   1394   darkcyan: "#008b8b",
   1395   darkgoldenrod: "#b8860b",
   1396   darkgray: "#a9a9a9",
   1397   darkgreen: "#006400",
   1398   darkgrey: "#a9a9a9",
   1399   darkkhaki: "#bdb76b",
   1400   darkmagenta: "#8b008b",
   1401   darkolivegreen: "#556b2f",
   1402   darkorange: "#ff8c00",
   1403   darkorchid: "#9932cc",
   1404   darkred: "#8b0000",
   1405   darksalmon: "#e9967a",
   1406   darkseagreen: "#8fbc8f",
   1407   darkslateblue: "#483d8b",
   1408   darkslategray: "#2f4f4f",
   1409   darkslategrey: "#2f4f4f",
   1410   darkturquoise: "#00ced1",
   1411   darkviolet: "#9400d3",
   1412   deeppink: "#ff1493",
   1413   deepskyblue: "#00bfff",
   1414   dimgray: "#696969",
   1415   dimgrey: "#696969",
   1416   dodgerblue: "#1e90ff",
   1417   firebrick: "#b22222",
   1418   floralwhite: "#fffaf0",
   1419   forestgreen: "#228b22",
   1420   fuchsia: "#ff00ff",
   1421   gainsboro: "#dcdcdc",
   1422   ghostwhite: "#f8f8ff",
   1423   gold: "#ffd700",
   1424   goldenrod: "#daa520",
   1425   gray: "#808080",
   1426   green: "#008000",
   1427   greenyellow: "#adff2f",
   1428   grey: "#808080",
   1429   honeydew: "#f0fff0",
   1430   hotpink: "#ff69b4",
   1431   indianred: "#cd5c5c",
   1432   indigo: "#4b0082",
   1433   ivory: "#fffff0",
   1434   khaki: "#f0e68c",
   1435   lavender: "#e6e6fa",
   1436   lavenderblush: "#fff0f5",
   1437   lawngreen: "#7cfc00",
   1438   lemonchiffon: "#fffacd",
   1439   lightblue: "#add8e6",
   1440   lightcoral: "#f08080",
   1441   lightcyan: "#e0ffff",
   1442   lightgoldenrodyellow: "#fafad2",
   1443   lightgray: "#d3d3d3",
   1444   lightgreen: "#90ee90",
   1445   lightgrey: "#d3d3d3",
   1446   lightpink: "#ffb6c1",
   1447   lightsalmon: "#ffa07a",
   1448   lightseagreen: "#20b2aa",
   1449   lightskyblue: "#87cefa",
   1450   lightslategray: "#778899",
   1451   lightslategrey: "#778899",
   1452   lightsteelblue: "#b0c4de",
   1453   lightyellow: "#ffffe0",
   1454   lime: "#00ff00",
   1455   limegreen: "#32cd32",
   1456   linen: "#faf0e6",
   1457   magenta: "#ff00ff",
   1458   maroon: "#800000",
   1459   mediumaquamarine: "#66cdaa",
   1460   mediumblue: "#0000cd",
   1461   mediumorchid: "#ba55d3",
   1462   mediumpurple: "#9370db",
   1463   mediumseagreen: "#3cb371",
   1464   mediumslateblue: "#7b68ee",
   1465   mediumspringgreen: "#00fa9a",
   1466   mediumturquoise: "#48d1cc",
   1467   mediumvioletred: "#c71585",
   1468   midnightblue: "#191970",
   1469   mintcream: "#f5fffa",
   1470   mistyrose: "#ffe4e1",
   1471   moccasin: "#ffe4b5",
   1472   navajowhite: "#ffdead",
   1473   navy: "#000080",
   1474   oldlace: "#fdf5e6",
   1475   olive: "#808000",
   1476   olivedrab: "#6b8e23",
   1477   orange: "#ffa500",
   1478   orangered: "#ff4500",
   1479   orchid: "#da70d6",
   1480   palegoldenrod: "#eee8aa",
   1481   palegreen: "#98fb98",
   1482   paleturquoise: "#afeeee",
   1483   palevioletred: "#db7093",
   1484   papayawhip: "#ffefd5",
   1485   peachpuff: "#ffdab9",
   1486   peru: "#cd853f",
   1487   pink: "#ffc0cb",
   1488   plum: "#dda0dd",
   1489   powderblue: "#b0e0e6",
   1490   purple: "#800080",
   1491   red: "#ff0000",
   1492   rosybrown: "#bc8f8f",
   1493   royalblue: "#4169e1",
   1494   saddlebrown: "#8b4513",
   1495   salmon: "#fa8072",
   1496   sandybrown: "#f4a460",
   1497   seagreen: "#2e8b57",
   1498   seashell: "#fff5ee",
   1499   sienna: "#a0522d",
   1500   silver: "#c0c0c0",
   1501   skyblue: "#87ceeb",
   1502   slateblue: "#6a5acd",
   1503   slategray: "#708090",
   1504   slategrey: "#708090",
   1505   snow: "#fffafa",
   1506   springgreen: "#00ff7f",
   1507   steelblue: "#4682b4",
   1508   tan: "#d2b48c",
   1509   teal: "#008080",
   1510   thistle: "#d8bfd8",
   1511   tomato: "#ff6347",
   1512   turquoise: "#40e0d0",
   1513   violet: "#ee82ee",
   1514   wheat: "#f5deb3",
   1515   white: "#ffffff",
   1516   whitesmoke: "#f5f5f5",
   1517   yellow: "#ffff00",
   1518   yellowgreen: "#9acd32"
   1519 });
   1520 
   1521 d3_rgb_names.forEach(function(key, value) {
   1522   d3_rgb_names.set(key, d3_rgb_parse(value, d3_rgb, d3_hsl_rgb));
   1523 });
   1524 d3.hsl = function(h, s, l) {
   1525   return arguments.length === 1
   1526       ? (h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l)
   1527       : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl))
   1528       : d3_hsl(+h, +s, +l);
   1529 };
   1530 
   1531 function d3_hsl(h, s, l) {
   1532   return new d3_Hsl(h, s, l);
   1533 }
   1534 
   1535 function d3_Hsl(h, s, l) {
   1536   this.h = h;
   1537   this.s = s;
   1538   this.l = l;
   1539 }
   1540 
   1541 d3_Hsl.prototype.brighter = function(k) {
   1542   k = Math.pow(0.7, arguments.length ? k : 1);
   1543   return d3_hsl(this.h, this.s, this.l / k);
   1544 };
   1545 
   1546 d3_Hsl.prototype.darker = function(k) {
   1547   k = Math.pow(0.7, arguments.length ? k : 1);
   1548   return d3_hsl(this.h, this.s, k * this.l);
   1549 };
   1550 
   1551 d3_Hsl.prototype.rgb = function() {
   1552   return d3_hsl_rgb(this.h, this.s, this.l);
   1553 };
   1554 
   1555 d3_Hsl.prototype.toString = function() {
   1556   return this.rgb().toString();
   1557 };
   1558 
   1559 function d3_hsl_rgb(h, s, l) {
   1560   var m1,
   1561       m2;
   1562 
   1563   /* Some simple corrections for h, s and l. */
   1564   h = h % 360; if (h < 0) h += 360;
   1565   s = s < 0 ? 0 : s > 1 ? 1 : s;
   1566   l = l < 0 ? 0 : l > 1 ? 1 : l;
   1567 
   1568   /* From FvD 13.37, CSS Color Module Level 3 */
   1569   m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
   1570   m1 = 2 * l - m2;
   1571 
   1572   function v(h) {
   1573     if (h > 360) h -= 360;
   1574     else if (h < 0) h += 360;
   1575     if (h < 60) return m1 + (m2 - m1) * h / 60;
   1576     if (h < 180) return m2;
   1577     if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
   1578     return m1;
   1579   }
   1580 
   1581   function vv(h) {
   1582     return Math.round(v(h) * 255);
   1583   }
   1584 
   1585   return d3_rgb(vv(h + 120), vv(h), vv(h - 120));
   1586 }
   1587 function d3_selection(groups) {
   1588   d3_arraySubclass(groups, d3_selectionPrototype);
   1589   return groups;
   1590 }
   1591 
   1592 var d3_select = function(s, n) { return n.querySelector(s); },
   1593     d3_selectAll = function(s, n) { return n.querySelectorAll(s); },
   1594     d3_selectRoot = document.documentElement,
   1595     d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector,
   1596     d3_selectMatches = function(n, s) { return d3_selectMatcher.call(n, s); };
   1597 
   1598 // Prefer Sizzle, if available.
   1599 if (typeof Sizzle === "function") {
   1600   d3_select = function(s, n) { return Sizzle(s, n)[0]; };
   1601   d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
   1602   d3_selectMatches = Sizzle.matchesSelector;
   1603 }
   1604 
   1605 var d3_selectionPrototype = [];
   1606 
   1607 d3.selection = function() {
   1608   return d3_selectionRoot;
   1609 };
   1610 
   1611 d3.selection.prototype = d3_selectionPrototype;
   1612 d3_selectionPrototype.select = function(selector) {
   1613   var subgroups = [],
   1614       subgroup,
   1615       subnode,
   1616       group,
   1617       node;
   1618 
   1619   if (typeof selector !== "function") selector = d3_selection_selector(selector);
   1620 
   1621   for (var j = -1, m = this.length; ++j < m;) {
   1622     subgroups.push(subgroup = []);
   1623     subgroup.parentNode = (group = this[j]).parentNode;
   1624     for (var i = -1, n = group.length; ++i < n;) {
   1625       if (node = group[i]) {
   1626         subgroup.push(subnode = selector.call(node, node.__data__, i));
   1627         if (subnode && "__data__" in node) subnode.__data__ = node.__data__;
   1628       } else {
   1629         subgroup.push(null);
   1630       }
   1631     }
   1632   }
   1633 
   1634   return d3_selection(subgroups);
   1635 };
   1636 
   1637 function d3_selection_selector(selector) {
   1638   return function() {
   1639     return d3_select(selector, this);
   1640   };
   1641 }
   1642 d3_selectionPrototype.selectAll = function(selector) {
   1643   var subgroups = [],
   1644       subgroup,
   1645       node;
   1646 
   1647   if (typeof selector !== "function") selector = d3_selection_selectorAll(selector);
   1648 
   1649   for (var j = -1, m = this.length; ++j < m;) {
   1650     for (var group = this[j], i = -1, n = group.length; ++i < n;) {
   1651       if (node = group[i]) {
   1652         subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i)));
   1653         subgroup.parentNode = node;
   1654       }
   1655     }
   1656   }
   1657 
   1658   return d3_selection(subgroups);
   1659 };
   1660 
   1661 function d3_selection_selectorAll(selector) {
   1662   return function() {
   1663     return d3_selectAll(selector, this);
   1664   };
   1665 }
   1666 d3_selectionPrototype.attr = function(name, value) {
   1667   name = d3.ns.qualify(name);
   1668 
   1669   // If no value is specified, return the first value.
   1670   if (arguments.length < 2) {
   1671     var node = this.node();
   1672     return name.local
   1673         ? node.getAttributeNS(name.space, name.local)
   1674         : node.getAttribute(name);
   1675   }
   1676 
   1677   function attrNull() {
   1678     this.removeAttribute(name);
   1679   }
   1680 
   1681   function attrNullNS() {
   1682     this.removeAttributeNS(name.space, name.local);
   1683   }
   1684 
   1685   function attrConstant() {
   1686     this.setAttribute(name, value);
   1687   }
   1688 
   1689   function attrConstantNS() {
   1690     this.setAttributeNS(name.space, name.local, value);
   1691   }
   1692 
   1693   function attrFunction() {
   1694     var x = value.apply(this, arguments);
   1695     if (x == null) this.removeAttribute(name);
   1696     else this.setAttribute(name, x);
   1697   }
   1698 
   1699   function attrFunctionNS() {
   1700     var x = value.apply(this, arguments);
   1701     if (x == null) this.removeAttributeNS(name.space, name.local);
   1702     else this.setAttributeNS(name.space, name.local, x);
   1703   }
   1704 
   1705   return this.each(value == null
   1706       ? (name.local ? attrNullNS : attrNull) : (typeof value === "function"
   1707       ? (name.local ? attrFunctionNS : attrFunction)
   1708       : (name.local ? attrConstantNS : attrConstant)));
   1709 };
   1710 d3_selectionPrototype.classed = function(name, value) {
   1711   var names = name.split(d3_selection_classedWhitespace),
   1712       n = names.length,
   1713       i = -1;
   1714   if (arguments.length > 1) {
   1715     while (++i < n) d3_selection_classed.call(this, names[i], value);
   1716     return this;
   1717   } else {
   1718     while (++i < n) if (!d3_selection_classed.call(this, names[i])) return false;
   1719     return true;
   1720   }
   1721 };
   1722 
   1723 var d3_selection_classedWhitespace = /\s+/g;
   1724 
   1725 function d3_selection_classed(name, value) {
   1726   var re = new RegExp("(^|\\s+)" + d3.requote(name) + "(\\s+|$)", "g");
   1727 
   1728   // If no value is specified, return the first value.
   1729   if (arguments.length < 2) {
   1730     var node = this.node();
   1731     if (c = node.classList) return c.contains(name);
   1732     var c = node.className;
   1733     re.lastIndex = 0;
   1734     return re.test(c.baseVal != null ? c.baseVal : c);
   1735   }
   1736 
   1737   function classedAdd() {
   1738     if (c = this.classList) return c.add(name);
   1739     var c = this.className,
   1740         cb = c.baseVal != null,
   1741         cv = cb ? c.baseVal : c;
   1742     re.lastIndex = 0;
   1743     if (!re.test(cv)) {
   1744       cv = d3_collapse(cv + " " + name);
   1745       if (cb) c.baseVal = cv;
   1746       else this.className = cv;
   1747     }
   1748   }
   1749 
   1750   function classedRemove() {
   1751     if (c = this.classList) return c.remove(name);
   1752     var c = this.className,
   1753         cb = c.baseVal != null,
   1754         cv = cb ? c.baseVal : c;
   1755     cv = d3_collapse(cv.replace(re, " "));
   1756     if (cb) c.baseVal = cv;
   1757     else this.className = cv;
   1758   }
   1759 
   1760   function classedFunction() {
   1761     (value.apply(this, arguments)
   1762         ? classedAdd
   1763         : classedRemove).call(this);
   1764   }
   1765 
   1766   return this.each(typeof value === "function"
   1767       ? classedFunction : value
   1768       ? classedAdd
   1769       : classedRemove);
   1770 }
   1771 d3_selectionPrototype.style = function(name, value, priority) {
   1772   if (arguments.length < 3) priority = "";
   1773 
   1774   // If no value is specified, return the first value.
   1775   if (arguments.length < 2) return window
   1776       .getComputedStyle(this.node(), null)
   1777       .getPropertyValue(name);
   1778 
   1779   function styleNull() {
   1780     this.style.removeProperty(name);
   1781   }
   1782 
   1783   function styleConstant() {
   1784     this.style.setProperty(name, value, priority);
   1785   }
   1786 
   1787   function styleFunction() {
   1788     var x = value.apply(this, arguments);
   1789     if (x == null) this.style.removeProperty(name);
   1790     else this.style.setProperty(name, x, priority);
   1791   }
   1792 
   1793   return this.each(value == null
   1794       ? styleNull : (typeof value === "function"
   1795       ? styleFunction : styleConstant));
   1796 };
   1797 d3_selectionPrototype.property = function(name, value) {
   1798 
   1799   // If no value is specified, return the first value.
   1800   if (arguments.length < 2) return this.node()[name];
   1801 
   1802   function propertyNull() {
   1803     delete this[name];
   1804   }
   1805 
   1806   function propertyConstant() {
   1807     this[name] = value;
   1808   }
   1809 
   1810   function propertyFunction() {
   1811     var x = value.apply(this, arguments);
   1812     if (x == null) delete this[name];
   1813     else this[name] = x;
   1814   }
   1815 
   1816   return this.each(value == null
   1817       ? propertyNull : (typeof value === "function"
   1818       ? propertyFunction : propertyConstant));
   1819 };
   1820 d3_selectionPrototype.text = function(value) {
   1821   return arguments.length < 1
   1822       ? this.node().textContent : this.each(typeof value === "function"
   1823       ? function() { var v = value.apply(this, arguments); this.textContent = v == null ? "" : v; } : value == null
   1824       ? function() { this.textContent = ""; }
   1825       : function() { this.textContent = value; });
   1826 };
   1827 d3_selectionPrototype.html = function(value) {
   1828   return arguments.length < 1
   1829       ? this.node().innerHTML : this.each(typeof value === "function"
   1830       ? function() { var v = value.apply(this, arguments); this.innerHTML = v == null ? "" : v; } : value == null
   1831       ? function() { this.innerHTML = ""; }
   1832       : function() { this.innerHTML = value; });
   1833 };
   1834 // TODO append(node)?
   1835 // TODO append(function)?
   1836 d3_selectionPrototype.append = function(name) {
   1837   name = d3.ns.qualify(name);
   1838 
   1839   function append() {
   1840     return this.appendChild(document.createElementNS(this.namespaceURI, name));
   1841   }
   1842 
   1843   function appendNS() {
   1844     return this.appendChild(document.createElementNS(name.space, name.local));
   1845   }
   1846 
   1847   return this.select(name.local ? appendNS : append);
   1848 };
   1849 // TODO insert(node, function)?
   1850 // TODO insert(function, string)?
   1851 // TODO insert(function, function)?
   1852 d3_selectionPrototype.insert = function(name, before) {
   1853   name = d3.ns.qualify(name);
   1854 
   1855   function insert() {
   1856     return this.insertBefore(
   1857         document.createElementNS(this.namespaceURI, name),
   1858         d3_select(before, this));
   1859   }
   1860 
   1861   function insertNS() {
   1862     return this.insertBefore(
   1863         document.createElementNS(name.space, name.local),
   1864         d3_select(before, this));
   1865   }
   1866 
   1867   return this.select(name.local ? insertNS : insert);
   1868 };
   1869 // TODO remove(selector)?
   1870 // TODO remove(node)?
   1871 // TODO remove(function)?
   1872 d3_selectionPrototype.remove = function() {
   1873   return this.each(function() {
   1874     var parent = this.parentNode;
   1875     if (parent) parent.removeChild(this);
   1876   });
   1877 };
   1878 d3_selectionPrototype.data = function(value, key) {
   1879   var i = -1,
   1880       n = this.length,
   1881       group,
   1882       node;
   1883 
   1884   // If no value is specified, return the first value.
   1885   if (!arguments.length) {
   1886     value = new Array(n = (group = this[0]).length);
   1887     while (++i < n) {
   1888       if (node = group[i]) {
   1889         value[i] = node.__data__;
   1890       }
   1891     }
   1892     return value;
   1893   }
   1894 
   1895   function bind(group, groupData) {
   1896     var i,
   1897         n = group.length,
   1898         m = groupData.length,
   1899         n0 = Math.min(n, m),
   1900         n1 = Math.max(n, m),
   1901         updateNodes = [],
   1902         enterNodes = [],
   1903         exitNodes = [],
   1904         node,
   1905         nodeData;
   1906 
   1907     if (key) {
   1908       var nodeByKeyValue = new d3_Map,
   1909           keyValues = [],
   1910           keyValue,
   1911           j = groupData.length;
   1912 
   1913       for (i = -1; ++i < n;) {
   1914         keyValue = key.call(node = group[i], node.__data__, i);
   1915         if (nodeByKeyValue.has(keyValue)) {
   1916           exitNodes[j++] = node; // duplicate key
   1917         } else {
   1918           nodeByKeyValue.set(keyValue, node);
   1919         }
   1920         keyValues.push(keyValue);
   1921       }
   1922 
   1923       for (i = -1; ++i < m;) {
   1924         keyValue = key.call(groupData, nodeData = groupData[i], i)
   1925         if (nodeByKeyValue.has(keyValue)) {
   1926           updateNodes[i] = node = nodeByKeyValue.get(keyValue);
   1927           node.__data__ = nodeData;
   1928           enterNodes[i] = exitNodes[i] = null;
   1929         } else {
   1930           enterNodes[i] = d3_selection_dataNode(nodeData);
   1931           updateNodes[i] = exitNodes[i] = null;
   1932         }
   1933         nodeByKeyValue.remove(keyValue);
   1934       }
   1935 
   1936       for (i = -1; ++i < n;) {
   1937         if (nodeByKeyValue.has(keyValues[i])) {
   1938           exitNodes[i] = group[i];
   1939         }
   1940       }
   1941     } else {
   1942       for (i = -1; ++i < n0;) {
   1943         node = group[i];
   1944         nodeData = groupData[i];
   1945         if (node) {
   1946           node.__data__ = nodeData;
   1947           updateNodes[i] = node;
   1948           enterNodes[i] = exitNodes[i] = null;
   1949         } else {
   1950           enterNodes[i] = d3_selection_dataNode(nodeData);
   1951           updateNodes[i] = exitNodes[i] = null;
   1952         }
   1953       }
   1954       for (; i < m; ++i) {
   1955         enterNodes[i] = d3_selection_dataNode(groupData[i]);
   1956         updateNodes[i] = exitNodes[i] = null;
   1957       }
   1958       for (; i < n1; ++i) {
   1959         exitNodes[i] = group[i];
   1960         enterNodes[i] = updateNodes[i] = null;
   1961       }
   1962     }
   1963 
   1964     enterNodes.update
   1965         = updateNodes;
   1966 
   1967     enterNodes.parentNode
   1968         = updateNodes.parentNode
   1969         = exitNodes.parentNode
   1970         = group.parentNode;
   1971 
   1972     enter.push(enterNodes);
   1973     update.push(updateNodes);
   1974     exit.push(exitNodes);
   1975   }
   1976 
   1977   var enter = d3_selection_enter([]),
   1978       update = d3_selection([]),
   1979       exit = d3_selection([]);
   1980 
   1981   if (typeof value === "function") {
   1982     while (++i < n) {
   1983       bind(group = this[i], value.call(group, group.parentNode.__data__, i));
   1984     }
   1985   } else {
   1986     while (++i < n) {
   1987       bind(group = this[i], value);
   1988     }
   1989   }
   1990 
   1991   update.enter = function() { return enter; };
   1992   update.exit = function() { return exit; };
   1993   return update;
   1994 };
   1995 
   1996 function d3_selection_dataNode(data) {
   1997   return {__data__: data};
   1998 }
   1999 d3_selectionPrototype.datum =
   2000 d3_selectionPrototype.map = function(value) {
   2001   return arguments.length < 1
   2002       ? this.property("__data__")
   2003       : this.property("__data__", value);
   2004 };
   2005 d3_selectionPrototype.filter = function(filter) {
   2006   var subgroups = [],
   2007       subgroup,
   2008       group,
   2009       node;
   2010 
   2011   if (typeof filter !== "function") filter = d3_selection_filter(filter);
   2012 
   2013   for (var j = 0, m = this.length; j < m; j++) {
   2014     subgroups.push(subgroup = []);
   2015     subgroup.parentNode = (group = this[j]).parentNode;
   2016     for (var i = 0, n = group.length; i < n; i++) {
   2017       if ((node = group[i]) && filter.call(node, node.__data__, i)) {
   2018         subgroup.push(node);
   2019       }
   2020     }
   2021   }
   2022 
   2023   return d3_selection(subgroups);
   2024 };
   2025 
   2026 function d3_selection_filter(selector) {
   2027   return function() {
   2028     return d3_selectMatches(this, selector);
   2029   };
   2030 }
   2031 d3_selectionPrototype.order = function() {
   2032   for (var j = -1, m = this.length; ++j < m;) {
   2033     for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
   2034       if (node = group[i]) {
   2035         if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
   2036         next = node;
   2037       }
   2038     }
   2039   }
   2040   return this;
   2041 };
   2042 d3_selectionPrototype.sort = function(comparator) {
   2043   comparator = d3_selection_sortComparator.apply(this, arguments);
   2044   for (var j = -1, m = this.length; ++j < m;) this[j].sort(comparator);
   2045   return this.order();
   2046 };
   2047 
   2048 function d3_selection_sortComparator(comparator) {
   2049   if (!arguments.length) comparator = d3.ascending;
   2050   return function(a, b) {
   2051     return comparator(a && a.__data__, b && b.__data__);
   2052   };
   2053 }
   2054 // type can be namespaced, e.g., "click.foo"
   2055 // listener can be null for removal
   2056 d3_selectionPrototype.on = function(type, listener, capture) {
   2057   if (arguments.length < 3) capture = false;
   2058 
   2059   // parse the type specifier
   2060   var name = "__on" + type, i = type.indexOf(".");
   2061   if (i > 0) type = type.substring(0, i);
   2062 
   2063   // if called with only one argument, return the current listener
   2064   if (arguments.length < 2) return (i = this.node()[name]) && i._;
   2065 
   2066   // remove the old event listener, and add the new event listener
   2067   return this.each(function(d, i) {
   2068     var node = this,
   2069         o = node[name];
   2070 
   2071     // remove the old listener, if any (using the previously-set capture)
   2072     if (o) {
   2073       node.removeEventListener(type, o, o.$);
   2074       delete node[name];
   2075     }
   2076 
   2077     // add the new listener, if any (remembering the capture flag)
   2078     if (listener) {
   2079       node.addEventListener(type, node[name] = l, l.$ = capture);
   2080       l._ = listener; // stash the unwrapped listener for get
   2081     }
   2082 
   2083     // wrapped event listener that preserves i
   2084     function l(e) {
   2085       var o = d3.event; // Events can be reentrant (e.g., focus).
   2086       d3.event = e;
   2087       try {
   2088         listener.call(node, node.__data__, i);
   2089       } finally {
   2090         d3.event = o;
   2091       }
   2092     }
   2093   });
   2094 };
   2095 d3_selectionPrototype.each = function(callback) {
   2096   for (var j = -1, m = this.length; ++j < m;) {
   2097     for (var group = this[j], i = -1, n = group.length; ++i < n;) {
   2098       var node = group[i];
   2099       if (node) callback.call(node, node.__data__, i, j);
   2100     }
   2101   }
   2102   return this;
   2103 };
   2104 //
   2105 // Note: assigning to the arguments array simultaneously changes the value of
   2106 // the corresponding argument!
   2107 //
   2108 // TODO The `this` argument probably shouldn't be the first argument to the
   2109 // callback, anyway, since it's redundant. However, that will require a major
   2110 // version bump due to backwards compatibility, so I'm not changing it right
   2111 // away.
   2112 //
   2113 d3_selectionPrototype.call = function(callback) {
   2114   callback.apply(this, (arguments[0] = this, arguments));
   2115   return this;
   2116 };
   2117 d3_selectionPrototype.empty = function() {
   2118   return !this.node();
   2119 };
   2120 d3_selectionPrototype.node = function(callback) {
   2121   for (var j = 0, m = this.length; j < m; j++) {
   2122     for (var group = this[j], i = 0, n = group.length; i < n; i++) {
   2123       var node = group[i];
   2124       if (node) return node;
   2125     }
   2126   }
   2127   return null;
   2128 };
   2129 d3_selectionPrototype.transition = function() {
   2130   var subgroups = [],
   2131       subgroup,
   2132       node;
   2133 
   2134   for (var j = -1, m = this.length; ++j < m;) {
   2135     subgroups.push(subgroup = []);
   2136     for (var group = this[j], i = -1, n = group.length; ++i < n;) {
   2137       subgroup.push((node = group[i]) ? {node: node, delay: d3_transitionDelay, duration: d3_transitionDuration} : null);
   2138     }
   2139   }
   2140 
   2141   return d3_transition(subgroups, d3_transitionId || ++d3_transitionNextId, Date.now());
   2142 };
   2143 var d3_selectionRoot = d3_selection([[document]]);
   2144 
   2145 d3_selectionRoot[0].parentNode = d3_selectRoot;
   2146 
   2147 // TODO fast singleton implementation!
   2148 // TODO select(function)
   2149 d3.select = function(selector) {
   2150   return typeof selector === "string"
   2151       ? d3_selectionRoot.select(selector)
   2152       : d3_selection([[selector]]); // assume node
   2153 };
   2154 
   2155 // TODO selectAll(function)
   2156 d3.selectAll = function(selector) {
   2157   return typeof selector === "string"
   2158       ? d3_selectionRoot.selectAll(selector)
   2159       : d3_selection([d3_array(selector)]); // assume node[]
   2160 };
   2161 function d3_selection_enter(selection) {
   2162   d3_arraySubclass(selection, d3_selection_enterPrototype);
   2163   return selection;
   2164 }
   2165 
   2166 var d3_selection_enterPrototype = [];
   2167 
   2168 d3.selection.enter = d3_selection_enter;
   2169 d3.selection.enter.prototype = d3_selection_enterPrototype;
   2170 
   2171 d3_selection_enterPrototype.append = d3_selectionPrototype.append;
   2172 d3_selection_enterPrototype.insert = d3_selectionPrototype.insert;
   2173 d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;
   2174 d3_selection_enterPrototype.node = d3_selectionPrototype.node;
   2175 d3_selection_enterPrototype.select = function(selector) {
   2176   var subgroups = [],
   2177       subgroup,
   2178       subnode,
   2179       upgroup,
   2180       group,
   2181       node;
   2182 
   2183   for (var j = -1, m = this.length; ++j < m;) {
   2184     upgroup = (group = this[j]).update;
   2185     subgroups.push(subgroup = []);
   2186     subgroup.parentNode = group.parentNode;
   2187     for (var i = -1, n = group.length; ++i < n;) {
   2188       if (node = group[i]) {
   2189         subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i));
   2190         subnode.__data__ = node.__data__;
   2191       } else {
   2192         subgroup.push(null);
   2193       }
   2194     }
   2195   }
   2196 
   2197   return d3_selection(subgroups);
   2198 };
   2199 function d3_transition(groups, id, time) {
   2200   d3_arraySubclass(groups, d3_transitionPrototype);
   2201 
   2202   var tweens = new d3_Map,
   2203       event = d3.dispatch("start", "end"),
   2204       ease = d3_transitionEase;
   2205 
   2206   groups.id = id;
   2207 
   2208   groups.time = time;
   2209 
   2210   groups.tween = function(name, tween) {
   2211     if (arguments.length < 2) return tweens.get(name);
   2212     if (tween == null) tweens.remove(name);
   2213     else tweens.set(name, tween);
   2214     return groups;
   2215   };
   2216 
   2217   groups.ease = function(value) {
   2218     if (!arguments.length) return ease;
   2219     ease = typeof value === "function" ? value : d3.ease.apply(d3, arguments);
   2220     return groups;
   2221   };
   2222 
   2223   groups.each = function(type, listener) {
   2224     if (arguments.length < 2) return d3_transition_each.call(groups, type);
   2225     event.on(type, listener);
   2226     return groups;
   2227   };
   2228 
   2229   d3.timer(function(elapsed) {
   2230     groups.each(function(d, i, j) {
   2231       var tweened = [],
   2232           node = this,
   2233           delay = groups[j][i].delay,
   2234           duration = groups[j][i].duration,
   2235           lock = node.__transition__ || (node.__transition__ = {active: 0, count: 0});
   2236 
   2237       ++lock.count;
   2238 
   2239       delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time);
   2240 
   2241       function start(elapsed) {
   2242         if (lock.active > id) return stop();
   2243         lock.active = id;
   2244 
   2245         tweens.forEach(function(key, value) {
   2246           if (tween = value.call(node, d, i)) {
   2247             tweened.push(tween);
   2248           }
   2249         });
   2250 
   2251         event.start.call(node, d, i);
   2252         if (!tick(elapsed)) d3.timer(tick, 0, time);
   2253         return 1;
   2254       }
   2255 
   2256       function tick(elapsed) {
   2257         if (lock.active !== id) return stop();
   2258 
   2259         var t = (elapsed - delay) / duration,
   2260             e = ease(t),
   2261             n = tweened.length;
   2262 
   2263         while (n > 0) {
   2264           tweened[--n].call(node, e);
   2265         }
   2266 
   2267         if (t >= 1) {
   2268           stop();
   2269           d3_transitionId = id;
   2270           event.end.call(node, d, i);
   2271           d3_transitionId = 0;
   2272           return 1;
   2273         }
   2274       }
   2275 
   2276       function stop() {
   2277         if (!--lock.count) delete node.__transition__;
   2278         return 1;
   2279       }
   2280     });
   2281     return 1;
   2282   }, 0, time);
   2283 
   2284   return groups;
   2285 }
   2286 
   2287 var d3_transitionRemove = {};
   2288 
   2289 function d3_transitionNull(d, i, a) {
   2290   return a != "" && d3_transitionRemove;
   2291 }
   2292 
   2293 function d3_transitionTween(name, b) {
   2294   var interpolate = d3_interpolateByName(name);
   2295 
   2296   function transitionFunction(d, i, a) {
   2297     var v = b.call(this, d, i);
   2298     return v == null
   2299         ? a != "" && d3_transitionRemove
   2300         : a != v && interpolate(a, v);
   2301   }
   2302 
   2303   function transitionString(d, i, a) {
   2304     return a != b && interpolate(a, b);
   2305   }
   2306 
   2307   return typeof b === "function" ? transitionFunction
   2308       : b == null ? d3_transitionNull
   2309       : (b += "", transitionString);
   2310 }
   2311 
   2312 var d3_transitionPrototype = [],
   2313     d3_transitionNextId = 0,
   2314     d3_transitionId = 0,
   2315     d3_transitionDefaultDelay = 0,
   2316     d3_transitionDefaultDuration = 250,
   2317     d3_transitionDefaultEase = d3.ease("cubic-in-out"),
   2318     d3_transitionDelay = d3_transitionDefaultDelay,
   2319     d3_transitionDuration = d3_transitionDefaultDuration,
   2320     d3_transitionEase = d3_transitionDefaultEase;
   2321 
   2322 d3_transitionPrototype.call = d3_selectionPrototype.call;
   2323 
   2324 d3.transition = function(selection) {
   2325   return arguments.length
   2326       ? (d3_transitionId ? selection.transition() : selection)
   2327       : d3_selectionRoot.transition();
   2328 };
   2329 
   2330 d3.transition.prototype = d3_transitionPrototype;
   2331 d3_transitionPrototype.select = function(selector) {
   2332   var subgroups = [],
   2333       subgroup,
   2334       subnode,
   2335       node;
   2336 
   2337   if (typeof selector !== "function") selector = d3_selection_selector(selector);
   2338 
   2339   for (var j = -1, m = this.length; ++j < m;) {
   2340     subgroups.push(subgroup = []);
   2341     for (var group = this[j], i = -1, n = group.length; ++i < n;) {
   2342       if ((node = group[i]) && (subnode = selector.call(node.node, node.node.__data__, i))) {
   2343         if ("__data__" in node.node) subnode.__data__ = node.node.__data__;
   2344         subgroup.push({node: subnode, delay: node.delay, duration: node.duration});
   2345       } else {
   2346         subgroup.push(null);
   2347       }
   2348     }
   2349   }
   2350 
   2351   return d3_transition(subgroups, this.id, this.time).ease(this.ease());
   2352 };
   2353 d3_transitionPrototype.selectAll = function(selector) {
   2354   var subgroups = [],
   2355       subgroup,
   2356       subnodes,
   2357       node;
   2358 
   2359   if (typeof selector !== "function") selector = d3_selection_selectorAll(selector);
   2360 
   2361   for (var j = -1, m = this.length; ++j < m;) {
   2362     for (var group = this[j], i = -1, n = group.length; ++i < n;) {
   2363       if (node = group[i]) {
   2364         subnodes = selector.call(node.node, node.node.__data__, i);
   2365         subgroups.push(subgroup = []);
   2366         for (var k = -1, o = subnodes.length; ++k < o;) {
   2367           subgroup.push({node: subnodes[k], delay: node.delay, duration: node.duration});
   2368         }
   2369       }
   2370     }
   2371   }
   2372 
   2373   return d3_transition(subgroups, this.id, this.time).ease(this.ease());
   2374 };
   2375 d3_transitionPrototype.attr = function(name, value) {
   2376   return this.attrTween(name, d3_transitionTween(name, value));
   2377 };
   2378 
   2379 d3_transitionPrototype.attrTween = function(nameNS, tween) {
   2380   var name = d3.ns.qualify(nameNS);
   2381 
   2382   function attrTween(d, i) {
   2383     var f = tween.call(this, d, i, this.getAttribute(name));
   2384     return f === d3_transitionRemove
   2385         ? (this.removeAttribute(name), null)
   2386         : f && function(t) { this.setAttribute(name, f(t)); };
   2387   }
   2388 
   2389   function attrTweenNS(d, i) {
   2390     var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));
   2391     return f === d3_transitionRemove
   2392         ? (this.removeAttributeNS(name.space, name.local), null)
   2393         : f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); };
   2394   }
   2395 
   2396   return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween);
   2397 };
   2398 d3_transitionPrototype.style = function(name, value, priority) {
   2399   if (arguments.length < 3) priority = "";
   2400   return this.styleTween(name, d3_transitionTween(name, value), priority);
   2401 };
   2402 
   2403 d3_transitionPrototype.styleTween = function(name, tween, priority) {
   2404   if (arguments.length < 3) priority = "";
   2405   return this.tween("style." + name, function(d, i) {
   2406     var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name));
   2407     return f === d3_transitionRemove
   2408         ? (this.style.removeProperty(name), null)
   2409         : f && function(t) { this.style.setProperty(name, f(t), priority); };
   2410   });
   2411 };
   2412 d3_transitionPrototype.text = function(value) {
   2413   return this.tween("text", function(d, i) {
   2414     this.textContent = typeof value === "function"
   2415         ? value.call(this, d, i)
   2416         : value;
   2417   });
   2418 };
   2419 d3_transitionPrototype.remove = function() {
   2420   return this.each("end.transition", function() {
   2421     var p;
   2422     if (!this.__transition__ && (p = this.parentNode)) p.removeChild(this);
   2423   });
   2424 };
   2425 d3_transitionPrototype.delay = function(value) {
   2426   var groups = this;
   2427   return groups.each(typeof value === "function"
   2428       ? function(d, i, j) { groups[j][i].delay = value.apply(this, arguments) | 0; }
   2429       : (value = value | 0, function(d, i, j) { groups[j][i].delay = value; }));
   2430 };
   2431 d3_transitionPrototype.duration = function(value) {
   2432   var groups = this;
   2433   return groups.each(typeof value === "function"
   2434       ? function(d, i, j) { groups[j][i].duration = Math.max(1, value.apply(this, arguments) | 0); }
   2435       : (value = Math.max(1, value | 0), function(d, i, j) { groups[j][i].duration = value; }));
   2436 };
   2437 function d3_transition_each(callback) {
   2438   var id = d3_transitionId,
   2439       ease = d3_transitionEase,
   2440       delay = d3_transitionDelay,
   2441       duration = d3_transitionDuration;
   2442 
   2443   d3_transitionId = this.id;
   2444   d3_transitionEase = this.ease();
   2445   for (var j = 0, m = this.length; j < m; j++) {
   2446     for (var group = this[j], i = 0, n = group.length; i < n; i++) {
   2447       var node = group[i];
   2448       if (node) {
   2449         d3_transitionDelay = this[j][i].delay;
   2450         d3_transitionDuration = this[j][i].duration;
   2451         callback.call(node = node.node, node.__data__, i, j);
   2452       }
   2453     }
   2454   }
   2455 
   2456   d3_transitionId = id;
   2457   d3_transitionEase = ease;
   2458   d3_transitionDelay = delay;
   2459   d3_transitionDuration = duration;
   2460   return this;
   2461 }
   2462 d3_transitionPrototype.transition = function() {
   2463   return this.select(d3_this);
   2464 };
   2465 var d3_timer_queue = null,
   2466     d3_timer_interval, // is an interval (or frame) active?
   2467     d3_timer_timeout; // is a timeout active?
   2468 
   2469 // The timer will continue to fire until callback returns true.
   2470 d3.timer = function(callback, delay, then) {
   2471   var found = false,
   2472       t0,
   2473       t1 = d3_timer_queue;
   2474 
   2475   if (arguments.length < 3) {
   2476     if (arguments.length < 2) delay = 0;
   2477     else if (!isFinite(delay)) return;
   2478     then = Date.now();
   2479   }
   2480 
   2481   // See if the callback's already in the queue.
   2482   while (t1) {
   2483     if (t1.callback === callback) {
   2484       t1.then = then;
   2485       t1.delay = delay;
   2486       found = true;
   2487       break;
   2488     }
   2489     t0 = t1;
   2490     t1 = t1.next;
   2491   }
   2492 
   2493   // Otherwise, add the callback to the queue.
   2494   if (!found) d3_timer_queue = {
   2495     callback: callback,
   2496     then: then,
   2497     delay: delay,
   2498     next: d3_timer_queue
   2499   };
   2500 
   2501   // Start animatin'!
   2502   if (!d3_timer_interval) {
   2503     d3_timer_timeout = clearTimeout(d3_timer_timeout);
   2504     d3_timer_interval = 1;
   2505     d3_timer_frame(d3_timer_step);
   2506   }
   2507 }
   2508 
   2509 function d3_timer_step() {
   2510   var elapsed,
   2511       now = Date.now(),
   2512       t1 = d3_timer_queue;
   2513 
   2514   while (t1) {
   2515     elapsed = now - t1.then;
   2516     if (elapsed >= t1.delay) t1.flush = t1.callback(elapsed);
   2517     t1 = t1.next;
   2518   }
   2519 
   2520   var delay = d3_timer_flush() - now;
   2521   if (delay > 24) {
   2522     if (isFinite(delay)) {
   2523       clearTimeout(d3_timer_timeout);
   2524       d3_timer_timeout = setTimeout(d3_timer_step, delay);
   2525     }
   2526     d3_timer_interval = 0;
   2527   } else {
   2528     d3_timer_interval = 1;
   2529     d3_timer_frame(d3_timer_step);
   2530   }
   2531 }
   2532 
   2533 d3.timer.flush = function() {
   2534   var elapsed,
   2535       now = Date.now(),
   2536       t1 = d3_timer_queue;
   2537 
   2538   while (t1) {
   2539     elapsed = now - t1.then;
   2540     if (!t1.delay) t1.flush = t1.callback(elapsed);
   2541     t1 = t1.next;
   2542   }
   2543 
   2544   d3_timer_flush();
   2545 };
   2546 
   2547 // Flush after callbacks, to avoid concurrent queue modification.
   2548 function d3_timer_flush() {
   2549   var t0 = null,
   2550       t1 = d3_timer_queue,
   2551       then = Infinity;
   2552   while (t1) {
   2553     if (t1.flush) {
   2554       t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next;
   2555     } else {
   2556       then = Math.min(then, t1.then + t1.delay);
   2557       t1 = (t0 = t1).next;
   2558     }
   2559   }
   2560   return then;
   2561 }
   2562 
   2563 var d3_timer_frame = window.requestAnimationFrame
   2564     || window.webkitRequestAnimationFrame
   2565     || window.mozRequestAnimationFrame
   2566     || window.oRequestAnimationFrame
   2567     || window.msRequestAnimationFrame
   2568     || function(callback) { setTimeout(callback, 17); };
   2569 d3.transform = function(string) {
   2570   var g = document.createElementNS(d3.ns.prefix.svg, "g"),
   2571       identity = {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0};
   2572   return (d3.transform = function(string) {
   2573     g.setAttribute("transform", string);
   2574     var t = g.transform.baseVal.consolidate();
   2575     return new d3_transform(t ? t.matrix : identity);
   2576   })(string);
   2577 };
   2578 
   2579 // Compute x-scale and normalize the first row.
   2580 // Compute shear and make second row orthogonal to first.
   2581 // Compute y-scale and normalize the second row.
   2582 // Finally, compute the rotation.
   2583 function d3_transform(m) {
   2584   var r0 = [m.a, m.b],
   2585       r1 = [m.c, m.d],
   2586       kx = d3_transformNormalize(r0),
   2587       kz = d3_transformDot(r0, r1),
   2588       ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0;
   2589   if (r0[0] * r1[1] < r1[0] * r0[1]) {
   2590     r0[0] *= -1;
   2591     r0[1] *= -1;
   2592     kx *= -1;
   2593     kz *= -1;
   2594   }
   2595   this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_transformDegrees;
   2596   this.translate = [m.e, m.f];
   2597   this.scale = [kx, ky];
   2598   this.skew = ky ? Math.atan2(kz, ky) * d3_transformDegrees : 0;
   2599 };
   2600 
   2601 d3_transform.prototype.toString = function() {
   2602   return "translate(" + this.translate
   2603       + ")rotate(" + this.rotate
   2604       + ")skewX(" + this.skew
   2605       + ")scale(" + this.scale
   2606       + ")";
   2607 };
   2608 
   2609 function d3_transformDot(a, b) {
   2610   return a[0] * b[0] + a[1] * b[1];
   2611 }
   2612 
   2613 function d3_transformNormalize(a) {
   2614   var k = Math.sqrt(d3_transformDot(a, a));
   2615   if (k) {
   2616     a[0] /= k;
   2617     a[1] /= k;
   2618   }
   2619   return k;
   2620 }
   2621 
   2622 function d3_transformCombine(a, b, k) {
   2623   a[0] += k * b[0];
   2624   a[1] += k * b[1];
   2625   return a;
   2626 }
   2627 
   2628 var d3_transformDegrees = 180 / Math.PI;
   2629 d3.mouse = function(container) {
   2630   return d3_mousePoint(container, d3_eventSource());
   2631 };
   2632 
   2633 // https://bugs.webkit.org/show_bug.cgi?id=44083
   2634 var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0;
   2635 
   2636 function d3_mousePoint(container, e) {
   2637   var svg = container.ownerSVGElement || container;
   2638   if (svg.createSVGPoint) {
   2639     var point = svg.createSVGPoint();
   2640     if ((d3_mouse_bug44083 < 0) && (window.scrollX || window.scrollY)) {
   2641       svg = d3.select(document.body)
   2642         .append("svg")
   2643           .style("position", "absolute")
   2644           .style("top", 0)
   2645           .style("left", 0);
   2646       var ctm = svg[0][0].getScreenCTM();
   2647       d3_mouse_bug44083 = !(ctm.f || ctm.e);
   2648       svg.remove();
   2649     }
   2650     if (d3_mouse_bug44083) {
   2651       point.x = e.pageX;
   2652       point.y = e.pageY;
   2653     } else {
   2654       point.x = e.clientX;
   2655       point.y = e.clientY;
   2656     }
   2657     point = point.matrixTransform(container.getScreenCTM().inverse());
   2658     return [point.x, point.y];
   2659   }
   2660   var rect = container.getBoundingClientRect();
   2661   return [e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop];
   2662 };
   2663 d3.touches = function(container, touches) {
   2664   if (arguments.length < 2) touches = d3_eventSource().touches;
   2665   return touches ? d3_array(touches).map(function(touch) {
   2666     var point = d3_mousePoint(container, touch);
   2667     point.identifier = touch.identifier;
   2668     return point;
   2669   }) : [];
   2670 };
   2671 function d3_noop() {}
   2672 d3.scale = {};
   2673 
   2674 function d3_scaleExtent(domain) {
   2675   var start = domain[0], stop = domain[domain.length - 1];
   2676   return start < stop ? [start, stop] : [stop, start];
   2677 }
   2678 
   2679 function d3_scaleRange(scale) {
   2680   return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());
   2681 }
   2682 function d3_scale_nice(domain, nice) {
   2683   var i0 = 0,
   2684       i1 = domain.length - 1,
   2685       x0 = domain[i0],
   2686       x1 = domain[i1],
   2687       dx;
   2688 
   2689   if (x1 < x0) {
   2690     dx = i0; i0 = i1; i1 = dx;
   2691     dx = x0; x0 = x1; x1 = dx;
   2692   }
   2693 
   2694   if (dx = x1 - x0) {
   2695     nice = nice(dx);
   2696     domain[i0] = nice.floor(x0);
   2697     domain[i1] = nice.ceil(x1);
   2698   }
   2699 
   2700   return domain;
   2701 }
   2702 
   2703 function d3_scale_niceDefault() {
   2704   return Math;
   2705 }
   2706 d3.scale.linear = function() {
   2707   return d3_scale_linear([0, 1], [0, 1], d3.interpolate, false);
   2708 };
   2709 
   2710 function d3_scale_linear(domain, range, interpolate, clamp) {
   2711   var output,
   2712       input;
   2713 
   2714   function rescale() {
   2715     var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear,
   2716         uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
   2717     output = linear(domain, range, uninterpolate, interpolate);
   2718     input = linear(range, domain, uninterpolate, d3.interpolate);
   2719     return scale;
   2720   }
   2721 
   2722   function scale(x) {
   2723     return output(x);
   2724   }
   2725 
   2726   // Note: requires range is coercible to number!
   2727   scale.invert = function(y) {
   2728     return input(y);
   2729   };
   2730 
   2731   scale.domain = function(x) {
   2732     if (!arguments.length) return domain;
   2733     domain = x.map(Number);
   2734     return rescale();
   2735   };
   2736 
   2737   scale.range = function(x) {
   2738     if (!arguments.length) return range;
   2739     range = x;
   2740     return rescale();
   2741   };
   2742 
   2743   scale.rangeRound = function(x) {
   2744     return scale.range(x).interpolate(d3.interpolateRound);
   2745   };
   2746 
   2747   scale.clamp = function(x) {
   2748     if (!arguments.length) return clamp;
   2749     clamp = x;
   2750     return rescale();
   2751   };
   2752 
   2753   scale.interpolate = function(x) {
   2754     if (!arguments.length) return interpolate;
   2755     interpolate = x;
   2756     return rescale();
   2757   };
   2758 
   2759   scale.ticks = function(m) {
   2760     return d3_scale_linearTicks(domain, m);
   2761   };
   2762 
   2763   scale.tickFormat = function(m) {
   2764     return d3_scale_linearTickFormat(domain, m);
   2765   };
   2766 
   2767   scale.nice = function() {
   2768     d3_scale_nice(domain, d3_scale_linearNice);
   2769     return rescale();
   2770   };
   2771 
   2772   scale.copy = function() {
   2773     return d3_scale_linear(domain, range, interpolate, clamp);
   2774   };
   2775 
   2776   return rescale();
   2777 }
   2778 
   2779 function d3_scale_linearRebind(scale, linear) {
   2780   return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
   2781 }
   2782 
   2783 function d3_scale_linearNice(dx) {
   2784   dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1);
   2785   return {
   2786     floor: function(x) { return Math.floor(x / dx) * dx; },
   2787     ceil: function(x) { return Math.ceil(x / dx) * dx; }
   2788   };
   2789 }
   2790 
   2791 function d3_scale_linearTickRange(domain, m) {
   2792   var extent = d3_scaleExtent(domain),
   2793       span = extent[1] - extent[0],
   2794       step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)),
   2795       err = m / span * step;
   2796 
   2797   // Filter ticks to get closer to the desired count.
   2798   if (err <= .15) step *= 10;
   2799   else if (err <= .35) step *= 5;
   2800   else if (err <= .75) step *= 2;
   2801 
   2802   // Round start and stop values to step interval.
   2803   extent[0] = Math.ceil(extent[0] / step) * step;
   2804   extent[1] = Math.floor(extent[1] / step) * step + step * .5; // inclusive
   2805   extent[2] = step;
   2806   return extent;
   2807 }
   2808 
   2809 function d3_scale_linearTicks(domain, m) {
   2810   return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));
   2811 }
   2812 
   2813 function d3_scale_linearTickFormat(domain, m) {
   2814   return d3.format(",." + Math.max(0, -Math.floor(Math.log(d3_scale_linearTickRange(domain, m)[2]) / Math.LN10 + .01)) + "f");
   2815 }
   2816 function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {
   2817   var u = uninterpolate(domain[0], domain[1]),
   2818       i = interpolate(range[0], range[1]);
   2819   return function(x) {
   2820     return i(u(x));
   2821   };
   2822 }
   2823 function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
   2824   var u = [],
   2825       i = [],
   2826       j = 0,
   2827       k = Math.min(domain.length, range.length) - 1;
   2828 
   2829   // Handle descending domains.
   2830   if (domain[k] < domain[0]) {
   2831     domain = domain.slice().reverse();
   2832     range = range.slice().reverse();
   2833   }
   2834 
   2835   while (++j <= k) {
   2836     u.push(uninterpolate(domain[j - 1], domain[j]));
   2837     i.push(interpolate(range[j - 1], range[j]));
   2838   }
   2839 
   2840   return function(x) {
   2841     var j = d3.bisect(domain, x, 1, k) - 1;
   2842     return i[j](u[j](x));
   2843   };
   2844 }
   2845 d3.scale.log = function() {
   2846   return d3_scale_log(d3.scale.linear(), d3_scale_logp);
   2847 };
   2848 
   2849 function d3_scale_log(linear, log) {
   2850   var pow = log.pow;
   2851 
   2852   function scale(x) {
   2853     return linear(log(x));
   2854   }
   2855 
   2856   scale.invert = function(x) {
   2857     return pow(linear.invert(x));
   2858   };
   2859 
   2860   scale.domain = function(x) {
   2861     if (!arguments.length) return linear.domain().map(pow);
   2862     log = x[0] < 0 ? d3_scale_logn : d3_scale_logp;
   2863     pow = log.pow;
   2864     linear.domain(x.map(log));
   2865     return scale;
   2866   };
   2867 
   2868   scale.nice = function() {
   2869     linear.domain(d3_scale_nice(linear.domain(), d3_scale_niceDefault));
   2870     return scale;
   2871   };
   2872 
   2873   scale.ticks = function() {
   2874     var extent = d3_scaleExtent(linear.domain()),
   2875         ticks = [];
   2876     if (extent.every(isFinite)) {
   2877       var i = Math.floor(extent[0]),
   2878           j = Math.ceil(extent[1]),
   2879           u = pow(extent[0]),
   2880           v = pow(extent[1]);
   2881       if (log === d3_scale_logn) {
   2882         ticks.push(pow(i));
   2883         for (; i++ < j;) for (var k = 9; k > 0; k--) ticks.push(pow(i) * k);
   2884       } else {
   2885         for (; i < j; i++) for (var k = 1; k < 10; k++) ticks.push(pow(i) * k);
   2886         ticks.push(pow(i));
   2887       }
   2888       for (i = 0; ticks[i] < u; i++) {} // strip small values
   2889       for (j = ticks.length; ticks[j - 1] > v; j--) {} // strip big values
   2890       ticks = ticks.slice(i, j);
   2891     }
   2892     return ticks;
   2893   };
   2894 
   2895   scale.tickFormat = function(n, format) {
   2896     if (arguments.length < 2) format = d3_scale_logFormat;
   2897     if (arguments.length < 1) return format;
   2898     var k = n / scale.ticks().length,
   2899         f = log === d3_scale_logn ? (e = -1e-12, Math.floor) : (e = 1e-12, Math.ceil),
   2900         e;
   2901     return function(d) {
   2902       return d / pow(f(log(d) + e)) < k ? format(d) : "";
   2903     };
   2904   };
   2905 
   2906   scale.copy = function() {
   2907     return d3_scale_log(linear.copy(), log);
   2908   };
   2909 
   2910   return d3_scale_linearRebind(scale, linear);
   2911 }
   2912 
   2913 var d3_scale_logFormat = d3.format(".0e");
   2914 
   2915 function d3_scale_logp(x) {
   2916   return Math.log(x < 0 ? 0 : x) / Math.LN10;
   2917 }
   2918 
   2919 function d3_scale_logn(x) {
   2920   return -Math.log(x > 0 ? 0 : -x) / Math.LN10;
   2921 }
   2922 
   2923 d3_scale_logp.pow = function(x) {
   2924   return Math.pow(10, x);
   2925 };
   2926 
   2927 d3_scale_logn.pow = function(x) {
   2928   return -Math.pow(10, -x);
   2929 };
   2930 d3.scale.pow = function() {
   2931   return d3_scale_pow(d3.scale.linear(), 1);
   2932 };
   2933 
   2934 function d3_scale_pow(linear, exponent) {
   2935   var powp = d3_scale_powPow(exponent),
   2936       powb = d3_scale_powPow(1 / exponent);
   2937 
   2938   function scale(x) {
   2939     return linear(powp(x));
   2940   }
   2941 
   2942   scale.invert = function(x) {
   2943     return powb(linear.invert(x));
   2944   };
   2945 
   2946   scale.domain = function(x) {
   2947     if (!arguments.length) return linear.domain().map(powb);
   2948     linear.domain(x.map(powp));
   2949     return scale;
   2950   };
   2951 
   2952   scale.ticks = function(m) {
   2953     return d3_scale_linearTicks(scale.domain(), m);
   2954   };
   2955 
   2956   scale.tickFormat = function(m) {
   2957     return d3_scale_linearTickFormat(scale.domain(), m);
   2958   };
   2959 
   2960   scale.nice = function() {
   2961     return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice));
   2962   };
   2963 
   2964   scale.exponent = function(x) {
   2965     if (!arguments.length) return exponent;
   2966     var domain = scale.domain();
   2967     powp = d3_scale_powPow(exponent = x);
   2968     powb = d3_scale_powPow(1 / exponent);
   2969     return scale.domain(domain);
   2970   };
   2971 
   2972   scale.copy = function() {
   2973     return d3_scale_pow(linear.copy(), exponent);
   2974   };
   2975 
   2976   return d3_scale_linearRebind(scale, linear);
   2977 }
   2978 
   2979 function d3_scale_powPow(e) {
   2980   return function(x) {
   2981     return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);
   2982   };
   2983 }
   2984 d3.scale.sqrt = function() {
   2985   return d3.scale.pow().exponent(.5);
   2986 };
   2987 d3.scale.ordinal = function() {
   2988   return d3_scale_ordinal([], {t: "range", x: []});
   2989 };
   2990 
   2991 function d3_scale_ordinal(domain, ranger) {
   2992   var index,
   2993       range,
   2994       rangeBand;
   2995 
   2996   function scale(x) {
   2997     return range[((index.get(x) || index.set(x, domain.push(x))) - 1) % range.length];
   2998   }
   2999 
   3000   function steps(start, step) {
   3001     return d3.range(domain.length).map(function(i) { return start + step * i; });
   3002   }
   3003 
   3004   scale.domain = function(x) {
   3005     if (!arguments.length) return domain;
   3006     domain = [];
   3007     index = new d3_Map;
   3008     var i = -1, n = x.length, xi;
   3009     while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));
   3010     return scale[ranger.t](ranger.x, ranger.p);
   3011   };
   3012 
   3013   scale.range = function(x) {
   3014     if (!arguments.length) return range;
   3015     range = x;
   3016     rangeBand = 0;
   3017     ranger = {t: "range", x: x};
   3018     return scale;
   3019   };
   3020 
   3021   scale.rangePoints = function(x, padding) {
   3022     if (arguments.length < 2) padding = 0;
   3023     var start = x[0],
   3024         stop = x[1],
   3025         step = (stop - start) / (domain.length - 1 + padding);
   3026     range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step);
   3027     rangeBand = 0;
   3028     ranger = {t: "rangePoints", x: x, p: padding};
   3029     return scale;
   3030   };
   3031 
   3032   scale.rangeBands = function(x, padding) {
   3033     if (arguments.length < 2) padding = 0;
   3034     var reverse = x[1] < x[0],
   3035         start = x[reverse - 0],
   3036         stop = x[1 - reverse],
   3037         step = (stop - start) / (domain.length + padding);
   3038     range = steps(start + step * padding, step);
   3039     if (reverse) range.reverse();
   3040     rangeBand = step * (1 - padding);
   3041     ranger = {t: "rangeBands", x: x, p: padding};
   3042     return scale;
   3043   };
   3044 
   3045   scale.rangeRoundBands = function(x, padding) {
   3046     if (arguments.length < 2) padding = 0;
   3047     var reverse = x[1] < x[0],
   3048         start = x[reverse - 0],
   3049         stop = x[1 - reverse],
   3050         step = Math.floor((stop - start) / (domain.length + padding)),
   3051         error = stop - start - (domain.length - padding) * step;
   3052     range = steps(start + Math.round(error / 2), step);
   3053     if (reverse) range.reverse();
   3054     rangeBand = Math.round(step * (1 - padding));
   3055     ranger = {t: "rangeRoundBands", x: x, p: padding};
   3056     return scale;
   3057   };
   3058 
   3059   scale.rangeBand = function() {
   3060     return rangeBand;
   3061   };
   3062 
   3063   scale.rangeExtent = function() {
   3064     return d3_scaleExtent(ranger.x);
   3065   };
   3066 
   3067   scale.copy = function() {
   3068     return d3_scale_ordinal(domain, ranger);
   3069   };
   3070 
   3071   return scale.domain(domain);
   3072 }
   3073 /*
   3074  * This product includes color specifications and designs developed by Cynthia
   3075  * Brewer (http://colorbrewer.org/). See lib/colorbrewer for more information.
   3076  */
   3077 
   3078 d3.scale.category10 = function() {
   3079   return d3.scale.ordinal().range(d3_category10);
   3080 };
   3081 
   3082 d3.scale.category20 = function() {
   3083   return d3.scale.ordinal().range(d3_category20);
   3084 };
   3085 
   3086 d3.scale.category20b = function() {
   3087   return d3.scale.ordinal().range(d3_category20b);
   3088 };
   3089 
   3090 d3.scale.category20c = function() {
   3091   return d3.scale.ordinal().range(d3_category20c);
   3092 };
   3093 
   3094 var d3_category10 = [
   3095   "#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
   3096   "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"
   3097 ];
   3098 
   3099 var d3_category20 = [
   3100   "#1f77b4", "#aec7e8",
   3101   "#ff7f0e", "#ffbb78",
   3102   "#2ca02c", "#98df8a",
   3103   "#d62728", "#ff9896",
   3104   "#9467bd", "#c5b0d5",
   3105   "#8c564b", "#c49c94",
   3106   "#e377c2", "#f7b6d2",
   3107   "#7f7f7f", "#c7c7c7",
   3108   "#bcbd22", "#dbdb8d",
   3109   "#17becf", "#9edae5"
   3110 ];
   3111 
   3112 var d3_category20b = [
   3113   "#393b79", "#5254a3", "#6b6ecf", "#9c9ede",
   3114   "#637939", "#8ca252", "#b5cf6b", "#cedb9c",
   3115   "#8c6d31", "#bd9e39", "#e7ba52", "#e7cb94",
   3116   "#843c39", "#ad494a", "#d6616b", "#e7969c",
   3117   "#7b4173", "#a55194", "#ce6dbd", "#de9ed6"
   3118 ];
   3119 
   3120 var d3_category20c = [
   3121   "#3182bd", "#6baed6", "#9ecae1", "#c6dbef",
   3122   "#e6550d", "#fd8d3c", "#fdae6b", "#fdd0a2",
   3123   "#31a354", "#74c476", "#a1d99b", "#c7e9c0",
   3124   "#756bb1", "#9e9ac8", "#bcbddc", "#dadaeb",
   3125   "#636363", "#969696", "#bdbdbd", "#d9d9d9"
   3126 ];
   3127 d3.scale.quantile = function() {
   3128   return d3_scale_quantile([], []);
   3129 };
   3130 
   3131 function d3_scale_quantile(domain, range) {
   3132   var thresholds;
   3133 
   3134   function rescale() {
   3135     var k = 0,
   3136         n = domain.length,
   3137         q = range.length;
   3138     thresholds = [];
   3139     while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);
   3140     return scale;
   3141   }
   3142 
   3143   function scale(x) {
   3144     if (isNaN(x = +x)) return NaN;
   3145     return range[d3.bisect(thresholds, x)];
   3146   }
   3147 
   3148   scale.domain = function(x) {
   3149     if (!arguments.length) return domain;
   3150     domain = x.filter(function(d) { return !isNaN(d); }).sort(d3.ascending);
   3151     return rescale();
   3152   };
   3153 
   3154   scale.range = function(x) {
   3155     if (!arguments.length) return range;
   3156     range = x;
   3157     return rescale();
   3158   };
   3159 
   3160   scale.quantiles = function() {
   3161     return thresholds;
   3162   };
   3163 
   3164   scale.copy = function() {
   3165     return d3_scale_quantile(domain, range); // copy on write!
   3166   };
   3167 
   3168   return rescale();
   3169 }
   3170 d3.scale.quantize = function() {
   3171   return d3_scale_quantize(0, 1, [0, 1]);
   3172 };
   3173 
   3174 function d3_scale_quantize(x0, x1, range) {
   3175   var kx, i;
   3176 
   3177   function scale(x) {
   3178     return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];
   3179   }
   3180 
   3181   function rescale() {
   3182     kx = range.length / (x1 - x0);
   3183     i = range.length - 1;
   3184     return scale;
   3185   }
   3186 
   3187   scale.domain = function(x) {
   3188     if (!arguments.length) return [x0, x1];
   3189     x0 = +x[0];
   3190     x1 = +x[x.length - 1];
   3191     return rescale();
   3192   };
   3193 
   3194   scale.range = function(x) {
   3195     if (!arguments.length) return range;
   3196     range = x;
   3197     return rescale();
   3198   };
   3199 
   3200   scale.copy = function() {
   3201     return d3_scale_quantize(x0, x1, range); // copy on write
   3202   };
   3203 
   3204   return rescale();
   3205 }
   3206 d3.scale.identity = function() {
   3207   return d3_scale_identity([0, 1]);
   3208 };
   3209 
   3210 function d3_scale_identity(domain) {
   3211 
   3212   function identity(x) { return +x; }
   3213 
   3214   identity.invert = identity;
   3215 
   3216   identity.domain = identity.range = function(x) {
   3217     if (!arguments.length) return domain;
   3218     domain = x.map(identity);
   3219     return identity;
   3220   };
   3221 
   3222   identity.ticks = function(m) {
   3223     return d3_scale_linearTicks(domain, m);
   3224   };
   3225 
   3226   identity.tickFormat = function(m) {
   3227     return d3_scale_linearTickFormat(domain, m);
   3228   };
   3229 
   3230   identity.copy = function() {
   3231     return d3_scale_identity(domain);
   3232   };
   3233 
   3234   return identity;
   3235 }
   3236 d3.svg = {};
   3237 d3.svg.arc = function() {
   3238   var innerRadius = d3_svg_arcInnerRadius,
   3239       outerRadius = d3_svg_arcOuterRadius,
   3240       startAngle = d3_svg_arcStartAngle,
   3241       endAngle = d3_svg_arcEndAngle;
   3242 
   3243   function arc() {
   3244     var r0 = innerRadius.apply(this, arguments),
   3245         r1 = outerRadius.apply(this, arguments),
   3246         a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset,
   3247         a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset,
   3248         da = (a1 < a0 && (da = a0, a0 = a1, a1 = da), a1 - a0),
   3249         df = da < Math.PI ? "0" : "1",
   3250         c0 = Math.cos(a0),
   3251         s0 = Math.sin(a0),
   3252         c1 = Math.cos(a1),
   3253         s1 = Math.sin(a1);
   3254     return da >= d3_svg_arcMax
   3255       ? (r0
   3256       ? "M0," + r1
   3257       + "A" + r1 + "," + r1 + " 0 1,1 0," + (-r1)
   3258       + "A" + r1 + "," + r1 + " 0 1,1 0," + r1
   3259       + "M0," + r0
   3260       + "A" + r0 + "," + r0 + " 0 1,0 0," + (-r0)
   3261       + "A" + r0 + "," + r0 + " 0 1,0 0," + r0
   3262       + "Z"
   3263       : "M0," + r1
   3264       + "A" + r1 + "," + r1 + " 0 1,1 0," + (-r1)
   3265       + "A" + r1 + "," + r1 + " 0 1,1 0," + r1
   3266       + "Z")
   3267       : (r0
   3268       ? "M" + r1 * c0 + "," + r1 * s0
   3269       + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1
   3270       + "L" + r0 * c1 + "," + r0 * s1
   3271       + "A" + r0 + "," + r0 + " 0 " + df + ",0 " + r0 * c0 + "," + r0 * s0
   3272       + "Z"
   3273       : "M" + r1 * c0 + "," + r1 * s0
   3274       + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1
   3275       + "L0,0"
   3276       + "Z");
   3277   }
   3278 
   3279   arc.innerRadius = function(v) {
   3280     if (!arguments.length) return innerRadius;
   3281     innerRadius = d3.functor(v);
   3282     return arc;
   3283   };
   3284 
   3285   arc.outerRadius = function(v) {
   3286     if (!arguments.length) return outerRadius;
   3287     outerRadius = d3.functor(v);
   3288     return arc;
   3289   };
   3290 
   3291   arc.startAngle = function(v) {
   3292     if (!arguments.length) return startAngle;
   3293     startAngle = d3.functor(v);
   3294     return arc;
   3295   };
   3296 
   3297   arc.endAngle = function(v) {
   3298     if (!arguments.length) return endAngle;
   3299     endAngle = d3.functor(v);
   3300     return arc;
   3301   };
   3302 
   3303   arc.centroid = function() {
   3304     var r = (innerRadius.apply(this, arguments)
   3305         + outerRadius.apply(this, arguments)) / 2,
   3306         a = (startAngle.apply(this, arguments)
   3307         + endAngle.apply(this, arguments)) / 2 + d3_svg_arcOffset;
   3308     return [Math.cos(a) * r, Math.sin(a) * r];
   3309   };
   3310 
   3311   return arc;
   3312 };
   3313 
   3314 var d3_svg_arcOffset = -Math.PI / 2,
   3315     d3_svg_arcMax = 2 * Math.PI - 1e-6;
   3316 
   3317 function d3_svg_arcInnerRadius(d) {
   3318   return d.innerRadius;
   3319 }
   3320 
   3321 function d3_svg_arcOuterRadius(d) {
   3322   return d.outerRadius;
   3323 }
   3324 
   3325 function d3_svg_arcStartAngle(d) {
   3326   return d.startAngle;
   3327 }
   3328 
   3329 function d3_svg_arcEndAngle(d) {
   3330   return d.endAngle;
   3331 }
   3332 function d3_svg_line(projection) {
   3333   var x = d3_svg_lineX,
   3334       y = d3_svg_lineY,
   3335       interpolate = d3_svg_lineInterpolatorDefault,
   3336       interpolator = d3_svg_lineInterpolators.get(interpolate),
   3337       tension = .7;
   3338 
   3339   function line(d) {
   3340     return d.length < 1 ? null : "M" + interpolator(projection(d3_svg_linePoints(this, d, x, y)), tension);
   3341   }
   3342 
   3343   line.x = function(v) {
   3344     if (!arguments.length) return x;
   3345     x = v;
   3346     return line;
   3347   };
   3348 
   3349   line.y = function(v) {
   3350     if (!arguments.length) return y;
   3351     y = v;
   3352     return line;
   3353   };
   3354 
   3355   line.interpolate = function(v) {
   3356     if (!arguments.length) return interpolate;
   3357     if (!d3_svg_lineInterpolators.has(v += "")) v = d3_svg_lineInterpolatorDefault;
   3358     interpolator = d3_svg_lineInterpolators.get(interpolate = v);
   3359     return line;
   3360   };
   3361 
   3362   line.tension = function(v) {
   3363     if (!arguments.length) return tension;
   3364     tension = v;
   3365     return line;
   3366   };
   3367 
   3368   return line;
   3369 }
   3370 
   3371 d3.svg.line = function() {
   3372   return d3_svg_line(Object);
   3373 };
   3374 
   3375 // Converts the specified array of data into an array of points
   3376 // (x-y tuples), by evaluating the specified `x` and `y` functions on each
   3377 // data point. The `this` context of the evaluated functions is the specified
   3378 // "self" object; each function is passed the current datum and index.
   3379 function d3_svg_linePoints(self, d, x, y) {
   3380   var points = [],
   3381       i = -1,
   3382       n = d.length,
   3383       fx = typeof x === "function",
   3384       fy = typeof y === "function",
   3385       value;
   3386   if (fx && fy) {
   3387     while (++i < n) points.push([
   3388       x.call(self, value = d[i], i),
   3389       y.call(self, value, i)
   3390     ]);
   3391   } else if (fx) {
   3392     while (++i < n) points.push([x.call(self, d[i], i), y]);
   3393   } else if (fy) {
   3394     while (++i < n) points.push([x, y.call(self, d[i], i)]);
   3395   } else {
   3396     while (++i < n) points.push([x, y]);
   3397   }
   3398   return points;
   3399 }
   3400 
   3401 // The default `x` property, which references d[0].
   3402 function d3_svg_lineX(d) {
   3403   return d[0];
   3404 }
   3405 
   3406 // The default `y` property, which references d[1].
   3407 function d3_svg_lineY(d) {
   3408   return d[1];
   3409 }
   3410 
   3411 var d3_svg_lineInterpolatorDefault = "linear";
   3412 
   3413 // The various interpolators supported by the `line` class.
   3414 var d3_svg_lineInterpolators = d3.map({
   3415   "linear": d3_svg_lineLinear,
   3416   "step-before": d3_svg_lineStepBefore,
   3417   "step-after": d3_svg_lineStepAfter,
   3418   "basis": d3_svg_lineBasis,
   3419   "basis-open": d3_svg_lineBasisOpen,
   3420   "basis-closed": d3_svg_lineBasisClosed,
   3421   "bundle": d3_svg_lineBundle,
   3422   "cardinal": d3_svg_lineCardinal,
   3423   "cardinal-open": d3_svg_lineCardinalOpen,
   3424   "cardinal-closed": d3_svg_lineCardinalClosed,
   3425   "monotone": d3_svg_lineMonotone
   3426 });
   3427 
   3428 // Linear interpolation; generates "L" commands.
   3429 function d3_svg_lineLinear(points) {
   3430   var i = 0,
   3431       n = points.length,
   3432       p = points[0],
   3433       path = [p[0], ",", p[1]];
   3434   while (++i < n) path.push("L", (p = points[i])[0], ",", p[1]);
   3435   return path.join("");
   3436 }
   3437 
   3438 // Step interpolation; generates "H" and "V" commands.
   3439 function d3_svg_lineStepBefore(points) {
   3440   var i = 0,
   3441       n = points.length,
   3442       p = points[0],
   3443       path = [p[0], ",", p[1]];
   3444   while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]);
   3445   return path.join("");
   3446 }
   3447 
   3448 // Step interpolation; generates "H" and "V" commands.
   3449 function d3_svg_lineStepAfter(points) {
   3450   var i = 0,
   3451       n = points.length,
   3452       p = points[0],
   3453       path = [p[0], ",", p[1]];
   3454   while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]);
   3455   return path.join("");
   3456 }
   3457 
   3458 // Open cardinal spline interpolation; generates "C" commands.
   3459 function d3_svg_lineCardinalOpen(points, tension) {
   3460   return points.length < 4
   3461       ? d3_svg_lineLinear(points)
   3462       : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1),
   3463         d3_svg_lineCardinalTangents(points, tension));
   3464 }
   3465 
   3466 // Closed cardinal spline interpolation; generates "C" commands.
   3467 function d3_svg_lineCardinalClosed(points, tension) {
   3468   return points.length < 3
   3469       ? d3_svg_lineLinear(points)
   3470       : points[0] + d3_svg_lineHermite((points.push(points[0]), points),
   3471         d3_svg_lineCardinalTangents([points[points.length - 2]]
   3472         .concat(points, [points[1]]), tension));
   3473 }
   3474 
   3475 // Cardinal spline interpolation; generates "C" commands.
   3476 function d3_svg_lineCardinal(points, tension, closed) {
   3477   return points.length < 3
   3478       ? d3_svg_lineLinear(points)
   3479       : points[0] + d3_svg_lineHermite(points,
   3480         d3_svg_lineCardinalTangents(points, tension));
   3481 }
   3482 
   3483 // Hermite spline construction; generates "C" commands.
   3484 function d3_svg_lineHermite(points, tangents) {
   3485   if (tangents.length < 1
   3486       || (points.length != tangents.length
   3487       && points.length != tangents.length + 2)) {
   3488     return d3_svg_lineLinear(points);
   3489   }
   3490 
   3491   var quad = points.length != tangents.length,
   3492       path = "",
   3493       p0 = points[0],
   3494       p = points[1],
   3495       t0 = tangents[0],
   3496       t = t0,
   3497       pi = 1;
   3498 
   3499   if (quad) {
   3500     path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3)
   3501         + "," + p[0] + "," + p[1];
   3502     p0 = points[1];
   3503     pi = 2;
   3504   }
   3505 
   3506   if (tangents.length > 1) {
   3507     t = tangents[1];
   3508     p = points[pi];
   3509     pi++;
   3510     path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1])
   3511         + "," + (p[0] - t[0]) + "," + (p[1] - t[1])
   3512         + "," + p[0] + "," + p[1];
   3513     for (var i = 2; i < tangents.length; i++, pi++) {
   3514       p = points[pi];
   3515       t = tangents[i];
   3516       path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1])
   3517           + "," + p[0] + "," + p[1];
   3518     }
   3519   }
   3520 
   3521   if (quad) {
   3522     var lp = points[pi];
   3523     path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3)
   3524         + "," + lp[0] + "," + lp[1];
   3525   }
   3526 
   3527   return path;
   3528 }
   3529 
   3530 // Generates tangents for a cardinal spline.
   3531 function d3_svg_lineCardinalTangents(points, tension) {
   3532   var tangents = [],
   3533       a = (1 - tension) / 2,
   3534       p0,
   3535       p1 = points[0],
   3536       p2 = points[1],
   3537       i = 1,
   3538       n = points.length;
   3539   while (++i < n) {
   3540     p0 = p1;
   3541     p1 = p2;
   3542     p2 = points[i];
   3543     tangents.push([a * (p2[0] - p0[0]), a * (p2[1] - p0[1])]);
   3544   }
   3545   return tangents;
   3546 }
   3547 
   3548 // B-spline interpolation; generates "C" commands.
   3549 function d3_svg_lineBasis(points) {
   3550   if (points.length < 3) return d3_svg_lineLinear(points);
   3551   var i = 1,
   3552       n = points.length,
   3553       pi = points[0],
   3554       x0 = pi[0],
   3555       y0 = pi[1],
   3556       px = [x0, x0, x0, (pi = points[1])[0]],
   3557       py = [y0, y0, y0, pi[1]],
   3558       path = [x0, ",", y0];
   3559   d3_svg_lineBasisBezier(path, px, py);
   3560   while (++i < n) {
   3561     pi = points[i];
   3562     px.shift(); px.push(pi[0]);
   3563     py.shift(); py.push(pi[1]);
   3564     d3_svg_lineBasisBezier(path, px, py);
   3565   }
   3566   i = -1;
   3567   while (++i < 2) {
   3568     px.shift(); px.push(pi[0]);
   3569     py.shift(); py.push(pi[1]);
   3570     d3_svg_lineBasisBezier(path, px, py);
   3571   }
   3572   return path.join("");
   3573 }
   3574 
   3575 // Open B-spline interpolation; generates "C" commands.
   3576 function d3_svg_lineBasisOpen(points) {
   3577   if (points.length < 4) return d3_svg_lineLinear(points);
   3578   var path = [],
   3579       i = -1,
   3580       n = points.length,
   3581       pi,
   3582       px = [0],
   3583       py = [0];
   3584   while (++i < 3) {
   3585     pi = points[i];
   3586     px.push(pi[0]);
   3587     py.push(pi[1]);
   3588   }
   3589   path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px)
   3590     + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));
   3591   --i; while (++i < n) {
   3592     pi = points[i];
   3593     px.shift(); px.push(pi[0]);
   3594     py.shift(); py.push(pi[1]);
   3595     d3_svg_lineBasisBezier(path, px, py);
   3596   }
   3597   return path.join("");
   3598 }
   3599 
   3600 // Closed B-spline interpolation; generates "C" commands.
   3601 function d3_svg_lineBasisClosed(points) {
   3602   var path,
   3603       i = -1,
   3604       n = points.length,
   3605       m = n + 4,
   3606       pi,
   3607       px = [],
   3608       py = [];
   3609   while (++i < 4) {
   3610     pi = points[i % n];
   3611     px.push(pi[0]);
   3612     py.push(pi[1]);
   3613   }
   3614   path = [
   3615     d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",",
   3616     d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)
   3617   ];
   3618   --i; while (++i < m) {
   3619     pi = points[i % n];
   3620     px.shift(); px.push(pi[0]);
   3621     py.shift(); py.push(pi[1]);
   3622     d3_svg_lineBasisBezier(path, px, py);
   3623   }
   3624   return path.join("");
   3625 }
   3626 
   3627 function d3_svg_lineBundle(points, tension) {
   3628   var n = points.length - 1,
   3629       x0 = points[0][0],
   3630       y0 = points[0][1],
   3631       dx = points[n][0] - x0,
   3632       dy = points[n][1] - y0,
   3633       i = -1,
   3634       p,
   3635       t;
   3636   while (++i <= n) {
   3637     p = points[i];
   3638     t = i / n;
   3639     p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
   3640     p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
   3641   }
   3642   return d3_svg_lineBasis(points);
   3643 }
   3644 
   3645 // Returns the dot product of the given four-element vectors.
   3646 function d3_svg_lineDot4(a, b) {
   3647   return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
   3648 }
   3649 
   3650 // Matrix to transform basis (b-spline) control points to bezier
   3651 // control points. Derived from FvD 11.2.8.
   3652 var d3_svg_lineBasisBezier1 = [0, 2/3, 1/3, 0],
   3653     d3_svg_lineBasisBezier2 = [0, 1/3, 2/3, 0],
   3654     d3_svg_lineBasisBezier3 = [0, 1/6, 2/3, 1/6];
   3655 
   3656 // Pushes a "C" Bézier curve onto the specified path array, given the
   3657 // two specified four-element arrays which define the control points.
   3658 function d3_svg_lineBasisBezier(path, x, y) {
   3659   path.push(
   3660       "C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x),
   3661       ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y),
   3662       ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x),
   3663       ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y),
   3664       ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x),
   3665       ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y));
   3666 }
   3667 
   3668 // Computes the slope from points p0 to p1.
   3669 function d3_svg_lineSlope(p0, p1) {
   3670   return (p1[1] - p0[1]) / (p1[0] - p0[0]);
   3671 }
   3672 
   3673 // Compute three-point differences for the given points.
   3674 // http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference
   3675 function d3_svg_lineFiniteDifferences(points) {
   3676   var i = 0,
   3677       j = points.length - 1,
   3678       m = [],
   3679       p0 = points[0],
   3680       p1 = points[1],
   3681       d = m[0] = d3_svg_lineSlope(p0, p1);
   3682   while (++i < j) {
   3683     m[i] = d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]));
   3684   }
   3685   m[i] = d;
   3686   return m;
   3687 }
   3688 
   3689 // Interpolates the given points using Fritsch-Carlson Monotone cubic Hermite
   3690 // interpolation. Returns an array of tangent vectors. For details, see
   3691 // http://en.wikipedia.org/wiki/Monotone_cubic_interpolation
   3692 function d3_svg_lineMonotoneTangents(points) {
   3693   var tangents = [],
   3694       d,
   3695       a,
   3696       b,
   3697       s,
   3698       m = d3_svg_lineFiniteDifferences(points),
   3699       i = -1,
   3700       j = points.length - 1;
   3701 
   3702   // The first two steps are done by computing finite-differences:
   3703   // 1. Compute the slopes of the secant lines between successive points.
   3704   // 2. Initialize the tangents at every point as the average of the secants.
   3705 
   3706   // Then, for each segment…
   3707   while (++i < j) {
   3708     d = d3_svg_lineSlope(points[i], points[i + 1]);
   3709 
   3710     // 3. If two successive yk = y{k + 1} are equal (i.e., d is zero), then set
   3711     // mk = m{k + 1} = 0 as the spline connecting these points must be flat to
   3712     // preserve monotonicity. Ignore step 4 and 5 for those k.
   3713 
   3714     if (Math.abs(d) < 1e-6) {
   3715       m[i] = m[i + 1] = 0;
   3716     } else {
   3717       // 4. Let ak = mk / dk and bk = m{k + 1} / dk.
   3718       a = m[i] / d;
   3719       b = m[i + 1] / d;
   3720 
   3721       // 5. Prevent overshoot and ensure monotonicity by restricting the
   3722       // magnitude of vector <ak, bk> to a circle of radius 3.
   3723       s = a * a + b * b;
   3724       if (s > 9) {
   3725         s = d * 3 / Math.sqrt(s);
   3726         m[i] = s * a;
   3727         m[i + 1] = s * b;
   3728       }
   3729     }
   3730   }
   3731 
   3732   // Compute the normalized tangent vector from the slopes. Note that if x is
   3733   // not monotonic, it's possible that the slope will be infinite, so we protect
   3734   // against NaN by setting the coordinate to zero.
   3735   i = -1; while (++i <= j) {
   3736     s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0])
   3737       / (6 * (1 + m[i] * m[i]));
   3738     tangents.push([s || 0, m[i] * s || 0]);
   3739   }
   3740 
   3741   return tangents;
   3742 }
   3743 
   3744 function d3_svg_lineMonotone(points) {
   3745   return points.length < 3
   3746       ? d3_svg_lineLinear(points)
   3747       : points[0] +
   3748         d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));
   3749 }
   3750 d3.svg.line.radial = function() {
   3751   var line = d3_svg_line(d3_svg_lineRadial);
   3752   line.radius = line.x, delete line.x;
   3753   line.angle = line.y, delete line.y;
   3754   return line;
   3755 };
   3756 
   3757 function d3_svg_lineRadial(points) {
   3758   var point,
   3759       i = -1,
   3760       n = points.length,
   3761       r,
   3762       a;
   3763   while (++i < n) {
   3764     point = points[i];
   3765     r = point[0];
   3766     a = point[1] + d3_svg_arcOffset;
   3767     point[0] = r * Math.cos(a);
   3768     point[1] = r * Math.sin(a);
   3769   }
   3770   return points;
   3771 }
   3772 function d3_svg_area(projection) {
   3773   var x0 = d3_svg_lineX,
   3774       x1 = d3_svg_lineX,
   3775       y0 = 0,
   3776       y1 = d3_svg_lineY,
   3777       interpolate,
   3778       i0,
   3779       i1,
   3780       tension = .7;
   3781 
   3782   function area(d) {
   3783     if (d.length < 1) return null;
   3784     var points0 = d3_svg_linePoints(this, d, x0, y0),
   3785         points1 = d3_svg_linePoints(this, d, x0 === x1 ? d3_svg_areaX(points0) : x1, y0 === y1 ? d3_svg_areaY(points0) : y1);
   3786     return "M" + i0(projection(points1), tension)
   3787          + "L" + i1(projection(points0.reverse()), tension)
   3788          + "Z";
   3789   }
   3790 
   3791   area.x = function(x) {
   3792     if (!arguments.length) return x1;
   3793     x0 = x1 = x;
   3794     return area;
   3795   };
   3796 
   3797   area.x0 = function(x) {
   3798     if (!arguments.length) return x0;
   3799     x0 = x;
   3800     return area;
   3801   };
   3802 
   3803   area.x1 = function(x) {
   3804     if (!arguments.length) return x1;
   3805     x1 = x;
   3806     return area;
   3807   };
   3808 
   3809   area.y = function(y) {
   3810     if (!arguments.length) return y1;
   3811     y0 = y1 = y;
   3812     return area;
   3813   };
   3814 
   3815   area.y0 = function(y) {
   3816     if (!arguments.length) return y0;
   3817     y0 = y;
   3818     return area;
   3819   };
   3820 
   3821   area.y1 = function(y) {
   3822     if (!arguments.length) return y1;
   3823     y1 = y;
   3824     return area;
   3825   };
   3826 
   3827   area.interpolate = function(x) {
   3828     if (!arguments.length) return interpolate;
   3829     if (!d3_svg_lineInterpolators.has(x += "")) x = d3_svg_lineInterpolatorDefault;
   3830     i0 = d3_svg_lineInterpolators.get(interpolate = x);
   3831     i1 = i0.reverse || i0;
   3832     return area;
   3833   };
   3834 
   3835   area.tension = function(x) {
   3836     if (!arguments.length) return tension;
   3837     tension = x;
   3838     return area;
   3839   };
   3840 
   3841   return area.interpolate("linear");
   3842 }
   3843 
   3844 d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;
   3845 d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;
   3846 
   3847 d3.svg.area = function() {
   3848   return d3_svg_area(Object);
   3849 };
   3850 
   3851 function d3_svg_areaX(points) {
   3852   return function(d, i) {
   3853     return points[i][0];
   3854   };
   3855 }
   3856 
   3857 function d3_svg_areaY(points) {
   3858   return function(d, i) {
   3859     return points[i][1];
   3860   };
   3861 }
   3862 d3.svg.area.radial = function() {
   3863   var area = d3_svg_area(d3_svg_lineRadial);
   3864   area.radius = area.x, delete area.x;
   3865   area.innerRadius = area.x0, delete area.x0;
   3866   area.outerRadius = area.x1, delete area.x1;
   3867   area.angle = area.y, delete area.y;
   3868   area.startAngle = area.y0, delete area.y0;
   3869   area.endAngle = area.y1, delete area.y1;
   3870   return area;
   3871 };
   3872 d3.svg.chord = function() {
   3873   var source = d3_svg_chordSource,
   3874       target = d3_svg_chordTarget,
   3875       radius = d3_svg_chordRadius,
   3876       startAngle = d3_svg_arcStartAngle,
   3877       endAngle = d3_svg_arcEndAngle;
   3878 
   3879   // TODO Allow control point to be customized.
   3880 
   3881   function chord(d, i) {
   3882     var s = subgroup(this, source, d, i),
   3883         t = subgroup(this, target, d, i);
   3884     return "M" + s.p0
   3885       + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t)
   3886       ? curve(s.r, s.p1, s.r, s.p0)
   3887       : curve(s.r, s.p1, t.r, t.p0)
   3888       + arc(t.r, t.p1, t.a1 - t.a0)
   3889       + curve(t.r, t.p1, s.r, s.p0))
   3890       + "Z";
   3891   }
   3892 
   3893   function subgroup(self, f, d, i) {
   3894     var subgroup = f.call(self, d, i),
   3895         r = radius.call(self, subgroup, i),
   3896         a0 = startAngle.call(self, subgroup, i) + d3_svg_arcOffset,
   3897         a1 = endAngle.call(self, subgroup, i) + d3_svg_arcOffset;
   3898     return {
   3899       r: r,
   3900       a0: a0,
   3901       a1: a1,
   3902       p0: [r * Math.cos(a0), r * Math.sin(a0)],
   3903       p1: [r * Math.cos(a1), r * Math.sin(a1)]
   3904     };
   3905   }
   3906 
   3907   function equals(a, b) {
   3908     return a.a0 == b.a0 && a.a1 == b.a1;
   3909   }
   3910 
   3911   function arc(r, p, a) {
   3912     return "A" + r + "," + r + " 0 " + +(a > Math.PI) + ",1 " + p;
   3913   }
   3914 
   3915   function curve(r0, p0, r1, p1) {
   3916     return "Q 0,0 " + p1;
   3917   }
   3918 
   3919   chord.radius = function(v) {
   3920     if (!arguments.length) return radius;
   3921     radius = d3.functor(v);
   3922     return chord;
   3923   };
   3924 
   3925   chord.source = function(v) {
   3926     if (!arguments.length) return source;
   3927     source = d3.functor(v);
   3928     return chord;
   3929   };
   3930 
   3931   chord.target = function(v) {
   3932     if (!arguments.length) return target;
   3933     target = d3.functor(v);
   3934     return chord;
   3935   };
   3936 
   3937   chord.startAngle = function(v) {
   3938     if (!arguments.length) return startAngle;
   3939     startAngle = d3.functor(v);
   3940     return chord;
   3941   };
   3942 
   3943   chord.endAngle = function(v) {
   3944     if (!arguments.length) return endAngle;
   3945     endAngle = d3.functor(v);
   3946     return chord;
   3947   };
   3948 
   3949   return chord;
   3950 };
   3951 
   3952 function d3_svg_chordSource(d) {
   3953   return d.source;
   3954 }
   3955 
   3956 function d3_svg_chordTarget(d) {
   3957   return d.target;
   3958 }
   3959 
   3960 function d3_svg_chordRadius(d) {
   3961   return d.radius;
   3962 }
   3963 
   3964 function d3_svg_chordStartAngle(d) {
   3965   return d.startAngle;
   3966 }
   3967 
   3968 function d3_svg_chordEndAngle(d) {
   3969   return d.endAngle;
   3970 }
   3971 d3.svg.diagonal = function() {
   3972   var source = d3_svg_chordSource,
   3973       target = d3_svg_chordTarget,
   3974       projection = d3_svg_diagonalProjection;
   3975 
   3976   function diagonal(d, i) {
   3977     var p0 = source.call(this, d, i),
   3978         p3 = target.call(this, d, i),
   3979         m = (p0.y + p3.y) / 2,
   3980         p = [p0, {x: p0.x, y: m}, {x: p3.x, y: m}, p3];
   3981     p = p.map(projection);
   3982     return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3];
   3983   }
   3984 
   3985   diagonal.source = function(x) {
   3986     if (!arguments.length) return source;
   3987     source = d3.functor(x);
   3988     return diagonal;
   3989   };
   3990 
   3991   diagonal.target = function(x) {
   3992     if (!arguments.length) return target;
   3993     target = d3.functor(x);
   3994     return diagonal;
   3995   };
   3996 
   3997   diagonal.projection = function(x) {
   3998     if (!arguments.length) return projection;
   3999     projection = x;
   4000     return diagonal;
   4001   };
   4002 
   4003   return diagonal;
   4004 };
   4005 
   4006 function d3_svg_diagonalProjection(d) {
   4007   return [d.x, d.y];
   4008 }
   4009 d3.svg.diagonal.radial = function() {
   4010   var diagonal = d3.svg.diagonal(),
   4011       projection = d3_svg_diagonalProjection,
   4012       projection_ = diagonal.projection;
   4013 
   4014   diagonal.projection = function(x) {
   4015     return arguments.length
   4016         ? projection_(d3_svg_diagonalRadialProjection(projection = x))
   4017         : projection;
   4018   };
   4019 
   4020   return diagonal;
   4021 };
   4022 
   4023 function d3_svg_diagonalRadialProjection(projection) {
   4024   return function() {
   4025     var d = projection.apply(this, arguments),
   4026         r = d[0],
   4027         a = d[1] + d3_svg_arcOffset;
   4028     return [r * Math.cos(a), r * Math.sin(a)];
   4029   };
   4030 }
   4031 d3.svg.mouse = d3.mouse;
   4032 d3.svg.touches = d3.touches;
   4033 d3.svg.symbol = function() {
   4034   var type = d3_svg_symbolType,
   4035       size = d3_svg_symbolSize;
   4036 
   4037   function symbol(d, i) {
   4038     return (d3_svg_symbols.get(type.call(this, d, i))
   4039         || d3_svg_symbolCircle)
   4040         (size.call(this, d, i));
   4041   }
   4042 
   4043   symbol.type = function(x) {
   4044     if (!arguments.length) return type;
   4045     type = d3.functor(x);
   4046     return symbol;
   4047   };
   4048 
   4049   // size of symbol in square pixels
   4050   symbol.size = function(x) {
   4051     if (!arguments.length) return size;
   4052     size = d3.functor(x);
   4053     return symbol;
   4054   };
   4055 
   4056   return symbol;
   4057 };
   4058 
   4059 function d3_svg_symbolSize() {
   4060   return 64;
   4061 }
   4062 
   4063 function d3_svg_symbolType() {
   4064   return "circle";
   4065 }
   4066 
   4067 function d3_svg_symbolCircle(size) {
   4068   var r = Math.sqrt(size / Math.PI);
   4069   return "M0," + r
   4070       + "A" + r + "," + r + " 0 1,1 0," + (-r)
   4071       + "A" + r + "," + r + " 0 1,1 0," + r
   4072       + "Z";
   4073 }
   4074 
   4075 // TODO cross-diagonal?
   4076 var d3_svg_symbols = d3.map({
   4077   "circle": d3_svg_symbolCircle,
   4078   "cross": function(size) {
   4079     var r = Math.sqrt(size / 5) / 2;
   4080     return "M" + -3 * r + "," + -r
   4081         + "H" + -r
   4082         + "V" + -3 * r
   4083         + "H" + r
   4084         + "V" + -r
   4085         + "H" + 3 * r
   4086         + "V" + r
   4087         + "H" + r
   4088         + "V" + 3 * r
   4089         + "H" + -r
   4090         + "V" + r
   4091         + "H" + -3 * r
   4092         + "Z";
   4093   },
   4094   "diamond": function(size) {
   4095     var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)),
   4096         rx = ry * d3_svg_symbolTan30;
   4097     return "M0," + -ry
   4098         + "L" + rx + ",0"
   4099         + " 0," + ry
   4100         + " " + -rx + ",0"
   4101         + "Z";
   4102   },
   4103   "square": function(size) {
   4104     var r = Math.sqrt(size) / 2;
   4105     return "M" + -r + "," + -r
   4106         + "L" + r + "," + -r
   4107         + " " + r + "," + r
   4108         + " " + -r + "," + r
   4109         + "Z";
   4110   },
   4111   "triangle-down": function(size) {
   4112     var rx = Math.sqrt(size / d3_svg_symbolSqrt3),
   4113         ry = rx * d3_svg_symbolSqrt3 / 2;
   4114     return "M0," + ry
   4115         + "L" + rx +"," + -ry
   4116         + " " + -rx + "," + -ry
   4117         + "Z";
   4118   },
   4119   "triangle-up": function(size) {
   4120     var rx = Math.sqrt(size / d3_svg_symbolSqrt3),
   4121         ry = rx * d3_svg_symbolSqrt3 / 2;
   4122     return "M0," + -ry
   4123         + "L" + rx +"," + ry
   4124         + " " + -rx + "," + ry
   4125         + "Z";
   4126   }
   4127 });
   4128 
   4129 d3.svg.symbolTypes = d3_svg_symbols.keys();
   4130 
   4131 var d3_svg_symbolSqrt3 = Math.sqrt(3),
   4132     d3_svg_symbolTan30 = Math.tan(30 * Math.PI / 180);
   4133 d3.svg.axis = function() {
   4134   var scale = d3.scale.linear(),
   4135       orient = "bottom",
   4136       tickMajorSize = 6,
   4137       tickMinorSize = 6,
   4138       tickEndSize = 6,
   4139       tickPadding = 3,
   4140       tickArguments_ = [10],
   4141       tickValues = null,
   4142       tickFormat_,
   4143       tickSubdivide = 0;
   4144 
   4145   function axis(g) {
   4146     g.each(function() {
   4147       var g = d3.select(this);
   4148 
   4149       // Ticks, or domain values for ordinal scales.
   4150       var ticks = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain()) : tickValues,
   4151           tickFormat = tickFormat_ == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : String) : tickFormat_;
   4152 
   4153       // Minor ticks.
   4154       var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide),
   4155           subtick = g.selectAll(".minor").data(subticks, String),
   4156           subtickEnter = subtick.enter().insert("line", "g").attr("class", "tick minor").style("opacity", 1e-6),
   4157           subtickExit = d3.transition(subtick.exit()).style("opacity", 1e-6).remove(),
   4158           subtickUpdate = d3.transition(subtick).style("opacity", 1);
   4159 
   4160       // Major ticks.
   4161       var tick = g.selectAll("g").data(ticks, String),
   4162           tickEnter = tick.enter().insert("g", "path").style("opacity", 1e-6),
   4163           tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(),
   4164           tickUpdate = d3.transition(tick).style("opacity", 1),
   4165           tickTransform;
   4166 
   4167       // Domain.
   4168       var range = d3_scaleRange(scale),
   4169           path = g.selectAll(".domain").data([0]),
   4170           pathEnter = path.enter().append("path").attr("class", "domain"),
   4171           pathUpdate = d3.transition(path);
   4172 
   4173       // Stash a snapshot of the new scale, and retrieve the old snapshot.
   4174       var scale1 = scale.copy(),
   4175           scale0 = this.__chart__ || scale1;
   4176       this.__chart__ = scale1;
   4177 
   4178       tickEnter.append("line").attr("class", "tick");
   4179       tickEnter.append("text");
   4180       tickUpdate.select("text").text(tickFormat);
   4181 
   4182       switch (orient) {
   4183         case "bottom": {
   4184           tickTransform = d3_svg_axisX;
   4185           subtickEnter.attr("y2", tickMinorSize);
   4186           subtickUpdate.attr("x2", 0).attr("y2", tickMinorSize);
   4187           tickEnter.select("line").attr("y2", tickMajorSize);
   4188           tickEnter.select("text").attr("y", Math.max(tickMajorSize, 0) + tickPadding);
   4189           tickUpdate.select("line").attr("x2", 0).attr("y2", tickMajorSize);
   4190           tickUpdate.select("text").attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding).attr("dy", ".71em").attr("text-anchor", "middle");
   4191           pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize);
   4192           break;
   4193         }
   4194         case "top": {
   4195           tickTransform = d3_svg_axisX;
   4196           subtickEnter.attr("y2", -tickMinorSize);
   4197           subtickUpdate.attr("x2", 0).attr("y2", -tickMinorSize);
   4198           tickEnter.select("line").attr("y2", -tickMajorSize);
   4199           tickEnter.select("text").attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
   4200           tickUpdate.select("line").attr("x2", 0).attr("y2", -tickMajorSize);
   4201           tickUpdate.select("text").attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("dy", "0em").attr("text-anchor", "middle");
   4202           pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize);
   4203           break;
   4204         }
   4205         case "left": {
   4206           tickTransform = d3_svg_axisY;
   4207           subtickEnter.attr("x2", -tickMinorSize);
   4208           subtickUpdate.attr("x2", -tickMinorSize).attr("y2", 0);
   4209           tickEnter.select("line").attr("x2", -tickMajorSize);
   4210           tickEnter.select("text").attr("x", -(Math.max(tickMajorSize, 0) + tickPadding));
   4211           tickUpdate.select("line").attr("x2", -tickMajorSize).attr("y2", 0);
   4212           tickUpdate.select("text").attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0).attr("dy", ".32em").attr("text-anchor", "end");
   4213           pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize);
   4214           break;
   4215         }
   4216         case "right": {
   4217           tickTransform = d3_svg_axisY;
   4218           subtickEnter.attr("x2", tickMinorSize);
   4219           subtickUpdate.attr("x2", tickMinorSize).attr("y2", 0);
   4220           tickEnter.select("line").attr("x2", tickMajorSize);
   4221           tickEnter.select("text").attr("x", Math.max(tickMajorSize, 0) + tickPadding);
   4222           tickUpdate.select("line").attr("x2", tickMajorSize).attr("y2", 0);
   4223           tickUpdate.select("text").attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0).attr("dy", ".32em").attr("text-anchor", "start");
   4224           pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize);
   4225           break;
   4226         }
   4227       }
   4228 
   4229       // For quantitative scales:
   4230       // - enter new ticks from the old scale
   4231       // - exit old ticks to the new scale
   4232       if (scale.ticks) {
   4233         tickEnter.call(tickTransform, scale0);
   4234         tickUpdate.call(tickTransform, scale1);
   4235         tickExit.call(tickTransform, scale1);
   4236         subtickEnter.call(tickTransform, scale0);
   4237         subtickUpdate.call(tickTransform, scale1);
   4238         subtickExit.call(tickTransform, scale1);
   4239       }
   4240 
   4241       // For ordinal scales:
   4242       // - any entering ticks are undefined in the old scale
   4243       // - any exiting ticks are undefined in the new scale
   4244       // Therefore, we only need to transition updating ticks.
   4245       else {
   4246         var dx = scale1.rangeBand() / 2, x = function(d) { return scale1(d) + dx; };
   4247         tickEnter.call(tickTransform, x);
   4248         tickUpdate.call(tickTransform, x);
   4249       }
   4250     });
   4251   }
   4252 
   4253   axis.scale = function(x) {
   4254     if (!arguments.length) return scale;
   4255     scale = x;
   4256     return axis;
   4257   };
   4258 
   4259   axis.orient = function(x) {
   4260     if (!arguments.length) return orient;
   4261     orient = x;
   4262     return axis;
   4263   };
   4264 
   4265   axis.ticks = function() {
   4266     if (!arguments.length) return tickArguments_;
   4267     tickArguments_ = arguments;
   4268     return axis;
   4269   };
   4270 
   4271   axis.tickValues = function(x) {
   4272     if (!arguments.length) return tickValues;
   4273     tickValues = x;
   4274     return axis;
   4275   };
   4276 
   4277   axis.tickFormat = function(x) {
   4278     if (!arguments.length) return tickFormat_;
   4279     tickFormat_ = x;
   4280     return axis;
   4281   };
   4282 
   4283   axis.tickSize = function(x, y, z) {
   4284     if (!arguments.length) return tickMajorSize;
   4285     var n = arguments.length - 1;
   4286     tickMajorSize = +x;
   4287     tickMinorSize = n > 1 ? +y : tickMajorSize;
   4288     tickEndSize = n > 0 ? +arguments[n] : tickMajorSize;
   4289     return axis;
   4290   };
   4291 
   4292   axis.tickPadding = function(x) {
   4293     if (!arguments.length) return tickPadding;
   4294     tickPadding = +x;
   4295     return axis;
   4296   };
   4297 
   4298   axis.tickSubdivide = function(x) {
   4299     if (!arguments.length) return tickSubdivide;
   4300     tickSubdivide = +x;
   4301     return axis;
   4302   };
   4303 
   4304   return axis;
   4305 };
   4306 
   4307 function d3_svg_axisX(selection, x) {
   4308   selection.attr("transform", function(d) { return "translate(" + x(d) + ",0)"; });
   4309 }
   4310 
   4311 function d3_svg_axisY(selection, y) {
   4312   selection.attr("transform", function(d) { return "translate(0," + y(d) + ")"; });
   4313 }
   4314 
   4315 function d3_svg_axisSubdivide(scale, ticks, m) {
   4316   subticks = [];
   4317   if (m && ticks.length > 1) {
   4318     var extent = d3_scaleExtent(scale.domain()),
   4319         subticks,
   4320         i = -1,
   4321         n = ticks.length,
   4322         d = (ticks[1] - ticks[0]) / ++m,
   4323         j,
   4324         v;
   4325     while (++i < n) {
   4326       for (j = m; --j > 0;) {
   4327         if ((v = +ticks[i] - j * d) >= extent[0]) {
   4328           subticks.push(v);
   4329         }
   4330       }
   4331     }
   4332     for (--i, j = 0; ++j < m && (v = +ticks[i] + j * d) < extent[1];) {
   4333       subticks.push(v);
   4334     }
   4335   }
   4336   return subticks;
   4337 }
   4338 d3.svg.brush = function() {
   4339   var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"),
   4340       x = null, // x-scale, optional
   4341       y = null, // y-scale, optional
   4342       resizes = d3_svg_brushResizes[0],
   4343       extent = [[0, 0], [0, 0]], // [x0, y0], [x1, y1], in pixels (integers)
   4344       extentDomain; // the extent in data space, lazily created
   4345 
   4346   function brush(g) {
   4347     g.each(function() {
   4348       var g = d3.select(this),
   4349           bg = g.selectAll(".background").data([0]),
   4350           fg = g.selectAll(".extent").data([0]),
   4351           tz = g.selectAll(".resize").data(resizes, String),
   4352           e;
   4353 
   4354       // Prepare the brush container for events.
   4355       g
   4356           .style("pointer-events", "all")
   4357           .on("mousedown.brush", brushstart)
   4358           .on("touchstart.brush", brushstart);
   4359 
   4360       // An invisible, mouseable area for starting a new brush.
   4361       bg.enter().append("rect")
   4362           .attr("class", "background")
   4363           .style("visibility", "hidden")
   4364           .style("cursor", "crosshair");
   4365 
   4366       // The visible brush extent; style this as you like!
   4367       fg.enter().append("rect")
   4368           .attr("class", "extent")
   4369           .style("cursor", "move");
   4370 
   4371       // More invisible rects for resizing the extent.
   4372       tz.enter().append("g")
   4373           .attr("class", function(d) { return "resize " + d; })
   4374           .style("cursor", function(d) { return d3_svg_brushCursor[d]; })
   4375         .append("rect")
   4376           .attr("x", function(d) { return /[ew]$/.test(d) ? -3 : null; })
   4377           .attr("y", function(d) { return /^[ns]/.test(d) ? -3 : null; })
   4378           .attr("width", 6)
   4379           .attr("height", 6)
   4380           .style("visibility", "hidden");
   4381 
   4382       // Show or hide the resizers.
   4383       tz.style("display", brush.empty() ? "none" : null);
   4384 
   4385       // Remove any superfluous resizers.
   4386       tz.exit().remove();
   4387 
   4388       // Initialize the background to fill the defined range.
   4389       // If the range isn't defined, you can post-process.
   4390       if (x) {
   4391         e = d3_scaleRange(x);
   4392         bg.attr("x", e[0]).attr("width", e[1] - e[0]);
   4393         redrawX(g);
   4394       }
   4395       if (y) {
   4396         e = d3_scaleRange(y);
   4397         bg.attr("y", e[0]).attr("height", e[1] - e[0]);
   4398         redrawY(g);
   4399       }
   4400       redraw(g);
   4401     });
   4402   }
   4403 
   4404   function redraw(g) {
   4405     g.selectAll(".resize").attr("transform", function(d) {
   4406       return "translate(" + extent[+/e$/.test(d)][0] + "," + extent[+/^s/.test(d)][1] + ")";
   4407     });
   4408   }
   4409 
   4410   function redrawX(g) {
   4411     g.select(".extent").attr("x", extent[0][0]);
   4412     g.selectAll(".extent,.n>rect,.s>rect").attr("width", extent[1][0] - extent[0][0]);
   4413   }
   4414 
   4415   function redrawY(g) {
   4416     g.select(".extent").attr("y", extent[0][1]);
   4417     g.selectAll(".extent,.e>rect,.w>rect").attr("height", extent[1][1] - extent[0][1]);
   4418   }
   4419 
   4420   function brushstart() {
   4421     var target = this,
   4422         eventTarget = d3.select(d3.event.target),
   4423         event_ = event.of(target, arguments),
   4424         g = d3.select(target),
   4425         resizing = eventTarget.datum(),
   4426         resizingX = !/^(n|s)$/.test(resizing) && x,
   4427         resizingY = !/^(e|w)$/.test(resizing) && y,
   4428         dragging = eventTarget.classed("extent"),
   4429         center,
   4430         origin = mouse(),
   4431         offset;
   4432 
   4433     var w = d3.select(window)
   4434         .on("mousemove.brush", brushmove)
   4435         .on("mouseup.brush", brushend)
   4436         .on("touchmove.brush", brushmove)
   4437         .on("touchend.brush", brushend)
   4438         .on("keydown.brush", keydown)
   4439         .on("keyup.brush", keyup);
   4440 
   4441     // If the extent was clicked on, drag rather than brush;
   4442     // store the point between the mouse and extent origin instead.
   4443     if (dragging) {
   4444       origin[0] = extent[0][0] - origin[0];
   4445       origin[1] = extent[0][1] - origin[1];
   4446     }
   4447 
   4448     // If a resizer was clicked on, record which side is to be resized.
   4449     // Also, set the origin to the opposite side.
   4450     else if (resizing) {
   4451       var ex = +/w$/.test(resizing),
   4452           ey = +/^n/.test(resizing);
   4453       offset = [extent[1 - ex][0] - origin[0], extent[1 - ey][1] - origin[1]];
   4454       origin[0] = extent[ex][0];
   4455       origin[1] = extent[ey][1];
   4456     }
   4457 
   4458     // If the ALT key is down when starting a brush, the center is at the mouse.
   4459     else if (d3.event.altKey) center = origin.slice();
   4460 
   4461     // Propagate the active cursor to the body for the drag duration.
   4462     g.style("pointer-events", "none").selectAll(".resize").style("display", null);
   4463     d3.select("body").style("cursor", eventTarget.style("cursor"));
   4464 
   4465     // Notify listeners.
   4466     event_({type: "brushstart"});
   4467     brushmove();
   4468     d3_eventCancel();
   4469 
   4470     function mouse() {
   4471       var touches = d3.event.changedTouches;
   4472       return touches ? d3.touches(target, touches)[0] : d3.mouse(target);
   4473     }
   4474 
   4475     function keydown() {
   4476       if (d3.event.keyCode == 32) {
   4477         if (!dragging) {
   4478           center = null;
   4479           origin[0] -= extent[1][0];
   4480           origin[1] -= extent[1][1];
   4481           dragging = 2;
   4482         }
   4483         d3_eventCancel();
   4484       }
   4485     }
   4486 
   4487     function keyup() {
   4488       if (d3.event.keyCode == 32 && dragging == 2) {
   4489         origin[0] += extent[1][0];
   4490         origin[1] += extent[1][1];
   4491         dragging = 0;
   4492         d3_eventCancel();
   4493       }
   4494     }
   4495 
   4496     function brushmove() {
   4497       var point = mouse(),
   4498           moved = false;
   4499 
   4500       // Preserve the offset for thick resizers.
   4501       if (offset) {
   4502         point[0] += offset[0];
   4503         point[1] += offset[1];
   4504       }
   4505 
   4506       if (!dragging) {
   4507 
   4508         // If needed, determine the center from the current extent.
   4509         if (d3.event.altKey) {
   4510           if (!center) center = [(extent[0][0] + extent[1][0]) / 2, (extent[0][1] + extent[1][1]) / 2];
   4511 
   4512           // Update the origin, for when the ALT key is released.
   4513           origin[0] = extent[+(point[0] < center[0])][0];
   4514           origin[1] = extent[+(point[1] < center[1])][1];
   4515         }
   4516 
   4517         // When the ALT key is released, we clear the center.
   4518         else center = null;
   4519       }
   4520 
   4521       // Update the brush extent for each dimension.
   4522       if (resizingX && move1(point, x, 0)) {
   4523         redrawX(g);
   4524         moved = true;
   4525       }
   4526       if (resizingY && move1(point, y, 1)) {
   4527         redrawY(g);
   4528         moved = true;
   4529       }
   4530 
   4531       // Final redraw and notify listeners.
   4532       if (moved) {
   4533         redraw(g);
   4534         event_({type: "brush", mode: dragging ? "move" : "resize"});
   4535       }
   4536     }
   4537 
   4538     function move1(point, scale, i) {
   4539       var range = d3_scaleRange(scale),
   4540           r0 = range[0],
   4541           r1 = range[1],
   4542           position = origin[i],
   4543           size = extent[1][i] - extent[0][i],
   4544           min,
   4545           max;
   4546 
   4547       // When dragging, reduce the range by the extent size and position.
   4548       if (dragging) {
   4549         r0 -= position;
   4550         r1 -= size + position;
   4551       }
   4552 
   4553       // Clamp the point so that the extent fits within the range extent.
   4554       min = Math.max(r0, Math.min(r1, point[i]));
   4555 
   4556       // Compute the new extent bounds.
   4557       if (dragging) {
   4558         max = (min += position) + size;
   4559       } else {
   4560 
   4561         // If the ALT key is pressed, then preserve the center of the extent.
   4562         if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min));
   4563 
   4564         // Compute the min and max of the position and point.
   4565         if (position < min) {
   4566           max = min;
   4567           min = position;
   4568         } else {
   4569           max = position;
   4570         }
   4571       }
   4572 
   4573       // Update the stored bounds.
   4574       if (extent[0][i] !== min || extent[1][i] !== max) {
   4575         extentDomain = null;
   4576         extent[0][i] = min;
   4577         extent[1][i] = max;
   4578         return true;
   4579       }
   4580     }
   4581 
   4582     function brushend() {
   4583       brushmove();
   4584 
   4585       // reset the cursor styles
   4586       g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null);
   4587       d3.select("body").style("cursor", null);
   4588 
   4589       w .on("mousemove.brush", null)
   4590         .on("mouseup.brush", null)
   4591         .on("touchmove.brush", null)
   4592         .on("touchend.brush", null)
   4593         .on("keydown.brush", null)
   4594         .on("keyup.brush", null);
   4595 
   4596       event_({type: "brushend"});
   4597       d3_eventCancel();
   4598     }
   4599   }
   4600 
   4601   brush.x = function(z) {
   4602     if (!arguments.length) return x;
   4603     x = z;
   4604     resizes = d3_svg_brushResizes[!x << 1 | !y]; // fore!
   4605     return brush;
   4606   };
   4607 
   4608   brush.y = function(z) {
   4609     if (!arguments.length) return y;
   4610     y = z;
   4611     resizes = d3_svg_brushResizes[!x << 1 | !y]; // fore!
   4612     return brush;
   4613   };
   4614 
   4615   brush.extent = function(z) {
   4616     var x0, x1, y0, y1, t;
   4617 
   4618     // Invert the pixel extent to data-space.
   4619     if (!arguments.length) {
   4620       z = extentDomain || extent;
   4621       if (x) {
   4622         x0 = z[0][0], x1 = z[1][0];
   4623         if (!extentDomain) {
   4624           x0 = extent[0][0], x1 = extent[1][0];
   4625           if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);
   4626           if (x1 < x0) t = x0, x0 = x1, x1 = t;
   4627         }
   4628       }
   4629       if (y) {
   4630         y0 = z[0][1], y1 = z[1][1];
   4631         if (!extentDomain) {
   4632           y0 = extent[0][1], y1 = extent[1][1];
   4633           if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);
   4634           if (y1 < y0) t = y0, y0 = y1, y1 = t;
   4635         }
   4636       }
   4637       return x && y ? [[x0, y0], [x1, y1]] : x ? [x0, x1] : y && [y0, y1];
   4638     }
   4639 
   4640     // Scale the data-space extent to pixels.
   4641     extentDomain = [[0, 0], [0, 0]];
   4642     if (x) {
   4643       x0 = z[0], x1 = z[1];
   4644       if (y) x0 = x0[0], x1 = x1[0];
   4645       extentDomain[0][0] = x0, extentDomain[1][0] = x1;
   4646       if (x.invert) x0 = x(x0), x1 = x(x1);
   4647       if (x1 < x0) t = x0, x0 = x1, x1 = t;
   4648       extent[0][0] = x0 | 0, extent[1][0] = x1 | 0;
   4649     }
   4650     if (y) {
   4651       y0 = z[0], y1 = z[1];
   4652       if (x) y0 = y0[1], y1 = y1[1];
   4653       extentDomain[0][1] = y0, extentDomain[1][1] = y1;
   4654       if (y.invert) y0 = y(y0), y1 = y(y1);
   4655       if (y1 < y0) t = y0, y0 = y1, y1 = t;
   4656       extent[0][1] = y0 | 0, extent[1][1] = y1 | 0;
   4657     }
   4658 
   4659     return brush;
   4660   };
   4661 
   4662   brush.clear = function() {
   4663     extentDomain = null;
   4664     extent[0][0] =
   4665     extent[0][1] =
   4666     extent[1][0] =
   4667     extent[1][1] = 0;
   4668     return brush;
   4669   };
   4670 
   4671   brush.empty = function() {
   4672     return (x && extent[0][0] === extent[1][0])
   4673         || (y && extent[0][1] === extent[1][1]);
   4674   };
   4675 
   4676   return d3.rebind(brush, event, "on");
   4677 };
   4678 
   4679 var d3_svg_brushCursor = {
   4680   n: "ns-resize",
   4681   e: "ew-resize",
   4682   s: "ns-resize",
   4683   w: "ew-resize",
   4684   nw: "nwse-resize",
   4685   ne: "nesw-resize",
   4686   se: "nwse-resize",
   4687   sw: "nesw-resize"
   4688 };
   4689 
   4690 var d3_svg_brushResizes = [
   4691   ["n", "e", "s", "w", "nw", "ne", "se", "sw"],
   4692   ["e", "w"],
   4693   ["n", "s"],
   4694   []
   4695 ];
   4696 d3.behavior = {};
   4697 // TODO Track touch points by identifier.
   4698 
   4699 d3.behavior.drag = function() {
   4700   var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"),
   4701       origin = null;
   4702 
   4703   function drag() {
   4704     this.on("mousedown.drag", mousedown)
   4705         .on("touchstart.drag", mousedown);
   4706   }
   4707 
   4708   function mousedown() {
   4709     var target = this,
   4710         event_ = event.of(target, arguments),
   4711         eventTarget = d3.event.target,
   4712         offset,
   4713         origin_ = point(),
   4714         moved = 0;
   4715 
   4716     var w = d3.select(window)
   4717         .on("mousemove.drag", dragmove)
   4718         .on("touchmove.drag", dragmove)
   4719         .on("mouseup.drag", dragend, true)
   4720         .on("touchend.drag", dragend, true);
   4721 
   4722     if (origin) {
   4723       offset = origin.apply(target, arguments);
   4724       offset = [offset.x - origin_[0], offset.y - origin_[1]];
   4725     } else {
   4726       offset = [0, 0];
   4727     }
   4728 
   4729     event_({type: "dragstart"});
   4730 
   4731     function point() {
   4732       var p = target.parentNode,
   4733           t = d3.event.changedTouches;
   4734       return t ? d3.touches(p, t)[0] : d3.mouse(p);
   4735     }
   4736 
   4737     function dragmove() {
   4738       if (!target.parentNode) return dragend(); // target removed from DOM
   4739 
   4740       var p = point(),
   4741           dx = p[0] - origin_[0],
   4742           dy = p[1] - origin_[1];
   4743 
   4744       moved |= dx | dy;
   4745       origin_ = p;
   4746       d3_eventCancel();
   4747 
   4748       event_({type: "drag", x: p[0] + offset[0], y: p[1] + offset[1], dx: dx, dy: dy});
   4749     }
   4750 
   4751     function dragend() {
   4752       event_({type: "dragend"});
   4753 
   4754       // if moved, prevent the mouseup (and possibly click) from propagating
   4755       if (moved) {
   4756         d3_eventCancel();
   4757         if (d3.event.target === eventTarget) w.on("click.drag", click, true);
   4758       }
   4759 
   4760       w .on("mousemove.drag", null)
   4761         .on("touchmove.drag", null)
   4762         .on("mouseup.drag", null)
   4763         .on("touchend.drag", null);
   4764     }
   4765 
   4766     // prevent the subsequent click from propagating (e.g., for anchors)
   4767     function click() {
   4768       d3_eventCancel();
   4769       w.on("click.drag", null);
   4770     }
   4771   }
   4772 
   4773   drag.origin = function(x) {
   4774     if (!arguments.length) return origin;
   4775     origin = x;
   4776     return drag;
   4777   };
   4778 
   4779   return d3.rebind(drag, event, "on");
   4780 };
   4781 d3.behavior.zoom = function() {
   4782   var translate = [0, 0],
   4783       translate0, // translate when we started zooming (to avoid drift)
   4784       scale = 1,
   4785       scale0, // scale when we started touching
   4786       scaleExtent = d3_behavior_zoomInfinity,
   4787       event = d3_eventDispatch(zoom, "zoom"),
   4788       x0,
   4789       x1,
   4790       y0,
   4791       y1,
   4792       touchtime; // time of last touchstart (to detect double-tap)
   4793 
   4794   function zoom() {
   4795     this
   4796         .on("mousedown.zoom", mousedown)
   4797         .on("mousewheel.zoom", mousewheel)
   4798         .on("mousemove.zoom", mousemove)
   4799         .on("DOMMouseScroll.zoom", mousewheel)
   4800         .on("dblclick.zoom", dblclick)
   4801         .on("touchstart.zoom", touchstart)
   4802         .on("touchmove.zoom", touchmove)
   4803         .on("touchend.zoom", touchstart);
   4804   }
   4805 
   4806   zoom.translate = function(x) {
   4807     if (!arguments.length) return translate;
   4808     translate = x.map(Number);
   4809     return zoom;
   4810   };
   4811 
   4812   zoom.scale = function(x) {
   4813     if (!arguments.length) return scale;
   4814     scale = +x;
   4815     return zoom;
   4816   };
   4817 
   4818   zoom.scaleExtent = function(x) {
   4819     if (!arguments.length) return scaleExtent;
   4820     scaleExtent = x == null ? d3_behavior_zoomInfinity : x.map(Number);
   4821     return zoom;
   4822   };
   4823 
   4824   zoom.x = function(z) {
   4825     if (!arguments.length) return x1;
   4826     x1 = z;
   4827     x0 = z.copy();
   4828     return zoom;
   4829   };
   4830 
   4831   zoom.y = function(z) {
   4832     if (!arguments.length) return y1;
   4833     y1 = z;
   4834     y0 = z.copy();
   4835     return zoom;
   4836   };
   4837 
   4838   function location(p) {
   4839     return [(p[0] - translate[0]) / scale, (p[1] - translate[1]) / scale];
   4840   }
   4841 
   4842   function point(l) {
   4843     return [l[0] * scale + translate[0], l[1] * scale + translate[1]];
   4844   }
   4845 
   4846   function scaleTo(s) {
   4847     scale = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));
   4848   }
   4849 
   4850   function translateTo(p, l) {
   4851     l = point(l);
   4852     translate[0] += p[0] - l[0];
   4853     translate[1] += p[1] - l[1];
   4854   }
   4855 
   4856   function dispatch(event) {
   4857     if (x1) x1.domain(x0.range().map(function(x) { return (x - translate[0]) / scale; }).map(x0.invert));
   4858     if (y1) y1.domain(y0.range().map(function(y) { return (y - translate[1]) / scale; }).map(y0.invert));
   4859     d3.event.preventDefault();
   4860     event({type: "zoom", scale: scale, translate: translate});
   4861   }
   4862 
   4863   function mousedown() {
   4864     var target = this,
   4865         event_ = event.of(target, arguments),
   4866         eventTarget = d3.event.target,
   4867         moved = 0,
   4868         w = d3.select(window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup),
   4869         l = location(d3.mouse(target));
   4870 
   4871     window.focus();
   4872     d3_eventCancel();
   4873 
   4874     function mousemove() {
   4875       moved = 1;
   4876       translateTo(d3.mouse(target), l);
   4877       dispatch(event_);
   4878     }
   4879 
   4880     function mouseup() {
   4881       if (moved) d3_eventCancel();
   4882       w.on("mousemove.zoom", null).on("mouseup.zoom", null);
   4883       if (moved && d3.event.target === eventTarget) w.on("click.zoom", click);
   4884     }
   4885 
   4886     function click() {
   4887       d3_eventCancel();
   4888       w.on("click.zoom", null);
   4889     }
   4890   }
   4891 
   4892   function mousewheel() {
   4893     if (!translate0) translate0 = location(d3.mouse(this));
   4894     scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * scale);
   4895     translateTo(d3.mouse(this), translate0);
   4896     dispatch(event.of(this, arguments));
   4897   }
   4898 
   4899   function mousemove() {
   4900     translate0 = null;
   4901   }
   4902 
   4903   function dblclick() {
   4904     var p = d3.mouse(this), l = location(p);
   4905     scaleTo(d3.event.shiftKey ? scale / 2 : scale * 2);
   4906     translateTo(p, l);
   4907     dispatch(event.of(this, arguments));
   4908   }
   4909 
   4910   function touchstart() {
   4911     var touches = d3.touches(this),
   4912         now = Date.now();
   4913 
   4914     scale0 = scale;
   4915     translate0 = {};
   4916     touches.forEach(function(t) { translate0[t.identifier] = location(t); });
   4917     d3_eventCancel();
   4918 
   4919     if ((touches.length === 1) && (now - touchtime < 500)) { // dbltap
   4920       var p = touches[0], l = location(touches[0]);
   4921       scaleTo(scale * 2);
   4922       translateTo(p, l);
   4923       dispatch(event.of(this, arguments));
   4924     }
   4925     touchtime = now;
   4926   }
   4927 
   4928   function touchmove() {
   4929     var touches = d3.touches(this),
   4930         p0 = touches[0],
   4931         l0 = translate0[p0.identifier];
   4932     if (p1 = touches[1]) {
   4933       var p1, l1 = translate0[p1.identifier];
   4934       p0 = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2];
   4935       l0 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
   4936       scaleTo(d3.event.scale * scale0);
   4937     }
   4938     translateTo(p0, l0);
   4939     dispatch(event.of(this, arguments));
   4940   }
   4941 
   4942   return d3.rebind(zoom, event, "on");
   4943 };
   4944 
   4945 var d3_behavior_zoomDiv, // for interpreting mousewheel events
   4946     d3_behavior_zoomInfinity = [0, Infinity]; // default scale extent
   4947 
   4948 function d3_behavior_zoomDelta() {
   4949 
   4950   // mousewheel events are totally broken!
   4951   // https://bugs.webkit.org/show_bug.cgi?id=40441
   4952   // not only that, but Chrome and Safari differ in re. to acceleration!
   4953   if (!d3_behavior_zoomDiv) {
   4954     d3_behavior_zoomDiv = d3.select("body").append("div")
   4955         .style("visibility", "hidden")
   4956         .style("top", 0)
   4957         .style("height", 0)
   4958         .style("width", 0)
   4959         .style("overflow-y", "scroll")
   4960       .append("div")
   4961         .style("height", "2000px")
   4962       .node().parentNode;
   4963   }
   4964 
   4965   var e = d3.event, delta;
   4966   try {
   4967     d3_behavior_zoomDiv.scrollTop = 1000;
   4968     d3_behavior_zoomDiv.dispatchEvent(e);
   4969     delta = 1000 - d3_behavior_zoomDiv.scrollTop;
   4970   } catch (error) {
   4971     delta = e.wheelDelta || (-e.detail * 5);
   4972   }
   4973 
   4974   return delta;
   4975 }
   4976 d3.layout = {};
   4977 // Implements hierarchical edge bundling using Holten's algorithm. For each
   4978 // input link, a path is computed that travels through the tree, up the parent
   4979 // hierarchy to the least common ancestor, and then back down to the destination
   4980 // node. Each path is simply an array of nodes.
   4981 d3.layout.bundle = function() {
   4982   return function(links) {
   4983     var paths = [],
   4984         i = -1,
   4985         n = links.length;
   4986     while (++i < n) paths.push(d3_layout_bundlePath(links[i]));
   4987     return paths;
   4988   };
   4989 };
   4990 
   4991 function d3_layout_bundlePath(link) {
   4992   var start = link.source,
   4993       end = link.target,
   4994       lca = d3_layout_bundleLeastCommonAncestor(start, end),
   4995       points = [start];
   4996   while (start !== lca) {
   4997     start = start.parent;
   4998     points.push(start);
   4999   }
   5000   var k = points.length;
   5001   while (end !== lca) {
   5002     points.splice(k, 0, end);
   5003     end = end.parent;
   5004   }
   5005   return points;
   5006 }
   5007 
   5008 function d3_layout_bundleAncestors(node) {
   5009   var ancestors = [],
   5010       parent = node.parent;
   5011   while (parent != null) {
   5012     ancestors.push(node);
   5013     node = parent;
   5014     parent = parent.parent;
   5015   }
   5016   ancestors.push(node);
   5017   return ancestors;
   5018 }
   5019 
   5020 function d3_layout_bundleLeastCommonAncestor(a, b) {
   5021   if (a === b) return a;
   5022   var aNodes = d3_layout_bundleAncestors(a),
   5023       bNodes = d3_layout_bundleAncestors(b),
   5024       aNode = aNodes.pop(),
   5025       bNode = bNodes.pop(),
   5026       sharedNode = null;
   5027   while (aNode === bNode) {
   5028     sharedNode = aNode;
   5029     aNode = aNodes.pop();
   5030     bNode = bNodes.pop();
   5031   }
   5032   return sharedNode;
   5033 }
   5034 d3.layout.chord = function() {
   5035   var chord = {},
   5036       chords,
   5037       groups,
   5038       matrix,
   5039       n,
   5040       padding = 0,
   5041       sortGroups,
   5042       sortSubgroups,
   5043       sortChords;
   5044 
   5045   function relayout() {
   5046     var subgroups = {},
   5047         groupSums = [],
   5048         groupIndex = d3.range(n),
   5049         subgroupIndex = [],
   5050         k,
   5051         x,
   5052         x0,
   5053         i,
   5054         j;
   5055 
   5056     chords = [];
   5057     groups = [];
   5058 
   5059     // Compute the sum.
   5060     k = 0, i = -1; while (++i < n) {
   5061       x = 0, j = -1; while (++j < n) {
   5062         x += matrix[i][j];
   5063       }
   5064       groupSums.push(x);
   5065       subgroupIndex.push(d3.range(n));
   5066       k += x;
   5067     }
   5068 
   5069     // Sort groups…
   5070     if (sortGroups) {
   5071       groupIndex.sort(function(a, b) {
   5072         return sortGroups(groupSums[a], groupSums[b]);
   5073       });
   5074     }
   5075 
   5076     // Sort subgroups…
   5077     if (sortSubgroups) {
   5078       subgroupIndex.forEach(function(d, i) {
   5079         d.sort(function(a, b) {
   5080           return sortSubgroups(matrix[i][a], matrix[i][b]);
   5081         });
   5082       });
   5083     }
   5084 
   5085     // Convert the sum to scaling factor for [0, 2pi].
   5086     // TODO Allow start and end angle to be specified.
   5087     // TODO Allow padding to be specified as percentage?
   5088     k = (2 * Math.PI - padding * n) / k;
   5089 
   5090     // Compute the start and end angle for each group and subgroup.
   5091     // Note: Opera has a bug reordering object literal properties!
   5092     x = 0, i = -1; while (++i < n) {
   5093       x0 = x, j = -1; while (++j < n) {
   5094         var di = groupIndex[i],
   5095             dj = subgroupIndex[di][j],
   5096             v = matrix[di][dj],
   5097             a0 = x,
   5098             a1 = x += v * k;
   5099         subgroups[di + "-" + dj] = {
   5100           index: di,
   5101           subindex: dj,
   5102           startAngle: a0,
   5103           endAngle: a1,
   5104           value: v
   5105         };
   5106       }
   5107       groups.push({
   5108         index: di,
   5109         startAngle: x0,
   5110         endAngle: x,
   5111         value: (x - x0) / k
   5112       });
   5113       x += padding;
   5114     }
   5115 
   5116     // Generate chords for each (non-empty) subgroup-subgroup link.
   5117     i = -1; while (++i < n) {
   5118       j = i - 1; while (++j < n) {
   5119         var source = subgroups[i + "-" + j],
   5120             target = subgroups[j + "-" + i];
   5121         if (source.value || target.value) {
   5122           chords.push(source.value < target.value
   5123               ? {source: target, target: source}
   5124               : {source: source, target: target});
   5125         }
   5126       }
   5127     }
   5128 
   5129     if (sortChords) resort();
   5130   }
   5131 
   5132   function resort() {
   5133     chords.sort(function(a, b) {
   5134       return sortChords(
   5135           (a.source.value + a.target.value) / 2,
   5136           (b.source.value + b.target.value) / 2);
   5137     });
   5138   }
   5139 
   5140   chord.matrix = function(x) {
   5141     if (!arguments.length) return matrix;
   5142     n = (matrix = x) && matrix.length;
   5143     chords = groups = null;
   5144     return chord;
   5145   };
   5146 
   5147   chord.padding = function(x) {
   5148     if (!arguments.length) return padding;
   5149     padding = x;
   5150     chords = groups = null;
   5151     return chord;
   5152   };
   5153 
   5154   chord.sortGroups = function(x) {
   5155     if (!arguments.length) return sortGroups;
   5156     sortGroups = x;
   5157     chords = groups = null;
   5158     return chord;
   5159   };
   5160 
   5161   chord.sortSubgroups = function(x) {
   5162     if (!arguments.length) return sortSubgroups;
   5163     sortSubgroups = x;
   5164     chords = null;
   5165     return chord;
   5166   };
   5167 
   5168   chord.sortChords = function(x) {
   5169     if (!arguments.length) return sortChords;
   5170     sortChords = x;
   5171     if (chords) resort();
   5172     return chord;
   5173   };
   5174 
   5175   chord.chords = function() {
   5176     if (!chords) relayout();
   5177     return chords;
   5178   };
   5179 
   5180   chord.groups = function() {
   5181     if (!groups) relayout();
   5182     return groups;
   5183   };
   5184 
   5185   return chord;
   5186 };
   5187 // A rudimentary force layout using Gauss-Seidel.
   5188 d3.layout.force = function() {
   5189   var force = {},
   5190       event = d3.dispatch("start", "tick", "end"),
   5191       size = [1, 1],
   5192       drag,
   5193       alpha,
   5194       friction = .9,
   5195       linkDistance = d3_layout_forceLinkDistance,
   5196       linkStrength = d3_layout_forceLinkStrength,
   5197       charge = -30,
   5198       gravity = .1,
   5199       theta = .8,
   5200       interval,
   5201       nodes = [],
   5202       links = [],
   5203       distances,
   5204       strengths,
   5205       charges;
   5206 
   5207   function repulse(node) {
   5208     return function(quad, x1, y1, x2, y2) {
   5209       if (quad.point !== node) {
   5210         var dx = quad.cx - node.x,
   5211             dy = quad.cy - node.y,
   5212             dn = 1 / Math.sqrt(dx * dx + dy * dy);
   5213 
   5214         /* Barnes-Hut criterion. */
   5215         if ((x2 - x1) * dn < theta) {
   5216           var k = quad.charge * dn * dn;
   5217           node.px -= dx * k;
   5218           node.py -= dy * k;
   5219           return true;
   5220         }
   5221 
   5222         if (quad.point && isFinite(dn)) {
   5223           var k = quad.pointCharge * dn * dn;
   5224           node.px -= dx * k;
   5225           node.py -= dy * k;
   5226         }
   5227       }
   5228       return !quad.charge;
   5229     };
   5230   }
   5231 
   5232   force.tick = function() {
   5233     // simulated annealing, basically
   5234     if ((alpha *= .99) < .005) {
   5235       event.end({type: "end", alpha: alpha = 0});
   5236       return true;
   5237     }
   5238 
   5239     var n = nodes.length,
   5240         m = links.length,
   5241         q,
   5242         i, // current index
   5243         o, // current object
   5244         s, // current source
   5245         t, // current target
   5246         l, // current distance
   5247         k, // current force
   5248         x, // x-distance
   5249         y; // y-distance
   5250 
   5251     // gauss-seidel relaxation for links
   5252     for (i = 0; i < m; ++i) {
   5253       o = links[i];
   5254       s = o.source;
   5255       t = o.target;
   5256       x = t.x - s.x;
   5257       y = t.y - s.y;
   5258       if (l = (x * x + y * y)) {
   5259         l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;
   5260         x *= l;
   5261         y *= l;
   5262         t.x -= x * (k = s.weight / (t.weight + s.weight));
   5263         t.y -= y * k;
   5264         s.x += x * (k = 1 - k);
   5265         s.y += y * k;
   5266       }
   5267     }
   5268 
   5269     // apply gravity forces
   5270     if (k = alpha * gravity) {
   5271       x = size[0] / 2;
   5272       y = size[1] / 2;
   5273       i = -1; if (k) while (++i < n) {
   5274         o = nodes[i];
   5275         o.x += (x - o.x) * k;
   5276         o.y += (y - o.y) * k;
   5277       }
   5278     }
   5279 
   5280     // compute quadtree center of mass and apply charge forces
   5281     if (charge) {
   5282       d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges);
   5283       i = -1; while (++i < n) {
   5284         if (!(o = nodes[i]).fixed) {
   5285           q.visit(repulse(o));
   5286         }
   5287       }
   5288     }
   5289 
   5290     // position verlet integration
   5291     i = -1; while (++i < n) {
   5292       o = nodes[i];
   5293       if (o.fixed) {
   5294         o.x = o.px;
   5295         o.y = o.py;
   5296       } else {
   5297         o.x -= (o.px - (o.px = o.x)) * friction;
   5298         o.y -= (o.py - (o.py = o.y)) * friction;
   5299       }
   5300     }
   5301 
   5302     event.tick({type: "tick", alpha: alpha});
   5303   };
   5304 
   5305   force.nodes = function(x) {
   5306     if (!arguments.length) return nodes;
   5307     nodes = x;
   5308     return force;
   5309   };
   5310 
   5311   force.links = function(x) {
   5312     if (!arguments.length) return links;
   5313     links = x;
   5314     return force;
   5315   };
   5316 
   5317   force.size = function(x) {
   5318     if (!arguments.length) return size;
   5319     size = x;
   5320     return force;
   5321   };
   5322 
   5323   force.linkDistance = function(x) {
   5324     if (!arguments.length) return linkDistance;
   5325     linkDistance = d3.functor(x);
   5326     return force;
   5327   };
   5328 
   5329   // For backwards-compatibility.
   5330   force.distance = force.linkDistance;
   5331 
   5332   force.linkStrength = function(x) {
   5333     if (!arguments.length) return linkStrength;
   5334     linkStrength = d3.functor(x);
   5335     return force;
   5336   };
   5337 
   5338   force.friction = function(x) {
   5339     if (!arguments.length) return friction;
   5340     friction = x;
   5341     return force;
   5342   };
   5343 
   5344   force.charge = function(x) {
   5345     if (!arguments.length) return charge;
   5346     charge = typeof x === "function" ? x : +x;
   5347     return force;
   5348   };
   5349 
   5350   force.gravity = function(x) {
   5351     if (!arguments.length) return gravity;
   5352     gravity = x;
   5353     return force;
   5354   };
   5355 
   5356   force.theta = function(x) {
   5357     if (!arguments.length) return theta;
   5358     theta = x;
   5359     return force;
   5360   };
   5361 
   5362   force.alpha = function(x) {
   5363     if (!arguments.length) return alpha;
   5364 
   5365     if (alpha) { // if we're already running
   5366       if (x > 0) alpha = x; // we might keep it hot
   5367       else alpha = 0; // or, next tick will dispatch "end"
   5368     } else if (x > 0) { // otherwise, fire it up!
   5369       event.start({type: "start", alpha: alpha = x});
   5370       d3.timer(force.tick);
   5371     }
   5372 
   5373     return force;
   5374   };
   5375 
   5376   force.start = function() {
   5377     var i,
   5378         j,
   5379         n = nodes.length,
   5380         m = links.length,
   5381         w = size[0],
   5382         h = size[1],
   5383         neighbors,
   5384         o;
   5385 
   5386     for (i = 0; i < n; ++i) {
   5387       (o = nodes[i]).index = i;
   5388       o.weight = 0;
   5389     }
   5390 
   5391     distances = [];
   5392     strengths = [];
   5393     for (i = 0; i < m; ++i) {
   5394       o = links[i];
   5395       if (typeof o.source == "number") o.source = nodes[o.source];
   5396       if (typeof o.target == "number") o.target = nodes[o.target];
   5397       distances[i] = linkDistance.call(this, o, i);
   5398       strengths[i] = linkStrength.call(this, o, i);
   5399       ++o.source.weight;
   5400       ++o.target.weight;
   5401     }
   5402 
   5403     for (i = 0; i < n; ++i) {
   5404       o = nodes[i];
   5405       if (isNaN(o.x)) o.x = position("x", w);
   5406       if (isNaN(o.y)) o.y = position("y", h);
   5407       if (isNaN(o.px)) o.px = o.x;
   5408       if (isNaN(o.py)) o.py = o.y;
   5409     }
   5410 
   5411     charges = [];
   5412     if (typeof charge === "function") {
   5413       for (i = 0; i < n; ++i) {
   5414         charges[i] = +charge.call(this, nodes[i], i);
   5415       }
   5416     } else {
   5417       for (i = 0; i < n; ++i) {
   5418         charges[i] = charge;
   5419       }
   5420     }
   5421 
   5422     // initialize node position based on first neighbor
   5423     function position(dimension, size) {
   5424       var neighbors = neighbor(i),
   5425           j = -1,
   5426           m = neighbors.length,
   5427           x;
   5428       while (++j < m) if (!isNaN(x = neighbors[j][dimension])) return x;
   5429       return Math.random() * size;
   5430     }
   5431 
   5432     // initialize neighbors lazily
   5433     function neighbor() {
   5434       if (!neighbors) {
   5435         neighbors = [];
   5436         for (j = 0; j < n; ++j) {
   5437           neighbors[j] = [];
   5438         }
   5439         for (j = 0; j < m; ++j) {
   5440           var o = links[j];
   5441           neighbors[o.source.index].push(o.target);
   5442           neighbors[o.target.index].push(o.source);
   5443         }
   5444       }
   5445       return neighbors[i];
   5446     }
   5447 
   5448     return force.resume();
   5449   };
   5450 
   5451   force.resume = function() {
   5452     return force.alpha(.1);
   5453   };
   5454 
   5455   force.stop = function() {
   5456     return force.alpha(0);
   5457   };
   5458 
   5459   // use `node.call(force.drag)` to make nodes draggable
   5460   force.drag = function() {
   5461     if (!drag) drag = d3.behavior.drag()
   5462         .origin(Object)
   5463         .on("dragstart", dragstart)
   5464         .on("drag", d3_layout_forceDrag)
   5465         .on("dragend", d3_layout_forceDragEnd);
   5466 
   5467     this.on("mouseover.force", d3_layout_forceDragOver)
   5468         .on("mouseout.force", d3_layout_forceDragOut)
   5469         .call(drag);
   5470   };
   5471 
   5472   function dragstart(d) {
   5473     d3_layout_forceDragOver(d3_layout_forceDragNode = d);
   5474     d3_layout_forceDragForce = force;
   5475   }
   5476 
   5477   return d3.rebind(force, event, "on");
   5478 };
   5479 
   5480 var d3_layout_forceDragForce,
   5481     d3_layout_forceDragNode;
   5482 
   5483 function d3_layout_forceDragOver(d) {
   5484   d.fixed |= 2;
   5485 }
   5486 
   5487 function d3_layout_forceDragOut(d) {
   5488   if (d !== d3_layout_forceDragNode) d.fixed &= 1;
   5489 }
   5490 
   5491 function d3_layout_forceDragEnd() {
   5492   d3_layout_forceDragNode.fixed &= 1;
   5493   d3_layout_forceDragForce = d3_layout_forceDragNode = null;
   5494 }
   5495 
   5496 function d3_layout_forceDrag() {
   5497   d3_layout_forceDragNode.px = d3.event.x;
   5498   d3_layout_forceDragNode.py = d3.event.y;
   5499   d3_layout_forceDragForce.resume(); // restart annealing
   5500 }
   5501 
   5502 function d3_layout_forceAccumulate(quad, alpha, charges) {
   5503   var cx = 0,
   5504       cy = 0;
   5505   quad.charge = 0;
   5506   if (!quad.leaf) {
   5507     var nodes = quad.nodes,
   5508         n = nodes.length,
   5509         i = -1,
   5510         c;
   5511     while (++i < n) {
   5512       c = nodes[i];
   5513       if (c == null) continue;
   5514       d3_layout_forceAccumulate(c, alpha, charges);
   5515       quad.charge += c.charge;
   5516       cx += c.charge * c.cx;
   5517       cy += c.charge * c.cy;
   5518     }
   5519   }
   5520   if (quad.point) {
   5521     // jitter internal nodes that are coincident
   5522     if (!quad.leaf) {
   5523       quad.point.x += Math.random() - .5;
   5524       quad.point.y += Math.random() - .5;
   5525     }
   5526     var k = alpha * charges[quad.point.index];
   5527     quad.charge += quad.pointCharge = k;
   5528     cx += k * quad.point.x;
   5529     cy += k * quad.point.y;
   5530   }
   5531   quad.cx = cx / quad.charge;
   5532   quad.cy = cy / quad.charge;
   5533 }
   5534 
   5535 function d3_layout_forceLinkDistance(link) {
   5536   return 20;
   5537 }
   5538 
   5539 function d3_layout_forceLinkStrength(link) {
   5540   return 1;
   5541 }
   5542 d3.layout.partition = function() {
   5543   var hierarchy = d3.layout.hierarchy(),
   5544       size = [1, 1]; // width, height
   5545 
   5546   function position(node, x, dx, dy) {
   5547     var children = node.children;
   5548     node.x = x;
   5549     node.y = node.depth * dy;
   5550     node.dx = dx;
   5551     node.dy = dy;
   5552     if (children && (n = children.length)) {
   5553       var i = -1,
   5554           n,
   5555           c,
   5556           d;
   5557       dx = node.value ? dx / node.value : 0;
   5558       while (++i < n) {
   5559         position(c = children[i], x, d = c.value * dx, dy);
   5560         x += d;
   5561       }
   5562     }
   5563   }
   5564 
   5565   function depth(node) {
   5566     var children = node.children,
   5567         d = 0;
   5568     if (children && (n = children.length)) {
   5569       var i = -1,
   5570           n;
   5571       while (++i < n) d = Math.max(d, depth(children[i]));
   5572     }
   5573     return 1 + d;
   5574   }
   5575 
   5576   function partition(d, i) {
   5577     var nodes = hierarchy.call(this, d, i);
   5578     position(nodes[0], 0, size[0], size[1] / depth(nodes[0]));
   5579     return nodes;
   5580   }
   5581 
   5582   partition.size = function(x) {
   5583     if (!arguments.length) return size;
   5584     size = x;
   5585     return partition;
   5586   };
   5587 
   5588   return d3_layout_hierarchyRebind(partition, hierarchy);
   5589 };
   5590 d3.layout.pie = function() {
   5591   var value = Number,
   5592       sort = d3_layout_pieSortByValue,
   5593       startAngle = 0,
   5594       endAngle = 2 * Math.PI;
   5595 
   5596   function pie(data, i) {
   5597 
   5598     // Compute the numeric values for each data element.
   5599     var values = data.map(function(d, i) { return +value.call(pie, d, i); });
   5600 
   5601     // Compute the start angle.
   5602     var a = +(typeof startAngle === "function"
   5603         ? startAngle.apply(this, arguments)
   5604         : startAngle);
   5605 
   5606     // Compute the angular scale factor: from value to radians.
   5607     var k = ((typeof endAngle === "function"
   5608         ? endAngle.apply(this, arguments)
   5609         : endAngle) - startAngle)
   5610         / d3.sum(values);
   5611 
   5612     // Optionally sort the data.
   5613     var index = d3.range(data.length);
   5614     if (sort != null) index.sort(sort === d3_layout_pieSortByValue
   5615         ? function(i, j) { return values[j] - values[i]; }
   5616         : function(i, j) { return sort(data[i], data[j]); });
   5617 
   5618     // Compute the arcs!
   5619     // They are stored in the original data's order.
   5620     var arcs = [];
   5621     index.forEach(function(i) {
   5622       arcs[i] = {
   5623         data: data[i],
   5624         value: d = values[i],
   5625         startAngle: a,
   5626         endAngle: a += d * k
   5627       };
   5628     });
   5629     return arcs;
   5630   }
   5631 
   5632   /**
   5633    * Specifies the value function *x*, which returns a nonnegative numeric value
   5634    * for each datum. The default value function is `Number`. The value function
   5635    * is passed two arguments: the current datum and the current index.
   5636    */
   5637   pie.value = function(x) {
   5638     if (!arguments.length) return value;
   5639     value = x;
   5640     return pie;
   5641   };
   5642 
   5643   /**
   5644    * Specifies a sort comparison operator *x*. The comparator is passed two data
   5645    * elements from the data array, a and b; it returns a negative value if a is
   5646    * less than b, a positive value if a is greater than b, and zero if a equals
   5647    * b.
   5648    */
   5649   pie.sort = function(x) {
   5650     if (!arguments.length) return sort;
   5651     sort = x;
   5652     return pie;
   5653   };
   5654 
   5655   /**
   5656    * Specifies the overall start angle of the pie chart. Defaults to 0. The
   5657    * start angle can be specified either as a constant or as a function; in the
   5658    * case of a function, it is evaluated once per array (as opposed to per
   5659    * element).
   5660    */
   5661   pie.startAngle = function(x) {
   5662     if (!arguments.length) return startAngle;
   5663     startAngle = x;
   5664     return pie;
   5665   };
   5666 
   5667   /**
   5668    * Specifies the overall end angle of the pie chart. Defaults to 2π. The
   5669    * end angle can be specified either as a constant or as a function; in the
   5670    * case of a function, it is evaluated once per array (as opposed to per
   5671    * element).
   5672    */
   5673   pie.endAngle = function(x) {
   5674     if (!arguments.length) return endAngle;
   5675     endAngle = x;
   5676     return pie;
   5677   };
   5678 
   5679   return pie;
   5680 };
   5681 
   5682 var d3_layout_pieSortByValue = {};
   5683 // data is two-dimensional array of x,y; we populate y0
   5684 d3.layout.stack = function() {
   5685   var values = Object,
   5686       order = d3_layout_stackOrderDefault,
   5687       offset = d3_layout_stackOffsetZero,
   5688       out = d3_layout_stackOut,
   5689       x = d3_layout_stackX,
   5690       y = d3_layout_stackY;
   5691 
   5692   function stack(data, index) {
   5693 
   5694     // Convert series to canonical two-dimensional representation.
   5695     var series = data.map(function(d, i) {
   5696       return values.call(stack, d, i);
   5697     });
   5698 
   5699     // Convert each series to canonical [[x,y]] representation.
   5700     var points = series.map(function(d, i) {
   5701       return d.map(function(v, i) {
   5702         return [x.call(stack, v, i), y.call(stack, v, i)];
   5703       });
   5704     });
   5705 
   5706     // Compute the order of series, and permute them.
   5707     var orders = order.call(stack, points, index);
   5708     series = d3.permute(series, orders);
   5709     points = d3.permute(points, orders);
   5710 
   5711     // Compute the baseline…
   5712     var offsets = offset.call(stack, points, index);
   5713 
   5714     // And propagate it to other series.
   5715     var n = series.length,
   5716         m = series[0].length,
   5717         i,
   5718         j,
   5719         o;
   5720     for (j = 0; j < m; ++j) {
   5721       out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);
   5722       for (i = 1; i < n; ++i) {
   5723         out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]);
   5724       }
   5725     }
   5726 
   5727     return data;
   5728   }
   5729 
   5730   stack.values = function(x) {
   5731     if (!arguments.length) return values;
   5732     values = x;
   5733     return stack;
   5734   };
   5735 
   5736   stack.order = function(x) {
   5737     if (!arguments.length) return order;
   5738     order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault;
   5739     return stack;
   5740   };
   5741 
   5742   stack.offset = function(x) {
   5743     if (!arguments.length) return offset;
   5744     offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero;
   5745     return stack;
   5746   };
   5747 
   5748   stack.x = function(z) {
   5749     if (!arguments.length) return x;
   5750     x = z;
   5751     return stack;
   5752   };
   5753 
   5754   stack.y = function(z) {
   5755     if (!arguments.length) return y;
   5756     y = z;
   5757     return stack;
   5758   };
   5759 
   5760   stack.out = function(z) {
   5761     if (!arguments.length) return out;
   5762     out = z;
   5763     return stack;
   5764   };
   5765 
   5766   return stack;
   5767 }
   5768 
   5769 function d3_layout_stackX(d) {
   5770   return d.x;
   5771 }
   5772 
   5773 function d3_layout_stackY(d) {
   5774   return d.y;
   5775 }
   5776 
   5777 function d3_layout_stackOut(d, y0, y) {
   5778   d.y0 = y0;
   5779   d.y = y;
   5780 }
   5781 
   5782 var d3_layout_stackOrders = d3.map({
   5783 
   5784   "inside-out": function(data) {
   5785     var n = data.length,
   5786         i,
   5787         j,
   5788         max = data.map(d3_layout_stackMaxIndex),
   5789         sums = data.map(d3_layout_stackReduceSum),
   5790         index = d3.range(n).sort(function(a, b) { return max[a] - max[b]; }),
   5791         top = 0,
   5792         bottom = 0,
   5793         tops = [],
   5794         bottoms = [];
   5795     for (i = 0; i < n; ++i) {
   5796       j = index[i];
   5797       if (top < bottom) {
   5798         top += sums[j];
   5799         tops.push(j);
   5800       } else {
   5801         bottom += sums[j];
   5802         bottoms.push(j);
   5803       }
   5804     }
   5805     return bottoms.reverse().concat(tops);
   5806   },
   5807 
   5808   "reverse": function(data) {
   5809     return d3.range(data.length).reverse();
   5810   },
   5811 
   5812   "default": d3_layout_stackOrderDefault
   5813 
   5814 });
   5815 
   5816 var d3_layout_stackOffsets = d3.map({
   5817 
   5818   "silhouette": function(data) {
   5819     var n = data.length,
   5820         m = data[0].length,
   5821         sums = [],
   5822         max = 0,
   5823         i,
   5824         j,
   5825         o,
   5826         y0 = [];
   5827     for (j = 0; j < m; ++j) {
   5828       for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
   5829       if (o > max) max = o;
   5830       sums.push(o);
   5831     }
   5832     for (j = 0; j < m; ++j) {
   5833       y0[j] = (max - sums[j]) / 2;
   5834     }
   5835     return y0;
   5836   },
   5837 
   5838   "wiggle": function(data) {
   5839     var n = data.length,
   5840         x = data[0],
   5841         m = x.length,
   5842         max = 0,
   5843         i,
   5844         j,
   5845         k,
   5846         s1,
   5847         s2,
   5848         s3,
   5849         dx,
   5850         o,
   5851         o0,
   5852         y0 = [];
   5853     y0[0] = o = o0 = 0;
   5854     for (j = 1; j < m; ++j) {
   5855       for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1];
   5856       for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) {
   5857         for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) {
   5858           s3 += (data[k][j][1] - data[k][j - 1][1]) / dx;
   5859         }
   5860         s2 += s3 * data[i][j][1];
   5861       }
   5862       y0[j] = o -= s1 ? s2 / s1 * dx : 0;
   5863       if (o < o0) o0 = o;
   5864     }
   5865     for (j = 0; j < m; ++j) y0[j] -= o0;
   5866     return y0;
   5867   },
   5868 
   5869   "expand": function(data) {
   5870     var n = data.length,
   5871         m = data[0].length,
   5872         k = 1 / n,
   5873         i,
   5874         j,
   5875         o,
   5876         y0 = [];
   5877     for (j = 0; j < m; ++j) {
   5878       for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
   5879       if (o) for (i = 0; i < n; i++) data[i][j][1] /= o;
   5880       else for (i = 0; i < n; i++) data[i][j][1] = k;
   5881     }
   5882     for (j = 0; j < m; ++j) y0[j] = 0;
   5883     return y0;
   5884   },
   5885 
   5886   "zero": d3_layout_stackOffsetZero
   5887 
   5888 });
   5889 
   5890 function d3_layout_stackOrderDefault(data) {
   5891   return d3.range(data.length);
   5892 }
   5893 
   5894 function d3_layout_stackOffsetZero(data) {
   5895   var j = -1,
   5896       m = data[0].length,
   5897       y0 = [];
   5898   while (++j < m) y0[j] = 0;
   5899   return y0;
   5900 }
   5901 
   5902 function d3_layout_stackMaxIndex(array) {
   5903   var i = 1,
   5904       j = 0,
   5905       v = array[0][1],
   5906       k,
   5907       n = array.length;
   5908   for (; i < n; ++i) {
   5909     if ((k = array[i][1]) > v) {
   5910       j = i;
   5911       v = k;
   5912     }
   5913   }
   5914   return j;
   5915 }
   5916 
   5917 function d3_layout_stackReduceSum(d) {
   5918   return d.reduce(d3_layout_stackSum, 0);
   5919 }
   5920 
   5921 function d3_layout_stackSum(p, d) {
   5922   return p + d[1];
   5923 }
   5924 d3.layout.histogram = function() {
   5925   var frequency = true,
   5926       valuer = Number,
   5927       ranger = d3_layout_histogramRange,
   5928       binner = d3_layout_histogramBinSturges;
   5929 
   5930   function histogram(data, i) {
   5931     var bins = [],
   5932         values = data.map(valuer, this),
   5933         range = ranger.call(this, values, i),
   5934         thresholds = binner.call(this, range, values, i),
   5935         bin,
   5936         i = -1,
   5937         n = values.length,
   5938         m = thresholds.length - 1,
   5939         k = frequency ? 1 : 1 / n,
   5940         x;
   5941 
   5942     // Initialize the bins.
   5943     while (++i < m) {
   5944       bin = bins[i] = [];
   5945       bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);
   5946       bin.y = 0;
   5947     }
   5948 
   5949     // Fill the bins, ignoring values outside the range.
   5950     i = -1; while(++i < n) {
   5951       x = values[i];
   5952       if ((x >= range[0]) && (x <= range[1])) {
   5953         bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
   5954         bin.y += k;
   5955         bin.push(data[i]);
   5956       }
   5957     }
   5958 
   5959     return bins;
   5960   }
   5961 
   5962   // Specifies how to extract a value from the associated data. The default
   5963   // value function is `Number`, which is equivalent to the identity function.
   5964   histogram.value = function(x) {
   5965     if (!arguments.length) return valuer;
   5966     valuer = x;
   5967     return histogram;
   5968   };
   5969 
   5970   // Specifies the range of the histogram. Values outside the specified range
   5971   // will be ignored. The argument `x` may be specified either as a two-element
   5972   // array representing the minimum and maximum value of the range, or as a
   5973   // function that returns the range given the array of values and the current
   5974   // index `i`. The default range is the extent (minimum and maximum) of the
   5975   // values.
   5976   histogram.range = function(x) {
   5977     if (!arguments.length) return ranger;
   5978     ranger = d3.functor(x);
   5979     return histogram;
   5980   };
   5981 
   5982   // Specifies how to bin values in the histogram. The argument `x` may be
   5983   // specified as a number, in which case the range of values will be split
   5984   // uniformly into the given number of bins. Or, `x` may be an array of
   5985   // threshold values, defining the bins; the specified array must contain the
   5986   // rightmost (upper) value, thus specifying n + 1 values for n bins. Or, `x`
   5987   // may be a function which is evaluated, being passed the range, the array of
   5988   // values, and the current index `i`, returning an array of thresholds. The
   5989   // default bin function will divide the values into uniform bins using
   5990   // Sturges' formula.
   5991   histogram.bins = function(x) {
   5992     if (!arguments.length) return binner;
   5993     binner = typeof x === "number"
   5994         ? function(range) { return d3_layout_histogramBinFixed(range, x); }
   5995         : d3.functor(x);
   5996     return histogram;
   5997   };
   5998 
   5999   // Specifies whether the histogram's `y` value is a count (frequency) or a
   6000   // probability (density). The default value is true.
   6001   histogram.frequency = function(x) {
   6002     if (!arguments.length) return frequency;
   6003     frequency = !!x;
   6004     return histogram;
   6005   };
   6006 
   6007   return histogram;
   6008 };
   6009 
   6010 function d3_layout_histogramBinSturges(range, values) {
   6011   return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));
   6012 }
   6013 
   6014 function d3_layout_histogramBinFixed(range, n) {
   6015   var x = -1,
   6016       b = +range[0],
   6017       m = (range[1] - b) / n,
   6018       f = [];
   6019   while (++x <= n) f[x] = m * x + b;
   6020   return f;
   6021 }
   6022 
   6023 function d3_layout_histogramRange(values) {
   6024   return [d3.min(values), d3.max(values)];
   6025 }
   6026 d3.layout.hierarchy = function() {
   6027   var sort = d3_layout_hierarchySort,
   6028       children = d3_layout_hierarchyChildren,
   6029       value = d3_layout_hierarchyValue;
   6030 
   6031   // Recursively compute the node depth and value.
   6032   // Also converts the data representation into a standard hierarchy structure.
   6033   function recurse(data, depth, nodes) {
   6034     var childs = children.call(hierarchy, data, depth),
   6035         node = d3_layout_hierarchyInline ? data : {data: data};
   6036     node.depth = depth;
   6037     nodes.push(node);
   6038     if (childs && (n = childs.length)) {
   6039       var i = -1,
   6040           n,
   6041           c = node.children = [],
   6042           v = 0,
   6043           j = depth + 1;
   6044       while (++i < n) {
   6045         d = recurse(childs[i], j, nodes);
   6046         d.parent = node;
   6047         c.push(d);
   6048         v += d.value;
   6049       }
   6050       if (sort) c.sort(sort);
   6051       if (value) node.value = v;
   6052     } else if (value) {
   6053       node.value = +value.call(hierarchy, data, depth) || 0;
   6054     }
   6055     return node;
   6056   }
   6057 
   6058   // Recursively re-evaluates the node value.
   6059   function revalue(node, depth) {
   6060     var children = node.children,
   6061         v = 0;
   6062     if (children && (n = children.length)) {
   6063       var i = -1,
   6064           n,
   6065           j = depth + 1;
   6066       while (++i < n) v += revalue(children[i], j);
   6067     } else if (value) {
   6068       v = +value.call(hierarchy, d3_layout_hierarchyInline ? node : node.data, depth) || 0;
   6069     }
   6070     if (value) node.value = v;
   6071     return v;
   6072   }
   6073 
   6074   function hierarchy(d) {
   6075     var nodes = [];
   6076     recurse(d, 0, nodes);
   6077     return nodes;
   6078   }
   6079 
   6080   hierarchy.sort = function(x) {
   6081     if (!arguments.length) return sort;
   6082     sort = x;
   6083     return hierarchy;
   6084   };
   6085 
   6086   hierarchy.children = function(x) {
   6087     if (!arguments.length) return children;
   6088     children = x;
   6089     return hierarchy;
   6090   };
   6091 
   6092   hierarchy.value = function(x) {
   6093     if (!arguments.length) return value;
   6094     value = x;
   6095     return hierarchy;
   6096   };
   6097 
   6098   // Re-evaluates the `value` property for the specified hierarchy.
   6099   hierarchy.revalue = function(root) {
   6100     revalue(root, 0);
   6101     return root;
   6102   };
   6103 
   6104   return hierarchy;
   6105 };
   6106 
   6107 // A method assignment helper for hierarchy subclasses.
   6108 function d3_layout_hierarchyRebind(object, hierarchy) {
   6109   d3.rebind(object, hierarchy, "sort", "children", "value");
   6110 
   6111   // Add an alias for links, for convenience.
   6112   object.links = d3_layout_hierarchyLinks;
   6113 
   6114   // If the new API is used, enabling inlining.
   6115   object.nodes = function(d) {
   6116     d3_layout_hierarchyInline = true;
   6117     return (object.nodes = object)(d);
   6118   };
   6119 
   6120   return object;
   6121 }
   6122 
   6123 function d3_layout_hierarchyChildren(d) {
   6124   return d.children;
   6125 }
   6126 
   6127 function d3_layout_hierarchyValue(d) {
   6128   return d.value;
   6129 }
   6130 
   6131 function d3_layout_hierarchySort(a, b) {
   6132   return b.value - a.value;
   6133 }
   6134 
   6135 // Returns an array source+target objects for the specified nodes.
   6136 function d3_layout_hierarchyLinks(nodes) {
   6137   return d3.merge(nodes.map(function(parent) {
   6138     return (parent.children || []).map(function(child) {
   6139       return {source: parent, target: child};
   6140     });
   6141   }));
   6142 }
   6143 
   6144 // For backwards-compatibility, don't enable inlining by default.
   6145 var d3_layout_hierarchyInline = false;
   6146 d3.layout.pack = function() {
   6147   var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort),
   6148       size = [1, 1];
   6149 
   6150   function pack(d, i) {
   6151     var nodes = hierarchy.call(this, d, i),
   6152         root = nodes[0];
   6153 
   6154     // Recursively compute the layout.
   6155     root.x = 0;
   6156     root.y = 0;
   6157     d3_layout_packTree(root);
   6158 
   6159     // Scale the layout to fit the requested size.
   6160     var w = size[0],
   6161         h = size[1],
   6162         k = 1 / Math.max(2 * root.r / w, 2 * root.r / h);
   6163     d3_layout_packTransform(root, w / 2, h / 2, k);
   6164 
   6165     return nodes;
   6166   }
   6167 
   6168   pack.size = function(x) {
   6169     if (!arguments.length) return size;
   6170     size = x;
   6171     return pack;
   6172   };
   6173 
   6174   return d3_layout_hierarchyRebind(pack, hierarchy);
   6175 };
   6176 
   6177 function d3_layout_packSort(a, b) {
   6178   return a.value - b.value;
   6179 }
   6180 
   6181 function d3_layout_packInsert(a, b) {
   6182   var c = a._pack_next;
   6183   a._pack_next = b;
   6184   b._pack_prev = a;
   6185   b._pack_next = c;
   6186   c._pack_prev = b;
   6187 }
   6188 
   6189 function d3_layout_packSplice(a, b) {
   6190   a._pack_next = b;
   6191   b._pack_prev = a;
   6192 }
   6193 
   6194 function d3_layout_packIntersects(a, b) {
   6195   var dx = b.x - a.x,
   6196       dy = b.y - a.y,
   6197       dr = a.r + b.r;
   6198   return dr * dr - dx * dx - dy * dy > .001; // within epsilon
   6199 }
   6200 
   6201 function d3_layout_packCircle(nodes) {
   6202   var xMin = Infinity,
   6203       xMax = -Infinity,
   6204       yMin = Infinity,
   6205       yMax = -Infinity,
   6206       n = nodes.length,
   6207       a, b, c, j, k;
   6208 
   6209   function bound(node) {
   6210     xMin = Math.min(node.x - node.r, xMin);
   6211     xMax = Math.max(node.x + node.r, xMax);
   6212     yMin = Math.min(node.y - node.r, yMin);
   6213     yMax = Math.max(node.y + node.r, yMax);
   6214   }
   6215 
   6216   // Create node links.
   6217   nodes.forEach(d3_layout_packLink);
   6218 
   6219   // Create first node.
   6220   a = nodes[0];
   6221   a.x = -a.r;
   6222   a.y = 0;
   6223   bound(a);
   6224 
   6225   // Create second node.
   6226   if (n > 1) {
   6227     b = nodes[1];
   6228     b.x = b.r;
   6229     b.y = 0;
   6230     bound(b);
   6231 
   6232     // Create third node and build chain.
   6233     if (n > 2) {
   6234       c = nodes[2];
   6235       d3_layout_packPlace(a, b, c);
   6236       bound(c);
   6237       d3_layout_packInsert(a, c);
   6238       a._pack_prev = c;
   6239       d3_layout_packInsert(c, b);
   6240       b = a._pack_next;
   6241 
   6242       // Now iterate through the rest.
   6243       for (var i = 3; i < n; i++) {
   6244         d3_layout_packPlace(a, b, c = nodes[i]);
   6245 
   6246         // Search for the closest intersection.
   6247         var isect = 0, s1 = 1, s2 = 1;
   6248         for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {
   6249           if (d3_layout_packIntersects(j, c)) {
   6250             isect = 1;
   6251             break;
   6252           }
   6253         }
   6254         if (isect == 1) {
   6255           for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {
   6256             if (d3_layout_packIntersects(k, c)) {
   6257               break;
   6258             }
   6259           }
   6260         }
   6261 
   6262         // Update node chain.
   6263         if (isect) {
   6264           if (s1 < s2 || (s1 == s2 && b.r < a.r)) d3_layout_packSplice(a, b = j);
   6265           else d3_layout_packSplice(a = k, b);
   6266           i--;
   6267         } else {
   6268           d3_layout_packInsert(a, c);
   6269           b = c;
   6270           bound(c);
   6271         }
   6272       }
   6273     }
   6274   }
   6275 
   6276   // Re-center the circles and return the encompassing radius.
   6277   var cx = (xMin + xMax) / 2,
   6278       cy = (yMin + yMax) / 2,
   6279       cr = 0;
   6280   for (var i = 0; i < n; i++) {
   6281     var node = nodes[i];
   6282     node.x -= cx;
   6283     node.y -= cy;
   6284     cr = Math.max(cr, node.r + Math.sqrt(node.x * node.x + node.y * node.y));
   6285   }
   6286 
   6287   // Remove node links.
   6288   nodes.forEach(d3_layout_packUnlink);
   6289 
   6290   return cr;
   6291 }
   6292 
   6293 function d3_layout_packLink(node) {
   6294   node._pack_next = node._pack_prev = node;
   6295 }
   6296 
   6297 function d3_layout_packUnlink(node) {
   6298   delete node._pack_next;
   6299   delete node._pack_prev;
   6300 }
   6301 
   6302 function d3_layout_packTree(node) {
   6303   var children = node.children;
   6304   if (children && children.length) {
   6305     children.forEach(d3_layout_packTree);
   6306     node.r = d3_layout_packCircle(children);
   6307   } else {
   6308     node.r = Math.sqrt(node.value);
   6309   }
   6310 }
   6311 
   6312 function d3_layout_packTransform(node, x, y, k) {
   6313   var children = node.children;
   6314   node.x = (x += k * node.x);
   6315   node.y = (y += k * node.y);
   6316   node.r *= k;
   6317   if (children) {
   6318     var i = -1, n = children.length;
   6319     while (++i < n) d3_layout_packTransform(children[i], x, y, k);
   6320   }
   6321 }
   6322 
   6323 function d3_layout_packPlace(a, b, c) {
   6324   var db = a.r + c.r,
   6325       dx = b.x - a.x,
   6326       dy = b.y - a.y;
   6327   if (db && (dx || dy)) {
   6328     var da = b.r + c.r,
   6329         dc = Math.sqrt(dx * dx + dy * dy),
   6330         cos = Math.max(-1, Math.min(1, (db * db + dc * dc - da * da) / (2 * db * dc))),
   6331         theta = Math.acos(cos),
   6332         x = cos * (db /= dc),
   6333         y = Math.sin(theta) * db;
   6334     c.x = a.x + x * dx + y * dy;
   6335     c.y = a.y + x * dy - y * dx;
   6336   } else {
   6337     c.x = a.x + db;
   6338     c.y = a.y;
   6339   }
   6340 }
   6341 // Implements a hierarchical layout using the cluster (or dendrogram)
   6342 // algorithm.
   6343 d3.layout.cluster = function() {
   6344   var hierarchy = d3.layout.hierarchy().sort(null).value(null),
   6345       separation = d3_layout_treeSeparation,
   6346       size = [1, 1]; // width, height
   6347 
   6348   function cluster(d, i) {
   6349     var nodes = hierarchy.call(this, d, i),
   6350         root = nodes[0],
   6351         previousNode,
   6352         x = 0,
   6353         kx,
   6354         ky;
   6355 
   6356     // First walk, computing the initial x & y values.
   6357     d3_layout_treeVisitAfter(root, function(node) {
   6358       var children = node.children;
   6359       if (children && children.length) {
   6360         node.x = d3_layout_clusterX(children);
   6361         node.y = d3_layout_clusterY(children);
   6362       } else {
   6363         node.x = previousNode ? x += separation(node, previousNode) : 0;
   6364         node.y = 0;
   6365         previousNode = node;
   6366       }
   6367     });
   6368 
   6369     // Compute the left-most, right-most, and depth-most nodes for extents.
   6370     var left = d3_layout_clusterLeft(root),
   6371         right = d3_layout_clusterRight(root),
   6372         x0 = left.x - separation(left, right) / 2,
   6373         x1 = right.x + separation(right, left) / 2;
   6374 
   6375     // Second walk, normalizing x & y to the desired size.
   6376     d3_layout_treeVisitAfter(root, function(node) {
   6377       node.x = (node.x - x0) / (x1 - x0) * size[0];
   6378       node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];
   6379     });
   6380 
   6381     return nodes;
   6382   }
   6383 
   6384   cluster.separation = function(x) {
   6385     if (!arguments.length) return separation;
   6386     separation = x;
   6387     return cluster;
   6388   };
   6389 
   6390   cluster.size = function(x) {
   6391     if (!arguments.length) return size;
   6392     size = x;
   6393     return cluster;
   6394   };
   6395 
   6396   return d3_layout_hierarchyRebind(cluster, hierarchy);
   6397 };
   6398 
   6399 function d3_layout_clusterY(children) {
   6400   return 1 + d3.max(children, function(child) {
   6401     return child.y;
   6402   });
   6403 }
   6404 
   6405 function d3_layout_clusterX(children) {
   6406   return children.reduce(function(x, child) {
   6407     return x + child.x;
   6408   }, 0) / children.length;
   6409 }
   6410 
   6411 function d3_layout_clusterLeft(node) {
   6412   var children = node.children;
   6413   return children && children.length ? d3_layout_clusterLeft(children[0]) : node;
   6414 }
   6415 
   6416 function d3_layout_clusterRight(node) {
   6417   var children = node.children, n;
   6418   return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;
   6419 }
   6420 // Node-link tree diagram using the Reingold-Tilford "tidy" algorithm
   6421 d3.layout.tree = function() {
   6422   var hierarchy = d3.layout.hierarchy().sort(null).value(null),
   6423       separation = d3_layout_treeSeparation,
   6424       size = [1, 1]; // width, height
   6425 
   6426   function tree(d, i) {
   6427     var nodes = hierarchy.call(this, d, i),
   6428         root = nodes[0];
   6429 
   6430     function firstWalk(node, previousSibling) {
   6431       var children = node.children,
   6432           layout = node._tree;
   6433       if (children && (n = children.length)) {
   6434         var n,
   6435             firstChild = children[0],
   6436             previousChild,
   6437             ancestor = firstChild,
   6438             child,
   6439             i = -1;
   6440         while (++i < n) {
   6441           child = children[i];
   6442           firstWalk(child, previousChild);
   6443           ancestor = apportion(child, previousChild, ancestor);
   6444           previousChild = child;
   6445         }
   6446         d3_layout_treeShift(node);
   6447         var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim);
   6448         if (previousSibling) {
   6449           layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
   6450           layout.mod = layout.prelim - midpoint;
   6451         } else {
   6452           layout.prelim = midpoint;
   6453         }
   6454       } else {
   6455         if (previousSibling) {
   6456           layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
   6457         }
   6458       }
   6459     }
   6460 
   6461     function secondWalk(node, x) {
   6462       node.x = node._tree.prelim + x;
   6463       var children = node.children;
   6464       if (children && (n = children.length)) {
   6465         var i = -1,
   6466             n;
   6467         x += node._tree.mod;
   6468         while (++i < n) {
   6469           secondWalk(children[i], x);
   6470         }
   6471       }
   6472     }
   6473 
   6474     function apportion(node, previousSibling, ancestor) {
   6475       if (previousSibling) {
   6476         var vip = node,
   6477             vop = node,
   6478             vim = previousSibling,
   6479             vom = node.parent.children[0],
   6480             sip = vip._tree.mod,
   6481             sop = vop._tree.mod,
   6482             sim = vim._tree.mod,
   6483             som = vom._tree.mod,
   6484             shift;
   6485         while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
   6486           vom = d3_layout_treeLeft(vom);
   6487           vop = d3_layout_treeRight(vop);
   6488           vop._tree.ancestor = node;
   6489           shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip);
   6490           if (shift > 0) {
   6491             d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift);
   6492             sip += shift;
   6493             sop += shift;
   6494           }
   6495           sim += vim._tree.mod;
   6496           sip += vip._tree.mod;
   6497           som += vom._tree.mod;
   6498           sop += vop._tree.mod;
   6499         }
   6500         if (vim && !d3_layout_treeRight(vop)) {
   6501           vop._tree.thread = vim;
   6502           vop._tree.mod += sim - sop;
   6503         }
   6504         if (vip && !d3_layout_treeLeft(vom)) {
   6505           vom._tree.thread = vip;
   6506           vom._tree.mod += sip - som;
   6507           ancestor = node;
   6508         }
   6509       }
   6510       return ancestor;
   6511     }
   6512 
   6513     // Initialize temporary layout variables.
   6514     d3_layout_treeVisitAfter(root, function(node, previousSibling) {
   6515       node._tree = {
   6516         ancestor: node,
   6517         prelim: 0,
   6518         mod: 0,
   6519         change: 0,
   6520         shift: 0,
   6521         number: previousSibling ? previousSibling._tree.number + 1 : 0
   6522       };
   6523     });
   6524 
   6525     // Compute the layout using Buchheim et al.'s algorithm.
   6526     firstWalk(root);
   6527     secondWalk(root, -root._tree.prelim);
   6528 
   6529     // Compute the left-most, right-most, and depth-most nodes for extents.
   6530     var left = d3_layout_treeSearch(root, d3_layout_treeLeftmost),
   6531         right = d3_layout_treeSearch(root, d3_layout_treeRightmost),
   6532         deep = d3_layout_treeSearch(root, d3_layout_treeDeepest),
   6533         x0 = left.x - separation(left, right) / 2,
   6534         x1 = right.x + separation(right, left) / 2,
   6535         y1 = deep.depth || 1;
   6536 
   6537     // Clear temporary layout variables; transform x and y.
   6538     d3_layout_treeVisitAfter(root, function(node) {
   6539       node.x = (node.x - x0) / (x1 - x0) * size[0];
   6540       node.y = node.depth / y1 * size[1];
   6541       delete node._tree;
   6542     });
   6543 
   6544     return nodes;
   6545   }
   6546 
   6547   tree.separation = function(x) {
   6548     if (!arguments.length) return separation;
   6549     separation = x;
   6550     return tree;
   6551   };
   6552 
   6553   tree.size = function(x) {
   6554     if (!arguments.length) return size;
   6555     size = x;
   6556     return tree;
   6557   };
   6558 
   6559   return d3_layout_hierarchyRebind(tree, hierarchy);
   6560 };
   6561 
   6562 function d3_layout_treeSeparation(a, b) {
   6563   return a.parent == b.parent ? 1 : 2;
   6564 }
   6565 
   6566 // function d3_layout_treeSeparationRadial(a, b) {
   6567 //   return (a.parent == b.parent ? 1 : 2) / a.depth;
   6568 // }
   6569 
   6570 function d3_layout_treeLeft(node) {
   6571   var children = node.children;
   6572   return children && children.length ? children[0] : node._tree.thread;
   6573 }
   6574 
   6575 function d3_layout_treeRight(node) {
   6576   var children = node.children,
   6577       n;
   6578   return children && (n = children.length) ? children[n - 1] : node._tree.thread;
   6579 }
   6580 
   6581 function d3_layout_treeSearch(node, compare) {
   6582   var children = node.children;
   6583   if (children && (n = children.length)) {
   6584     var child,
   6585         n,
   6586         i = -1;
   6587     while (++i < n) {
   6588       if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) {
   6589         node = child;
   6590       }
   6591     }
   6592   }
   6593   return node;
   6594 }
   6595 
   6596 function d3_layout_treeRightmost(a, b) {
   6597   return a.x - b.x;
   6598 }
   6599 
   6600 function d3_layout_treeLeftmost(a, b) {
   6601   return b.x - a.x;
   6602 }
   6603 
   6604 function d3_layout_treeDeepest(a, b) {
   6605   return a.depth - b.depth;
   6606 }
   6607 
   6608 function d3_layout_treeVisitAfter(node, callback) {
   6609   function visit(node, previousSibling) {
   6610     var children = node.children;
   6611     if (children && (n = children.length)) {
   6612       var child,
   6613           previousChild = null,
   6614           i = -1,
   6615           n;
   6616       while (++i < n) {
   6617         child = children[i];
   6618         visit(child, previousChild);
   6619         previousChild = child;
   6620       }
   6621     }
   6622     callback(node, previousSibling);
   6623   }
   6624   visit(node, null);
   6625 }
   6626 
   6627 function d3_layout_treeShift(node) {
   6628   var shift = 0,
   6629       change = 0,
   6630       children = node.children,
   6631       i = children.length,
   6632       child;
   6633   while (--i >= 0) {
   6634     child = children[i]._tree;
   6635     child.prelim += shift;
   6636     child.mod += shift;
   6637     shift += child.shift + (change += child.change);
   6638   }
   6639 }
   6640 
   6641 function d3_layout_treeMove(ancestor, node, shift) {
   6642   ancestor = ancestor._tree;
   6643   node = node._tree;
   6644   var change = shift / (node.number - ancestor.number);
   6645   ancestor.change += change;
   6646   node.change -= change;
   6647   node.shift += shift;
   6648   node.prelim += shift;
   6649   node.mod += shift;
   6650 }
   6651 
   6652 function d3_layout_treeAncestor(vim, node, ancestor) {
   6653   return vim._tree.ancestor.parent == node.parent
   6654       ? vim._tree.ancestor
   6655       : ancestor;
   6656 }
   6657 // Squarified Treemaps by Mark Bruls, Kees Huizing, and Jarke J. van Wijk
   6658 // Modified to support a target aspect ratio by Jeff Heer
   6659 d3.layout.treemap = function() {
   6660   var hierarchy = d3.layout.hierarchy(),
   6661       round = Math.round,
   6662       size = [1, 1], // width, height
   6663       padding = null,
   6664       pad = d3_layout_treemapPadNull,
   6665       sticky = false,
   6666       stickies,
   6667       ratio = 0.5 * (1 + Math.sqrt(5)); // golden ratio
   6668 
   6669   // Compute the area for each child based on value & scale.
   6670   function scale(children, k) {
   6671     var i = -1,
   6672         n = children.length,
   6673         child,
   6674         area;
   6675     while (++i < n) {
   6676       area = (child = children[i]).value * (k < 0 ? 0 : k);
   6677       child.area = isNaN(area) || area <= 0 ? 0 : area;
   6678     }
   6679   }
   6680 
   6681   // Recursively arranges the specified node's children into squarified rows.
   6682   function squarify(node) {
   6683     var children = node.children;
   6684     if (children && children.length) {
   6685       var rect = pad(node),
   6686           row = [],
   6687           remaining = children.slice(), // copy-on-write
   6688           child,
   6689           best = Infinity, // the best row score so far
   6690           score, // the current row score
   6691           u = Math.min(rect.dx, rect.dy), // initial orientation
   6692           n;
   6693       scale(remaining, rect.dx * rect.dy / node.value);
   6694       row.area = 0;
   6695       while ((n = remaining.length) > 0) {
   6696         row.push(child = remaining[n - 1]);
   6697         row.area += child.area;
   6698         if ((score = worst(row, u)) <= best) { // continue with this orientation
   6699           remaining.pop();
   6700           best = score;
   6701         } else { // abort, and try a different orientation
   6702           row.area -= row.pop().area;
   6703           position(row, u, rect, false);
   6704           u = Math.min(rect.dx, rect.dy);
   6705           row.length = row.area = 0;
   6706           best = Infinity;
   6707         }
   6708       }
   6709       if (row.length) {
   6710         position(row, u, rect, true);
   6711         row.length = row.area = 0;
   6712       }
   6713       children.forEach(squarify);
   6714     }
   6715   }
   6716 
   6717   // Recursively resizes the specified node's children into existing rows.
   6718   // Preserves the existing layout!
   6719   function stickify(node) {
   6720     var children = node.children;
   6721     if (children && children.length) {
   6722       var rect = pad(node),
   6723           remaining = children.slice(), // copy-on-write
   6724           child,
   6725           row = [];
   6726       scale(remaining, rect.dx * rect.dy / node.value);
   6727       row.area = 0;
   6728       while (child = remaining.pop()) {
   6729         row.push(child);
   6730         row.area += child.area;
   6731         if (child.z != null) {
   6732           position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length);
   6733           row.length = row.area = 0;
   6734         }
   6735       }
   6736       children.forEach(stickify);
   6737     }
   6738   }
   6739 
   6740   // Computes the score for the specified row, as the worst aspect ratio.
   6741   function worst(row, u) {
   6742     var s = row.area,
   6743         r,
   6744         rmax = 0,
   6745         rmin = Infinity,
   6746         i = -1,
   6747         n = row.length;
   6748     while (++i < n) {
   6749       if (!(r = row[i].area)) continue;
   6750       if (r < rmin) rmin = r;
   6751       if (r > rmax) rmax = r;
   6752     }
   6753     s *= s;
   6754     u *= u;
   6755     return s
   6756         ? Math.max((u * rmax * ratio) / s, s / (u * rmin * ratio))
   6757         : Infinity;
   6758   }
   6759 
   6760   // Positions the specified row of nodes. Modifies `rect`.
   6761   function position(row, u, rect, flush) {
   6762     var i = -1,
   6763         n = row.length,
   6764         x = rect.x,
   6765         y = rect.y,
   6766         v = u ? round(row.area / u) : 0,
   6767         o;
   6768     if (u == rect.dx) { // horizontal subdivision
   6769       if (flush || v > rect.dy) v = rect.dy; // over+underflow
   6770       while (++i < n) {
   6771         o = row[i];
   6772         o.x = x;
   6773         o.y = y;
   6774         o.dy = v;
   6775         x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0);
   6776       }
   6777       o.z = true;
   6778       o.dx += rect.x + rect.dx - x; // rounding error
   6779       rect.y += v;
   6780       rect.dy -= v;
   6781     } else { // vertical subdivision
   6782       if (flush || v > rect.dx) v = rect.dx; // over+underflow
   6783       while (++i < n) {
   6784         o = row[i];
   6785         o.x = x;
   6786         o.y = y;
   6787         o.dx = v;
   6788         y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0);
   6789       }
   6790       o.z = false;
   6791       o.dy += rect.y + rect.dy - y; // rounding error
   6792       rect.x += v;
   6793       rect.dx -= v;
   6794     }
   6795   }
   6796 
   6797   function treemap(d) {
   6798     var nodes = stickies || hierarchy(d),
   6799         root = nodes[0];
   6800     root.x = 0;
   6801     root.y = 0;
   6802     root.dx = size[0];
   6803     root.dy = size[1];
   6804     if (stickies) hierarchy.revalue(root);
   6805     scale([root], root.dx * root.dy / root.value);
   6806     (stickies ? stickify : squarify)(root);
   6807     if (sticky) stickies = nodes;
   6808     return nodes;
   6809   }
   6810 
   6811   treemap.size = function(x) {
   6812     if (!arguments.length) return size;
   6813     size = x;
   6814     return treemap;
   6815   };
   6816 
   6817   treemap.padding = function(x) {
   6818     if (!arguments.length) return padding;
   6819 
   6820     function padFunction(node) {
   6821       var p = x.call(treemap, node, node.depth);
   6822       return p == null
   6823           ? d3_layout_treemapPadNull(node)
   6824           : d3_layout_treemapPad(node, typeof p === "number" ? [p, p, p, p] : p);
   6825     }
   6826 
   6827     function padConstant(node) {
   6828       return d3_layout_treemapPad(node, x);
   6829     }
   6830 
   6831     var type;
   6832     pad = (padding = x) == null ? d3_layout_treemapPadNull
   6833         : (type = typeof x) === "function" ? padFunction
   6834         : type === "number" ? (x = [x, x, x, x], padConstant)
   6835         : padConstant;
   6836     return treemap;
   6837   };
   6838 
   6839   treemap.round = function(x) {
   6840     if (!arguments.length) return round != Number;
   6841     round = x ? Math.round : Number;
   6842     return treemap;
   6843   };
   6844 
   6845   treemap.sticky = function(x) {
   6846     if (!arguments.length) return sticky;
   6847     sticky = x;
   6848     stickies = null;
   6849     return treemap;
   6850   };
   6851 
   6852   treemap.ratio = function(x) {
   6853     if (!arguments.length) return ratio;
   6854     ratio = x;
   6855     return treemap;
   6856   };
   6857 
   6858   return d3_layout_hierarchyRebind(treemap, hierarchy);
   6859 };
   6860 
   6861 function d3_layout_treemapPadNull(node) {
   6862   return {x: node.x, y: node.y, dx: node.dx, dy: node.dy};
   6863 }
   6864 
   6865 function d3_layout_treemapPad(node, padding) {
   6866   var x = node.x + padding[3],
   6867       y = node.y + padding[0],
   6868       dx = node.dx - padding[1] - padding[3],
   6869       dy = node.dy - padding[0] - padding[2];
   6870   if (dx < 0) { x += dx / 2; dx = 0; }
   6871   if (dy < 0) { y += dy / 2; dy = 0; }
   6872   return {x: x, y: y, dx: dx, dy: dy};
   6873 }
   6874 d3.csv = function(url, callback) {
   6875   d3.text(url, "text/csv", function(text) {
   6876     callback(text && d3.csv.parse(text));
   6877   });
   6878 };
   6879 d3.csv.parse = function(text) {
   6880   var header;
   6881   return d3.csv.parseRows(text, function(row, i) {
   6882     if (i) {
   6883       var o = {}, j = -1, m = header.length;
   6884       while (++j < m) o[header[j]] = row[j];
   6885       return o;
   6886     } else {
   6887       header = row;
   6888       return null;
   6889     }
   6890   });
   6891 };
   6892 
   6893 d3.csv.parseRows = function(text, f) {
   6894   var EOL = {}, // sentinel value for end-of-line
   6895       EOF = {}, // sentinel value for end-of-file
   6896       rows = [], // output rows
   6897       re = /\r\n|[,\r\n]/g, // field separator regex
   6898       n = 0, // the current line number
   6899       t, // the current token
   6900       eol; // is the current token followed by EOL?
   6901 
   6902   re.lastIndex = 0; // work-around bug in FF 3.6
   6903 
   6904   /** @private Returns the next token. */
   6905   function token() {
   6906     if (re.lastIndex >= text.length) return EOF; // special case: end of file
   6907     if (eol) { eol = false; return EOL; } // special case: end of line
   6908 
   6909     // special case: quotes
   6910     var j = re.lastIndex;
   6911     if (text.charCodeAt(j) === 34) {
   6912       var i = j;
   6913       while (i++ < text.length) {
   6914         if (text.charCodeAt(i) === 34) {
   6915           if (text.charCodeAt(i + 1) !== 34) break;
   6916           i++;
   6917         }
   6918       }
   6919       re.lastIndex = i + 2;
   6920       var c = text.charCodeAt(i + 1);
   6921       if (c === 13) {
   6922         eol = true;
   6923         if (text.charCodeAt(i + 2) === 10) re.lastIndex++;
   6924       } else if (c === 10) {
   6925         eol = true;
   6926       }
   6927       return text.substring(j + 1, i).replace(/""/g, "\"");
   6928     }
   6929 
   6930     // common case
   6931     var m = re.exec(text);
   6932     if (m) {
   6933       eol = m[0].charCodeAt(0) !== 44;
   6934       return text.substring(j, m.index);
   6935     }
   6936     re.lastIndex = text.length;
   6937     return text.substring(j);
   6938   }
   6939 
   6940   while ((t = token()) !== EOF) {
   6941     var a = [];
   6942     while ((t !== EOL) && (t !== EOF)) {
   6943       a.push(t);
   6944       t = token();
   6945     }
   6946     if (f && !(a = f(a, n++))) continue;
   6947     rows.push(a);
   6948   }
   6949 
   6950   return rows;
   6951 };
   6952 d3.csv.format = function(rows) {
   6953   return rows.map(d3_csv_formatRow).join("\n");
   6954 };
   6955 
   6956 function d3_csv_formatRow(row) {
   6957   return row.map(d3_csv_formatValue).join(",");
   6958 }
   6959 
   6960 function d3_csv_formatValue(text) {
   6961   return /[",\n]/.test(text)
   6962       ? "\"" + text.replace(/\"/g, "\"\"") + "\""
   6963       : text;
   6964 }
   6965 d3.geo = {};
   6966 
   6967 var d3_geo_radians = Math.PI / 180;
   6968 // TODO clip input coordinates on opposite hemisphere
   6969 d3.geo.azimuthal = function() {
   6970   var mode = "orthographic", // or stereographic, gnomonic, equidistant or equalarea
   6971       origin,
   6972       scale = 200,
   6973       translate = [480, 250],
   6974       x0,
   6975       y0,
   6976       cy0,
   6977       sy0;
   6978 
   6979   function azimuthal(coordinates) {
   6980     var x1 = coordinates[0] * d3_geo_radians - x0,
   6981         y1 = coordinates[1] * d3_geo_radians,
   6982         cx1 = Math.cos(x1),
   6983         sx1 = Math.sin(x1),
   6984         cy1 = Math.cos(y1),
   6985         sy1 = Math.sin(y1),
   6986         cc = mode !== "orthographic" ? sy0 * sy1 + cy0 * cy1 * cx1 : null,
   6987         c,
   6988         k = mode === "stereographic" ? 1 / (1 + cc)
   6989           : mode === "gnomonic" ? 1 / cc
   6990           : mode === "equidistant" ? (c = Math.acos(cc), c ? c / Math.sin(c) : 0)
   6991           : mode === "equalarea" ? Math.sqrt(2 / (1 + cc))
   6992           : 1,
   6993         x = k * cy1 * sx1,
   6994         y = k * (sy0 * cy1 * cx1 - cy0 * sy1);
   6995     return [
   6996       scale * x + translate[0],
   6997       scale * y + translate[1]
   6998     ];
   6999   }
   7000 
   7001   azimuthal.invert = function(coordinates) {
   7002     var x = (coordinates[0] - translate[0]) / scale,
   7003         y = (coordinates[1] - translate[1]) / scale,
   7004         p = Math.sqrt(x * x + y * y),
   7005         c = mode === "stereographic" ? 2 * Math.atan(p)
   7006           : mode === "gnomonic" ? Math.atan(p)
   7007           : mode === "equidistant" ? p
   7008           : mode === "equalarea" ? 2 * Math.asin(.5 * p)
   7009           : Math.asin(p),
   7010         sc = Math.sin(c),
   7011         cc = Math.cos(c);
   7012     return [
   7013       (x0 + Math.atan2(x * sc, p * cy0 * cc + y * sy0 * sc)) / d3_geo_radians,
   7014       Math.asin(cc * sy0 - (p ? (y * sc * cy0) / p : 0)) / d3_geo_radians
   7015     ];
   7016   };
   7017 
   7018   azimuthal.mode = function(x) {
   7019     if (!arguments.length) return mode;
   7020     mode = x + "";
   7021     return azimuthal;
   7022   };
   7023 
   7024   azimuthal.origin = function(x) {
   7025     if (!arguments.length) return origin;
   7026     origin = x;
   7027     x0 = origin[0] * d3_geo_radians;
   7028     y0 = origin[1] * d3_geo_radians;
   7029     cy0 = Math.cos(y0);
   7030     sy0 = Math.sin(y0);
   7031     return azimuthal;
   7032   };
   7033 
   7034   azimuthal.scale = function(x) {
   7035     if (!arguments.length) return scale;
   7036     scale = +x;
   7037     return azimuthal;
   7038   };
   7039 
   7040   azimuthal.translate = function(x) {
   7041     if (!arguments.length) return translate;
   7042     translate = [+x[0], +x[1]];
   7043     return azimuthal;
   7044   };
   7045 
   7046   return azimuthal.origin([0, 0]);
   7047 };
   7048 // Derived from Tom Carden's Albers implementation for Protovis.
   7049 // http://gist.github.com/476238
   7050 // http://mathworld.wolfram.com/AlbersEqual-AreaConicProjection.html
   7051 
   7052 d3.geo.albers = function() {
   7053   var origin = [-98, 38],
   7054       parallels = [29.5, 45.5],
   7055       scale = 1000,
   7056       translate = [480, 250],
   7057       lng0, // d3_geo_radians * origin[0]
   7058       n,
   7059       C,
   7060       p0;
   7061 
   7062   function albers(coordinates) {
   7063     var t = n * (d3_geo_radians * coordinates[0] - lng0),
   7064         p = Math.sqrt(C - 2 * n * Math.sin(d3_geo_radians * coordinates[1])) / n;
   7065     return [
   7066       scale * p * Math.sin(t) + translate[0],
   7067       scale * (p * Math.cos(t) - p0) + translate[1]
   7068     ];
   7069   }
   7070 
   7071   albers.invert = function(coordinates) {
   7072     var x = (coordinates[0] - translate[0]) / scale,
   7073         y = (coordinates[1] - translate[1]) / scale,
   7074         p0y = p0 + y,
   7075         t = Math.atan2(x, p0y),
   7076         p = Math.sqrt(x * x + p0y * p0y);
   7077     return [
   7078       (lng0 + t / n) / d3_geo_radians,
   7079       Math.asin((C - p * p * n * n) / (2 * n)) / d3_geo_radians
   7080     ];
   7081   };
   7082 
   7083   function reload() {
   7084     var phi1 = d3_geo_radians * parallels[0],
   7085         phi2 = d3_geo_radians * parallels[1],
   7086         lat0 = d3_geo_radians * origin[1],
   7087         s = Math.sin(phi1),
   7088         c = Math.cos(phi1);
   7089     lng0 = d3_geo_radians * origin[0];
   7090     n = .5 * (s + Math.sin(phi2));
   7091     C = c * c + 2 * n * s;
   7092     p0 = Math.sqrt(C - 2 * n * Math.sin(lat0)) / n;
   7093     return albers;
   7094   }
   7095 
   7096   albers.origin = function(x) {
   7097     if (!arguments.length) return origin;
   7098     origin = [+x[0], +x[1]];
   7099     return reload();
   7100   };
   7101 
   7102   albers.parallels = function(x) {
   7103     if (!arguments.length) return parallels;
   7104     parallels = [+x[0], +x[1]];
   7105     return reload();
   7106   };
   7107 
   7108   albers.scale = function(x) {
   7109     if (!arguments.length) return scale;
   7110     scale = +x;
   7111     return albers;
   7112   };
   7113 
   7114   albers.translate = function(x) {
   7115     if (!arguments.length) return translate;
   7116     translate = [+x[0], +x[1]];
   7117     return albers;
   7118   };
   7119 
   7120   return reload();
   7121 };
   7122 
   7123 // A composite projection for the United States, 960x500. The set of standard
   7124 // parallels for each region comes from USGS, which is published here:
   7125 // http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers
   7126 // TODO allow the composite projection to be rescaled?
   7127 d3.geo.albersUsa = function() {
   7128   var lower48 = d3.geo.albers();
   7129 
   7130   var alaska = d3.geo.albers()
   7131       .origin([-160, 60])
   7132       .parallels([55, 65]);
   7133 
   7134   var hawaii = d3.geo.albers()
   7135       .origin([-160, 20])
   7136       .parallels([8, 18]);
   7137 
   7138   var puertoRico = d3.geo.albers()
   7139       .origin([-60, 10])
   7140       .parallels([8, 18]);
   7141 
   7142   function albersUsa(coordinates) {
   7143     var lon = coordinates[0],
   7144         lat = coordinates[1];
   7145     return (lat > 50 ? alaska
   7146         : lon < -140 ? hawaii
   7147         : lat < 21 ? puertoRico
   7148         : lower48)(coordinates);
   7149   }
   7150 
   7151   albersUsa.scale = function(x) {
   7152     if (!arguments.length) return lower48.scale();
   7153     lower48.scale(x);
   7154     alaska.scale(x * .6);
   7155     hawaii.scale(x);
   7156     puertoRico.scale(x * 1.5);
   7157     return albersUsa.translate(lower48.translate());
   7158   };
   7159 
   7160   albersUsa.translate = function(x) {
   7161     if (!arguments.length) return lower48.translate();
   7162     var dz = lower48.scale() / 1000,
   7163         dx = x[0],
   7164         dy = x[1];
   7165     lower48.translate(x);
   7166     alaska.translate([dx - 400 * dz, dy + 170 * dz]);
   7167     hawaii.translate([dx - 190 * dz, dy + 200 * dz]);
   7168     puertoRico.translate([dx + 580 * dz, dy + 430 * dz]);
   7169     return albersUsa;
   7170   };
   7171 
   7172   return albersUsa.scale(lower48.scale());
   7173 };
   7174 d3.geo.bonne = function() {
   7175   var scale = 200,
   7176       translate = [480, 250],
   7177       x0, // origin longitude in radians
   7178       y0, // origin latitude in radians
   7179       y1, // parallel latitude in radians
   7180       c1; // cot(y1)
   7181 
   7182   function bonne(coordinates) {
   7183     var x = coordinates[0] * d3_geo_radians - x0,
   7184         y = coordinates[1] * d3_geo_radians - y0;
   7185     if (y1) {
   7186       var p = c1 + y1 - y, E = x * Math.cos(y) / p;
   7187       x = p * Math.sin(E);
   7188       y = p * Math.cos(E) - c1;
   7189     } else {
   7190       x *= Math.cos(y);
   7191       y *= -1;
   7192     }
   7193     return [
   7194       scale * x + translate[0],
   7195       scale * y + translate[1]
   7196     ];
   7197   }
   7198 
   7199   bonne.invert = function(coordinates) {
   7200     var x = (coordinates[0] - translate[0]) / scale,
   7201         y = (coordinates[1] - translate[1]) / scale;
   7202     if (y1) {
   7203       var c = c1 + y, p = Math.sqrt(x * x + c * c);
   7204       y = c1 + y1 - p;
   7205       x = x0 + p * Math.atan2(x, c) / Math.cos(y);
   7206     } else {
   7207       y *= -1;
   7208       x /= Math.cos(y);
   7209     }
   7210     return [
   7211       x / d3_geo_radians,
   7212       y / d3_geo_radians
   7213     ];
   7214   };
   7215 
   7216   // 90° for Werner, 0° for Sinusoidal
   7217   bonne.parallel = function(x) {
   7218     if (!arguments.length) return y1 / d3_geo_radians;
   7219     c1 = 1 / Math.tan(y1 = x * d3_geo_radians);
   7220     return bonne;
   7221   };
   7222 
   7223   bonne.origin = function(x) {
   7224     if (!arguments.length) return [x0 / d3_geo_radians, y0 / d3_geo_radians];
   7225     x0 = x[0] * d3_geo_radians;
   7226     y0 = x[1] * d3_geo_radians;
   7227     return bonne;
   7228   };
   7229 
   7230   bonne.scale = function(x) {
   7231     if (!arguments.length) return scale;
   7232     scale = +x;
   7233     return bonne;
   7234   };
   7235 
   7236   bonne.translate = function(x) {
   7237     if (!arguments.length) return translate;
   7238     translate = [+x[0], +x[1]];
   7239     return bonne;
   7240   };
   7241 
   7242   return bonne.origin([0, 0]).parallel(45);
   7243 };
   7244 d3.geo.equirectangular = function() {
   7245   var scale = 500,
   7246       translate = [480, 250];
   7247 
   7248   function equirectangular(coordinates) {
   7249     var x = coordinates[0] / 360,
   7250         y = -coordinates[1] / 360;
   7251     return [
   7252       scale * x + translate[0],
   7253       scale * y + translate[1]
   7254     ];
   7255   }
   7256 
   7257   equirectangular.invert = function(coordinates) {
   7258     var x = (coordinates[0] - translate[0]) / scale,
   7259         y = (coordinates[1] - translate[1]) / scale;
   7260     return [
   7261       360 * x,
   7262       -360 * y
   7263     ];
   7264   };
   7265 
   7266   equirectangular.scale = function(x) {
   7267     if (!arguments.length) return scale;
   7268     scale = +x;
   7269     return equirectangular;
   7270   };
   7271 
   7272   equirectangular.translate = function(x) {
   7273     if (!arguments.length) return translate;
   7274     translate = [+x[0], +x[1]];
   7275     return equirectangular;
   7276   };
   7277 
   7278   return equirectangular;
   7279 };
   7280 d3.geo.mercator = function() {
   7281   var scale = 500,
   7282       translate = [480, 250];
   7283 
   7284   function mercator(coordinates) {
   7285     var x = coordinates[0] / 360,
   7286         y = -(Math.log(Math.tan(Math.PI / 4 + coordinates[1] * d3_geo_radians / 2)) / d3_geo_radians) / 360;
   7287     return [
   7288       scale * x + translate[0],
   7289       scale * Math.max(-.5, Math.min(.5, y)) + translate[1]
   7290     ];
   7291   }
   7292 
   7293   mercator.invert = function(coordinates) {
   7294     var x = (coordinates[0] - translate[0]) / scale,
   7295         y = (coordinates[1] - translate[1]) / scale;
   7296     return [
   7297       360 * x,
   7298       2 * Math.atan(Math.exp(-360 * y * d3_geo_radians)) / d3_geo_radians - 90
   7299     ];
   7300   };
   7301 
   7302   mercator.scale = function(x) {
   7303     if (!arguments.length) return scale;
   7304     scale = +x;
   7305     return mercator;
   7306   };
   7307 
   7308   mercator.translate = function(x) {
   7309     if (!arguments.length) return translate;
   7310     translate = [+x[0], +x[1]];
   7311     return mercator;
   7312   };
   7313 
   7314   return mercator;
   7315 };
   7316 function d3_geo_type(types, defaultValue) {
   7317   return function(object) {
   7318     return object && types.hasOwnProperty(object.type) ? types[object.type](object) : defaultValue;
   7319   };
   7320 }
   7321 /**
   7322  * Returns a function that, given a GeoJSON object (e.g., a feature), returns
   7323  * the corresponding SVG path. The function can be customized by overriding the
   7324  * projection. Point features are mapped to circles with a default radius of
   7325  * 4.5px; the radius can be specified either as a constant or a function that
   7326  * is evaluated per object.
   7327  */
   7328 d3.geo.path = function() {
   7329   var pointRadius = 4.5,
   7330       pointCircle = d3_path_circle(pointRadius),
   7331       projection = d3.geo.albersUsa();
   7332 
   7333   function path(d, i) {
   7334     if (typeof pointRadius === "function") {
   7335       pointCircle = d3_path_circle(pointRadius.apply(this, arguments));
   7336     }
   7337     return pathType(d) || null;
   7338   }
   7339 
   7340   function project(coordinates) {
   7341     return projection(coordinates).join(",");
   7342   }
   7343 
   7344   var pathType = d3_geo_type({
   7345 
   7346     FeatureCollection: function(o) {
   7347       var path = [],
   7348           features = o.features,
   7349           i = -1, // features.index
   7350           n = features.length;
   7351       while (++i < n) path.push(pathType(features[i].geometry));
   7352       return path.join("");
   7353     },
   7354 
   7355     Feature: function(o) {
   7356       return pathType(o.geometry);
   7357     },
   7358 
   7359     Point: function(o) {
   7360       return "M" + project(o.coordinates) + pointCircle;
   7361     },
   7362 
   7363     MultiPoint: function(o) {
   7364       var path = [],
   7365           coordinates = o.coordinates,
   7366           i = -1, // coordinates.index
   7367           n = coordinates.length;
   7368       while (++i < n) path.push("M", project(coordinates[i]), pointCircle);
   7369       return path.join("");
   7370     },
   7371 
   7372     LineString: function(o) {
   7373       var path = ["M"],
   7374           coordinates = o.coordinates,
   7375           i = -1, // coordinates.index
   7376           n = coordinates.length;
   7377       while (++i < n) path.push(project(coordinates[i]), "L");
   7378       path.pop();
   7379       return path.join("");
   7380     },
   7381 
   7382     MultiLineString: function(o) {
   7383       var path = [],
   7384           coordinates = o.coordinates,
   7385           i = -1, // coordinates.index
   7386           n = coordinates.length,
   7387           subcoordinates, // coordinates[i]
   7388           j, // subcoordinates.index
   7389           m; // subcoordinates.length
   7390       while (++i < n) {
   7391         subcoordinates = coordinates[i];
   7392         j = -1;
   7393         m = subcoordinates.length;
   7394         path.push("M");
   7395         while (++j < m) path.push(project(subcoordinates[j]), "L");
   7396         path.pop();
   7397       }
   7398       return path.join("");
   7399     },
   7400 
   7401     Polygon: function(o) {
   7402       var path = [],
   7403           coordinates = o.coordinates,
   7404           i = -1, // coordinates.index
   7405           n = coordinates.length,
   7406           subcoordinates, // coordinates[i]
   7407           j, // subcoordinates.index
   7408           m; // subcoordinates.length
   7409       while (++i < n) {
   7410         subcoordinates = coordinates[i];
   7411         j = -1;
   7412         if ((m = subcoordinates.length - 1) > 0) {
   7413           path.push("M");
   7414           while (++j < m) path.push(project(subcoordinates[j]), "L");
   7415           path[path.length - 1] = "Z";
   7416         }
   7417       }
   7418       return path.join("");
   7419     },
   7420 
   7421     MultiPolygon: function(o) {
   7422       var path = [],
   7423           coordinates = o.coordinates,
   7424           i = -1, // coordinates index
   7425           n = coordinates.length,
   7426           subcoordinates, // coordinates[i]
   7427           j, // subcoordinates index
   7428           m, // subcoordinates.length
   7429           subsubcoordinates, // subcoordinates[j]
   7430           k, // subsubcoordinates index
   7431           p; // subsubcoordinates.length
   7432       while (++i < n) {
   7433         subcoordinates = coordinates[i];
   7434         j = -1;
   7435         m = subcoordinates.length;
   7436         while (++j < m) {
   7437           subsubcoordinates = subcoordinates[j];
   7438           k = -1;
   7439           if ((p = subsubcoordinates.length - 1) > 0) {
   7440             path.push("M");
   7441             while (++k < p) path.push(project(subsubcoordinates[k]), "L");
   7442             path[path.length - 1] = "Z";
   7443           }
   7444         }
   7445       }
   7446       return path.join("");
   7447     },
   7448 
   7449     GeometryCollection: function(o) {
   7450       var path = [],
   7451           geometries = o.geometries,
   7452           i = -1, // geometries index
   7453           n = geometries.length;
   7454       while (++i < n) path.push(pathType(geometries[i]));
   7455       return path.join("");
   7456     }
   7457 
   7458   });
   7459 
   7460   var areaType = path.area = d3_geo_type({
   7461 
   7462     FeatureCollection: function(o) {
   7463       var area = 0,
   7464           features = o.features,
   7465           i = -1, // features.index
   7466           n = features.length;
   7467       while (++i < n) area += areaType(features[i]);
   7468       return area;
   7469     },
   7470 
   7471     Feature: function(o) {
   7472       return areaType(o.geometry);
   7473     },
   7474 
   7475     Polygon: function(o) {
   7476       return polygonArea(o.coordinates);
   7477     },
   7478 
   7479     MultiPolygon: function(o) {
   7480       var sum = 0,
   7481           coordinates = o.coordinates,
   7482           i = -1, // coordinates index
   7483           n = coordinates.length;
   7484       while (++i < n) sum += polygonArea(coordinates[i]);
   7485       return sum;
   7486     },
   7487 
   7488     GeometryCollection: function(o) {
   7489       var sum = 0,
   7490           geometries = o.geometries,
   7491           i = -1, // geometries index
   7492           n = geometries.length;
   7493       while (++i < n) sum += areaType(geometries[i]);
   7494       return sum;
   7495     }
   7496 
   7497   }, 0);
   7498 
   7499   function polygonArea(coordinates) {
   7500     var sum = area(coordinates[0]), // exterior ring
   7501         i = 0, // coordinates.index
   7502         n = coordinates.length;
   7503     while (++i < n) sum -= area(coordinates[i]); // holes
   7504     return sum;
   7505   }
   7506 
   7507   function polygonCentroid(coordinates) {
   7508     var polygon = d3.geom.polygon(coordinates[0].map(projection)), // exterior ring
   7509         area = polygon.area(),
   7510         centroid = polygon.centroid(area < 0 ? (area *= -1, 1) : -1),
   7511         x = centroid[0],
   7512         y = centroid[1],
   7513         z = area,
   7514         i = 0, // coordinates index
   7515         n = coordinates.length;
   7516     while (++i < n) {
   7517       polygon = d3.geom.polygon(coordinates[i].map(projection)); // holes
   7518       area = polygon.area();
   7519       centroid = polygon.centroid(area < 0 ? (area *= -1, 1) : -1);
   7520       x -= centroid[0];
   7521       y -= centroid[1];
   7522       z -= area;
   7523     }
   7524     return [x, y, 6 * z]; // weighted centroid
   7525   }
   7526 
   7527   var centroidType = path.centroid = d3_geo_type({
   7528 
   7529     // TODO FeatureCollection
   7530     // TODO Point
   7531     // TODO MultiPoint
   7532     // TODO LineString
   7533     // TODO MultiLineString
   7534     // TODO GeometryCollection
   7535 
   7536     Feature: function(o) {
   7537       return centroidType(o.geometry);
   7538     },
   7539 
   7540     Polygon: function(o) {
   7541       var centroid = polygonCentroid(o.coordinates);
   7542       return [centroid[0] / centroid[2], centroid[1] / centroid[2]];
   7543     },
   7544 
   7545     MultiPolygon: function(o) {
   7546       var area = 0,
   7547           coordinates = o.coordinates,
   7548           centroid,
   7549           x = 0,
   7550           y = 0,
   7551           z = 0,
   7552           i = -1, // coordinates index
   7553           n = coordinates.length;
   7554       while (++i < n) {
   7555         centroid = polygonCentroid(coordinates[i]);
   7556         x += centroid[0];
   7557         y += centroid[1];
   7558         z += centroid[2];
   7559       }
   7560       return [x / z, y / z];
   7561     }
   7562 
   7563   });
   7564 
   7565   function area(coordinates) {
   7566     return Math.abs(d3.geom.polygon(coordinates.map(projection)).area());
   7567   }
   7568 
   7569   path.projection = function(x) {
   7570     projection = x;
   7571     return path;
   7572   };
   7573 
   7574   path.pointRadius = function(x) {
   7575     if (typeof x === "function") pointRadius = x;
   7576     else {
   7577       pointRadius = +x;
   7578       pointCircle = d3_path_circle(pointRadius);
   7579     }
   7580     return path;
   7581   };
   7582 
   7583   return path;
   7584 };
   7585 
   7586 function d3_path_circle(radius) {
   7587   return "m0," + radius
   7588       + "a" + radius + "," + radius + " 0 1,1 0," + (-2 * radius)
   7589       + "a" + radius + "," + radius + " 0 1,1 0," + (+2 * radius)
   7590       + "z";
   7591 }
   7592 /**
   7593  * Given a GeoJSON object, returns the corresponding bounding box. The bounding
   7594  * box is represented by a two-dimensional array: [[left, bottom], [right,
   7595  * top]], where left is the minimum longitude, bottom is the minimum latitude,
   7596  * right is maximum longitude, and top is the maximum latitude.
   7597  */
   7598 d3.geo.bounds = function(feature) {
   7599   var left = Infinity,
   7600       bottom = Infinity,
   7601       right = -Infinity,
   7602       top = -Infinity;
   7603   d3_geo_bounds(feature, function(x, y) {
   7604     if (x < left) left = x;
   7605     if (x > right) right = x;
   7606     if (y < bottom) bottom = y;
   7607     if (y > top) top = y;
   7608   });
   7609   return [[left, bottom], [right, top]];
   7610 };
   7611 
   7612 function d3_geo_bounds(o, f) {
   7613   if (d3_geo_boundsTypes.hasOwnProperty(o.type)) d3_geo_boundsTypes[o.type](o, f);
   7614 }
   7615 
   7616 var d3_geo_boundsTypes = {
   7617   Feature: d3_geo_boundsFeature,
   7618   FeatureCollection: d3_geo_boundsFeatureCollection,
   7619   GeometryCollection: d3_geo_boundsGeometryCollection,
   7620   LineString: d3_geo_boundsLineString,
   7621   MultiLineString: d3_geo_boundsMultiLineString,
   7622   MultiPoint: d3_geo_boundsLineString,
   7623   MultiPolygon: d3_geo_boundsMultiPolygon,
   7624   Point: d3_geo_boundsPoint,
   7625   Polygon: d3_geo_boundsPolygon
   7626 };
   7627 
   7628 function d3_geo_boundsFeature(o, f) {
   7629   d3_geo_bounds(o.geometry, f);
   7630 }
   7631 
   7632 function d3_geo_boundsFeatureCollection(o, f) {
   7633   for (var a = o.features, i = 0, n = a.length; i < n; i++) {
   7634     d3_geo_bounds(a[i].geometry, f);
   7635   }
   7636 }
   7637 
   7638 function d3_geo_boundsGeometryCollection(o, f) {
   7639   for (var a = o.geometries, i = 0, n = a.length; i < n; i++) {
   7640     d3_geo_bounds(a[i], f);
   7641   }
   7642 }
   7643 
   7644 function d3_geo_boundsLineString(o, f) {
   7645   for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
   7646     f.apply(null, a[i]);
   7647   }
   7648 }
   7649 
   7650 function d3_geo_boundsMultiLineString(o, f) {
   7651   for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
   7652     for (var b = a[i], j = 0, m = b.length; j < m; j++) {
   7653       f.apply(null, b[j]);
   7654     }
   7655   }
   7656 }
   7657 
   7658 function d3_geo_boundsMultiPolygon(o, f) {
   7659   for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
   7660     for (var b = a[i][0], j = 0, m = b.length; j < m; j++) {
   7661       f.apply(null, b[j]);
   7662     }
   7663   }
   7664 }
   7665 
   7666 function d3_geo_boundsPoint(o, f) {
   7667   f.apply(null, o.coordinates);
   7668 }
   7669 
   7670 function d3_geo_boundsPolygon(o, f) {
   7671   for (var a = o.coordinates[0], i = 0, n = a.length; i < n; i++) {
   7672     f.apply(null, a[i]);
   7673   }
   7674 }
   7675 // TODO breakAtDateLine?
   7676 
   7677 d3.geo.circle = function() {
   7678   var origin = [0, 0],
   7679       degrees = 90 - 1e-2,
   7680       radians = degrees * d3_geo_radians,
   7681       arc = d3.geo.greatArc().target(Object);
   7682 
   7683   function circle() {
   7684     // TODO render a circle as a Polygon
   7685   }
   7686 
   7687   function visible(point) {
   7688     return arc.distance(point) < radians;
   7689   }
   7690 
   7691   circle.clip = function(d) {
   7692     arc.source(typeof origin === "function" ? origin.apply(this, arguments) : origin);
   7693     return clipType(d);
   7694   };
   7695 
   7696   var clipType = d3_geo_type({
   7697 
   7698     FeatureCollection: function(o) {
   7699       var features = o.features.map(clipType).filter(Object);
   7700       return features && (o = Object.create(o), o.features = features, o);
   7701     },
   7702 
   7703     Feature: function(o) {
   7704       var geometry = clipType(o.geometry);
   7705       return geometry && (o = Object.create(o), o.geometry = geometry, o);
   7706     },
   7707 
   7708     Point: function(o) {
   7709       return visible(o.coordinates) && o;
   7710     },
   7711 
   7712     MultiPoint: function(o) {
   7713       var coordinates = o.coordinates.filter(visible);
   7714       return coordinates.length && {
   7715         type: o.type,
   7716         coordinates: coordinates
   7717       };
   7718     },
   7719 
   7720     LineString: function(o) {
   7721       var coordinates = clip(o.coordinates);
   7722       return coordinates.length && (o = Object.create(o), o.coordinates = coordinates, o);
   7723     },
   7724 
   7725     MultiLineString: function(o) {
   7726       var coordinates = o.coordinates.map(clip).filter(function(d) { return d.length; });
   7727       return coordinates.length && (o = Object.create(o), o.coordinates = coordinates, o);
   7728     },
   7729 
   7730     Polygon: function(o) {
   7731       var coordinates = o.coordinates.map(clip);
   7732       return coordinates[0].length && (o = Object.create(o), o.coordinates = coordinates, o);
   7733     },
   7734 
   7735     MultiPolygon: function(o) {
   7736       var coordinates = o.coordinates.map(function(d) { return d.map(clip); }).filter(function(d) { return d[0].length; });
   7737       return coordinates.length && (o = Object.create(o), o.coordinates = coordinates, o);
   7738     },
   7739 
   7740     GeometryCollection: function(o) {
   7741       var geometries = o.geometries.map(clipType).filter(Object);
   7742       return geometries.length && (o = Object.create(o), o.geometries = geometries, o);
   7743     }
   7744 
   7745   });
   7746 
   7747   function clip(coordinates) {
   7748     var i = -1,
   7749         n = coordinates.length,
   7750         clipped = [],
   7751         p0,
   7752         p1,
   7753         p2,
   7754         d0,
   7755         d1;
   7756 
   7757     while (++i < n) {
   7758       d1 = arc.distance(p2 = coordinates[i]);
   7759       if (d1 < radians) {
   7760         if (p1) clipped.push(d3_geo_greatArcInterpolate(p1, p2)((d0 - radians) / (d0 - d1)));
   7761         clipped.push(p2);
   7762         p0 = p1 = null;
   7763       } else {
   7764         p1 = p2;
   7765         if (!p0 && clipped.length) {
   7766           clipped.push(d3_geo_greatArcInterpolate(clipped[clipped.length - 1], p1)((radians - d0) / (d1 - d0)));
   7767           p0 = p1;
   7768         }
   7769       }
   7770       d0 = d1;
   7771     }
   7772 
   7773     if (p1 && clipped.length) {
   7774       d1 = arc.distance(p2 = clipped[0]);
   7775       clipped.push(d3_geo_greatArcInterpolate(p1, p2)((d0 - radians) / (d0 - d1)));
   7776     }
   7777 
   7778     return resample(clipped);
   7779   }
   7780 
   7781   // Resample coordinates, creating great arcs between each.
   7782   function resample(coordinates) {
   7783     var i = 0,
   7784         n = coordinates.length,
   7785         j,
   7786         m,
   7787         resampled = n ? [coordinates[0]] : coordinates,
   7788         resamples,
   7789         origin = arc.source();
   7790 
   7791     while (++i < n) {
   7792       resamples = arc.source(coordinates[i - 1])(coordinates[i]).coordinates;
   7793       for (j = 0, m = resamples.length; ++j < m;) resampled.push(resamples[j]);
   7794     }
   7795 
   7796     arc.source(origin);
   7797     return resampled;
   7798   }
   7799 
   7800   circle.origin = function(x) {
   7801     if (!arguments.length) return origin;
   7802     origin = x;
   7803     return circle;
   7804   };
   7805 
   7806   circle.angle = function(x) {
   7807     if (!arguments.length) return degrees;
   7808     radians = (degrees = +x) * d3_geo_radians;
   7809     return circle;
   7810   };
   7811 
   7812   // Precision is specified in degrees.
   7813   circle.precision = function(x) {
   7814     if (!arguments.length) return arc.precision();
   7815     arc.precision(x);
   7816     return circle;
   7817   };
   7818 
   7819   return circle;
   7820 }
   7821 d3.geo.greatArc = function() {
   7822   var source = d3_geo_greatArcSource,
   7823       target = d3_geo_greatArcTarget,
   7824       precision = 6 * d3_geo_radians;
   7825 
   7826   function greatArc() {
   7827     var a = typeof source === "function" ? source.apply(this, arguments) : source,
   7828         b = typeof target === "function" ? target.apply(this, arguments) : target,
   7829         i = d3_geo_greatArcInterpolate(a, b),
   7830         dt = precision / i.d,
   7831         t = 0,
   7832         coordinates = [a];
   7833     while ((t += dt) < 1) coordinates.push(i(t));
   7834     coordinates.push(b);
   7835     return {
   7836       type: "LineString",
   7837       coordinates: coordinates
   7838     };
   7839   }
   7840 
   7841   // Length returned in radians; multiply by radius for distance.
   7842   greatArc.distance = function() {
   7843     var a = typeof source === "function" ? source.apply(this, arguments) : source,
   7844         b = typeof target === "function" ? target.apply(this, arguments) : target;
   7845      return d3_geo_greatArcInterpolate(a, b).d;
   7846   };
   7847 
   7848   greatArc.source = function(x) {
   7849     if (!arguments.length) return source;
   7850     source = x;
   7851     return greatArc;
   7852   };
   7853 
   7854   greatArc.target = function(x) {
   7855     if (!arguments.length) return target;
   7856     target = x;
   7857     return greatArc;
   7858   };
   7859 
   7860   // Precision is specified in degrees.
   7861   greatArc.precision = function(x) {
   7862     if (!arguments.length) return precision / d3_geo_radians;
   7863     precision = x * d3_geo_radians;
   7864     return greatArc;
   7865   };
   7866 
   7867   return greatArc;
   7868 };
   7869 
   7870 function d3_geo_greatArcSource(d) {
   7871   return d.source;
   7872 }
   7873 
   7874 function d3_geo_greatArcTarget(d) {
   7875   return d.target;
   7876 }
   7877 
   7878 function d3_geo_greatArcInterpolate(a, b) {
   7879   var x0 = a[0] * d3_geo_radians, cx0 = Math.cos(x0), sx0 = Math.sin(x0),
   7880       y0 = a[1] * d3_geo_radians, cy0 = Math.cos(y0), sy0 = Math.sin(y0),
   7881       x1 = b[0] * d3_geo_radians, cx1 = Math.cos(x1), sx1 = Math.sin(x1),
   7882       y1 = b[1] * d3_geo_radians, cy1 = Math.cos(y1), sy1 = Math.sin(y1),
   7883       d = interpolate.d = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0)))),
   7884       sd = Math.sin(d);
   7885 
   7886   // From http://williams.best.vwh.net/avform.htm#Intermediate
   7887   function interpolate(t) {
   7888     var A = Math.sin(d - (t *= d)) / sd,
   7889         B = Math.sin(t) / sd,
   7890         x = A * cy0 * cx0 + B * cy1 * cx1,
   7891         y = A * cy0 * sx0 + B * cy1 * sx1,
   7892         z = A * sy0       + B * sy1;
   7893     return [
   7894       Math.atan2(y, x) / d3_geo_radians,
   7895       Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_geo_radians
   7896     ];
   7897   }
   7898 
   7899   return interpolate;
   7900 }
   7901 d3.geo.greatCircle = d3.geo.circle;
   7902 d3.geom = {};
   7903 /**
   7904  * Computes a contour for a given input grid function using the <a
   7905  * href="http://en.wikipedia.org/wiki/Marching_squares">marching
   7906  * squares</a> algorithm. Returns the contour polygon as an array of points.
   7907  *
   7908  * @param grid a two-input function(x, y) that returns true for values
   7909  * inside the contour and false for values outside the contour.
   7910  * @param start an optional starting point [x, y] on the grid.
   7911  * @returns polygon [[x1, y1], [x2, y2], …]
   7912  */
   7913 d3.geom.contour = function(grid, start) {
   7914   var s = start || d3_geom_contourStart(grid), // starting point
   7915       c = [],    // contour polygon
   7916       x = s[0],  // current x position
   7917       y = s[1],  // current y position
   7918       dx = 0,    // next x direction
   7919       dy = 0,    // next y direction
   7920       pdx = NaN, // previous x direction
   7921       pdy = NaN, // previous y direction
   7922       i = 0;
   7923 
   7924   do {
   7925     // determine marching squares index
   7926     i = 0;
   7927     if (grid(x-1, y-1)) i += 1;
   7928     if (grid(x,   y-1)) i += 2;
   7929     if (grid(x-1, y  )) i += 4;
   7930     if (grid(x,   y  )) i += 8;
   7931 
   7932     // determine next direction
   7933     if (i === 6) {
   7934       dx = pdy === -1 ? -1 : 1;
   7935       dy = 0;
   7936     } else if (i === 9) {
   7937       dx = 0;
   7938       dy = pdx === 1 ? -1 : 1;
   7939     } else {
   7940       dx = d3_geom_contourDx[i];
   7941       dy = d3_geom_contourDy[i];
   7942     }
   7943 
   7944     // update contour polygon
   7945     if (dx != pdx && dy != pdy) {
   7946       c.push([x, y]);
   7947       pdx = dx;
   7948       pdy = dy;
   7949     }
   7950 
   7951     x += dx;
   7952     y += dy;
   7953   } while (s[0] != x || s[1] != y);
   7954 
   7955   return c;
   7956 };
   7957 
   7958 // lookup tables for marching directions
   7959 var d3_geom_contourDx = [1, 0, 1, 1,-1, 0,-1, 1,0, 0,0,0,-1, 0,-1,NaN],
   7960     d3_geom_contourDy = [0,-1, 0, 0, 0,-1, 0, 0,1,-1,1,1, 0,-1, 0,NaN];
   7961 
   7962 function d3_geom_contourStart(grid) {
   7963   var x = 0,
   7964       y = 0;
   7965 
   7966   // search for a starting point; begin at origin
   7967   // and proceed along outward-expanding diagonals
   7968   while (true) {
   7969     if (grid(x,y)) {
   7970       return [x,y];
   7971     }
   7972     if (x === 0) {
   7973       x = y + 1;
   7974       y = 0;
   7975     } else {
   7976       x = x - 1;
   7977       y = y + 1;
   7978     }
   7979   }
   7980 }
   7981 /**
   7982  * Computes the 2D convex hull of a set of points using Graham's scanning
   7983  * algorithm. The algorithm has been implemented as described in Cormen,
   7984  * Leiserson, and Rivest's Introduction to Algorithms. The running time of
   7985  * this algorithm is O(n log n), where n is the number of input points.
   7986  *
   7987  * @param vertices [[x1, y1], [x2, y2], …]
   7988  * @returns polygon [[x1, y1], [x2, y2], …]
   7989  */
   7990 d3.geom.hull = function(vertices) {
   7991   if (vertices.length < 3) return [];
   7992 
   7993   var len = vertices.length,
   7994       plen = len - 1,
   7995       points = [],
   7996       stack = [],
   7997       i, j, h = 0, x1, y1, x2, y2, u, v, a, sp;
   7998 
   7999   // find the starting ref point: leftmost point with the minimum y coord
   8000   for (i=1; i<len; ++i) {
   8001     if (vertices[i][1] < vertices[h][1]) {
   8002       h = i;
   8003     } else if (vertices[i][1] == vertices[h][1]) {
   8004       h = (vertices[i][0] < vertices[h][0] ? i : h);
   8005     }
   8006   }
   8007 
   8008   // calculate polar angles from ref point and sort
   8009   for (i=0; i<len; ++i) {
   8010     if (i === h) continue;
   8011     y1 = vertices[i][1] - vertices[h][1];
   8012     x1 = vertices[i][0] - vertices[h][0];
   8013     points.push({angle: Math.atan2(y1, x1), index: i});
   8014   }
   8015   points.sort(function(a, b) { return a.angle - b.angle; });
   8016 
   8017   // toss out duplicate angles
   8018   a = points[0].angle;
   8019   v = points[0].index;
   8020   u = 0;
   8021   for (i=1; i<plen; ++i) {
   8022     j = points[i].index;
   8023     if (a == points[i].angle) {
   8024       // keep angle for point most distant from the reference
   8025       x1 = vertices[v][0] - vertices[h][0];
   8026       y1 = vertices[v][1] - vertices[h][1];
   8027       x2 = vertices[j][0] - vertices[h][0];
   8028       y2 = vertices[j][1] - vertices[h][1];
   8029       if ((x1*x1 + y1*y1) >= (x2*x2 + y2*y2)) {
   8030         points[i].index = -1;
   8031       } else {
   8032         points[u].index = -1;
   8033         a = points[i].angle;
   8034         u = i;
   8035         v = j;
   8036       }
   8037     } else {
   8038       a = points[i].angle;
   8039       u = i;
   8040       v = j;
   8041     }
   8042   }
   8043 
   8044   // initialize the stack
   8045   stack.push(h);
   8046   for (i=0, j=0; i<2; ++j) {
   8047     if (points[j].index !== -1) {
   8048       stack.push(points[j].index);
   8049       i++;
   8050     }
   8051   }
   8052   sp = stack.length;
   8053 
   8054   // do graham's scan
   8055   for (; j<plen; ++j) {
   8056     if (points[j].index === -1) continue; // skip tossed out points
   8057     while (!d3_geom_hullCCW(stack[sp-2], stack[sp-1], points[j].index, vertices)) {
   8058       --sp;
   8059     }
   8060     stack[sp++] = points[j].index;
   8061   }
   8062 
   8063   // construct the hull
   8064   var poly = [];
   8065   for (i=0; i<sp; ++i) {
   8066     poly.push(vertices[stack[i]]);
   8067   }
   8068   return poly;
   8069 }
   8070 
   8071 // are three points in counter-clockwise order?
   8072 function d3_geom_hullCCW(i1, i2, i3, v) {
   8073   var t, a, b, c, d, e, f;
   8074   t = v[i1]; a = t[0]; b = t[1];
   8075   t = v[i2]; c = t[0]; d = t[1];
   8076   t = v[i3]; e = t[0]; f = t[1];
   8077   return ((f-b)*(c-a) - (d-b)*(e-a)) > 0;
   8078 }
   8079 // Note: requires coordinates to be counterclockwise and convex!
   8080 d3.geom.polygon = function(coordinates) {
   8081 
   8082   coordinates.area = function() {
   8083     var i = 0,
   8084         n = coordinates.length,
   8085         a = coordinates[n - 1][0] * coordinates[0][1],
   8086         b = coordinates[n - 1][1] * coordinates[0][0];
   8087     while (++i < n) {
   8088       a += coordinates[i - 1][0] * coordinates[i][1];
   8089       b += coordinates[i - 1][1] * coordinates[i][0];
   8090     }
   8091     return (b - a) * .5;
   8092   };
   8093 
   8094   coordinates.centroid = function(k) {
   8095     var i = -1,
   8096         n = coordinates.length,
   8097         x = 0,
   8098         y = 0,
   8099         a,
   8100         b = coordinates[n - 1],
   8101         c;
   8102     if (!arguments.length) k = -1 / (6 * coordinates.area());
   8103     while (++i < n) {
   8104       a = b;
   8105       b = coordinates[i];
   8106       c = a[0] * b[1] - b[0] * a[1];
   8107       x += (a[0] + b[0]) * c;
   8108       y += (a[1] + b[1]) * c;
   8109     }
   8110     return [x * k, y * k];
   8111   };
   8112 
   8113   // The Sutherland-Hodgman clipping algorithm.
   8114   coordinates.clip = function(subject) {
   8115     var input,
   8116         i = -1,
   8117         n = coordinates.length,
   8118         j,
   8119         m,
   8120         a = coordinates[n - 1],
   8121         b,
   8122         c,
   8123         d;
   8124     while (++i < n) {
   8125       input = subject.slice();
   8126       subject.length = 0;
   8127       b = coordinates[i];
   8128       c = input[(m = input.length) - 1];
   8129       j = -1;
   8130       while (++j < m) {
   8131         d = input[j];
   8132         if (d3_geom_polygonInside(d, a, b)) {
   8133           if (!d3_geom_polygonInside(c, a, b)) {
   8134             subject.push(d3_geom_polygonIntersect(c, d, a, b));
   8135           }
   8136           subject.push(d);
   8137         } else if (d3_geom_polygonInside(c, a, b)) {
   8138           subject.push(d3_geom_polygonIntersect(c, d, a, b));
   8139         }
   8140         c = d;
   8141       }
   8142       a = b;
   8143     }
   8144     return subject;
   8145   };
   8146 
   8147   return coordinates;
   8148 };
   8149 
   8150 function d3_geom_polygonInside(p, a, b) {
   8151   return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);
   8152 }
   8153 
   8154 // Intersect two infinite lines cd and ab.
   8155 function d3_geom_polygonIntersect(c, d, a, b) {
   8156   var x1 = c[0], x2 = d[0], x3 = a[0], x4 = b[0],
   8157       y1 = c[1], y2 = d[1], y3 = a[1], y4 = b[1],
   8158       x13 = x1 - x3,
   8159       x21 = x2 - x1,
   8160       x43 = x4 - x3,
   8161       y13 = y1 - y3,
   8162       y21 = y2 - y1,
   8163       y43 = y4 - y3,
   8164       ua = (x43 * y13 - y43 * x13) / (y43 * x21 - x43 * y21);
   8165   return [x1 + ua * x21, y1 + ua * y21];
   8166 }
   8167 // Adapted from Nicolas Garcia Belmonte's JIT implementation:
   8168 // http://blog.thejit.org/2010/02/12/voronoi-tessellation/
   8169 // http://blog.thejit.org/assets/voronoijs/voronoi.js
   8170 // See lib/jit/LICENSE for details.
   8171 
   8172 // Notes:
   8173 //
   8174 // This implementation does not clip the returned polygons, so if you want to
   8175 // clip them to a particular shape you will need to do that either in SVG or by
   8176 // post-processing with d3.geom.polygon's clip method.
   8177 //
   8178 // If any vertices are coincident or have NaN positions, the behavior of this
   8179 // method is undefined. Most likely invalid polygons will be returned. You
   8180 // should filter invalid points, and consolidate coincident points, before
   8181 // computing the tessellation.
   8182 
   8183 /**
   8184  * @param vertices [[x1, y1], [x2, y2], …]
   8185  * @returns polygons [[[x1, y1], [x2, y2], …], …]
   8186  */
   8187 d3.geom.voronoi = function(vertices) {
   8188   var polygons = vertices.map(function() { return []; });
   8189 
   8190   d3_voronoi_tessellate(vertices, function(e) {
   8191     var s1,
   8192         s2,
   8193         x1,
   8194         x2,
   8195         y1,
   8196         y2;
   8197     if (e.a === 1 && e.b >= 0) {
   8198       s1 = e.ep.r;
   8199       s2 = e.ep.l;
   8200     } else {
   8201       s1 = e.ep.l;
   8202       s2 = e.ep.r;
   8203     }
   8204     if (e.a === 1) {
   8205       y1 = s1 ? s1.y : -1e6;
   8206       x1 = e.c - e.b * y1;
   8207       y2 = s2 ? s2.y : 1e6;
   8208       x2 = e.c - e.b * y2;
   8209     } else {
   8210       x1 = s1 ? s1.x : -1e6;
   8211       y1 = e.c - e.a * x1;
   8212       x2 = s2 ? s2.x : 1e6;
   8213       y2 = e.c - e.a * x2;
   8214     }
   8215     var v1 = [x1, y1],
   8216         v2 = [x2, y2];
   8217     polygons[e.region.l.index].push(v1, v2);
   8218     polygons[e.region.r.index].push(v1, v2);
   8219   });
   8220 
   8221   // Reconnect the polygon segments into counterclockwise loops.
   8222   return polygons.map(function(polygon, i) {
   8223     var cx = vertices[i][0],
   8224         cy = vertices[i][1];
   8225     polygon.forEach(function(v) {
   8226       v.angle = Math.atan2(v[0] - cx, v[1] - cy);
   8227     });
   8228     return polygon.sort(function(a, b) {
   8229       return a.angle - b.angle;
   8230     }).filter(function(d, i) {
   8231       return !i || (d.angle - polygon[i - 1].angle > 1e-10);
   8232     });
   8233   });
   8234 };
   8235 
   8236 var d3_voronoi_opposite = {"l": "r", "r": "l"};
   8237 
   8238 function d3_voronoi_tessellate(vertices, callback) {
   8239 
   8240   var Sites = {
   8241     list: vertices
   8242       .map(function(v, i) {
   8243         return {
   8244           index: i,
   8245           x: v[0],
   8246           y: v[1]
   8247         };
   8248       })
   8249       .sort(function(a, b) {
   8250         return a.y < b.y ? -1
   8251           : a.y > b.y ? 1
   8252           : a.x < b.x ? -1
   8253           : a.x > b.x ? 1
   8254           : 0;
   8255       }),
   8256     bottomSite: null
   8257   };
   8258 
   8259   var EdgeList = {
   8260     list: [],
   8261     leftEnd: null,
   8262     rightEnd: null,
   8263 
   8264     init: function() {
   8265       EdgeList.leftEnd = EdgeList.createHalfEdge(null, "l");
   8266       EdgeList.rightEnd = EdgeList.createHalfEdge(null, "l");
   8267       EdgeList.leftEnd.r = EdgeList.rightEnd;
   8268       EdgeList.rightEnd.l = EdgeList.leftEnd;
   8269       EdgeList.list.unshift(EdgeList.leftEnd, EdgeList.rightEnd);
   8270     },
   8271 
   8272     createHalfEdge: function(edge, side) {
   8273       return {
   8274         edge: edge,
   8275         side: side,
   8276         vertex: null,
   8277         "l": null,
   8278         "r": null
   8279       };
   8280     },
   8281 
   8282     insert: function(lb, he) {
   8283       he.l = lb;
   8284       he.r = lb.r;
   8285       lb.r.l = he;
   8286       lb.r = he;
   8287     },
   8288 
   8289     leftBound: function(p) {
   8290       var he = EdgeList.leftEnd;
   8291       do {
   8292         he = he.r;
   8293       } while (he != EdgeList.rightEnd && Geom.rightOf(he, p));
   8294       he = he.l;
   8295       return he;
   8296     },
   8297 
   8298     del: function(he) {
   8299       he.l.r = he.r;
   8300       he.r.l = he.l;
   8301       he.edge = null;
   8302     },
   8303 
   8304     right: function(he) {
   8305       return he.r;
   8306     },
   8307 
   8308     left: function(he) {
   8309       return he.l;
   8310     },
   8311 
   8312     leftRegion: function(he) {
   8313       return he.edge == null
   8314           ? Sites.bottomSite
   8315           : he.edge.region[he.side];
   8316     },
   8317 
   8318     rightRegion: function(he) {
   8319       return he.edge == null
   8320           ? Sites.bottomSite
   8321           : he.edge.region[d3_voronoi_opposite[he.side]];
   8322     }
   8323   };
   8324 
   8325   var Geom = {
   8326 
   8327     bisect: function(s1, s2) {
   8328       var newEdge = {
   8329         region: {"l": s1, "r": s2},
   8330         ep: {"l": null, "r": null}
   8331       };
   8332 
   8333       var dx = s2.x - s1.x,
   8334           dy = s2.y - s1.y,
   8335           adx = dx > 0 ? dx : -dx,
   8336           ady = dy > 0 ? dy : -dy;
   8337 
   8338       newEdge.c = s1.x * dx + s1.y * dy
   8339           + (dx * dx + dy * dy) * .5;
   8340 
   8341       if (adx > ady) {
   8342         newEdge.a = 1;
   8343         newEdge.b = dy / dx;
   8344         newEdge.c /= dx;
   8345       } else {
   8346         newEdge.b = 1;
   8347         newEdge.a = dx / dy;
   8348         newEdge.c /= dy;
   8349       }
   8350 
   8351       return newEdge;
   8352     },
   8353 
   8354     intersect: function(el1, el2) {
   8355       var e1 = el1.edge,
   8356           e2 = el2.edge;
   8357       if (!e1 || !e2 || (e1.region.r == e2.region.r)) {
   8358         return null;
   8359       }
   8360       var d = (e1.a * e2.b) - (e1.b * e2.a);
   8361       if (Math.abs(d) < 1e-10) {
   8362         return null;
   8363       }
   8364       var xint = (e1.c * e2.b - e2.c * e1.b) / d,
   8365           yint = (e2.c * e1.a - e1.c * e2.a) / d,
   8366           e1r = e1.region.r,
   8367           e2r = e2.region.r,
   8368           el,
   8369           e;
   8370       if ((e1r.y < e2r.y) ||
   8371          (e1r.y == e2r.y && e1r.x < e2r.x)) {
   8372         el = el1;
   8373         e = e1;
   8374       } else {
   8375         el = el2;
   8376         e = e2;
   8377       }
   8378       var rightOfSite = (xint >= e.region.r.x);
   8379       if ((rightOfSite && (el.side === "l")) ||
   8380         (!rightOfSite && (el.side === "r"))) {
   8381         return null;
   8382       }
   8383       return {
   8384         x: xint,
   8385         y: yint
   8386       };
   8387     },
   8388 
   8389     rightOf: function(he, p) {
   8390       var e = he.edge,
   8391           topsite = e.region.r,
   8392           rightOfSite = (p.x > topsite.x);
   8393 
   8394       if (rightOfSite && (he.side === "l")) {
   8395         return 1;
   8396       }
   8397       if (!rightOfSite && (he.side === "r")) {
   8398         return 0;
   8399       }
   8400       if (e.a === 1) {
   8401         var dyp = p.y - topsite.y,
   8402             dxp = p.x - topsite.x,
   8403             fast = 0,
   8404             above = 0;
   8405 
   8406         if ((!rightOfSite && (e.b < 0)) ||
   8407           (rightOfSite && (e.b >= 0))) {
   8408           above = fast = (dyp >= e.b * dxp);
   8409         } else {
   8410           above = ((p.x + p.y * e.b) > e.c);
   8411           if (e.b < 0) {
   8412             above = !above;
   8413           }
   8414           if (!above) {
   8415             fast = 1;
   8416           }
   8417         }
   8418         if (!fast) {
   8419           var dxs = topsite.x - e.region.l.x;
   8420           above = (e.b * (dxp * dxp - dyp * dyp)) <
   8421             (dxs * dyp * (1 + 2 * dxp / dxs + e.b * e.b));
   8422 
   8423           if (e.b < 0) {
   8424             above = !above;
   8425           }
   8426         }
   8427       } else /* e.b == 1 */ {
   8428         var yl = e.c - e.a * p.x,
   8429             t1 = p.y - yl,
   8430             t2 = p.x - topsite.x,
   8431             t3 = yl - topsite.y;
   8432 
   8433         above = (t1 * t1) > (t2 * t2 + t3 * t3);
   8434       }
   8435       return he.side === "l" ? above : !above;
   8436     },
   8437 
   8438     endPoint: function(edge, side, site) {
   8439       edge.ep[side] = site;
   8440       if (!edge.ep[d3_voronoi_opposite[side]]) return;
   8441       callback(edge);
   8442     },
   8443 
   8444     distance: function(s, t) {
   8445       var dx = s.x - t.x,
   8446           dy = s.y - t.y;
   8447       return Math.sqrt(dx * dx + dy * dy);
   8448     }
   8449   };
   8450 
   8451   var EventQueue = {
   8452     list: [],
   8453 
   8454     insert: function(he, site, offset) {
   8455       he.vertex = site;
   8456       he.ystar = site.y + offset;
   8457       for (var i=0, list=EventQueue.list, l=list.length; i<l; i++) {
   8458         var next = list[i];
   8459         if (he.ystar > next.ystar ||
   8460           (he.ystar == next.ystar &&
   8461           site.x > next.vertex.x)) {
   8462           continue;
   8463         } else {
   8464           break;
   8465         }
   8466       }
   8467       list.splice(i, 0, he);
   8468     },
   8469 
   8470     del: function(he) {
   8471       for (var i=0, ls=EventQueue.list, l=ls.length; i<l && (ls[i] != he); ++i) {}
   8472       ls.splice(i, 1);
   8473     },
   8474 
   8475     empty: function() { return EventQueue.list.length === 0; },
   8476 
   8477     nextEvent: function(he) {
   8478       for (var i=0, ls=EventQueue.list, l=ls.length; i<l; ++i) {
   8479         if (ls[i] == he) return ls[i+1];
   8480       }
   8481       return null;
   8482     },
   8483 
   8484     min: function() {
   8485       var elem = EventQueue.list[0];
   8486       return {
   8487         x: elem.vertex.x,
   8488         y: elem.ystar
   8489       };
   8490     },
   8491 
   8492     extractMin: function() {
   8493       return EventQueue.list.shift();
   8494     }
   8495   };
   8496 
   8497   EdgeList.init();
   8498   Sites.bottomSite = Sites.list.shift();
   8499 
   8500   var newSite = Sites.list.shift(), newIntStar;
   8501   var lbnd, rbnd, llbnd, rrbnd, bisector;
   8502   var bot, top, temp, p, v;
   8503   var e, pm;
   8504 
   8505   while (true) {
   8506     if (!EventQueue.empty()) {
   8507       newIntStar = EventQueue.min();
   8508     }
   8509     if (newSite && (EventQueue.empty()
   8510       || newSite.y < newIntStar.y
   8511       || (newSite.y == newIntStar.y
   8512       && newSite.x < newIntStar.x))) { //new site is smallest
   8513       lbnd = EdgeList.leftBound(newSite);
   8514       rbnd = EdgeList.right(lbnd);
   8515       bot = EdgeList.rightRegion(lbnd);
   8516       e = Geom.bisect(bot, newSite);
   8517       bisector = EdgeList.createHalfEdge(e, "l");
   8518       EdgeList.insert(lbnd, bisector);
   8519       p = Geom.intersect(lbnd, bisector);
   8520       if (p) {
   8521         EventQueue.del(lbnd);
   8522         EventQueue.insert(lbnd, p, Geom.distance(p, newSite));
   8523       }
   8524       lbnd = bisector;
   8525       bisector = EdgeList.createHalfEdge(e, "r");
   8526       EdgeList.insert(lbnd, bisector);
   8527       p = Geom.intersect(bisector, rbnd);
   8528       if (p) {
   8529         EventQueue.insert(bisector, p, Geom.distance(p, newSite));
   8530       }
   8531       newSite = Sites.list.shift();
   8532     } else if (!EventQueue.empty()) { //intersection is smallest
   8533       lbnd = EventQueue.extractMin();
   8534       llbnd = EdgeList.left(lbnd);
   8535       rbnd = EdgeList.right(lbnd);
   8536       rrbnd = EdgeList.right(rbnd);
   8537       bot = EdgeList.leftRegion(lbnd);
   8538       top = EdgeList.rightRegion(rbnd);
   8539       v = lbnd.vertex;
   8540       Geom.endPoint(lbnd.edge, lbnd.side, v);
   8541       Geom.endPoint(rbnd.edge, rbnd.side, v);
   8542       EdgeList.del(lbnd);
   8543       EventQueue.del(rbnd);
   8544       EdgeList.del(rbnd);
   8545       pm = "l";
   8546       if (bot.y > top.y) {
   8547         temp = bot;
   8548         bot = top;
   8549         top = temp;
   8550         pm = "r";
   8551       }
   8552       e = Geom.bisect(bot, top);
   8553       bisector = EdgeList.createHalfEdge(e, pm);
   8554       EdgeList.insert(llbnd, bisector);
   8555       Geom.endPoint(e, d3_voronoi_opposite[pm], v);
   8556       p = Geom.intersect(llbnd, bisector);
   8557       if (p) {
   8558         EventQueue.del(llbnd);
   8559         EventQueue.insert(llbnd, p, Geom.distance(p, bot));
   8560       }
   8561       p = Geom.intersect(bisector, rrbnd);
   8562       if (p) {
   8563         EventQueue.insert(bisector, p, Geom.distance(p, bot));
   8564       }
   8565     } else {
   8566       break;
   8567     }
   8568   }//end while
   8569 
   8570   for (lbnd = EdgeList.right(EdgeList.leftEnd);
   8571       lbnd != EdgeList.rightEnd;
   8572       lbnd = EdgeList.right(lbnd)) {
   8573     callback(lbnd.edge);
   8574   }
   8575 }
   8576 /**
   8577 * @param vertices [[x1, y1], [x2, y2], …]
   8578 * @returns triangles [[[x1, y1], [x2, y2], [x3, y3]], …]
   8579  */
   8580 d3.geom.delaunay = function(vertices) {
   8581   var edges = vertices.map(function() { return []; }),
   8582       triangles = [];
   8583 
   8584   // Use the Voronoi tessellation to determine Delaunay edges.
   8585   d3_voronoi_tessellate(vertices, function(e) {
   8586     edges[e.region.l.index].push(vertices[e.region.r.index]);
   8587   });
   8588 
   8589   // Reconnect the edges into counterclockwise triangles.
   8590   edges.forEach(function(edge, i) {
   8591     var v = vertices[i],
   8592         cx = v[0],
   8593         cy = v[1];
   8594     edge.forEach(function(v) {
   8595       v.angle = Math.atan2(v[0] - cx, v[1] - cy);
   8596     });
   8597     edge.sort(function(a, b) {
   8598       return a.angle - b.angle;
   8599     });
   8600     for (var j = 0, m = edge.length - 1; j < m; j++) {
   8601       triangles.push([v, edge[j], edge[j + 1]]);
   8602     }
   8603   });
   8604 
   8605   return triangles;
   8606 };
   8607 // Constructs a new quadtree for the specified array of points. A quadtree is a
   8608 // two-dimensional recursive spatial subdivision. This implementation uses
   8609 // square partitions, dividing each square into four equally-sized squares. Each
   8610 // point exists in a unique node; if multiple points are in the same position,
   8611 // some points may be stored on internal nodes rather than leaf nodes. Quadtrees
   8612 // can be used to accelerate various spatial operations, such as the Barnes-Hut
   8613 // approximation for computing n-body forces, or collision detection.
   8614 d3.geom.quadtree = function(points, x1, y1, x2, y2) {
   8615   var p,
   8616       i = -1,
   8617       n = points.length;
   8618 
   8619   // Type conversion for deprecated API.
   8620   if (n && isNaN(points[0].x)) points = points.map(d3_geom_quadtreePoint);
   8621 
   8622   // Allow bounds to be specified explicitly.
   8623   if (arguments.length < 5) {
   8624     if (arguments.length === 3) {
   8625       y2 = x2 = y1;
   8626       y1 = x1;
   8627     } else {
   8628       x1 = y1 = Infinity;
   8629       x2 = y2 = -Infinity;
   8630 
   8631       // Compute bounds.
   8632       while (++i < n) {
   8633         p = points[i];
   8634         if (p.x < x1) x1 = p.x;
   8635         if (p.y < y1) y1 = p.y;
   8636         if (p.x > x2) x2 = p.x;
   8637         if (p.y > y2) y2 = p.y;
   8638       }
   8639 
   8640       // Squarify the bounds.
   8641       var dx = x2 - x1,
   8642           dy = y2 - y1;
   8643       if (dx > dy) y2 = y1 + dx;
   8644       else x2 = x1 + dy;
   8645     }
   8646   }
   8647 
   8648   // Recursively inserts the specified point p at the node n or one of its
   8649   // descendants. The bounds are defined by [x1, x2] and [y1, y2].
   8650   function insert(n, p, x1, y1, x2, y2) {
   8651     if (isNaN(p.x) || isNaN(p.y)) return; // ignore invalid points
   8652     if (n.leaf) {
   8653       var v = n.point;
   8654       if (v) {
   8655         // If the point at this leaf node is at the same position as the new
   8656         // point we are adding, we leave the point associated with the
   8657         // internal node while adding the new point to a child node. This
   8658         // avoids infinite recursion.
   8659         if ((Math.abs(v.x - p.x) + Math.abs(v.y - p.y)) < .01) {
   8660           insertChild(n, p, x1, y1, x2, y2);
   8661         } else {
   8662           n.point = null;
   8663           insertChild(n, v, x1, y1, x2, y2);
   8664           insertChild(n, p, x1, y1, x2, y2);
   8665         }
   8666       } else {
   8667         n.point = p;
   8668       }
   8669     } else {
   8670       insertChild(n, p, x1, y1, x2, y2);
   8671     }
   8672   }
   8673 
   8674   // Recursively inserts the specified point p into a descendant of node n. The
   8675   // bounds are defined by [x1, x2] and [y1, y2].
   8676   function insertChild(n, p, x1, y1, x2, y2) {
   8677     // Compute the split point, and the quadrant in which to insert p.
   8678     var sx = (x1 + x2) * .5,
   8679         sy = (y1 + y2) * .5,
   8680         right = p.x >= sx,
   8681         bottom = p.y >= sy,
   8682         i = (bottom << 1) + right;
   8683 
   8684     // Recursively insert into the child node.
   8685     n.leaf = false;
   8686     n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());
   8687 
   8688     // Update the bounds as we recurse.
   8689     if (right) x1 = sx; else x2 = sx;
   8690     if (bottom) y1 = sy; else y2 = sy;
   8691     insert(n, p, x1, y1, x2, y2);
   8692   }
   8693 
   8694   // Create the root node.
   8695   var root = d3_geom_quadtreeNode();
   8696 
   8697   root.add = function(p) {
   8698     insert(root, p, x1, y1, x2, y2);
   8699   };
   8700 
   8701   root.visit = function(f) {
   8702     d3_geom_quadtreeVisit(f, root, x1, y1, x2, y2);
   8703   };
   8704 
   8705   // Insert all points.
   8706   points.forEach(root.add);
   8707   return root;
   8708 };
   8709 
   8710 function d3_geom_quadtreeNode() {
   8711   return {
   8712     leaf: true,
   8713     nodes: [],
   8714     point: null
   8715   };
   8716 }
   8717 
   8718 function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {
   8719   if (!f(node, x1, y1, x2, y2)) {
   8720     var sx = (x1 + x2) * .5,
   8721         sy = (y1 + y2) * .5,
   8722         children = node.nodes;
   8723     if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);
   8724     if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);
   8725     if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);
   8726     if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
   8727   }
   8728 }
   8729 
   8730 function d3_geom_quadtreePoint(p) {
   8731   return {
   8732     x: p[0],
   8733     y: p[1]
   8734   };
   8735 }
   8736 d3.time = {};
   8737 
   8738 var d3_time = Date;
   8739 
   8740 function d3_time_utc() {
   8741   this._ = new Date(arguments.length > 1
   8742       ? Date.UTC.apply(this, arguments)
   8743       : arguments[0]);
   8744 }
   8745 
   8746 d3_time_utc.prototype = {
   8747   getDate: function() { return this._.getUTCDate(); },
   8748   getDay: function() { return this._.getUTCDay(); },
   8749   getFullYear: function() { return this._.getUTCFullYear(); },
   8750   getHours: function() { return this._.getUTCHours(); },
   8751   getMilliseconds: function() { return this._.getUTCMilliseconds(); },
   8752   getMinutes: function() { return this._.getUTCMinutes(); },
   8753   getMonth: function() { return this._.getUTCMonth(); },
   8754   getSeconds: function() { return this._.getUTCSeconds(); },
   8755   getTime: function() { return this._.getTime(); },
   8756   getTimezoneOffset: function() { return 0; },
   8757   valueOf: function() { return this._.valueOf(); },
   8758   setDate: function() { d3_time_prototype.setUTCDate.apply(this._, arguments); },
   8759   setDay: function() { d3_time_prototype.setUTCDay.apply(this._, arguments); },
   8760   setFullYear: function() { d3_time_prototype.setUTCFullYear.apply(this._, arguments); },
   8761   setHours: function() { d3_time_prototype.setUTCHours.apply(this._, arguments); },
   8762   setMilliseconds: function() { d3_time_prototype.setUTCMilliseconds.apply(this._, arguments); },
   8763   setMinutes: function() { d3_time_prototype.setUTCMinutes.apply(this._, arguments); },
   8764   setMonth: function() { d3_time_prototype.setUTCMonth.apply(this._, arguments); },
   8765   setSeconds: function() { d3_time_prototype.setUTCSeconds.apply(this._, arguments); },
   8766   setTime: function() { d3_time_prototype.setTime.apply(this._, arguments); }
   8767 };
   8768 
   8769 var d3_time_prototype = Date.prototype;
   8770 d3.time.format = function(template) {
   8771   var n = template.length;
   8772 
   8773   function format(date) {
   8774     var string = [],
   8775         i = -1,
   8776         j = 0,
   8777         c,
   8778         f;
   8779     while (++i < n) {
   8780       if (template.charCodeAt(i) == 37) {
   8781         string.push(
   8782             template.substring(j, i),
   8783             (f = d3_time_formats[c = template.charAt(++i)])
   8784             ? f(date) : c);
   8785         j = i + 1;
   8786       }
   8787     }
   8788     string.push(template.substring(j, i));
   8789     return string.join("");
   8790   }
   8791 
   8792   format.parse = function(string) {
   8793     var d = {y: 1900, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0},
   8794         i = d3_time_parse(d, template, string, 0);
   8795     if (i != string.length) return null;
   8796 
   8797     // The am-pm flag is 0 for AM, and 1 for PM.
   8798     if ("p" in d) d.H = d.H % 12 + d.p * 12;
   8799 
   8800     var date = new d3_time();
   8801     date.setFullYear(d.y, d.m, d.d);
   8802     date.setHours(d.H, d.M, d.S, d.L);
   8803     return date;
   8804   };
   8805 
   8806   format.toString = function() {
   8807     return template;
   8808   };
   8809 
   8810   return format;
   8811 };
   8812 
   8813 function d3_time_parse(date, template, string, j) {
   8814   var c,
   8815       p,
   8816       i = 0,
   8817       n = template.length,
   8818       m = string.length;
   8819   while (i < n) {
   8820     if (j >= m) return -1;
   8821     c = template.charCodeAt(i++);
   8822     if (c == 37) {
   8823       p = d3_time_parsers[template.charAt(i++)];
   8824       if (!p || ((j = p(date, string, j)) < 0)) return -1;
   8825     } else if (c != string.charCodeAt(j++)) {
   8826       return -1;
   8827     }
   8828   }
   8829   return j;
   8830 }
   8831 
   8832 var d3_time_zfill2 = d3.format("02d"),
   8833     d3_time_zfill3 = d3.format("03d"),
   8834     d3_time_zfill4 = d3.format("04d"),
   8835     d3_time_sfill2 = d3.format("2d");
   8836 
   8837 var d3_time_formats = {
   8838   a: function(d) { return d3_time_weekdays[d.getDay()].substring(0, 3); },
   8839   A: function(d) { return d3_time_weekdays[d.getDay()]; },
   8840   b: function(d) { return d3_time_months[d.getMonth()].substring(0, 3); },
   8841   B: function(d) { return d3_time_months[d.getMonth()]; },
   8842   c: d3.time.format("%a %b %e %H:%M:%S %Y"),
   8843   d: function(d) { return d3_time_zfill2(d.getDate()); },
   8844   e: function(d) { return d3_time_sfill2(d.getDate()); },
   8845   H: function(d) { return d3_time_zfill2(d.getHours()); },
   8846   I: function(d) { return d3_time_zfill2(d.getHours() % 12 || 12); },
   8847   j: function(d) { return d3_time_zfill3(1 + d3.time.dayOfYear(d)); },
   8848   L: function(d) { return d3_time_zfill3(d.getMilliseconds()); },
   8849   m: function(d) { return d3_time_zfill2(d.getMonth() + 1); },
   8850   M: function(d) { return d3_time_zfill2(d.getMinutes()); },
   8851   p: function(d) { return d.getHours() >= 12 ? "PM" : "AM"; },
   8852   S: function(d) { return d3_time_zfill2(d.getSeconds()); },
   8853   U: function(d) { return d3_time_zfill2(d3.time.sundayOfYear(d)); },
   8854   w: function(d) { return d.getDay(); },
   8855   W: function(d) { return d3_time_zfill2(d3.time.mondayOfYear(d)); },
   8856   x: d3.time.format("%m/%d/%y"),
   8857   X: d3.time.format("%H:%M:%S"),
   8858   y: function(d) { return d3_time_zfill2(d.getFullYear() % 100); },
   8859   Y: function(d) { return d3_time_zfill4(d.getFullYear() % 10000); },
   8860   Z: d3_time_zone,
   8861   "%": function(d) { return "%"; }
   8862 };
   8863 
   8864 var d3_time_parsers = {
   8865   a: d3_time_parseWeekdayAbbrev,
   8866   A: d3_time_parseWeekday,
   8867   b: d3_time_parseMonthAbbrev,
   8868   B: d3_time_parseMonth,
   8869   c: d3_time_parseLocaleFull,
   8870   d: d3_time_parseDay,
   8871   e: d3_time_parseDay,
   8872   H: d3_time_parseHour24,
   8873   I: d3_time_parseHour24,
   8874   // j: function(d, s, i) { /*TODO day of year [001,366] */ return i; },
   8875   L: d3_time_parseMilliseconds,
   8876   m: d3_time_parseMonthNumber,
   8877   M: d3_time_parseMinutes,
   8878   p: d3_time_parseAmPm,
   8879   S: d3_time_parseSeconds,
   8880   // U: function(d, s, i) { /*TODO week number (sunday) [00,53] */ return i; },
   8881   // w: function(d, s, i) { /*TODO weekday [0,6] */ return i; },
   8882   // W: function(d, s, i) { /*TODO week number (monday) [00,53] */ return i; },
   8883   x: d3_time_parseLocaleDate,
   8884   X: d3_time_parseLocaleTime,
   8885   y: d3_time_parseYear,
   8886   Y: d3_time_parseFullYear
   8887   // ,
   8888   // Z: function(d, s, i) { /*TODO time zone */ return i; },
   8889   // "%": function(d, s, i) { /*TODO literal % */ return i; }
   8890 };
   8891 
   8892 // Note: weekday is validated, but does not set the date.
   8893 function d3_time_parseWeekdayAbbrev(date, string, i) {
   8894   return d3_time_weekdayAbbrevRe.test(string.substring(i, i += 3)) ? i : -1;
   8895 }
   8896 
   8897 // Note: weekday is validated, but does not set the date.
   8898 function d3_time_parseWeekday(date, string, i) {
   8899   d3_time_weekdayRe.lastIndex = 0;
   8900   var n = d3_time_weekdayRe.exec(string.substring(i, i + 10));
   8901   return n ? i += n[0].length : -1;
   8902 }
   8903 
   8904 var d3_time_weekdayAbbrevRe = /^(?:sun|mon|tue|wed|thu|fri|sat)/i,
   8905     d3_time_weekdayRe = /^(?:Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)/i;
   8906     d3_time_weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
   8907 
   8908 function d3_time_parseMonthAbbrev(date, string, i) {
   8909   var n = d3_time_monthAbbrevLookup.get(string.substring(i, i += 3).toLowerCase());
   8910   return n == null ? -1 : (date.m = n, i);
   8911 }
   8912 
   8913 var d3_time_monthAbbrevLookup = d3.map({
   8914   jan: 0,
   8915   feb: 1,
   8916   mar: 2,
   8917   apr: 3,
   8918   may: 4,
   8919   jun: 5,
   8920   jul: 6,
   8921   aug: 7,
   8922   sep: 8,
   8923   oct: 9,
   8924   nov: 10,
   8925   dec: 11
   8926 });
   8927 
   8928 function d3_time_parseMonth(date, string, i) {
   8929   d3_time_monthRe.lastIndex = 0;
   8930   var n = d3_time_monthRe.exec(string.substring(i, i + 12));
   8931   return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i += n[0].length) : -1;
   8932 }
   8933 
   8934 var d3_time_monthRe = /^(?:January|February|March|April|May|June|July|August|September|October|November|December)/ig;
   8935 
   8936 var d3_time_monthLookup = d3.map({
   8937   january: 0,
   8938   february: 1,
   8939   march: 2,
   8940   april: 3,
   8941   may: 4,
   8942   june: 5,
   8943   july: 6,
   8944   august: 7,
   8945   september: 8,
   8946   october: 9,
   8947   november: 10,
   8948   december: 11
   8949 });
   8950 
   8951 var d3_time_months = [
   8952   "January",
   8953   "February",
   8954   "March",
   8955   "April",
   8956   "May",
   8957   "June",
   8958   "July",
   8959   "August",
   8960   "September",
   8961   "October",
   8962   "November",
   8963   "December"
   8964 ];
   8965 
   8966 function d3_time_parseLocaleFull(date, string, i) {
   8967   return d3_time_parse(date, d3_time_formats.c.toString(), string, i);
   8968 }
   8969 
   8970 function d3_time_parseLocaleDate(date, string, i) {
   8971   return d3_time_parse(date, d3_time_formats.x.toString(), string, i);
   8972 }
   8973 
   8974 function d3_time_parseLocaleTime(date, string, i) {
   8975   return d3_time_parse(date, d3_time_formats.X.toString(), string, i);
   8976 }
   8977 
   8978 function d3_time_parseFullYear(date, string, i) {
   8979   d3_time_numberRe.lastIndex = 0;
   8980   var n = d3_time_numberRe.exec(string.substring(i, i + 4));
   8981   return n ? (date.y = +n[0], i += n[0].length) : -1;
   8982 }
   8983 
   8984 function d3_time_parseYear(date, string, i) {
   8985   d3_time_numberRe.lastIndex = 0;
   8986   var n = d3_time_numberRe.exec(string.substring(i, i + 2));
   8987   return n ? (date.y = d3_time_century() + +n[0], i += n[0].length) : -1;
   8988 }
   8989 
   8990 function d3_time_century() {
   8991   return ~~(new Date().getFullYear() / 1000) * 1000;
   8992 }
   8993 
   8994 function d3_time_parseMonthNumber(date, string, i) {
   8995   d3_time_numberRe.lastIndex = 0;
   8996   var n = d3_time_numberRe.exec(string.substring(i, i + 2));
   8997   return n ? (date.m = n[0] - 1, i += n[0].length) : -1;
   8998 }
   8999 
   9000 function d3_time_parseDay(date, string, i) {
   9001   d3_time_numberRe.lastIndex = 0;
   9002   var n = d3_time_numberRe.exec(string.substring(i, i + 2));
   9003   return n ? (date.d = +n[0], i += n[0].length) : -1;
   9004 }
   9005 
   9006 // Note: we don't validate that the hour is in the range [0,23] or [1,12].
   9007 function d3_time_parseHour24(date, string, i) {
   9008   d3_time_numberRe.lastIndex = 0;
   9009   var n = d3_time_numberRe.exec(string.substring(i, i + 2));
   9010   return n ? (date.H = +n[0], i += n[0].length) : -1;
   9011 }
   9012 
   9013 function d3_time_parseMinutes(date, string, i) {
   9014   d3_time_numberRe.lastIndex = 0;
   9015   var n = d3_time_numberRe.exec(string.substring(i, i + 2));
   9016   return n ? (date.M = +n[0], i += n[0].length) : -1;
   9017 }
   9018 
   9019 function d3_time_parseSeconds(date, string, i) {
   9020   d3_time_numberRe.lastIndex = 0;
   9021   var n = d3_time_numberRe.exec(string.substring(i, i + 2));
   9022   return n ? (date.S = +n[0], i += n[0].length) : -1;
   9023 }
   9024 
   9025 function d3_time_parseMilliseconds(date, string, i) {
   9026   d3_time_numberRe.lastIndex = 0;
   9027   var n = d3_time_numberRe.exec(string.substring(i, i + 3));
   9028   return n ? (date.L = +n[0], i += n[0].length) : -1;
   9029 }
   9030 
   9031 // Note: we don't look at the next directive.
   9032 var d3_time_numberRe = /\s*\d+/;
   9033 
   9034 function d3_time_parseAmPm(date, string, i) {
   9035   var n = d3_time_amPmLookup.get(string.substring(i, i += 2).toLowerCase());
   9036   return n == null ? -1 : (date.p = n, i);
   9037 }
   9038 
   9039 var d3_time_amPmLookup = d3.map({
   9040   am: 0,
   9041   pm: 1
   9042 });
   9043 
   9044 // TODO table of time zone offset names?
   9045 function d3_time_zone(d) {
   9046   var z = d.getTimezoneOffset(),
   9047       zs = z > 0 ? "-" : "+",
   9048       zh = ~~(Math.abs(z) / 60),
   9049       zm = Math.abs(z) % 60;
   9050   return zs + d3_time_zfill2(zh) + d3_time_zfill2(zm);
   9051 }
   9052 d3.time.format.utc = function(template) {
   9053   var local = d3.time.format(template);
   9054 
   9055   function format(date) {
   9056     try {
   9057       d3_time = d3_time_utc;
   9058       var utc = new d3_time();
   9059       utc._ = date;
   9060       return local(utc);
   9061     } finally {
   9062       d3_time = Date;
   9063     }
   9064   }
   9065 
   9066   format.parse = function(string) {
   9067     try {
   9068       d3_time = d3_time_utc;
   9069       var date = local.parse(string);
   9070       return date && date._;
   9071     } finally {
   9072       d3_time = Date;
   9073     }
   9074   };
   9075 
   9076   format.toString = local.toString;
   9077 
   9078   return format;
   9079 };
   9080 var d3_time_formatIso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");
   9081 
   9082 d3.time.format.iso = Date.prototype.toISOString ? d3_time_formatIsoNative : d3_time_formatIso;
   9083 
   9084 function d3_time_formatIsoNative(date) {
   9085   return date.toISOString();
   9086 }
   9087 
   9088 d3_time_formatIsoNative.parse = function(string) {
   9089   return new Date(string);
   9090 };
   9091 
   9092 d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
   9093 function d3_time_interval(local, step, number) {
   9094 
   9095   function round(date) {
   9096     var d0 = local(date), d1 = offset(d0, 1);
   9097     return date - d0 < d1 - date ? d0 : d1;
   9098   }
   9099 
   9100   function ceil(date) {
   9101     step(date = local(new d3_time(date - 1)), 1);
   9102     return date;
   9103   }
   9104 
   9105   function offset(date, k) {
   9106     step(date = new d3_time(+date), k);
   9107     return date;
   9108   }
   9109 
   9110   function range(t0, t1, dt) {
   9111     var time = ceil(t0), times = [];
   9112     if (dt > 1) {
   9113       while (time < t1) {
   9114         if (!(number(time) % dt)) times.push(new Date(+time));
   9115         step(time, 1);
   9116       }
   9117     } else {
   9118       while (time < t1) times.push(new Date(+time)), step(time, 1);
   9119     }
   9120     return times;
   9121   }
   9122 
   9123   function range_utc(t0, t1, dt) {
   9124     try {
   9125       d3_time = d3_time_utc;
   9126       var utc = new d3_time_utc();
   9127       utc._ = t0;
   9128       return range(utc, t1, dt);
   9129     } finally {
   9130       d3_time = Date;
   9131     }
   9132   }
   9133 
   9134   local.floor = local;
   9135   local.round = round;
   9136   local.ceil = ceil;
   9137   local.offset = offset;
   9138   local.range = range;
   9139 
   9140   var utc = local.utc = d3_time_interval_utc(local);
   9141   utc.floor = utc;
   9142   utc.round = d3_time_interval_utc(round);
   9143   utc.ceil = d3_time_interval_utc(ceil);
   9144   utc.offset = d3_time_interval_utc(offset);
   9145   utc.range = range_utc;
   9146 
   9147   return local;
   9148 }
   9149 
   9150 function d3_time_interval_utc(method) {
   9151   return function(date, k) {
   9152     try {
   9153       d3_time = d3_time_utc;
   9154       var utc = new d3_time_utc();
   9155       utc._ = date;
   9156       return method(utc, k)._;
   9157     } finally {
   9158       d3_time = Date;
   9159     }
   9160   };
   9161 }
   9162 d3.time.second = d3_time_interval(function(date) {
   9163   return new d3_time(Math.floor(date / 1e3) * 1e3);
   9164 }, function(date, offset) {
   9165   date.setTime(date.getTime() + Math.floor(offset) * 1e3); // DST breaks setSeconds
   9166 }, function(date) {
   9167   return date.getSeconds();
   9168 });
   9169 
   9170 d3.time.seconds = d3.time.second.range;
   9171 d3.time.seconds.utc = d3.time.second.utc.range;
   9172 d3.time.minute = d3_time_interval(function(date) {
   9173   return new d3_time(Math.floor(date / 6e4) * 6e4);
   9174 }, function(date, offset) {
   9175   date.setTime(date.getTime() + Math.floor(offset) * 6e4); // DST breaks setMinutes
   9176 }, function(date) {
   9177   return date.getMinutes();
   9178 });
   9179 
   9180 d3.time.minutes = d3.time.minute.range;
   9181 d3.time.minutes.utc = d3.time.minute.utc.range;
   9182 d3.time.hour = d3_time_interval(function(date) {
   9183   var timezone = date.getTimezoneOffset() / 60;
   9184   return new d3_time((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);
   9185 }, function(date, offset) {
   9186   date.setTime(date.getTime() + Math.floor(offset) * 36e5); // DST breaks setHours
   9187 }, function(date) {
   9188   return date.getHours();
   9189 });
   9190 
   9191 d3.time.hours = d3.time.hour.range;
   9192 d3.time.hours.utc = d3.time.hour.utc.range;
   9193 d3.time.day = d3_time_interval(function(date) {
   9194   return new d3_time(date.getFullYear(), date.getMonth(), date.getDate());
   9195 }, function(date, offset) {
   9196   date.setDate(date.getDate() + offset);
   9197 }, function(date) {
   9198   return date.getDate() - 1;
   9199 });
   9200 
   9201 d3.time.days = d3.time.day.range;
   9202 d3.time.days.utc = d3.time.day.utc.range;
   9203 
   9204 d3.time.dayOfYear = function(date) {
   9205   var year = d3.time.year(date);
   9206   return Math.floor((date - year) / 864e5 - (date.getTimezoneOffset() - year.getTimezoneOffset()) / 1440);
   9207 };
   9208 d3_time_weekdays.forEach(function(day, i) {
   9209   day = day.toLowerCase();
   9210   i = 7 - i;
   9211 
   9212   var interval = d3.time[day] = d3_time_interval(function(date) {
   9213     (date = d3.time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);
   9214     return date;
   9215   }, function(date, offset) {
   9216     date.setDate(date.getDate() + Math.floor(offset) * 7);
   9217   }, function(date) {
   9218     var day = d3.time.year(date).getDay();
   9219     return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);
   9220   });
   9221 
   9222   d3.time[day + "s"] = interval.range;
   9223   d3.time[day + "s"].utc = interval.utc.range;
   9224 
   9225   d3.time[day + "OfYear"] = function(date) {
   9226     var day = d3.time.year(date).getDay();
   9227     return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7);
   9228   };
   9229 });
   9230 
   9231 d3.time.week = d3.time.sunday;
   9232 d3.time.weeks = d3.time.sunday.range;
   9233 d3.time.weeks.utc = d3.time.sunday.utc.range;
   9234 d3.time.weekOfYear = d3.time.sundayOfYear;
   9235 d3.time.month = d3_time_interval(function(date) {
   9236   return new d3_time(date.getFullYear(), date.getMonth(), 1);
   9237 }, function(date, offset) {
   9238   date.setMonth(date.getMonth() + offset);
   9239 }, function(date) {
   9240   return date.getMonth();
   9241 });
   9242 
   9243 d3.time.months = d3.time.month.range;
   9244 d3.time.months.utc = d3.time.month.utc.range;
   9245 d3.time.year = d3_time_interval(function(date) {
   9246   return new d3_time(date.getFullYear(), 0, 1);
   9247 }, function(date, offset) {
   9248   date.setFullYear(date.getFullYear() + offset);
   9249 }, function(date) {
   9250   return date.getFullYear();
   9251 });
   9252 
   9253 d3.time.years = d3.time.year.range;
   9254 d3.time.years.utc = d3.time.year.utc.range;
   9255 function d3_time_scale(linear, methods, format) {
   9256 
   9257   function scale(x) {
   9258     return linear(x);
   9259   }
   9260 
   9261   scale.invert = function(x) {
   9262     return d3_time_scaleDate(linear.invert(x));
   9263   };
   9264 
   9265   scale.domain = function(x) {
   9266     if (!arguments.length) return linear.domain().map(d3_time_scaleDate);
   9267     linear.domain(x);
   9268     return scale;
   9269   };
   9270 
   9271   scale.nice = function(m) {
   9272     var extent = d3_time_scaleExtent(scale.domain());
   9273     return scale.domain([m.floor(extent[0]), m.ceil(extent[1])]);
   9274   };
   9275 
   9276   scale.ticks = function(m, k) {
   9277     var extent = d3_time_scaleExtent(scale.domain());
   9278     if (typeof m !== "function") {
   9279       var span = extent[1] - extent[0],
   9280           target = span / m,
   9281           i = d3.bisect(d3_time_scaleSteps, target);
   9282       if (i == d3_time_scaleSteps.length) return methods.year(extent, m);
   9283       if (!i) return linear.ticks(m).map(d3_time_scaleDate);
   9284       if (Math.log(target / d3_time_scaleSteps[i - 1]) < Math.log(d3_time_scaleSteps[i] / target)) --i;
   9285       m = methods[i];
   9286       k = m[1];
   9287       m = m[0].range;
   9288     }
   9289     return m(extent[0], new Date(+extent[1] + 1), k); // inclusive upper bound
   9290   };
   9291 
   9292   scale.tickFormat = function() {
   9293     return format;
   9294   };
   9295 
   9296   scale.copy = function() {
   9297     return d3_time_scale(linear.copy(), methods, format);
   9298   };
   9299 
   9300   // TOOD expose d3_scale_linear_rebind?
   9301   return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
   9302 }
   9303 
   9304 // TODO expose d3_scaleExtent?
   9305 function d3_time_scaleExtent(domain) {
   9306   var start = domain[0], stop = domain[domain.length - 1];
   9307   return start < stop ? [start, stop] : [stop, start];
   9308 }
   9309 
   9310 function d3_time_scaleDate(t) {
   9311   return new Date(t);
   9312 }
   9313 
   9314 function d3_time_scaleFormat(formats) {
   9315   return function(date) {
   9316     var i = formats.length - 1, f = formats[i];
   9317     while (!f[1](date)) f = formats[--i];
   9318     return f[0](date);
   9319   };
   9320 }
   9321 
   9322 function d3_time_scaleSetYear(y) {
   9323   var d = new Date(y, 0, 1);
   9324   d.setFullYear(y); // Y2K fail
   9325   return d;
   9326 }
   9327 
   9328 function d3_time_scaleGetYear(d) {
   9329   var y = d.getFullYear(),
   9330       d0 = d3_time_scaleSetYear(y),
   9331       d1 = d3_time_scaleSetYear(y + 1);
   9332   return y + (d - d0) / (d1 - d0);
   9333 }
   9334 
   9335 var d3_time_scaleSteps = [
   9336   1e3,    // 1-second
   9337   5e3,    // 5-second
   9338   15e3,   // 15-second
   9339   3e4,    // 30-second
   9340   6e4,    // 1-minute
   9341   3e5,    // 5-minute
   9342   9e5,    // 15-minute
   9343   18e5,   // 30-minute
   9344   36e5,   // 1-hour
   9345   108e5,  // 3-hour
   9346   216e5,  // 6-hour
   9347   432e5,  // 12-hour
   9348   864e5,  // 1-day
   9349   1728e5, // 2-day
   9350   6048e5, // 1-week
   9351   2592e6, // 1-month
   9352   7776e6, // 3-month
   9353   31536e6 // 1-year
   9354 ];
   9355 
   9356 var d3_time_scaleLocalMethods = [
   9357   [d3.time.second, 1],
   9358   [d3.time.second, 5],
   9359   [d3.time.second, 15],
   9360   [d3.time.second, 30],
   9361   [d3.time.minute, 1],
   9362   [d3.time.minute, 5],
   9363   [d3.time.minute, 15],
   9364   [d3.time.minute, 30],
   9365   [d3.time.hour, 1],
   9366   [d3.time.hour, 3],
   9367   [d3.time.hour, 6],
   9368   [d3.time.hour, 12],
   9369   [d3.time.day, 1],
   9370   [d3.time.day, 2],
   9371   [d3.time.week, 1],
   9372   [d3.time.month, 1],
   9373   [d3.time.month, 3],
   9374   [d3.time.year, 1]
   9375 ];
   9376 
   9377 var d3_time_scaleLocalFormats = [
   9378   [d3.time.format("%Y"), function(d) { return true; }],
   9379   [d3.time.format("%B"), function(d) { return d.getMonth(); }],
   9380   [d3.time.format("%b %d"), function(d) { return d.getDate() != 1; }],
   9381   [d3.time.format("%a %d"), function(d) { return d.getDay() && d.getDate() != 1; }],
   9382   [d3.time.format("%I %p"), function(d) { return d.getHours(); }],
   9383   [d3.time.format("%I:%M"), function(d) { return d.getMinutes(); }],
   9384   [d3.time.format(":%S"), function(d) { return d.getSeconds(); }],
   9385   [d3.time.format(".%L"), function(d) { return d.getMilliseconds(); }]
   9386 ];
   9387 
   9388 var d3_time_scaleLinear = d3.scale.linear(),
   9389     d3_time_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats);
   9390 
   9391 d3_time_scaleLocalMethods.year = function(extent, m) {
   9392   return d3_time_scaleLinear.domain(extent.map(d3_time_scaleGetYear)).ticks(m).map(d3_time_scaleSetYear);
   9393 };
   9394 
   9395 d3.time.scale = function() {
   9396   return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);
   9397 };
   9398 var d3_time_scaleUTCMethods = d3_time_scaleLocalMethods.map(function(m) {
   9399   return [m[0].utc, m[1]];
   9400 });
   9401 
   9402 var d3_time_scaleUTCFormats = [
   9403   [d3.time.format.utc("%Y"), function(d) { return true; }],
   9404   [d3.time.format.utc("%B"), function(d) { return d.getUTCMonth(); }],
   9405   [d3.time.format.utc("%b %d"), function(d) { return d.getUTCDate() != 1; }],
   9406   [d3.time.format.utc("%a %d"), function(d) { return d.getUTCDay() && d.getUTCDate() != 1; }],
   9407   [d3.time.format.utc("%I %p"), function(d) { return d.getUTCHours(); }],
   9408   [d3.time.format.utc("%I:%M"), function(d) { return d.getUTCMinutes(); }],
   9409   [d3.time.format.utc(":%S"), function(d) { return d.getUTCSeconds(); }],
   9410   [d3.time.format.utc(".%L"), function(d) { return d.getUTCMilliseconds(); }]
   9411 ];
   9412 
   9413 var d3_time_scaleUTCFormat = d3_time_scaleFormat(d3_time_scaleUTCFormats);
   9414 
   9415 function d3_time_scaleUTCSetYear(y) {
   9416   var d = new Date(Date.UTC(y, 0, 1));
   9417   d.setUTCFullYear(y); // Y2K fail
   9418   return d;
   9419 }
   9420 
   9421 function d3_time_scaleUTCGetYear(d) {
   9422   var y = d.getUTCFullYear(),
   9423       d0 = d3_time_scaleUTCSetYear(y),
   9424       d1 = d3_time_scaleUTCSetYear(y + 1);
   9425   return y + (d - d0) / (d1 - d0);
   9426 }
   9427 
   9428 d3_time_scaleUTCMethods.year = function(extent, m) {
   9429   return d3_time_scaleLinear.domain(extent.map(d3_time_scaleUTCGetYear)).ticks(m).map(d3_time_scaleUTCSetYear);
   9430 };
   9431 
   9432 d3.time.scale.utc = function() {
   9433   return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat);
   9434 };
   9435 })();
   9436 
   9437         /* END contents of d3.v2.js */
   9438 
   9439         svRawData = {
   9440 	"": {
   9441 		"svUnique": 0,
   9442 		"svTotal": 355,
   9443 		"svChildren": {
   9444 			"0x80b5713": {
   9445 				"svUnique": 0,
   9446 				"svTotal": 5,
   9447 				"svChildren": {
   9448 					"0x8391f3a": {
   9449 						"svUnique": 0,
   9450 						"svTotal": 5,
   9451 						"svChildren": {
   9452 							"0x8265952": {
   9453 								"svUnique": 0,
   9454 								"svTotal": 5,
   9455 								"svChildren": {
   9456 									"0x8264ec6": {
   9457 										"svUnique": 0,
   9458 										"svTotal": 5,
   9459 										"svChildren": {
   9460 											"0x82a0e64": {
   9461 												"svUnique": 0,
   9462 												"svTotal": 5,
   9463 												"svChildren": {
   9464 													"0x836cedf": {
   9465 														"svUnique": 0,
   9466 														"svTotal": 4,
   9467 														"svChildren": {
   9468 															"0x8355ff5": {
   9469 																"svUnique": 0,
   9470 																"svTotal": 3,
   9471 																"svChildren": {
   9472 																	"0x8351dc9": {
   9473 																		"svUnique": 0,
   9474 																		"svTotal": 1,
   9475 																		"svChildren": {
   9476 																			"0x837c9fa": {
   9477 																				"svUnique": 1,
   9478 																				"svTotal": 1,
   9479 																				"svChildren": {}
   9480 																			}
   9481 																		}
   9482 																	},
   9483 																	"0x8351e87": {
   9484 																		"svUnique": 0,
   9485 																		"svTotal": 1,
   9486 																		"svChildren": {
   9487 																			"0xfea85e97": {
   9488 																				"svUnique": 0,
   9489 																				"svTotal": 1,
   9490 																				"svChildren": {
   9491 																					"0xfea821d6": {
   9492 																						"svUnique": 0,
   9493 																						"svTotal": 1,
   9494 																						"svChildren": {
   9495 																							"0xfeab5cc5": {
   9496 																								"svUnique": 1,
   9497 																								"svTotal": 1,
   9498 																								"svChildren": {}
   9499 																							}
   9500 																						}
   9501 																					}
   9502 																				}
   9503 																			}
   9504 																		}
   9505 																	},
   9506 																	"0x835220f": {
   9507 																		"svUnique": 0,
   9508 																		"svTotal": 1,
   9509 																		"svChildren": {
   9510 																			"0x837c97e": {
   9511 																				"svUnique": 0,
   9512 																				"svTotal": 1,
   9513 																				"svChildren": {
   9514 																					"0xfea436ea": {
   9515 																						"svUnique": 0,
   9516 																						"svTotal": 1,
   9517 																						"svChildren": {
   9518 																							"0xfea43586": {
   9519 																								"svUnique": 0,
   9520 																								"svTotal": 1,
   9521 																								"svChildren": {
   9522 																									"0xfea43359": {
   9523 																										"svUnique": 0,
   9524 																										"svTotal": 1,
   9525 																										"svChildren": {
   9526 																											"0xfea8d7f8": {
   9527 																												"svUnique": 0,
   9528 																												"svTotal": 1,
   9529 																												"svChildren": {
   9530 																													"0xfeab5535": {
   9531 																														"svUnique": 1,
   9532 																														"svTotal": 1,
   9533 																														"svChildren": {}
   9534 																													}
   9535 																												}
   9536 																											}
   9537 																										}
   9538 																									}
   9539 																								}
   9540 																							}
   9541 																						}
   9542 																					}
   9543 																				}
   9544 																			}
   9545 																		}
   9546 																	}
   9547 																}
   9548 															},
   9549 															"0x83562aa": {
   9550 																"svUnique": 1,
   9551 																"svTotal": 1,
   9552 																"svChildren": {}
   9553 															}
   9554 														}
   9555 													},
   9556 													"0x836d536": {
   9557 														"svUnique": 0,
   9558 														"svTotal": 1,
   9559 														"svChildren": {
   9560 															"0x836bc42": {
   9561 																"svUnique": 0,
   9562 																"svTotal": 1,
   9563 																"svChildren": {
   9564 																	"0x83766b6": {
   9565 																		"svUnique": 0,
   9566 																		"svTotal": 1,
   9567 																		"svChildren": {
   9568 																			"0x8375c66": {
   9569 																				"svUnique": 0,
   9570 																				"svTotal": 1,
   9571 																				"svChildren": {
   9572 																					"0x836be9e": {
   9573 																						"svUnique": 0,
   9574 																						"svTotal": 1,
   9575 																						"svChildren": {
   9576 																							"0x83766b6": {
   9577 																								"svUnique": 0,
   9578 																								"svTotal": 1,
   9579 																								"svChildren": {
   9580 																									"0x837519b": {
   9581 																										"svUnique": 0,
   9582 																										"svTotal": 1,
   9583 																										"svChildren": {
   9584 																											"0x8372ab4": {
   9585 																												"svUnique": 0,
   9586 																												"svTotal": 1,
   9587 																												"svChildren": {
   9588 																													"0x8371afc": {
   9589 																														"svUnique": 1,
   9590 																														"svTotal": 1,
   9591 																														"svChildren": {}
   9592 																													}
   9593 																												}
   9594 																											}
   9595 																										}
   9596 																									}
   9597 																								}
   9598 																							}
   9599 																						}
   9600 																					}
   9601 																				}
   9602 																			}
   9603 																		}
   9604 																	}
   9605 																}
   9606 															}
   9607 														}
   9608 													}
   9609 												}
   9610 											}
   9611 										}
   9612 									}
   9613 								}
   9614 							}
   9615 						}
   9616 					}
   9617 				}
   9618 			},
   9619 			"0xfffffd7fff1b250d": {
   9620 				"svUnique": 1,
   9621 				"svTotal": 1,
   9622 				"svChildren": {}
   9623 			},
   9624 			"0xfffffd7fff2542fa": {
   9625 				"svUnique": 0,
   9626 				"svTotal": 2,
   9627 				"svChildren": {
   9628 					"0xfffffd7fff2407be": {
   9629 						"svUnique": 0,
   9630 						"svTotal": 2,
   9631 						"svChildren": {
   9632 							"0xfffffd7fff24044b": {
   9633 								"svUnique": 0,
   9634 								"svTotal": 2,
   9635 								"svChildren": {
   9636 									"0xfffffd7fff24d5f6": {
   9637 										"svUnique": 0,
   9638 										"svTotal": 2,
   9639 										"svChildren": {
   9640 											"0x6b3602": {
   9641 												"svUnique": 0,
   9642 												"svTotal": 2,
   9643 												"svChildren": {
   9644 													"0x6aa0ca": {
   9645 														"svUnique": 0,
   9646 														"svTotal": 2,
   9647 														"svChildren": {
   9648 															"0x6a9df7": {
   9649 																"svUnique": 0,
   9650 																"svTotal": 1,
   9651 																"svChildren": {
   9652 																	"0x6d06ba": {
   9653 																		"svUnique": 0,
   9654 																		"svTotal": 1,
   9655 																		"svChildren": {
   9656 																			"0xfffffd7fff1b5f7d": {
   9657 																				"svUnique": 1,
   9658 																				"svTotal": 1,
   9659 																				"svChildren": {}
   9660 																			}
   9661 																		}
   9662 																	}
   9663 																}
   9664 															},
   9665 															"0x6a9f21": {
   9666 																"svUnique": 0,
   9667 																"svTotal": 1,
   9668 																"svChildren": {
   9669 																	"0x6d8f2e": {
   9670 																		"svUnique": 0,
   9671 																		"svTotal": 1,
   9672 																		"svChildren": {
   9673 																			"0xfffffd7fff1b2501": {
   9674 																				"svUnique": 0,
   9675 																				"svTotal": 1,
   9676 																				"svChildren": {
   9677 																					"0xfffffd7fff1c88ac": {
   9678 																						"svUnique": 0,
   9679 																						"svTotal": 1,
   9680 																						"svChildren": {
   9681 																							"0xfffffd7fff1c882c": {
   9682 																								"svUnique": 0,
   9683 																								"svTotal": 1,
   9684 																								"svChildren": {
   9685 																									"0xfffffd7fff3bf9fe": {
   9686 																										"svUnique": 0,
   9687 																										"svTotal": 1,
   9688 																										"svChildren": {
   9689 																											"0xfffffd7fff3bf881": {
   9690 																												"svUnique": 0,
   9691 																												"svTotal": 1,
   9692 																												"svChildren": {
   9693 																													"0xfffffd7ffa9d9649": {
   9694 																														"svUnique": 0,
   9695 																														"svTotal": 1,
   9696 																														"svChildren": {
   9697 																															"0xfffffd7fff2e0030": {
   9698 																																"svUnique": 0,
   9699 																																"svTotal": 1,
   9700 																																"svChildren": {
   9701 																																	"0xfffffd7fff3b14c2": {
   9702 																																		"svUnique": 0,
   9703 																																		"svTotal": 1,
   9704 																																		"svChildren": {
   9705 																																			"0xfffffd7fff3cf060": {
   9706 																																				"svUnique": 1,
   9707 																																				"svTotal": 1,
   9708 																																				"svChildren": {}
   9709 																																			}
   9710 																																		}
   9711 																																	}
   9712 																																}
   9713 																															}
   9714 																														}
   9715 																													}
   9716 																												}
   9717 																											}
   9718 																										}
   9719 																									}
   9720 																								}
   9721 																							}
   9722 																						}
   9723 																					}
   9724 																				}
   9725 																			}
   9726 																		}
   9727 																	}
   9728 																}
   9729 															}
   9730 														}
   9731 													}
   9732 												}
   9733 											}
   9734 										}
   9735 									}
   9736 								}
   9737 							}
   9738 						}
   9739 					}
   9740 				}
   9741 			},
   9742 			"libc.so.1`__pollsys": {
   9743 				"svUnique": 0,
   9744 				"svTotal": 3,
   9745 				"svChildren": {
   9746 					"libc.so.1`sigacthandler": {
   9747 						"svUnique": 0,
   9748 						"svTotal": 3,
   9749 						"svChildren": {
   9750 							"libc.so.1`call_user_handler": {
   9751 								"svUnique": 0,
   9752 								"svTotal": 3,
   9753 								"svChildren": {
   9754 									"libc.so.1`__sighndlr": {
   9755 										"svUnique": 0,
   9756 										"svTotal": 3,
   9757 										"svChildren": {
   9758 											"postgres`reaper": {
   9759 												"svUnique": 0,
   9760 												"svTotal": 3,
   9761 												"svChildren": {
   9762 													"postgres`pgstat_start": {
   9763 														"svUnique": 0,
   9764 														"svTotal": 3,
   9765 														"svChildren": {
   9766 															"postgres`PgstatCollectorMain.isra.20": {
   9767 																"svUnique": 0,
   9768 																"svTotal": 3,
   9769 																"svChildren": {
   9770 																	"libsocket.so.1`recv": {
   9771 																		"svUnique": 0,
   9772 																		"svTotal": 1,
   9773 																		"svChildren": {
   9774 																			"libc.so.1`__so_recv": {
   9775 																				"svUnique": 1,
   9776 																				"svTotal": 1,
   9777 																				"svChildren": {}
   9778 																			}
   9779 																		}
   9780 																	},
   9781 																	"postgres`WaitLatchOrSocket": {
   9782 																		"svUnique": 0,
   9783 																		"svTotal": 2,
   9784 																		"svChildren": {
   9785 																			"libc.so.1`poll": {
   9786 																				"svUnique": 0,
   9787 																				"svTotal": 2,
   9788 																				"svChildren": {
   9789 																					"libc.so.1`__pollsys": {
   9790 																						"svUnique": 2,
   9791 																						"svTotal": 2,
   9792 																						"svChildren": {}
   9793 																					}
   9794 																				}
   9795 																			}
   9796 																		}
   9797 																	}
   9798 																}
   9799 															}
   9800 														}
   9801 													}
   9802 												}
   9803 											}
   9804 										}
   9805 									}
   9806 								}
   9807 							}
   9808 						}
   9809 					}
   9810 				}
   9811 			},
   9812 			"postgres`_start": {
   9813 				"svUnique": 0,
   9814 				"svTotal": 344,
   9815 				"svChildren": {
   9816 					"postgres`main": {
   9817 						"svUnique": 0,
   9818 						"svTotal": 344,
   9819 						"svChildren": {
   9820 							"postgres`PostmasterMain": {
   9821 								"svUnique": 0,
   9822 								"svTotal": 344,
   9823 								"svChildren": {
   9824 									"postgres`ServerLoop": {
   9825 										"svUnique": 0,
   9826 										"svTotal": 343,
   9827 										"svChildren": {
   9828 											"libc.so.1`fork": {
   9829 												"svUnique": 0,
   9830 												"svTotal": 6,
   9831 												"svChildren": {
   9832 													"libc.so.1`__forkx": {
   9833 														"svUnique": 6,
   9834 														"svTotal": 6,
   9835 														"svChildren": {}
   9836 													}
   9837 												}
   9838 											},
   9839 											"libc.so.1`select": {
   9840 												"svUnique": 0,
   9841 												"svTotal": 5,
   9842 												"svChildren": {
   9843 													"libc.so.1`pselect": {
   9844 														"svUnique": 0,
   9845 														"svTotal": 5,
   9846 														"svChildren": {
   9847 															"libc.so.1`__pollsys": {
   9848 																"svUnique": 0,
   9849 																"svTotal": 5,
   9850 																"svChildren": {
   9851 																	"libc.so.1`sigacthandler": {
   9852 																		"svUnique": 0,
   9853 																		"svTotal": 5,
   9854 																		"svChildren": {
   9855 																			"libc.so.1`call_user_handler": {
   9856 																				"svUnique": 0,
   9857 																				"svTotal": 5,
   9858 																				"svChildren": {
   9859 																					"libc.so.1`__sighndlr": {
   9860 																						"svUnique": 0,
   9861 																						"svTotal": 5,
   9862 																						"svChildren": {
   9863 																							"postgres`reaper": {
   9864 																								"svUnique": 0,
   9865 																								"svTotal": 1,
   9866 																								"svChildren": {
   9867 																									"postgres`pgstat_start": {
   9868 																										"svUnique": 0,
   9869 																										"svTotal": 1,
   9870 																										"svChildren": {
   9871 																											"postgres`PgstatCollectorMain.isra.19": {
   9872 																												"svUnique": 0,
   9873 																												"svTotal": 1,
   9874 																												"svChildren": {
   9875 																													"libsocket.so.1`recv": {
   9876 																														"svUnique": 0,
   9877 																														"svTotal": 1,
   9878 																														"svChildren": {
   9879 																															"libc.so.1`__so_recv": {
   9880 																																"svUnique": 1,
   9881 																																"svTotal": 1,
   9882 																																"svChildren": {}
   9883 																															}
   9884 																														}
   9885 																													}
   9886 																												}
   9887 																											}
   9888 																										}
   9889 																									}
   9890 																								}
   9891 																							},
   9892 																							"postgres`sigusr1_handler": {
   9893 																								"svUnique": 0,
   9894 																								"svTotal": 4,
   9895 																								"svChildren": {
   9896 																									"postgres`StartAutoVacWorker": {
   9897 																										"svUnique": 0,
   9898 																										"svTotal": 4,
   9899 																										"svChildren": {
   9900 																											"libc.so.1`fork": {
   9901 																												"svUnique": 0,
   9902 																												"svTotal": 1,
   9903 																												"svChildren": {
   9904 																													"libc.so.1`__forkx": {
   9905 																														"svUnique": 1,
   9906 																														"svTotal": 1,
   9907 																														"svChildren": {}
   9908 																													}
   9909 																												}
   9910 																											},
   9911 																											"postgres`fork_process": {
   9912 																												"svUnique": 0,
   9913 																												"svTotal": 3,
   9914 																												"svChildren": {
   9915 																													"libc.so.1`fork": {
   9916 																														"svUnique": 0,
   9917 																														"svTotal": 3,
   9918 																														"svChildren": {
   9919 																															"libc.so.1`__forkx": {
   9920 																																"svUnique": 3,
   9921 																																"svTotal": 3,
   9922 																																"svChildren": {}
   9923 																															}
   9924 																														}
   9925 																													}
   9926 																												}
   9927 																											}
   9928 																										}
   9929 																									}
   9930 																								}
   9931 																							}
   9932 																						}
   9933 																					}
   9934 																				}
   9935 																			}
   9936 																		}
   9937 																	}
   9938 																}
   9939 															}
   9940 														}
   9941 													}
   9942 												}
   9943 											},
   9944 											"postgres`PostgresMain": {
   9945 												"svUnique": 1,
   9946 												"svTotal": 330,
   9947 												"svChildren": {
   9948 													"libc.so.1`memset": {
   9949 														"svUnique": 1,
   9950 														"svTotal": 1,
   9951 														"svChildren": {}
   9952 													},
   9953 													"libc.so.1`strlcpy": {
   9954 														"svUnique": 1,
   9955 														"svTotal": 1,
   9956 														"svChildren": {}
   9957 													},
   9958 													"postgres`CompleteCachedPlan": {
   9959 														"svUnique": 0,
   9960 														"svTotal": 2,
   9961 														"svChildren": {
   9962 															"postgres`CreateTemplateTupleDesc": {
   9963 																"svUnique": 1,
   9964 																"svTotal": 1,
   9965 																"svChildren": {}
   9966 															},
   9967 															"postgres`extract_query_dependencies": {
   9968 																"svUnique": 0,
   9969 																"svTotal": 1,
   9970 																"svChildren": {
   9971 																	"postgres`expression_tree_walker": {
   9972 																		"svUnique": 0,
   9973 																		"svTotal": 1,
   9974 																		"svChildren": {
   9975 																			"postgres`query_tree_walker": {
   9976 																				"svUnique": 0,
   9977 																				"svTotal": 1,
   9978 																				"svChildren": {
   9979 																					"postgres`expression_tree_walker": {
   9980 																						"svUnique": 1,
   9981 																						"svTotal": 1,
   9982 																						"svChildren": {}
   9983 																					}
   9984 																				}
   9985 																			}
   9986 																		}
   9987 																	}
   9988 																}
   9989 															}
   9990 														}
   9991 													},
   9992 													"postgres`CreateCachedPlan": {
   9993 														"svUnique": 0,
   9994 														"svTotal": 3,
   9995 														"svChildren": {
   9996 															"postgres`_copySelectStmt": {
   9997 																"svUnique": 0,
   9998 																"svTotal": 3,
   9999 																"svChildren": {
  10000 																	"postgres`_copyList.isra.15": {
  10001 																		"svUnique": 0,
  10002 																		"svTotal": 1,
  10003 																		"svChildren": {
  10004 																			"postgres`_copyRangeVar": {
  10005 																				"svUnique": 1,
  10006 																				"svTotal": 1,
  10007 																				"svChildren": {}
  10008 																			}
  10009 																		}
  10010 																	},
  10011 																	"postgres`copyObject": {
  10012 																		"svUnique": 1,
  10013 																		"svTotal": 2,
  10014 																		"svChildren": {
  10015 																			"postgres`check_stack_depth": {
  10016 																				"svUnique": 1,
  10017 																				"svTotal": 1,
  10018 																				"svChildren": {}
  10019 																			}
  10020 																		}
  10021 																	}
  10022 																}
  10023 															}
  10024 														}
  10025 													},
  10026 													"postgres`CreatePortal": {
  10027 														"svUnique": 0,
  10028 														"svTotal": 3,
  10029 														"svChildren": {
  10030 															"postgres`AllocSetContextCreate": {
  10031 																"svUnique": 0,
  10032 																"svTotal": 1,
  10033 																"svChildren": {
  10034 																	"libc.so.1`strcpy": {
  10035 																		"svUnique": 1,
  10036 																		"svTotal": 1,
  10037 																		"svChildren": {}
  10038 																	}
  10039 																}
  10040 															},
  10041 															"postgres`GetPortalByName": {
  10042 																"svUnique": 0,
  10043 																"svTotal": 1,
  10044 																"svChildren": {
  10045 																	"postgres`hash_search": {
  10046 																		"svUnique": 1,
  10047 																		"svTotal": 1,
  10048 																		"svChildren": {}
  10049 																	}
  10050 																}
  10051 															},
  10052 															"postgres`PortalDrop": {
  10053 																"svUnique": 0,
  10054 																"svTotal": 1,
  10055 																"svChildren": {
  10056 																	"postgres`hash_search_with_hash_value": {
  10057 																		"svUnique": 1,
  10058 																		"svTotal": 1,
  10059 																		"svChildren": {}
  10060 																	}
  10061 																}
  10062 															}
  10063 														}
  10064 													},
  10065 													"postgres`GetCachedPlan": {
  10066 														"svUnique": 0,
  10067 														"svTotal": 155,
  10068 														"svChildren": {
  10069 															"postgres`ActiveSnapshotSet": {
  10070 																"svUnique": 1,
  10071 																"svTotal": 1,
  10072 																"svChildren": {}
  10073 															},
  10074 															"postgres`BuildCachedPlan": {
  10075 																"svUnique": 0,
  10076 																"svTotal": 154,
  10077 																"svChildren": {
  10078 																	"postgres`_copyList.isra.15": {
  10079 																		"svUnique": 0,
  10080 																		"svTotal": 16,
  10081 																		"svChildren": {
  10082 																			"postgres`_copyPlannedStmt": {
  10083 																				"svUnique": 0,
  10084 																				"svTotal": 9,
  10085 																				"svChildren": {
  10086 																					"postgres`_copyList.isra.15": {
  10087 																						"svUnique": 0,
  10088 																						"svTotal": 1,
  10089 																						"svChildren": {
  10090 																							"postgres`_copyRangeTblEntry": {
  10091 																								"svUnique": 0,
  10092 																								"svTotal": 1,
  10093 																								"svChildren": {
  10094 																									"postgres`copyObject": {
  10095 																										"svUnique": 0,
  10096 																										"svTotal": 1,
  10097 																										"svChildren": {
  10098 																											"postgres`_copyList.isra.15": {
  10099 																												"svUnique": 0,
  10100 																												"svTotal": 1,
  10101 																												"svChildren": {
  10102 																													"postgres`_copyValue": {
  10103 																														"svUnique": 0,
  10104 																														"svTotal": 1,
  10105 																														"svChildren": {
  10106 																															"postgres`MemoryContextAllocZeroAligned": {
  10107 																																"svUnique": 0,
  10108 																																"svTotal": 1,
  10109 																																"svChildren": {
  10110 																																	"postgres`AllocSetAlloc": {
  10111 																																		"svUnique": 1,
  10112 																																		"svTotal": 1,
  10113 																																		"svChildren": {}
  10114 																																	}
  10115 																																}
  10116 																															}
  10117 																														}
  10118 																													}
  10119 																												}
  10120 																											}
  10121 																										}
  10122 																									}
  10123 																								}
  10124 																							}
  10125 																						}
  10126 																					},
  10127 																					"postgres`copyObject": {
  10128 																						"svUnique": 1,
  10129 																						"svTotal": 8,
  10130 																						"svChildren": {
  10131 																							"postgres`CopyPlanFields": {
  10132 																								"svUnique": 0,
  10133 																								"svTotal": 7,
  10134 																								"svChildren": {
  10135 																									"postgres`_copyList.isra.15": {
  10136 																										"svUnique": 0,
  10137 																										"svTotal": 3,
  10138 																										"svChildren": {
  10139 																											"postgres`_copyTargetEntry": {
  10140 																												"svUnique": 2,
  10141 																												"svTotal": 3,
  10142 																												"svChildren": {
  10143 																													"postgres`MemoryContextAllocZeroAligned": {
  10144 																														"svUnique": 0,
  10145 																														"svTotal": 1,
  10146 																														"svChildren": {
  10147 																															"postgres`AllocSetAlloc": {
  10148 																																"svUnique": 1,
  10149 																																"svTotal": 1,
  10150 																																"svChildren": {}
  10151 																															}
  10152 																														}
  10153 																													}
  10154 																												}
  10155 																											}
  10156 																										}
  10157 																									},
  10158 																									"postgres`_copyWindowAgg": {
  10159 																										"svUnique": 0,
  10160 																										"svTotal": 4,
  10161 																										"svChildren": {
  10162 																											"postgres`CopyPlanFields": {
  10163 																												"svUnique": 0,
  10164 																												"svTotal": 4,
  10165 																												"svChildren": {
  10166 																													"postgres`_copyIndexScan": {
  10167 																														"svUnique": 0,
  10168 																														"svTotal": 3,
  10169 																														"svChildren": {
  10170 																															"postgres`CopyScanFields": {
  10171 																																"svUnique": 0,
  10172 																																"svTotal": 2,
  10173 																																"svChildren": {
  10174 																																	"postgres`CopyPlanFields": {
  10175 																																		"svUnique": 0,
  10176 																																		"svTotal": 2,
  10177 																																		"svChildren": {
  10178 																																			"postgres`_copyList.isra.15": {
  10179 																																				"svUnique": 0,
  10180 																																				"svTotal": 1,
  10181 																																				"svChildren": {
  10182 																																					"postgres`_copyTargetEntry": {
  10183 																																						"svUnique": 0,
  10184 																																						"svTotal": 1,
  10185 																																						"svChildren": {
  10186 																																							"postgres`MemoryContextAllocZeroAligned": {
  10187 																																								"svUnique": 0,
  10188 																																								"svTotal": 1,
  10189 																																								"svChildren": {
  10190 																																									"postgres`AllocSetAlloc": {
  10191 																																										"svUnique": 1,
  10192 																																										"svTotal": 1,
  10193 																																										"svChildren": {}
  10194 																																									}
  10195 																																								}
  10196 																																							}
  10197 																																						}
  10198 																																					}
  10199 																																				}
  10200 																																			},
  10201 																																			"postgres`copyObject": {
  10202 																																				"svUnique": 1,
  10203 																																				"svTotal": 1,
  10204 																																				"svChildren": {}
  10205 																																			}
  10206 																																		}
  10207 																																	}
  10208 																																}
  10209 																															},
  10210 																															"postgres`_copyList.isra.15": {
  10211 																																"svUnique": 0,
  10212 																																"svTotal": 1,
  10213 																																"svChildren": {
  10214 																																	"postgres`copyObject": {
  10215 																																		"svUnique": 1,
  10216 																																		"svTotal": 1,
  10217 																																		"svChildren": {}
  10218 																																	}
  10219 																																}
  10220 																															}
  10221 																														}
  10222 																													},
  10223 																													"postgres`_copyList.isra.15": {
  10224 																														"svUnique": 0,
  10225 																														"svTotal": 1,
  10226 																														"svChildren": {
  10227 																															"postgres`_copyTargetEntry": {
  10228 																																"svUnique": 0,
  10229 																																"svTotal": 1,
  10230 																																"svChildren": {
  10231 																																	"postgres`_copyConst": {
  10232 																																		"svUnique": 0,
  10233 																																		"svTotal": 1,
  10234 																																		"svChildren": {
  10235 																																			"postgres`datumCopy": {
  10236 																																				"svUnique": 0,
  10237 																																				"svTotal": 1,
  10238 																																				"svChildren": {
  10239 																																					"postgres`datumGetSize": {
  10240 																																						"svUnique": 1,
  10241 																																						"svTotal": 1,
  10242 																																						"svChildren": {}
  10243 																																					}
  10244 																																				}
  10245 																																			}
  10246 																																		}
  10247 																																	}
  10248 																																}
  10249 																															}
  10250 																														}
  10251 																													}
  10252 																												}
  10253 																											}
  10254 																										}
  10255 																									}
  10256 																								}
  10257 																							}
  10258 																						}
  10259 																					}
  10260 																				}
  10261 																			},
  10262 																			"postgres`_copyQuery": {
  10263 																				"svUnique": 0,
  10264 																				"svTotal": 6,
  10265 																				"svChildren": {
  10266 																					"postgres`_copyList.isra.15": {
  10267 																						"svUnique": 0,
  10268 																						"svTotal": 5,
  10269 																						"svChildren": {
  10270 																							"postgres`_copyRangeTblEntry": {
  10271 																								"svUnique": 0,
  10272 																								"svTotal": 3,
  10273 																								"svChildren": {
  10274 																									"postgres`copyObject": {
  10275 																										"svUnique": 0,
  10276 																										"svTotal": 3,
  10277 																										"svChildren": {
  10278 																											"postgres`_copyList.isra.15": {
  10279 																												"svUnique": 0,
  10280 																												"svTotal": 2,
  10281 																												"svChildren": {
  10282 																													"postgres`_copyValue": {
  10283 																														"svUnique": 0,
  10284 																														"svTotal": 2,
  10285 																														"svChildren": {
  10286 																															"libc.so.1`strlen": {
  10287 																																"svUnique": 1,
  10288 																																"svTotal": 1,
  10289 																																"svChildren": {}
  10290 																															},
  10291 																															"postgres`0x4f5de8": {
  10292 																																"svUnique": 1,
  10293 																																"svTotal": 1,
  10294 																																"svChildren": {}
  10295 																															}
  10296 																														}
  10297 																													}
  10298 																												}
  10299 																											},
  10300 																											"postgres`_copyValue": {
  10301 																												"svUnique": 1,
  10302 																												"svTotal": 1,
  10303 																												"svChildren": {}
  10304 																											}
  10305 																										}
  10306 																									}
  10307 																								}
  10308 																							},
  10309 																							"postgres`_copyTargetEntry": {
  10310 																								"svUnique": 0,
  10311 																								"svTotal": 2,
  10312 																								"svChildren": {
  10313 																									"libc.so.1`memcpy": {
  10314 																										"svUnique": 1,
  10315 																										"svTotal": 1,
  10316 																										"svChildren": {}
  10317 																									},
  10318 																									"postgres`MemoryContextAllocZeroAligned": {
  10319 																										"svUnique": 0,
  10320 																										"svTotal": 1,
  10321 																										"svChildren": {
  10322 																											"postgres`AllocSetAlloc": {
  10323 																												"svUnique": 1,
  10324 																												"svTotal": 1,
  10325 																												"svChildren": {}
  10326 																											}
  10327 																										}
  10328 																									}
  10329 																								}
  10330 																							}
  10331 																						}
  10332 																					},
  10333 																					"postgres`copyObject": {
  10334 																						"svUnique": 0,
  10335 																						"svTotal": 1,
  10336 																						"svChildren": {
  10337 																							"postgres`copyObject": {
  10338 																								"svUnique": 1,
  10339 																								"svTotal": 1,
  10340 																								"svChildren": {}
  10341 																							}
  10342 																						}
  10343 																					}
  10344 																				}
  10345 																			},
  10346 																			"postgres`copyObject": {
  10347 																				"svUnique": 1,
  10348 																				"svTotal": 1,
  10349 																				"svChildren": {}
  10350 																			}
  10351 																		}
  10352 																	},
  10353 																	"postgres`copyObject": {
  10354 																		"svUnique": 1,
  10355 																		"svTotal": 1,
  10356 																		"svChildren": {}
  10357 																	},
  10358 																	"postgres`pg_plan_queries": {
  10359 																		"svUnique": 0,
  10360 																		"svTotal": 137,
  10361 																		"svChildren": {
  10362 																			"postgres`pg_plan_query": {
  10363 																				"svUnique": 0,
  10364 																				"svTotal": 136,
  10365 																				"svChildren": {
  10366 																					"postgres`standard_planner": {
  10367 																						"svUnique": 0,
  10368 																						"svTotal": 136,
  10369 																						"svChildren": {
  10370 																							"postgres`set_plan_refs": {
  10371 																								"svUnique": 0,
  10372 																								"svTotal": 7,
  10373 																								"svChildren": {
  10374 																									"postgres`set_dummy_tlist_references.isra.2": {
  10375 																										"svUnique": 0,
  10376 																										"svTotal": 2,
  10377 																										"svChildren": {
  10378 																											"postgres`exprType": {
  10379 																												"svUnique": 1,
  10380 																												"svTotal": 1,
  10381 																												"svChildren": {}
  10382 																											},
  10383 																											"postgres`lappend": {
  10384 																												"svUnique": 0,
  10385 																												"svTotal": 1,
  10386 																												"svChildren": {
  10387 																													"postgres`new_tail_cell.isra.2": {
  10388 																														"svUnique": 1,
  10389 																														"svTotal": 1,
  10390 																														"svChildren": {}
  10391 																													}
  10392 																												}
  10393 																											}
  10394 																										}
  10395 																									},
  10396 																									"postgres`set_plan_refs": {
  10397 																										"svUnique": 0,
  10398 																										"svTotal": 5,
  10399 																										"svChildren": {
  10400 																											"postgres`set_plan_refs": {
  10401 																												"svUnique": 0,
  10402 																												"svTotal": 1,
  10403 																												"svChildren": {
  10404 																													"postgres`fix_scan_expr": {
  10405 																														"svUnique": 0,
  10406 																														"svTotal": 1,
  10407 																														"svChildren": {
  10408 																															"postgres`expression_tree_walker": {
  10409 																																"svUnique": 1,
  10410 																																"svTotal": 1,
  10411 																																"svChildren": {}
  10412 																															}
  10413 																														}
  10414 																													}
  10415 																												}
  10416 																											},
  10417 																											"postgres`set_upper_references": {
  10418 																												"svUnique": 0,
  10419 																												"svTotal": 4,
  10420 																												"svChildren": {
  10421 																													"postgres`build_tlist_index": {
  10422 																														"svUnique": 1,
  10423 																														"svTotal": 1,
  10424 																														"svChildren": {}
  10425 																													},
  10426 																													"postgres`fix_upper_expr_mutator": {
  10427 																														"svUnique": 0,
  10428 																														"svTotal": 3,
  10429 																														"svChildren": {
  10430 																															"postgres`search_indexed_tlist_for_var": {
  10431 																																"svUnique": 2,
  10432 																																"svTotal": 3,
  10433 																																"svChildren": {
  10434 																																	"postgres`MemoryContextAlloc": {
  10435 																																		"svUnique": 1,
  10436 																																		"svTotal": 1,
  10437 																																		"svChildren": {}
  10438 																																	}
  10439 																																}
  10440 																															}
  10441 																														}
  10442 																													}
  10443 																												}
  10444 																											}
  10445 																										}
  10446 																									}
  10447 																								}
  10448 																							},
  10449 																							"postgres`subquery_planner": {
  10450 																								"svUnique": 1,
  10451 																								"svTotal": 129,
  10452 																								"svChildren": {
  10453 																									"postgres`expand_inherited_tables": {
  10454 																										"svUnique": 0,
  10455 																										"svTotal": 1,
  10456 																										"svChildren": {
  10457 																											"postgres`has_subclass": {
  10458 																												"svUnique": 0,
  10459 																												"svTotal": 1,
  10460 																												"svChildren": {
  10461 																													"postgres`SearchCatCache": {
  10462 																														"svUnique": 1,
  10463 																														"svTotal": 1,
  10464 																														"svChildren": {}
  10465 																													}
  10466 																												}
  10467 																											}
  10468 																										}
  10469 																									},
  10470 																									"postgres`grouping_planner": {
  10471 																										"svUnique": 0,
  10472 																										"svTotal": 123,
  10473 																										"svChildren": {
  10474 																											"postgres`_copyList.isra.15": {
  10475 																												"svUnique": 0,
  10476 																												"svTotal": 8,
  10477 																												"svChildren": {
  10478 																													"postgres`_copyTargetEntry": {
  10479 																														"svUnique": 2,
  10480 																														"svTotal": 7,
  10481 																														"svChildren": {
  10482 																															"postgres`_copyWindowFunc": {
  10483 																																"svUnique": 0,
  10484 																																"svTotal": 1,
  10485 																																"svChildren": {
  10486 																																	"postgres`_copyList.isra.15": {
  10487 																																		"svUnique": 0,
  10488 																																		"svTotal": 1,
  10489 																																		"svChildren": {
  10490 																																			"postgres`_copyConst": {
  10491 																																				"svUnique": 0,
  10492 																																				"svTotal": 1,
  10493 																																				"svChildren": {
  10494 																																					"postgres`MemoryContextAllocZeroAligned": {
  10495 																																						"svUnique": 1,
  10496 																																						"svTotal": 1,
  10497 																																						"svChildren": {}
  10498 																																					}
  10499 																																				}
  10500 																																			}
  10501 																																		}
  10502 																																	}
  10503 																																}
  10504 																															},
  10505 																															"postgres`copyObject": {
  10506 																																"svUnique": 0,
  10507 																																"svTotal": 4,
  10508 																																"svChildren": {
  10509 																																	"postgres`AllocSetAlloc": {
  10510 																																		"svUnique": 1,
  10511 																																		"svTotal": 1,
  10512 																																		"svChildren": {}
  10513 																																	},
  10514 																																	"postgres`MemoryContextAllocZeroAligned": {
  10515 																																		"svUnique": 1,
  10516 																																		"svTotal": 3,
  10517 																																		"svChildren": {
  10518 																																			"postgres`AllocSetAlloc": {
  10519 																																				"svUnique": 2,
  10520 																																				"svTotal": 2,
  10521 																																				"svChildren": {}
  10522 																																			}
  10523 																																		}
  10524 																																	}
  10525 																																}
  10526 																															}
  10527 																														}
  10528 																													},
  10529 																													"postgres`copyObject": {
  10530 																														"svUnique": 1,
  10531 																														"svTotal": 1,
  10532 																														"svChildren": {}
  10533 																													}
  10534 																												}
  10535 																											},
  10536 																											"postgres`add_to_flat_tlist": {
  10537 																												"svUnique": 0,
  10538 																												"svTotal": 4,
  10539 																												"svChildren": {
  10540 																													"postgres`copyObject": {
  10541 																														"svUnique": 0,
  10542 																														"svTotal": 2,
  10543 																														"svChildren": {
  10544 																															"postgres`MemoryContextAllocZeroAligned": {
  10545 																																"svUnique": 0,
  10546 																																"svTotal": 2,
  10547 																																"svChildren": {
  10548 																																	"postgres`AllocSetAlloc": {
  10549 																																		"svUnique": 2,
  10550 																																		"svTotal": 2,
  10551 																																		"svChildren": {}
  10552 																																	}
  10553 																																}
  10554 																															}
  10555 																														}
  10556 																													},
  10557 																													"postgres`lappend": {
  10558 																														"svUnique": 0,
  10559 																														"svTotal": 1,
  10560 																														"svChildren": {
  10561 																															"postgres`new_tail_cell.isra.2": {
  10562 																																"svUnique": 0,
  10563 																																"svTotal": 1,
  10564 																																"svChildren": {
  10565 																																	"postgres`AllocSetAlloc": {
  10566 																																		"svUnique": 1,
  10567 																																		"svTotal": 1,
  10568 																																		"svChildren": {}
  10569 																																	}
  10570 																																}
  10571 																															}
  10572 																														}
  10573 																													},
  10574 																													"postgres`tlist_member": {
  10575 																														"svUnique": 1,
  10576 																														"svTotal": 1,
  10577 																														"svChildren": {}
  10578 																													}
  10579 																												}
  10580 																											},
  10581 																											"postgres`build_base_rel_tlists": {
  10582 																												"svUnique": 1,
  10583 																												"svTotal": 1,
  10584 																												"svChildren": {}
  10585 																											},
  10586 																											"postgres`create_plan": {
  10587 																												"svUnique": 0,
  10588 																												"svTotal": 2,
  10589 																												"svChildren": {
  10590 																													"postgres`create_plan_recurse": {
  10591 																														"svUnique": 0,
  10592 																														"svTotal": 2,
  10593 																														"svChildren": {
  10594 																															"postgres`build_physical_tlist": {
  10595 																																"svUnique": 0,
  10596 																																"svTotal": 2,
  10597 																																"svChildren": {
  10598 																																	"postgres`makeTargetEntry": {
  10599 																																		"svUnique": 1,
  10600 																																		"svTotal": 2,
  10601 																																		"svChildren": {
  10602 																																			"postgres`AllocSetAlloc": {
  10603 																																				"svUnique": 1,
  10604 																																				"svTotal": 1,
  10605 																																				"svChildren": {}
  10606 																																			}
  10607 																																		}
  10608 																																	}
  10609 																																}
  10610 																															}
  10611 																														}
  10612 																													}
  10613 																												}
  10614 																											},
  10615 																											"postgres`find_window_functions": {
  10616 																												"svUnique": 0,
  10617 																												"svTotal": 1,
  10618 																												"svChildren": {
  10619 																													"postgres`expression_tree_walker": {
  10620 																														"svUnique": 0,
  10621 																														"svTotal": 1,
  10622 																														"svChildren": {
  10623 																															"postgres`expression_tree_walker": {
  10624 																																"svUnique": 0,
  10625 																																"svTotal": 1,
  10626 																																"svChildren": {
  10627 																																	"postgres`check_stack_depth": {
  10628 																																		"svUnique": 1,
  10629 																																		"svTotal": 1,
  10630 																																		"svChildren": {}
  10631 																																	}
  10632 																																}
  10633 																															}
  10634 																														}
  10635 																													}
  10636 																												}
  10637 																											},
  10638 																											"postgres`lappend": {
  10639 																												"svUnique": 0,
  10640 																												"svTotal": 1,
  10641 																												"svChildren": {
  10642 																													"postgres`new_list": {
  10643 																														"svUnique": 0,
  10644 																														"svTotal": 1,
  10645 																														"svChildren": {
  10646 																															"postgres`MemoryContextAlloc": {
  10647 																																"svUnique": 1,
  10648 																																"svTotal": 1,
  10649 																																"svChildren": {}
  10650 																															}
  10651 																														}
  10652 																													}
  10653 																												}
  10654 																											},
  10655 																											"postgres`list_copy": {
  10656 																												"svUnique": 1,
  10657 																												"svTotal": 1,
  10658 																												"svChildren": {}
  10659 																											},
  10660 																											"postgres`make_windowagg": {
  10661 																												"svUnique": 0,
  10662 																												"svTotal": 1,
  10663 																												"svChildren": {
  10664 																													"postgres`add_tlist_costs_to_plan": {
  10665 																														"svUnique": 0,
  10666 																														"svTotal": 1,
  10667 																														"svChildren": {
  10668 																															"postgres`cost_qual_eval": {
  10669 																																"svUnique": 0,
  10670 																																"svTotal": 1,
  10671 																																"svChildren": {
  10672 																																	"postgres`cost_qual_eval_walker": {
  10673 																																		"svUnique": 0,
  10674 																																		"svTotal": 1,
  10675 																																		"svChildren": {
  10676 																																			"postgres`cost_qual_eval_walker": {
  10677 																																				"svUnique": 0,
  10678 																																				"svTotal": 1,
  10679 																																				"svChildren": {
  10680 																																					"postgres`check_stack_depth": {
  10681 																																						"svUnique": 1,
  10682 																																						"svTotal": 1,
  10683 																																						"svChildren": {}
  10684 																																					}
  10685 																																				}
  10686 																																			}
  10687 																																		}
  10688 																																	}
  10689 																																}
  10690 																															}
  10691 																														}
  10692 																													}
  10693 																												}
  10694 																											},
  10695 																											"postgres`pull_var_clause": {
  10696 																												"svUnique": 0,
  10697 																												"svTotal": 2,
  10698 																												"svChildren": {
  10699 																													"postgres`expression_tree_walker": {
  10700 																														"svUnique": 0,
  10701 																														"svTotal": 2,
  10702 																														"svChildren": {
  10703 																															"postgres`expression_tree_walker": {
  10704 																																"svUnique": 0,
  10705 																																"svTotal": 1,
  10706 																																"svChildren": {
  10707 																																	"postgres`check_stack_depth": {
  10708 																																		"svUnique": 1,
  10709 																																		"svTotal": 1,
  10710 																																		"svChildren": {}
  10711 																																	}
  10712 																																}
  10713 																															},
  10714 																															"postgres`pull_var_clause_walker": {
  10715 																																"svUnique": 0,
  10716 																																"svTotal": 1,
  10717 																																"svChildren": {
  10718 																																	"postgres`lappend": {
  10719 																																		"svUnique": 0,
  10720 																																		"svTotal": 1,
  10721 																																		"svChildren": {
  10722 																																			"postgres`AllocSetAlloc": {
  10723 																																				"svUnique": 1,
  10724 																																				"svTotal": 1,
  10725 																																				"svChildren": {}
  10726 																																			}
  10727 																																		}
  10728 																																	}
  10729 																																}
  10730 																															}
  10731 																														}
  10732 																													}
  10733 																												}
  10734 																											},
  10735 																											"postgres`query_planner": {
  10736 																												"svUnique": 0,
  10737 																												"svTotal": 101,
  10738 																												"svChildren": {
  10739 																													"postgres`MemoryContextAllocZero": {
  10740 																														"svUnique": 1,
  10741 																														"svTotal": 1,
  10742 																														"svChildren": {}
  10743 																													},
  10744 																													"postgres`add_base_rels_to_query": {
  10745 																														"svUnique": 1,
  10746 																														"svTotal": 64,
  10747 																														"svChildren": {
  10748 																															"postgres`build_simple_rel": {
  10749 																																"svUnique": 0,
  10750 																																"svTotal": 63,
  10751 																																"svChildren": {
  10752 																																	"postgres`_copyList.isra.15": {
  10753 																																		"svUnique": 1,
  10754 																																		"svTotal": 1,
  10755 																																		"svChildren": {}
  10756 																																	},
  10757 																																	"postgres`get_relation_info": {
  10758 																																		"svUnique": 13,
  10759 																																		"svTotal": 60,
  10760 																																		"svChildren": {
  10761 																																			"postgres`MemoryContextAlloc": {
  10762 																																				"svUnique": 1,
  10763 																																				"svTotal": 1,
  10764 																																				"svChildren": {}
  10765 																																			},
  10766 																																			"postgres`MemoryContextAllocZeroAligned": {
  10767 																																				"svUnique": 1,
  10768 																																				"svTotal": 1,
  10769 																																				"svChildren": {}
  10770 																																			},
  10771 																																			"postgres`_copyList.isra.15": {
  10772 																																				"svUnique": 0,
  10773 																																				"svTotal": 1,
  10774 																																				"svChildren": {
  10775 																																					"postgres`copyObject": {
  10776 																																						"svUnique": 0,
  10777 																																						"svTotal": 1,
  10778 																																						"svChildren": {
  10779 																																							"postgres`MemoryContextAllocZeroAligned": {
  10780 																																								"svUnique": 1,
  10781 																																								"svTotal": 1,
  10782 																																								"svChildren": {}
  10783 																																							}
  10784 																																						}
  10785 																																					}
  10786 																																				}
  10787 																																			},
  10788 																																			"postgres`estimate_rel_size": {
  10789 																																				"svUnique": 1,
  10790 																																				"svTotal": 20,
  10791 																																				"svChildren": {
  10792 																																					"postgres`get_rel_data_width": {
  10793 																																						"svUnique": 0,
  10794 																																						"svTotal": 2,
  10795 																																						"svChildren": {
  10796 																																							"postgres`get_attavgwidth": {
  10797 																																								"svUnique": 0,
  10798 																																								"svTotal": 2,
  10799 																																								"svChildren": {
  10800 																																									"postgres`SearchCatCache": {
  10801 																																										"svUnique": 2,
  10802 																																										"svTotal": 2,
  10803 																																										"svChildren": {}
  10804 																																									}
  10805 																																								}
  10806 																																							}
  10807 																																						}
  10808 																																					},
  10809 																																					"postgres`mdnblocks": {
  10810 																																						"svUnique": 1,
  10811 																																						"svTotal": 17,
  10812 																																						"svChildren": {
  10813 																																							"postgres`_mdnblocks.isra.1": {
  10814 																																								"svUnique": 0,
  10815 																																								"svTotal": 16,
  10816 																																								"svChildren": {
  10817 																																									"libc.so.1`lseek": {
  10818 																																										"svUnique": 15,
  10819 																																										"svTotal": 15,
  10820 																																										"svChildren": {}
  10821 																																									},
  10822 																																									"postgres`FileSeek": {
  10823 																																										"svUnique": 1,
  10824 																																										"svTotal": 1,
  10825 																																										"svChildren": {}
  10826 																																									}
  10827 																																								}
  10828 																																							}
  10829 																																						}
  10830 																																					}
  10831 																																				}
  10832 																																			},
  10833 																																			"postgres`heap_open": {
  10834 																																				"svUnique": 0,
  10835 																																				"svTotal": 2,
  10836 																																				"svChildren": {
  10837 																																					"postgres`relation_open": {
  10838 																																						"svUnique": 0,
  10839 																																						"svTotal": 2,
  10840 																																						"svChildren": {
  10841 																																							"postgres`RelationIdGetRelation": {
  10842 																																								"svUnique": 0,
  10843 																																								"svTotal": 2,
  10844 																																								"svChildren": {
  10845 																																									"postgres`hash_search_with_hash_value": {
  10846 																																										"svUnique": 2,
  10847 																																										"svTotal": 2,
  10848 																																										"svChildren": {}
  10849 																																									}
  10850 																																								}
  10851 																																							}
  10852 																																						}
  10853 																																					}
  10854 																																				}
  10855 																																			},
  10856 																																			"postgres`index_can_return": {
  10857 																																				"svUnique": 1,
  10858 																																				"svTotal": 1,
  10859 																																				"svChildren": {}
  10860 																																			},
  10861 																																			"postgres`index_open": {
  10862 																																				"svUnique": 0,
  10863 																																				"svTotal": 17,
  10864 																																				"svChildren": {
  10865 																																					"postgres`relation_open": {
  10866 																																						"svUnique": 1,
  10867 																																						"svTotal": 17,
  10868 																																						"svChildren": {
  10869 																																							"postgres`LockRelationOid": {
  10870 																																								"svUnique": 1,
  10871 																																								"svTotal": 10,
  10872 																																								"svChildren": {
  10873 																																									"postgres`LockAcquireExtended": {
  10874 																																										"svUnique": 1,
  10875 																																										"svTotal": 7,
  10876 																																										"svChildren": {
  10877 																																											"postgres`AllocSetAlloc": {
  10878 																																												"svUnique": 1,
  10879 																																												"svTotal": 1,
  10880 																																												"svChildren": {}
  10881 																																											},
  10882 																																											"postgres`hash_search": {
  10883 																																												"svUnique": 1,
  10884 																																												"svTotal": 2,
  10885 																																												"svChildren": {
  10886 																																													"postgres`hash_any": {
  10887 																																														"svUnique": 1,
  10888 																																														"svTotal": 1,
  10889 																																														"svChildren": {}
  10890 																																													}
  10891 																																												}
  10892 																																											},
  10893 																																											"postgres`hash_search_with_hash_value": {
  10894 																																												"svUnique": 3,
  10895 																																												"svTotal": 3,
  10896 																																												"svChildren": {}
  10897 																																											}
  10898 																																										}
  10899 																																									},
  10900 																																									"postgres`ReceiveSharedInvalidMessages": {
  10901 																																										"svUnique": 0,
  10902 																																										"svTotal": 1,
  10903 																																										"svChildren": {
  10904 																																											"postgres`SIGetDataEntries": {
  10905 																																												"svUnique": 1,
  10906 																																												"svTotal": 1,
  10907 																																												"svChildren": {}
  10908 																																											}
  10909 																																										}
  10910 																																									},
  10911 																																									"postgres`RecoveryInProgress": {
  10912 																																										"svUnique": 1,
  10913 																																										"svTotal": 1,
  10914 																																										"svChildren": {}
  10915 																																									}
  10916 																																								}
  10917 																																							},
  10918 																																							"postgres`RelationIdGetRelation": {
  10919 																																								"svUnique": 0,
  10920 																																								"svTotal": 6,
  10921 																																								"svChildren": {
  10922 																																									"postgres`RelationIncrementReferenceCount": {
  10923 																																										"svUnique": 3,
  10924 																																										"svTotal": 3,
  10925 																																										"svChildren": {}
  10926 																																									},
  10927 																																									"postgres`hash_search_with_hash_value": {
  10928 																																										"svUnique": 3,
  10929 																																										"svTotal": 3,
  10930 																																										"svChildren": {}
  10931 																																									}
  10932 																																								}
  10933 																																							}
  10934 																																						}
  10935 																																					}
  10936 																																				}
  10937 																																			},
  10938 																																			"postgres`lcons": {
  10939 																																				"svUnique": 0,
  10940 																																				"svTotal": 1,
  10941 																																				"svChildren": {
  10942 																																					"postgres`new_list": {
  10943 																																						"svUnique": 0,
  10944 																																						"svTotal": 1,
  10945 																																						"svChildren": {
  10946 																																							"postgres`AllocSetAlloc": {
  10947 																																								"svUnique": 1,
  10948 																																								"svTotal": 1,
  10949 																																								"svChildren": {}
  10950 																																							}
  10951 																																						}
  10952 																																					}
  10953 																																				}
  10954 																																			},
  10955 																																			"postgres`list_free_private": {
  10956 																																				"svUnique": 0,
  10957 																																				"svTotal": 1,
  10958 																																				"svChildren": {
  10959 																																					"postgres`AllocSetFree": {
  10960 																																						"svUnique": 1,
  10961 																																						"svTotal": 1,
  10962 																																						"svChildren": {}
  10963 																																					}
  10964 																																				}
  10965 																																			},
  10966 																																			"postgres`smgrnblocks": {
  10967 																																				"svUnique": 2,
  10968 																																				"svTotal": 2,
  10969 																																				"svChildren": {}
  10970 																																			}
  10971 																																		}
  10972 																																	},
  10973 																																	"postgres`lappend": {
  10974 																																		"svUnique": 1,
  10975 																																		"svTotal": 1,
  10976 																																		"svChildren": {}
  10977 																																	},
  10978 																																	"postgres`smgrnblocks": {
  10979 																																		"svUnique": 1,
  10980 																																		"svTotal": 1,
  10981 																																		"svChildren": {}
  10982 																																	}
  10983 																																}
  10984 																															}
  10985 																														}
  10986 																													},
  10987 																													"postgres`build_base_rel_tlists": {
  10988 																														"svUnique": 0,
  10989 																														"svTotal": 2,
  10990 																														"svChildren": {
  10991 																															"postgres`pull_var_clause": {
  10992 																																"svUnique": 0,
  10993 																																"svTotal": 2,
  10994 																																"svChildren": {
  10995 																																	"postgres`expression_tree_walker": {
  10996 																																		"svUnique": 1,
  10997 																																		"svTotal": 2,
  10998 																																		"svChildren": {
  10999 																																			"postgres`pull_var_clause_walker": {
  11000 																																				"svUnique": 0,
  11001 																																				"svTotal": 1,
  11002 																																				"svChildren": {
  11003 																																					"postgres`lappend": {
  11004 																																						"svUnique": 0,
  11005 																																						"svTotal": 1,
  11006 																																						"svChildren": {
  11007 																																							"postgres`new_tail_cell.isra.2": {
  11008 																																								"svUnique": 0,
  11009 																																								"svTotal": 1,
  11010 																																								"svChildren": {
  11011 																																									"postgres`AllocSetAlloc": {
  11012 																																										"svUnique": 1,
  11013 																																										"svTotal": 1,
  11014 																																										"svChildren": {}
  11015 																																									}
  11016 																																								}
  11017 																																							}
  11018 																																						}
  11019 																																					}
  11020 																																				}
  11021 																																			}
  11022 																																		}
  11023 																																	}
  11024 																																}
  11025 																															}
  11026 																														}
  11027 																													},
  11028 																													"postgres`deconstruct_jointree": {
  11029 																														"svUnique": 0,
  11030 																														"svTotal": 1,
  11031 																														"svChildren": {
  11032 																															"postgres`deconstruct_recurse": {
  11033 																																"svUnique": 0,
  11034 																																"svTotal": 1,
  11035 																																"svChildren": {
  11036 																																	"postgres`distribute_qual_to_rels": {
  11037 																																		"svUnique": 0,
  11038 																																		"svTotal": 1,
  11039 																																		"svChildren": {
  11040 																																			"postgres`process_equivalence": {
  11041 																																				"svUnique": 0,
  11042 																																				"svTotal": 1,
  11043 																																				"svChildren": {
  11044 																																					"postgres`add_eq_member": {
  11045 																																						"svUnique": 1,
  11046 																																						"svTotal": 1,
  11047 																																						"svChildren": {}
  11048 																																					}
  11049 																																				}
  11050 																																			}
  11051 																																		}
  11052 																																	}
  11053 																																}
  11054 																															}
  11055 																														}
  11056 																													},
  11057 																													"postgres`get_cheapest_fractional_path_for_pathkeys": {
  11058 																														"svUnique": 1,
  11059 																														"svTotal": 1,
  11060 																														"svChildren": {}
  11061 																													},
  11062 																													"postgres`make_one_rel": {
  11063 																														"svUnique": 0,
  11064 																														"svTotal": 31,
  11065 																														"svChildren": {
  11066 																															"postgres`set_baserel_size_estimates": {
  11067 																																"svUnique": 1,
  11068 																																"svTotal": 1,
  11069 																																"svChildren": {}
  11070 																															},
  11071 																															"postgres`set_rel_pathlist": {
  11072 																																"svUnique": 0,
  11073 																																"svTotal": 14,
  11074 																																"svChildren": {
  11075 																																	"postgres`create_index_paths": {
  11076 																																		"svUnique": 1,
  11077 																																		"svTotal": 12,
  11078 																																		"svChildren": {
  11079 																																			"postgres`choose_bitmap_and": {
  11080 																																				"svUnique": 0,
  11081 																																				"svTotal": 1,
  11082 																																				"svChildren": {
  11083 																																					"postgres`lcons": {
  11084 																																						"svUnique": 0,
  11085 																																						"svTotal": 1,
  11086 																																						"svChildren": {
  11087 																																							"postgres`new_list": {
  11088 																																								"svUnique": 0,
  11089 																																								"svTotal": 1,
  11090 																																								"svChildren": {
  11091 																																									"postgres`AllocSetAlloc": {
  11092 																																										"svUnique": 1,
  11093 																																										"svTotal": 1,
  11094 																																										"svChildren": {}
  11095 																																									}
  11096 																																								}
  11097 																																							}
  11098 																																						}
  11099 																																					}
  11100 																																				}
  11101 																																			},
  11102 																																			"postgres`create_bitmap_heap_path": {
  11103 																																				"svUnique": 0,
  11104 																																				"svTotal": 1,
  11105 																																				"svChildren": {
  11106 																																					"postgres`get_tablespace_page_costs": {
  11107 																																						"svUnique": 1,
  11108 																																						"svTotal": 1,
  11109 																																						"svChildren": {}
  11110 																																					}
  11111 																																				}
  11112 																																			},
  11113 																																			"postgres`get_index_paths": {
  11114 																																				"svUnique": 0,
  11115 																																				"svTotal": 7,
  11116 																																				"svChildren": {
  11117 																																					"postgres`bms_is_subset": {
  11118 																																						"svUnique": 1,
  11119 																																						"svTotal": 1,
  11120 																																						"svChildren": {}
  11121 																																					},
  11122 																																					"postgres`build_index_paths": {
  11123 																																						"svUnique": 1,
  11124 																																						"svTotal": 6,
  11125 																																						"svChildren": {
  11126 																																							"postgres`build_index_pathkeys": {
  11127 																																								"svUnique": 0,
  11128 																																								"svTotal": 1,
  11129 																																								"svChildren": {
  11130 																																									"postgres`make_pathkey_from_sortinfo": {
  11131 																																										"svUnique": 0,
  11132 																																										"svTotal": 1,
  11133 																																										"svChildren": {
  11134 																																											"postgres`get_mergejoin_opfamilies": {
  11135 																																												"svUnique": 0,
  11136 																																												"svTotal": 1,
  11137 																																												"svChildren": {
  11138 																																													"postgres`SearchCatCacheList": {
  11139 																																														"svUnique": 0,
  11140 																																														"svTotal": 1,
  11141 																																														"svChildren": {
  11142 																																															"postgres`oideq": {
  11143 																																																"svUnique": 1,
  11144 																																																"svTotal": 1,
  11145 																																																"svChildren": {}
  11146 																																															}
  11147 																																														}
  11148 																																													}
  11149 																																												}
  11150 																																											}
  11151 																																										}
  11152 																																									}
  11153 																																								}
  11154 																																							},
  11155 																																							"postgres`create_index_path": {
  11156 																																								"svUnique": 0,
  11157 																																								"svTotal": 2,
  11158 																																								"svChildren": {
  11159 																																									"postgres`cost_index": {
  11160 																																										"svUnique": 0,
  11161 																																										"svTotal": 2,
  11162 																																										"svChildren": {
  11163 																																											"postgres`OidFunctionCall7Coll": {
  11164 																																												"svUnique": 0,
  11165 																																												"svTotal": 2,
  11166 																																												"svChildren": {
  11167 																																													"postgres`btcostestimate": {
  11168 																																														"svUnique": 0,
  11169 																																														"svTotal": 2,
  11170 																																														"svChildren": {
  11171 																																															"postgres`genericcostestimate": {
  11172 																																																"svUnique": 0,
  11173 																																																"svTotal": 1,
  11174 																																																"svChildren": {
  11175 																																																	"postgres`add_predicate_to_quals.isra.3": {
  11176 																																																		"svUnique": 0,
  11177 																																																		"svTotal": 1,
  11178 																																																		"svChildren": {
  11179 																																																			"postgres`predicate_implied_by_recurse": {
  11180 																																																				"svUnique": 0,
  11181 																																																				"svTotal": 1,
  11182 																																																				"svChildren": {
  11183 																																																					"postgres`SearchSysCache": {
  11184 																																																						"svUnique": 1,
  11185 																																																						"svTotal": 1,
  11186 																																																						"svChildren": {}
  11187 																																																					}
  11188 																																																				}
  11189 																																																			}
  11190 																																																		}
  11191 																																																	}
  11192 																																																}
  11193 																																															},
  11194 																																															"postgres`lappend": {
  11195 																																																"svUnique": 0,
  11196 																																																"svTotal": 1,
  11197 																																																"svChildren": {
  11198 																																																	"postgres`new_list": {
  11199 																																																		"svUnique": 0,
  11200 																																																		"svTotal": 1,
  11201 																																																		"svChildren": {
  11202 																																																			"postgres`AllocSetAlloc": {
  11203 																																																				"svUnique": 1,
  11204 																																																				"svTotal": 1,
  11205 																																																				"svChildren": {}
  11206 																																																			}
  11207 																																																		}
  11208 																																																	}
  11209 																																																}
  11210 																																															}
  11211 																																														}
  11212 																																													}
  11213 																																												}
  11214 																																											}
  11215 																																										}
  11216 																																									}
  11217 																																								}
  11218 																																							},
  11219 																																							"postgres`pull_varattnos": {
  11220 																																								"svUnique": 0,
  11221 																																								"svTotal": 2,
  11222 																																								"svChildren": {
  11223 																																									"postgres`expression_tree_walker": {
  11224 																																										"svUnique": 0,
  11225 																																										"svTotal": 1,
  11226 																																										"svChildren": {
  11227 																																											"postgres`pull_varattnos_walker": {
  11228 																																												"svUnique": 0,
  11229 																																												"svTotal": 1,
  11230 																																												"svChildren": {
  11231 																																													"postgres`bms_add_member": {
  11232 																																														"svUnique": 0,
  11233 																																														"svTotal": 1,
  11234 																																														"svChildren": {
  11235 																																															"postgres`bms_make_singleton": {
  11236 																																																"svUnique": 1,
  11237 																																																"svTotal": 1,
  11238 																																																"svChildren": {}
  11239 																																															}
  11240 																																														}
  11241 																																													}
  11242 																																												}
  11243 																																											}
  11244 																																										}
  11245 																																									},
  11246 																																									"postgres`pull_varattnos_walker": {
  11247 																																										"svUnique": 1,
  11248 																																										"svTotal": 1,
  11249 																																										"svChildren": {}
  11250 																																									}
  11251 																																								}
  11252 																																							}
  11253 																																						}
  11254 																																					}
  11255 																																				}
  11256 																																			},
  11257 																																			"postgres`match_clauses_to_index": {
  11258 																																				"svUnique": 0,
  11259 																																				"svTotal": 2,
  11260 																																				"svChildren": {
  11261 																																					"postgres`match_clause_to_index": {
  11262 																																						"svUnique": 0,
  11263 																																						"svTotal": 2,
  11264 																																						"svChildren": {
  11265 																																							"postgres`SearchSysCacheExists": {
  11266 																																								"svUnique": 0,
  11267 																																								"svTotal": 2,
  11268 																																								"svChildren": {
  11269 																																									"postgres`SearchCatCache": {
  11270 																																										"svUnique": 1,
  11271 																																										"svTotal": 2,
  11272 																																										"svChildren": {
  11273 																																											"postgres`CatalogCacheComputeHashValue": {
  11274 																																												"svUnique": 0,
  11275 																																												"svTotal": 1,
  11276 																																												"svChildren": {
  11277 																																													"postgres`hashchar": {
  11278 																																														"svUnique": 1,
  11279 																																														"svTotal": 1,
  11280 																																														"svChildren": {}
  11281 																																													}
  11282 																																												}
  11283 																																											}
  11284 																																										}
  11285 																																									}
  11286 																																								}
  11287 																																							}
  11288 																																						}
  11289 																																					}
  11290 																																				}
  11291 																																			}
  11292 																																		}
  11293 																																	},
  11294 																																	"postgres`create_seqscan_path": {
  11295 																																		"svUnique": 0,
  11296 																																		"svTotal": 1,
  11297 																																		"svChildren": {
  11298 																																			"postgres`MemoryContextAllocZeroAligned": {
  11299 																																				"svUnique": 0,
  11300 																																				"svTotal": 1,
  11301 																																				"svChildren": {
  11302 																																					"postgres`AllocSetAlloc": {
  11303 																																						"svUnique": 1,
  11304 																																						"svTotal": 1,
  11305 																																						"svChildren": {}
  11306 																																					}
  11307 																																				}
  11308 																																			}
  11309 																																		}
  11310 																																	},
  11311 																																	"postgres`create_tidscan_paths": {
  11312 																																		"svUnique": 1,
  11313 																																		"svTotal": 1,
  11314 																																		"svChildren": {}
  11315 																																	}
  11316 																																}
  11317 																															},
  11318 																															"postgres`set_rel_size": {
  11319 																																"svUnique": 1,
  11320 																																"svTotal": 16,
  11321 																																"svChildren": {
  11322 																																	"postgres`check_partial_indexes": {
  11323 																																		"svUnique": 0,
  11324 																																		"svTotal": 5,
  11325 																																		"svChildren": {
  11326 																																			"postgres`predicate_implied_by_recurse": {
  11327 																																				"svUnique": 0,
  11328 																																				"svTotal": 5,
  11329 																																				"svChildren": {
  11330 																																					"postgres`predicate_implied_by_recurse": {
  11331 																																						"svUnique": 3,
  11332 																																						"svTotal": 5,
  11333 																																						"svChildren": {
  11334 																																							"postgres`list_member_strip": {
  11335 																																								"svUnique": 1,
  11336 																																								"svTotal": 1,
  11337 																																								"svChildren": {}
  11338 																																							},
  11339 																																							"postgres`predicate_implied_by_recurse": {
  11340 																																								"svUnique": 0,
  11341 																																								"svTotal": 1,
  11342 																																								"svChildren": {
  11343 																																									"postgres`op_strict": {
  11344 																																										"svUnique": 0,
  11345 																																										"svTotal": 1,
  11346 																																										"svChildren": {
  11347 																																											"postgres`get_opcode": {
  11348 																																												"svUnique": 0,
  11349 																																												"svTotal": 1,
  11350 																																												"svChildren": {
  11351 																																													"postgres`SearchCatCache": {
  11352 																																														"svUnique": 0,
  11353 																																														"svTotal": 1,
  11354 																																														"svChildren": {
  11355 																																															"postgres`CatalogCacheComputeHashValue": {
  11356 																																																"svUnique": 0,
  11357 																																																"svTotal": 1,
  11358 																																																"svChildren": {
  11359 																																																	"postgres`hashoid": {
  11360 																																																		"svUnique": 1,
  11361 																																																		"svTotal": 1,
  11362 																																																		"svChildren": {}
  11363 																																																	}
  11364 																																																}
  11365 																																															}
  11366 																																														}
  11367 																																													}
  11368 																																												}
  11369 																																											}
  11370 																																										}
  11371 																																									}
  11372 																																								}
  11373 																																							}
  11374 																																						}
  11375 																																					}
  11376 																																				}
  11377 																																			}
  11378 																																		}
  11379 																																	},
  11380 																																	"postgres`set_baserel_size_estimates": {
  11381 																																		"svUnique": 0,
  11382 																																		"svTotal": 4,
  11383 																																		"svChildren": {
  11384 																																			"postgres`clauselist_selectivity": {
  11385 																																				"svUnique": 0,
  11386 																																				"svTotal": 4,
  11387 																																				"svChildren": {
  11388 																																					"postgres`clause_selectivity": {
  11389 																																						"svUnique": 0,
  11390 																																						"svTotal": 4,
  11391 																																						"svChildren": {
  11392 																																							"postgres`restriction_selectivity": {
  11393 																																								"svUnique": 0,
  11394 																																								"svTotal": 4,
  11395 																																								"svChildren": {
  11396 																																									"postgres`OidFunctionCall4Coll": {
  11397 																																										"svUnique": 0,
  11398 																																										"svTotal": 4,
  11399 																																										"svChildren": {
  11400 																																											"postgres`eqsel": {
  11401 																																												"svUnique": 0,
  11402 																																												"svTotal": 3,
  11403 																																												"svChildren": {
  11404 																																													"libm.so.2`floor": {
  11405 																																														"svUnique": 1,
  11406 																																														"svTotal": 1,
  11407 																																														"svChildren": {}
  11408 																																													},
  11409 																																													"postgres`get_restriction_variable": {
  11410 																																														"svUnique": 0,
  11411 																																														"svTotal": 1,
  11412 																																														"svChildren": {
  11413 																																															"postgres`has_unique_index": {
  11414 																																																"svUnique": 1,
  11415 																																																"svTotal": 1,
  11416 																																																"svChildren": {}
  11417 																																															}
  11418 																																														}
  11419 																																													},
  11420 																																													"postgres`var_eq_const": {
  11421 																																														"svUnique": 0,
  11422 																																														"svTotal": 1,
  11423 																																														"svChildren": {
  11424 																																															"postgres`FunctionCall2Coll": {
  11425 																																																"svUnique": 0,
  11426 																																																"svTotal": 1,
  11427 																																																"svChildren": {
  11428 																																																	"postgres`texteq": {
  11429 																																																		"svUnique": 1,
  11430 																																																		"svTotal": 1,
  11431 																																																		"svChildren": {}
  11432 																																																	}
  11433 																																																}
  11434 																																															}
  11435 																																														}
  11436 																																													}
  11437 																																												}
  11438 																																											},
  11439 																																											"postgres`nlikesel": {
  11440 																																												"svUnique": 0,
  11441 																																												"svTotal": 1,
  11442 																																												"svChildren": {
  11443 																																													"postgres`patternsel": {
  11444 																																														"svUnique": 0,
  11445 																																														"svTotal": 1,
  11446 																																														"svChildren": {
  11447 																																															"postgres`mcv_selectivity": {
  11448 																																																"svUnique": 0,
  11449 																																																"svTotal": 1,
  11450 																																																"svChildren": {
  11451 																																																	"postgres`FunctionCall2Coll": {
  11452 																																																		"svUnique": 0,
  11453 																																																		"svTotal": 1,
  11454 																																																		"svChildren": {
  11455 																																																			"postgres`textlike": {
  11456 																																																				"svUnique": 1,
  11457 																																																				"svTotal": 1,
  11458 																																																				"svChildren": {}
  11459 																																																			}
  11460 																																																		}
  11461 																																																	}
  11462 																																																}
  11463 																																															}
  11464 																																														}
  11465 																																													}
  11466 																																												}
  11467 																																											}
  11468 																																										}
  11469 																																									}
  11470 																																								}
  11471 																																							}
  11472 																																						}
  11473 																																					}
  11474 																																				}
  11475 																																			}
  11476 																																		}
  11477 																																	},
  11478 																																	"postgres`set_rel_width": {
  11479 																																		"svUnique": 1,
  11480 																																		"svTotal": 6,
  11481 																																		"svChildren": {
  11482 																																			"postgres`get_attavgwidth": {
  11483 																																				"svUnique": 0,
  11484 																																				"svTotal": 5,
  11485 																																				"svChildren": {
  11486 																																					"postgres`SearchCatCache": {
  11487 																																						"svUnique": 1,
  11488 																																						"svTotal": 5,
  11489 																																						"svChildren": {
  11490 																																							"postgres`CatalogCacheComputeHashValue": {
  11491 																																								"svUnique": 0,
  11492 																																								"svTotal": 1,
  11493 																																								"svChildren": {
  11494 																																									"postgres`DirectFunctionCall1Coll": {
  11495 																																										"svUnique": 1,
  11496 																																										"svTotal": 1,
  11497 																																										"svChildren": {}
  11498 																																									}
  11499 																																								}
  11500 																																							},
  11501 																																							"postgres`booleq": {
  11502 																																								"svUnique": 1,
  11503 																																								"svTotal": 1,
  11504 																																								"svChildren": {}
  11505 																																							},
  11506 																																							"postgres`nocachegetattr": {
  11507 																																								"svUnique": 1,
  11508 																																								"svTotal": 1,
  11509 																																								"svChildren": {}
  11510 																																							},
  11511 																																							"postgres`systable_beginscan": {
  11512 																																								"svUnique": 0,
  11513 																																								"svTotal": 1,
  11514 																																								"svChildren": {
  11515 																																									"postgres`index_beginscan": {
  11516 																																										"svUnique": 0,
  11517 																																										"svTotal": 1,
  11518 																																										"svChildren": {
  11519 																																											"postgres`btbeginscan": {
  11520 																																												"svUnique": 1,
  11521 																																												"svTotal": 1,
  11522 																																												"svChildren": {}
  11523 																																											}
  11524 																																										}
  11525 																																									}
  11526 																																								}
  11527 																																							}
  11528 																																						}
  11529 																																					}
  11530 																																				}
  11531 																																			}
  11532 																																		}
  11533 																																	}
  11534 																																}
  11535 																															}
  11536 																														}
  11537 																													},
  11538 																													"postgres`make_rel_from_joinlist": {
  11539 																														"svUnique": 1,
  11540 																														"svTotal": 1,
  11541 																														"svChildren": {}
  11542 																													}
  11543 																												}
  11544 																											},
  11545 																											"postgres`tlist_member": {
  11546 																												"svUnique": 1,
  11547 																												"svTotal": 1,
  11548 																												"svChildren": {}
  11549 																											}
  11550 																										}
  11551 																									},
  11552 																									"postgres`preprocess_expression": {
  11553 																										"svUnique": 0,
  11554 																										"svTotal": 3,
  11555 																										"svChildren": {
  11556 																											"postgres`eval_const_expressions": {
  11557 																												"svUnique": 0,
  11558 																												"svTotal": 3,
  11559 																												"svChildren": {
  11560 																													"postgres`eval_const_expressions_mutator": {
  11561 																														"svUnique": 0,
  11562 																														"svTotal": 3,
  11563 																														"svChildren": {
  11564 																															"postgres`simplify_function": {
  11565 																																"svUnique": 0,
  11566 																																"svTotal": 3,
  11567 																																"svChildren": {
  11568 																																	"postgres`evaluate_expr": {
  11569 																																		"svUnique": 0,
  11570 																																		"svTotal": 3,
  11571 																																		"svChildren": {
  11572 																																			"postgres`ExecEvalExprSwitchContext": {
  11573 																																				"svUnique": 0,
  11574 																																				"svTotal": 2,
  11575 																																				"svChildren": {
  11576 																																					"postgres`ExecEvalFunc": {
  11577 																																						"svUnique": 0,
  11578 																																						"svTotal": 1,
  11579 																																						"svChildren": {
  11580 																																							"postgres`fmgr_info_cxt": {
  11581 																																								"svUnique": 1,
  11582 																																								"svTotal": 1,
  11583 																																								"svChildren": {}
  11584 																																							}
  11585 																																						}
  11586 																																					},
  11587 																																					"postgres`ExecMakeFunctionResult": {
  11588 																																						"svUnique": 1,
  11589 																																						"svTotal": 1,
  11590 																																						"svChildren": {}
  11591 																																					}
  11592 																																				}
  11593 																																			},
  11594 																																			"postgres`MemoryContextDelete": {
  11595 																																				"svUnique": 0,
  11596 																																				"svTotal": 1,
  11597 																																				"svChildren": {
  11598 																																					"postgres`AllocSetDelete": {
  11599 																																						"svUnique": 0,
  11600 																																						"svTotal": 1,
  11601 																																						"svChildren": {
  11602 																																							"libumem.so.1`free": {
  11603 																																								"svUnique": 0,
  11604 																																								"svTotal": 1,
  11605 																																								"svChildren": {
  11606 																																									"libumem.so.1`process_free": {
  11607 																																										"svUnique": 0,
  11608 																																										"svTotal": 1,
  11609 																																										"svChildren": {
  11610 																																											"libumem.so.1`umem_cache_free": {
  11611 																																												"svUnique": 1,
  11612 																																												"svTotal": 1,
  11613 																																												"svChildren": {}
  11614 																																											}
  11615 																																										}
  11616 																																									}
  11617 																																								}
  11618 																																							}
  11619 																																						}
  11620 																																					}
  11621 																																				}
  11622 																																			}
  11623 																																		}
  11624 																																	}
  11625 																																}
  11626 																															}
  11627 																														}
  11628 																													}
  11629 																												}
  11630 																											}
  11631 																										}
  11632 																									},
  11633 																									"postgres`preprocess_qual_conditions": {
  11634 																										"svUnique": 0,
  11635 																										"svTotal": 1,
  11636 																										"svChildren": {
  11637 																											"postgres`preprocess_expression": {
  11638 																												"svUnique": 0,
  11639 																												"svTotal": 1,
  11640 																												"svChildren": {
  11641 																													"postgres`find_duplicate_ors": {
  11642 																														"svUnique": 1,
  11643 																														"svTotal": 1,
  11644 																														"svChildren": {}
  11645 																													}
  11646 																												}
  11647 																											}
  11648 																										}
  11649 																									}
  11650 																								}
  11651 																							}
  11652 																						}
  11653 																					}
  11654 																				}
  11655 																			},
  11656 																			"postgres`planner": {
  11657 																				"svUnique": 1,
  11658 																				"svTotal": 1,
  11659 																				"svChildren": {}
  11660 																			}
  11661 																		}
  11662 																	}
  11663 																}
  11664 															}
  11665 														}
  11666 													},
  11667 													"postgres`MemoryContextDelete": {
  11668 														"svUnique": 0,
  11669 														"svTotal": 1,
  11670 														"svChildren": {
  11671 															"postgres`MemoryContextDeleteChildren": {
  11672 																"svUnique": 1,
  11673 																"svTotal": 1,
  11674 																"svChildren": {}
  11675 															}
  11676 														}
  11677 													},
  11678 													"postgres`MemoryContextReset": {
  11679 														"svUnique": 0,
  11680 														"svTotal": 2,
  11681 														"svChildren": {
  11682 															"postgres`AllocSetReset": {
  11683 																"svUnique": 1,
  11684 																"svTotal": 2,
  11685 																"svChildren": {
  11686 																	"libumem.so.1`free": {
  11687 																		"svUnique": 0,
  11688 																		"svTotal": 1,
  11689 																		"svChildren": {
  11690 																			"libc.so.1`___errno": {
  11691 																				"svUnique": 1,
  11692 																				"svTotal": 1,
  11693 																				"svChildren": {}
  11694 																			}
  11695 																		}
  11696 																	}
  11697 																}
  11698 															}
  11699 														}
  11700 													},
  11701 													"postgres`PortalRun": {
  11702 														"svUnique": 0,
  11703 														"svTotal": 47,
  11704 														"svChildren": {
  11705 															"libc.so.1`snprintf": {
  11706 																"svUnique": 0,
  11707 																"svTotal": 3,
  11708 																"svChildren": {
  11709 																	"libc.so.1`_ndoprnt": {
  11710 																		"svUnique": 3,
  11711 																		"svTotal": 3,
  11712 																		"svChildren": {}
  11713 																	}
  11714 																}
  11715 															},
  11716 															"postgres`FillPortalStore": {
  11717 																"svUnique": 0,
  11718 																"svTotal": 13,
  11719 																"svChildren": {
  11720 																	"postgres`PortalRunMulti": {
  11721 																		"svUnique": 0,
  11722 																		"svTotal": 13,
  11723 																		"svChildren": {
  11724 																			"postgres`ProcessQuery": {
  11725 																				"svUnique": 0,
  11726 																				"svTotal": 13,
  11727 																				"svChildren": {
  11728 																					"postgres`standard_ExecutorRun": {
  11729 																						"svUnique": 0,
  11730 																						"svTotal": 13,
  11731 																						"svChildren": {
  11732 																							"postgres`ExecProcNode": {
  11733 																								"svUnique": 0,
  11734 																								"svTotal": 13,
  11735 																								"svChildren": {
  11736 																									"postgres`ExecModifyTable": {
  11737 																										"svUnique": 0,
  11738 																										"svTotal": 13,
  11739 																										"svChildren": {
  11740 																											"postgres`ExecInsertIndexTuples": {
  11741 																												"svUnique": 0,
  11742 																												"svTotal": 8,
  11743 																												"svChildren": {
  11744 																													"postgres`index_insert": {
  11745 																														"svUnique": 0,
  11746 																														"svTotal": 8,
  11747 																														"svChildren": {
  11748 																															"postgres`FunctionCall6Coll": {
  11749 																																"svUnique": 0,
  11750 																																"svTotal": 8,
  11751 																																"svChildren": {
  11752 																																	"postgres`btinsert": {
  11753 																																		"svUnique": 0,
  11754 																																		"svTotal": 8,
  11755 																																		"svChildren": {
  11756 																																			"postgres`_bt_doinsert": {
  11757 																																				"svUnique": 0,
  11758 																																				"svTotal": 8,
  11759 																																				"svChildren": {
  11760 																																					"postgres`_bt_check_unique": {
  11761 																																						"svUnique": 0,
  11762 																																						"svTotal": 8,
  11763 																																						"svChildren": {
  11764 																																							"postgres`_bt_isequal": {
  11765 																																								"svUnique": 1,
  11766 																																								"svTotal": 4,
  11767 																																								"svChildren": {
  11768 																																									"postgres`FunctionCall2Coll": {
  11769 																																										"svUnique": 0,
  11770 																																										"svTotal": 3,
  11771 																																										"svChildren": {
  11772 																																											"postgres`bttextcmp": {
  11773 																																												"svUnique": 0,
  11774 																																												"svTotal": 2,
  11775 																																												"svChildren": {
  11776 																																													"libc.so.1`memcmp": {
  11777 																																														"svUnique": 2,
  11778 																																														"svTotal": 2,
  11779 																																														"svChildren": {}
  11780 																																													}
  11781 																																												}
  11782 																																											},
  11783 																																											"postgres`varstr_cmp": {
  11784 																																												"svUnique": 1,
  11785 																																												"svTotal": 1,
  11786 																																												"svChildren": {}
  11787 																																											}
  11788 																																										}
  11789 																																									}
  11790 																																								}
  11791 																																							},
  11792 																																							"postgres`heap_hot_search": {
  11793 																																								"svUnique": 0,
  11794 																																								"svTotal": 4,
  11795 																																								"svChildren": {
  11796 																																									"postgres`LWLockAcquire": {
  11797 																																										"svUnique": 1,
  11798 																																										"svTotal": 1,
  11799 																																										"svChildren": {}
  11800 																																									},
  11801 																																									"postgres`ReadBufferExtended": {
  11802 																																										"svUnique": 1,
  11803 																																										"svTotal": 3,
  11804 																																										"svChildren": {
  11805 																																											"postgres`ReadBuffer_common": {
  11806 																																												"svUnique": 0,
  11807 																																												"svTotal": 2,
  11808 																																												"svChildren": {
  11809 																																													"postgres`LWLockAcquire": {
  11810 																																														"svUnique": 1,
  11811 																																														"svTotal": 1,
  11812 																																														"svChildren": {}
  11813 																																													},
  11814 																																													"postgres`PinBuffer": {
  11815 																																														"svUnique": 1,
  11816 																																														"svTotal": 1,
  11817 																																														"svChildren": {}
  11818 																																													}
  11819 																																												}
  11820 																																											}
  11821 																																										}
  11822 																																									}
  11823 																																								}
  11824 																																							}
  11825 																																						}
  11826 																																					}
  11827 																																				}
  11828 																																			}
  11829 																																		}
  11830 																																	}
  11831 																																}
  11832 																															}
  11833 																														}
  11834 																													}
  11835 																												}
  11836 																											},
  11837 																											"postgres`ExecProcNode": {
  11838 																												"svUnique": 0,
  11839 																												"svTotal": 4,
  11840 																												"svChildren": {
  11841 																													"postgres`ExecScan": {
  11842 																														"svUnique": 0,
  11843 																														"svTotal": 4,
  11844 																														"svChildren": {
  11845 																															"postgres`IndexNext": {
  11846 																																"svUnique": 0,
  11847 																																"svTotal": 4,
  11848 																																"svChildren": {
  11849 																																	"postgres`index_getnext": {
  11850 																																		"svUnique": 0,
  11851 																																		"svTotal": 4,
  11852 																																		"svChildren": {
  11853 																																			"postgres`index_fetch_heap": {
  11854 																																				"svUnique": 0,
  11855 																																				"svTotal": 3,
  11856 																																				"svChildren": {
  11857 																																					"postgres`ReleaseAndReadBuffer": {
  11858 																																						"svUnique": 1,
  11859 																																						"svTotal": 1,
  11860 																																						"svChildren": {}
  11861 																																					},
  11862 																																					"postgres`heap_hot_search_buffer": {
  11863 																																						"svUnique": 1,
  11864 																																						"svTotal": 2,
  11865 																																						"svChildren": {
  11866 																																							"postgres`XidInMVCCSnapshot": {
  11867 																																								"svUnique": 1,
  11868 																																								"svTotal": 1,
  11869 																																								"svChildren": {}
  11870 																																							}
  11871 																																						}
  11872 																																					}
  11873 																																				}
  11874 																																			},
  11875 																																			"postgres`index_getnext_tid": {
  11876 																																				"svUnique": 0,
  11877 																																				"svTotal": 1,
  11878 																																				"svChildren": {
  11879 																																					"postgres`FunctionCall2Coll": {
  11880 																																						"svUnique": 0,
  11881 																																						"svTotal": 1,
  11882 																																						"svChildren": {
  11883 																																							"postgres`btgettuple": {
  11884 																																								"svUnique": 0,
  11885 																																								"svTotal": 1,
  11886 																																								"svChildren": {
  11887 																																									"postgres`_bt_next": {
  11888 																																										"svUnique": 0,
  11889 																																										"svTotal": 1,
  11890 																																										"svChildren": {
  11891 																																											"postgres`_bt_steppage": {
  11892 																																												"svUnique": 0,
  11893 																																												"svTotal": 1,
  11894 																																												"svChildren": {
  11895 																																													"postgres`_bt_checkkeys": {
  11896 																																														"svUnique": 1,
  11897 																																														"svTotal": 1,
  11898 																																														"svChildren": {}
  11899 																																													}
  11900 																																												}
  11901 																																											}
  11902 																																										}
  11903 																																									}
  11904 																																								}
  11905 																																							}
  11906 																																						}
  11907 																																					}
  11908 																																				}
  11909 																																			}
  11910 																																		}
  11911 																																	}
  11912 																																}
  11913 																															}
  11914 																														}
  11915 																													}
  11916 																												}
  11917 																											},
  11918 																											"postgres`bms_first_member": {
  11919 																												"svUnique": 1,
  11920 																												"svTotal": 1,
  11921 																												"svChildren": {}
  11922 																											}
  11923 																										}
  11924 																									}
  11925 																								}
  11926 																							}
  11927 																						}
  11928 																					}
  11929 																				}
  11930 																			}
  11931 																		}
  11932 																	}
  11933 																}
  11934 															},
  11935 															"postgres`PortalRunSelect": {
  11936 																"svUnique": 0,
  11937 																"svTotal": 31,
  11938 																"svChildren": {
  11939 																	"postgres`standard_ExecutorRun": {
  11940 																		"svUnique": 0,
  11941 																		"svTotal": 31,
  11942 																		"svChildren": {
  11943 																			"postgres`ExecProcNode": {
  11944 																				"svUnique": 0,
  11945 																				"svTotal": 30,
  11946 																				"svChildren": {
  11947 																					"postgres`ExecLimit": {
  11948 																						"svUnique": 0,
  11949 																						"svTotal": 17,
  11950 																						"svChildren": {
  11951 																							"postgres`ExecProcNode": {
  11952 																								"svUnique": 0,
  11953 																								"svTotal": 17,
  11954 																								"svChildren": {
  11955 																									"postgres`ExecWindowAgg": {
  11956 																										"svUnique": 0,
  11957 																										"svTotal": 16,
  11958 																										"svChildren": {
  11959 																											"postgres`begin_partition": {
  11960 																												"svUnique": 0,
  11961 																												"svTotal": 16,
  11962 																												"svChildren": {
  11963 																													"postgres`ExecProcNode": {
  11964 																														"svUnique": 0,
  11965 																														"svTotal": 16,
  11966 																														"svChildren": {
  11967 																															"postgres`ExecScan": {
  11968 																																"svUnique": 0,
  11969 																																"svTotal": 16,
  11970 																																"svChildren": {
  11971 																																	"postgres`ExecQual": {
  11972 																																		"svUnique": 0,
  11973 																																		"svTotal": 8,
  11974 																																		"svChildren": {
  11975 																																			"postgres`ExecEvalNullTest": {
  11976 																																				"svUnique": 0,
  11977 																																				"svTotal": 8,
  11978 																																				"svChildren": {
  11979 																																					"postgres`slot_getattr": {
  11980 																																						"svUnique": 1,
  11981 																																						"svTotal": 8,
  11982 																																						"svChildren": {
  11983 																																							"postgres`slot_deform_tuple": {
  11984 																																								"svUnique": 7,
  11985 																																								"svTotal": 7,
  11986 																																								"svChildren": {}
  11987 																																							}
  11988 																																						}
  11989 																																					}
  11990 																																				}
  11991 																																			}
  11992 																																		}
  11993 																																	},
  11994 																																	"postgres`IndexNext": {
  11995 																																		"svUnique": 0,
  11996 																																		"svTotal": 5,
  11997 																																		"svChildren": {
  11998 																																			"postgres`index_getnext": {
  11999 																																				"svUnique": 0,
  12000 																																				"svTotal": 5,
  12001 																																				"svChildren": {
  12002 																																					"postgres`index_getnext_tid": {
  12003 																																						"svUnique": 0,
  12004 																																						"svTotal": 5,
  12005 																																						"svChildren": {
  12006 																																							"postgres`FunctionCall2Coll": {
  12007 																																								"svUnique": 0,
  12008 																																								"svTotal": 5,
  12009 																																								"svChildren": {
  12010 																																									"postgres`btgettuple": {
  12011 																																										"svUnique": 0,
  12012 																																										"svTotal": 5,
  12013 																																										"svChildren": {
  12014 																																											"postgres`_bt_first": {
  12015 																																												"svUnique": 1,
  12016 																																												"svTotal": 5,
  12017 																																												"svChildren": {
  12018 																																													"postgres`_bt_binsrch": {
  12019 																																														"svUnique": 0,
  12020 																																														"svTotal": 1,
  12021 																																														"svChildren": {
  12022 																																															"postgres`_bt_compare": {
  12023 																																																"svUnique": 1,
  12024 																																																"svTotal": 1,
  12025 																																																"svChildren": {}
  12026 																																															}
  12027 																																														}
  12028 																																													},
  12029 																																													"postgres`_bt_get_endpoint": {
  12030 																																														"svUnique": 0,
  12031 																																														"svTotal": 1,
  12032 																																														"svChildren": {
  12033 																																															"postgres`_bt_getroot": {
  12034 																																																"svUnique": 0,
  12035 																																																"svTotal": 1,
  12036 																																																"svChildren": {
  12037 																																																	"postgres`_bt_getbuf": {
  12038 																																																		"svUnique": 0,
  12039 																																																		"svTotal": 1,
  12040 																																																		"svChildren": {
  12041 																																																			"postgres`LWLockAcquire": {
  12042 																																																				"svUnique": 1,
  12043 																																																				"svTotal": 1,
  12044 																																																				"svChildren": {}
  12045 																																																			}
  12046 																																																		}
  12047 																																																	}
  12048 																																																}
  12049 																																															}
  12050 																																														}
  12051 																																													},
  12052 																																													"postgres`_bt_search": {
  12053 																																														"svUnique": 0,
  12054 																																														"svTotal": 2,
  12055 																																														"svChildren": {
  12056 																																															"postgres`_bt_getroot": {
  12057 																																																"svUnique": 0,
  12058 																																																"svTotal": 1,
  12059 																																																"svChildren": {
  12060 																																																	"postgres`_bt_getbuf": {
  12061 																																																		"svUnique": 0,
  12062 																																																		"svTotal": 1,
  12063 																																																		"svChildren": {
  12064 																																																			"postgres`ReadBufferExtended": {
  12065 																																																				"svUnique": 0,
  12066 																																																				"svTotal": 1,
  12067 																																																				"svChildren": {
  12068 																																																					"postgres`ReadBuffer_common": {
  12069 																																																						"svUnique": 1,
  12070 																																																						"svTotal": 1,
  12071 																																																						"svChildren": {}
  12072 																																																					}
  12073 																																																				}
  12074 																																																			}
  12075 																																																		}
  12076 																																																	}
  12077 																																																}
  12078 																																															},
  12079 																																															"postgres`_bt_relandgetbuf": {
  12080 																																																"svUnique": 0,
  12081 																																																"svTotal": 1,
  12082 																																																"svChildren": {
  12083 																																																	"postgres`ReadBufferExtended": {
  12084 																																																		"svUnique": 0,
  12085 																																																		"svTotal": 1,
  12086 																																																		"svChildren": {
  12087 																																																			"postgres`ReadBuffer_common": {
  12088 																																																				"svUnique": 0,
  12089 																																																				"svTotal": 1,
  12090 																																																				"svChildren": {
  12091 																																																					"postgres`LWLockAcquire": {
  12092 																																																						"svUnique": 1,
  12093 																																																						"svTotal": 1,
  12094 																																																						"svChildren": {}
  12095 																																																					}
  12096 																																																				}
  12097 																																																			}
  12098 																																																		}
  12099 																																																	}
  12100 																																																}
  12101 																																															}
  12102 																																														}
  12103 																																													}
  12104 																																												}
  12105 																																											}
  12106 																																										}
  12107 																																									}
  12108 																																								}
  12109 																																							}
  12110 																																						}
  12111 																																					}
  12112 																																				}
  12113 																																			}
  12114 																																		}
  12115 																																	},
  12116 																																	"postgres`SeqNext": {
  12117 																																		"svUnique": 0,
  12118 																																		"svTotal": 3,
  12119 																																		"svChildren": {
  12120 																																			"postgres`heap_getnext": {
  12121 																																				"svUnique": 0,
  12122 																																				"svTotal": 3,
  12123 																																				"svChildren": {
  12124 																																					"postgres`heapgettup_pagemode": {
  12125 																																						"svUnique": 0,
  12126 																																						"svTotal": 3,
  12127 																																						"svChildren": {
  12128 																																							"postgres`heapgetpage": {
  12129 																																								"svUnique": 0,
  12130 																																								"svTotal": 3,
  12131 																																								"svChildren": {
  12132 																																									"postgres`LockBuffer": {
  12133 																																										"svUnique": 1,
  12134 																																										"svTotal": 1,
  12135 																																										"svChildren": {}
  12136 																																									},
  12137 																																									"postgres`ReadBufferExtended": {
  12138 																																										"svUnique": 0,
  12139 																																										"svTotal": 1,
  12140 																																										"svChildren": {
  12141 																																											"postgres`ReadBuffer_common": {
  12142 																																												"svUnique": 0,
  12143 																																												"svTotal": 1,
  12144 																																												"svChildren": {
  12145 																																													"postgres`hash_any": {
  12146 																																														"svUnique": 1,
  12147 																																														"svTotal": 1,
  12148 																																														"svChildren": {}
  12149 																																													}
  12150 																																												}
  12151 																																											}
  12152 																																										}
  12153 																																									},
  12154 																																									"postgres`heap_page_prune_opt": {
  12155 																																										"svUnique": 1,
  12156 																																										"svTotal": 1,
  12157 																																										"svChildren": {}
  12158 																																									}
  12159 																																								}
  12160 																																							}
  12161 																																						}
  12162 																																					}
  12163 																																				}
  12164 																																			}
  12165 																																		}
  12166 																																	}
  12167 																																}
  12168 																															}
  12169 																														}
  12170 																													}
  12171 																												}
  12172 																											}
  12173 																										}
  12174 																									},
  12175 																									"postgres`spool_tuples": {
  12176 																										"svUnique": 1,
  12177 																										"svTotal": 1,
  12178 																										"svChildren": {}
  12179 																									}
  12180 																								}
  12181 																							}
  12182 																						}
  12183 																					},
  12184 																					"postgres`ExecLockRows": {
  12185 																						"svUnique": 0,
  12186 																						"svTotal": 6,
  12187 																						"svChildren": {
  12188 																							"postgres`ExecProcNode": {
  12189 																								"svUnique": 0,
  12190 																								"svTotal": 6,
  12191 																								"svChildren": {
  12192 																									"postgres`ExecScan": {
  12193 																										"svUnique": 0,
  12194 																										"svTotal": 6,
  12195 																										"svChildren": {
  12196 																											"postgres`IndexNext": {
  12197 																												"svUnique": 0,
  12198 																												"svTotal": 6,
  12199 																												"svChildren": {
  12200 																													"postgres`index_getnext": {
  12201 																														"svUnique": 0,
  12202 																														"svTotal": 6,
  12203 																														"svChildren": {
  12204 																															"postgres`index_fetch_heap": {
  12205 																																"svUnique": 0,
  12206 																																"svTotal": 1,
  12207 																																"svChildren": {
  12208 																																	"postgres`ReadBufferExtended": {
  12209 																																		"svUnique": 0,
  12210 																																		"svTotal": 1,
  12211 																																		"svChildren": {
  12212 																																			"postgres`PinBuffer": {
  12213 																																				"svUnique": 1,
  12214 																																				"svTotal": 1,
  12215 																																				"svChildren": {}
  12216 																																			}
  12217 																																		}
  12218 																																	}
  12219 																																}
  12220 																															},
  12221 																															"postgres`index_getnext_tid": {
  12222 																																"svUnique": 2,
  12223 																																"svTotal": 5,
  12224 																																"svChildren": {
  12225 																																	"postgres`FunctionCall2Coll": {
  12226 																																		"svUnique": 0,
  12227 																																		"svTotal": 3,
  12228 																																		"svChildren": {
  12229 																																			"postgres`btgettuple": {
  12230 																																				"svUnique": 0,
  12231 																																				"svTotal": 3,
  12232 																																				"svChildren": {
  12233 																																					"postgres`_bt_next": {
  12234 																																						"svUnique": 0,
  12235 																																						"svTotal": 3,
  12236 																																						"svChildren": {
  12237 																																							"postgres`_bt_steppage": {
  12238 																																								"svUnique": 0,
  12239 																																								"svTotal": 3,
  12240 																																								"svChildren": {
  12241 																																									"postgres`_bt_readpage": {
  12242 																																										"svUnique": 1,
  12243 																																										"svTotal": 3,
  12244 																																										"svChildren": {
  12245 																																											"postgres`_bt_checkkeys": {
  12246 																																												"svUnique": 0,
  12247 																																												"svTotal": 2,
  12248 																																												"svChildren": {
  12249 																																													"postgres`FunctionCall2Coll": {
  12250 																																														"svUnique": 0,
  12251 																																														"svTotal": 2,
  12252 																																														"svChildren": {
  12253 																																															"postgres`toast_raw_datum_size": {
  12254 																																																"svUnique": 2,
  12255 																																																"svTotal": 2,
  12256 																																																"svChildren": {}
  12257 																																															}
  12258 																																														}
  12259 																																													}
  12260 																																												}
  12261 																																											}
  12262 																																										}
  12263 																																									}
  12264 																																								}
  12265 																																							}
  12266 																																						}
  12267 																																					}
  12268 																																				}
  12269 																																			}
  12270 																																		}
  12271 																																	}
  12272 																																}
  12273 																															}
  12274 																														}
  12275 																													}
  12276 																												}
  12277 																											}
  12278 																										}
  12279 																									}
  12280 																								}
  12281 																							}
  12282 																						}
  12283 																					},
  12284 																					"postgres`ExecScan": {
  12285 																						"svUnique": 0,
  12286 																						"svTotal": 7,
  12287 																						"svChildren": {
  12288 																							"postgres`IndexNext": {
  12289 																								"svUnique": 0,
  12290 																								"svTotal": 7,
  12291 																								"svChildren": {
  12292 																									"postgres`index_getnext": {
  12293 																										"svUnique": 0,
  12294 																										"svTotal": 7,
  12295 																										"svChildren": {
  12296 																											"postgres`LockBuffer": {
  12297 																												"svUnique": 1,
  12298 																												"svTotal": 1,
  12299 																												"svChildren": {}
  12300 																											},
  12301 																											"postgres`index_fetch_heap": {
  12302 																												"svUnique": 0,
  12303 																												"svTotal": 2,
  12304 																												"svChildren": {
  12305 																													"postgres`HeapTupleIsSurelyDead": {
  12306 																														"svUnique": 1,
  12307 																														"svTotal": 1,
  12308 																														"svChildren": {}
  12309 																													},
  12310 																													"postgres`ReleaseAndReadBuffer": {
  12311 																														"svUnique": 1,
  12312 																														"svTotal": 1,
  12313 																														"svChildren": {}
  12314 																													}
  12315 																												}
  12316 																											},
  12317 																											"postgres`index_getnext_tid": {
  12318 																												"svUnique": 1,
  12319 																												"svTotal": 4,
  12320 																												"svChildren": {
  12321 																													"postgres`FunctionCall2Coll": {
  12322 																														"svUnique": 0,
  12323 																														"svTotal": 2,
  12324 																														"svChildren": {
  12325 																															"postgres`btgettuple": {
  12326 																																"svUnique": 0,
  12327 																																"svTotal": 2,
  12328 																																"svChildren": {
  12329 																																	"postgres`_bt_next": {
  12330 																																		"svUnique": 0,
  12331 																																		"svTotal": 2,
  12332 																																		"svChildren": {
  12333 																																			"postgres`_bt_steppage": {
  12334 																																				"svUnique": 0,
  12335 																																				"svTotal": 2,
  12336 																																				"svChildren": {
  12337 																																					"postgres`_bt_readpage": {
  12338 																																						"svUnique": 1,
  12339 																																						"svTotal": 2,
  12340 																																						"svChildren": {
  12341 																																							"postgres`_bt_checkkeys": {
  12342 																																								"svUnique": 1,
  12343 																																								"svTotal": 1,
  12344 																																								"svChildren": {}
  12345 																																							}
  12346 																																						}
  12347 																																					}
  12348 																																				}
  12349 																																			}
  12350 																																		}
  12351 																																	}
  12352 																																}
  12353 																															}
  12354 																														}
  12355 																													},
  12356 																													"postgres`btgettuple": {
  12357 																														"svUnique": 1,
  12358 																														"svTotal": 1,
  12359 																														"svChildren": {}
  12360 																													}
  12361 																												}
  12362 																											}
  12363 																										}
  12364 																									}
  12365 																								}
  12366 																							}
  12367 																						}
  12368 																					}
  12369 																				}
  12370 																			},
  12371 																			"postgres`printtup": {
  12372 																				"svUnique": 0,
  12373 																				"svTotal": 1,
  12374 																				"svChildren": {
  12375 																					"postgres`heap_tuple_untoast_attr": {
  12376 																						"svUnique": 0,
  12377 																						"svTotal": 1,
  12378 																						"svChildren": {
  12379 																							"postgres`toast_fetch_datum": {
  12380 																								"svUnique": 0,
  12381 																								"svTotal": 1,
  12382 																								"svChildren": {
  12383 																									"postgres`systable_getnext_ordered": {
  12384 																										"svUnique": 0,
  12385 																										"svTotal": 1,
  12386 																										"svChildren": {
  12387 																											"postgres`index_getnext": {
  12388 																												"svUnique": 0,
  12389 																												"svTotal": 1,
  12390 																												"svChildren": {
  12391 																													"postgres`index_getnext_tid": {
  12392 																														"svUnique": 0,
  12393 																														"svTotal": 1,
  12394 																														"svChildren": {
  12395 																															"postgres`FunctionCall2Coll": {
  12396 																																"svUnique": 0,
  12397 																																"svTotal": 1,
  12398 																																"svChildren": {
  12399 																																	"postgres`btgettuple": {
  12400 																																		"svUnique": 0,
  12401 																																		"svTotal": 1,
  12402 																																		"svChildren": {
  12403 																																			"postgres`_bt_first": {
  12404 																																				"svUnique": 0,
  12405 																																				"svTotal": 1,
  12406 																																				"svChildren": {
  12407 																																					"postgres`_bt_search": {
  12408 																																						"svUnique": 0,
  12409 																																						"svTotal": 1,
  12410 																																						"svChildren": {
  12411 																																							"postgres`_bt_moveright": {
  12412 																																								"svUnique": 1,
  12413 																																								"svTotal": 1,
  12414 																																								"svChildren": {}
  12415 																																							}
  12416 																																						}
  12417 																																					}
  12418 																																				}
  12419 																																			}
  12420 																																		}
  12421 																																	}
  12422 																																}
  12423 																															}
  12424 																														}
  12425 																													}
  12426 																												}
  12427 																											}
  12428 																										}
  12429 																									}
  12430 																								}
  12431 																							}
  12432 																						}
  12433 																					}
  12434 																				}
  12435 																			}
  12436 																		}
  12437 																	}
  12438 																}
  12439 															}
  12440 														}
  12441 													},
  12442 													"postgres`PortalStart": {
  12443 														"svUnique": 0,
  12444 														"svTotal": 20,
  12445 														"svChildren": {
  12446 															"postgres`GetTransactionSnapshot": {
  12447 																"svUnique": 0,
  12448 																"svTotal": 1,
  12449 																"svChildren": {
  12450 																	"postgres`GetSnapshotData": {
  12451 																		"svUnique": 1,
  12452 																		"svTotal": 1,
  12453 																		"svChildren": {}
  12454 																	}
  12455 																}
  12456 															},
  12457 															"postgres`standard_ExecutorStart": {
  12458 																"svUnique": 0,
  12459 																"svTotal": 19,
  12460 																"svChildren": {
  12461 																	"postgres`ExecInitNode": {
  12462 																		"svUnique": 0,
  12463 																		"svTotal": 18,
  12464 																		"svChildren": {
  12465 																			"postgres`ExecInitLimit": {
  12466 																				"svUnique": 0,
  12467 																				"svTotal": 18,
  12468 																				"svChildren": {
  12469 																					"postgres`ExecAssignResultTypeFromTL": {
  12470 																						"svUnique": 0,
  12471 																						"svTotal": 3,
  12472 																						"svChildren": {
  12473 																							"postgres`ExecTypeFromTLInternal": {
  12474 																								"svUnique": 0,
  12475 																								"svTotal": 3,
  12476 																								"svChildren": {
  12477 																									"postgres`TupleDescInitEntry": {
  12478 																										"svUnique": 0,
  12479 																										"svTotal": 2,
  12480 																										"svChildren": {
  12481 																											"libc.so.1`strncpy": {
  12482 																												"svUnique": 1,
  12483 																												"svTotal": 1,
  12484 																												"svChildren": {}
  12485 																											},
  12486 																											"postgres`SearchCatCache": {
  12487 																												"svUnique": 1,
  12488 																												"svTotal": 1,
  12489 																												"svChildren": {}
  12490 																											}
  12491 																										}
  12492 																									},
  12493 																									"postgres`namestrcpy": {
  12494 																										"svUnique": 1,
  12495 																										"svTotal": 1,
  12496 																										"svChildren": {}
  12497 																									}
  12498 																								}
  12499 																							}
  12500 																						}
  12501 																					},
  12502 																					"postgres`ExecInitNode": {
  12503 																						"svUnique": 0,
  12504 																						"svTotal": 15,
  12505 																						"svChildren": {
  12506 																							"postgres`ExecInitSort": {
  12507 																								"svUnique": 0,
  12508 																								"svTotal": 1,
  12509 																								"svChildren": {
  12510 																									"postgres`ExecInitNode": {
  12511 																										"svUnique": 0,
  12512 																										"svTotal": 1,
  12513 																										"svChildren": {
  12514 																											"postgres`ExecInitWindowAgg": {
  12515 																												"svUnique": 0,
  12516 																												"svTotal": 1,
  12517 																												"svChildren": {
  12518 																													"postgres`ExecInitExpr": {
  12519 																														"svUnique": 0,
  12520 																														"svTotal": 1,
  12521 																														"svChildren": {
  12522 																															"postgres`ExecInitExpr": {
  12523 																																"svUnique": 0,
  12524 																																"svTotal": 1,
  12525 																																"svChildren": {
  12526 																																	"postgres`MemoryContextAllocZeroAligned": {
  12527 																																		"svUnique": 0,
  12528 																																		"svTotal": 1,
  12529 																																		"svChildren": {
  12530 																																			"postgres`AllocSetAlloc": {
  12531 																																				"svUnique": 1,
  12532 																																				"svTotal": 1,
  12533 																																				"svChildren": {}
  12534 																																			}
  12535 																																		}
  12536 																																	}
  12537 																																}
  12538 																															}
  12539 																														}
  12540 																													}
  12541 																												}
  12542 																											}
  12543 																										}
  12544 																									}
  12545 																								}
  12546 																							},
  12547 																							"postgres`ExecInitWindowAgg": {
  12548 																								"svUnique": 0,
  12549 																								"svTotal": 14,
  12550 																								"svChildren": {
  12551 																									"postgres`ExecAssignExprContext": {
  12552 																										"svUnique": 0,
  12553 																										"svTotal": 1,
  12554 																										"svChildren": {
  12555 																											"postgres`CreateExprContext": {
  12556 																												"svUnique": 1,
  12557 																												"svTotal": 1,
  12558 																												"svChildren": {}
  12559 																											}
  12560 																										}
  12561 																									},
  12562 																									"postgres`ExecAssignProjectionInfo": {
  12563 																										"svUnique": 0,
  12564 																										"svTotal": 1,
  12565 																										"svChildren": {
  12566 																											"postgres`ExecBuildProjectionInfo": {
  12567 																												"svUnique": 1,
  12568 																												"svTotal": 1,
  12569 																												"svChildren": {}
  12570 																											}
  12571 																										}
  12572 																									},
  12573 																									"postgres`ExecAssignResultTypeFromTL": {
  12574 																										"svUnique": 0,
  12575 																										"svTotal": 2,
  12576 																										"svChildren": {
  12577 																											"postgres`ExecTypeFromTLInternal": {
  12578 																												"svUnique": 0,
  12579 																												"svTotal": 2,
  12580 																												"svChildren": {
  12581 																													"postgres`TupleDescInitEntry": {
  12582 																														"svUnique": 0,
  12583 																														"svTotal": 2,
  12584 																														"svChildren": {
  12585 																															"postgres`SearchCatCache": {
  12586 																																"svUnique": 0,
  12587 																																"svTotal": 2,
  12588 																																"svChildren": {
  12589 																																	"postgres`CatalogCacheComputeHashValue": {
  12590 																																		"svUnique": 1,
  12591 																																		"svTotal": 2,
  12592 																																		"svChildren": {
  12593 																																			"postgres`DirectFunctionCall1Coll": {
  12594 																																				"svUnique": 1,
  12595 																																				"svTotal": 1,
  12596 																																				"svChildren": {}
  12597 																																			}
  12598 																																		}
  12599 																																	}
  12600 																																}
  12601 																															}
  12602 																														}
  12603 																													}
  12604 																												}
  12605 																											}
  12606 																										}
  12607 																									},
  12608 																									"postgres`ExecInitNode": {
  12609 																										"svUnique": 0,
  12610 																										"svTotal": 9,
  12611 																										"svChildren": {
  12612 																											"postgres`ExecInitIndexScan": {
  12613 																												"svUnique": 0,
  12614 																												"svTotal": 8,
  12615 																												"svChildren": {
  12616 																													"postgres`ExecAssignResultTypeFromTL": {
  12617 																														"svUnique": 0,
  12618 																														"svTotal": 3,
  12619 																														"svChildren": {
  12620 																															"postgres`ExecTypeFromTLInternal": {
  12621 																																"svUnique": 0,
  12622 																																"svTotal": 2,
  12623 																																"svChildren": {
  12624 																																	"postgres`TupleDescInitEntry": {
  12625 																																		"svUnique": 0,
  12626 																																		"svTotal": 2,
  12627 																																		"svChildren": {
  12628 																																			"postgres`SearchCatCache": {
  12629 																																				"svUnique": 1,
  12630 																																				"svTotal": 2,
  12631 																																				"svChildren": {
  12632 																																					"postgres`ResourceOwnerEnlargeCatCacheRefs": {
  12633 																																						"svUnique": 1,
  12634 																																						"svTotal": 1,
  12635 																																						"svChildren": {}
  12636 																																					}
  12637 																																				}
  12638 																																			}
  12639 																																		}
  12640 																																	}
  12641 																																}
  12642 																															},
  12643 																															"postgres`exprCollation": {
  12644 																																"svUnique": 1,
  12645 																																"svTotal": 1,
  12646 																																"svChildren": {}
  12647 																															}
  12648 																														}
  12649 																													},
  12650 																													"postgres`ExecInitExpr": {
  12651 																														"svUnique": 0,
  12652 																														"svTotal": 3,
  12653 																														"svChildren": {
  12654 																															"postgres`ExecInitExpr": {
  12655 																																"svUnique": 1,
  12656 																																"svTotal": 3,
  12657 																																"svChildren": {
  12658 																																	"postgres`MemoryContextAllocZeroAligned": {
  12659 																																		"svUnique": 1,
  12660 																																		"svTotal": 1,
  12661 																																		"svChildren": {}
  12662 																																	},
  12663 																																	"postgres`lappend": {
  12664 																																		"svUnique": 1,
  12665 																																		"svTotal": 1,
  12666 																																		"svChildren": {}
  12667 																																	}
  12668 																																}
  12669 																															}
  12670 																														}
  12671 																													},
  12672 																													"postgres`heap_open": {
  12673 																														"svUnique": 0,
  12674 																														"svTotal": 1,
  12675 																														"svChildren": {
  12676 																															"postgres`relation_open": {
  12677 																																"svUnique": 0,
  12678 																																"svTotal": 1,
  12679 																																"svChildren": {
  12680 																																	"postgres`RelationIdGetRelation": {
  12681 																																		"svUnique": 0,
  12682 																																		"svTotal": 1,
  12683 																																		"svChildren": {
  12684 																																			"postgres`hash_search_with_hash_value": {
  12685 																																				"svUnique": 1,
  12686 																																				"svTotal": 1,
  12687 																																				"svChildren": {}
  12688 																																			}
  12689 																																		}
  12690 																																	}
  12691 																																}
  12692 																															}
  12693 																														}
  12694 																													},
  12695 																													"postgres`pfree": {
  12696 																														"svUnique": 1,
  12697 																														"svTotal": 1,
  12698 																														"svChildren": {}
  12699 																													}
  12700 																												}
  12701 																											},
  12702 																											"postgres`ExecInitSeqScan": {
  12703 																												"svUnique": 0,
  12704 																												"svTotal": 1,
  12705 																												"svChildren": {
  12706 																													"postgres`ExecAssignResultTypeFromTL": {
  12707 																														"svUnique": 0,
  12708 																														"svTotal": 1,
  12709 																														"svChildren": {
  12710 																															"postgres`ExecTypeFromTLInternal": {
  12711 																																"svUnique": 0,
  12712 																																"svTotal": 1,
  12713 																																"svChildren": {
  12714 																																	"postgres`ReleaseCatCache": {
  12715 																																		"svUnique": 1,
  12716 																																		"svTotal": 1,
  12717 																																		"svChildren": {}
  12718 																																	}
  12719 																																}
  12720 																															}
  12721 																														}
  12722 																													}
  12723 																												}
  12724 																											}
  12725 																										}
  12726 																									},
  12727 																									"postgres`initialize_peragg.isra.0": {
  12728 																										"svUnique": 0,
  12729 																										"svTotal": 1,
  12730 																										"svChildren": {
  12731 																											"libc.so.1`memcpy": {
  12732 																												"svUnique": 1,
  12733 																												"svTotal": 1,
  12734 																												"svChildren": {}
  12735 																											}
  12736 																										}
  12737 																									}
  12738 																								}
  12739 																							}
  12740 																						}
  12741 																					}
  12742 																				}
  12743 																			}
  12744 																		}
  12745 																	},
  12746 																	"postgres`RegisterSnapshotOnOwner": {
  12747 																		"svUnique": 0,
  12748 																		"svTotal": 1,
  12749 																		"svChildren": {
  12750 																			"postgres`ResourceOwnerEnlargeSnapshots": {
  12751 																				"svUnique": 1,
  12752 																				"svTotal": 1,
  12753 																				"svChildren": {}
  12754 																			}
  12755 																		}
  12756 																	}
  12757 																}
  12758 															}
  12759 														}
  12760 													},
  12761 													"postgres`ReadyForQuery": {
  12762 														"svUnique": 0,
  12763 														"svTotal": 1,
  12764 														"svChildren": {
  12765 															"postgres`pq_flush": {
  12766 																"svUnique": 0,
  12767 																"svTotal": 1,
  12768 																"svChildren": {
  12769 																	"postgres`internal_flush": {
  12770 																		"svUnique": 0,
  12771 																		"svTotal": 1,
  12772 																		"svChildren": {
  12773 																			"libsocket.so.1`send": {
  12774 																				"svUnique": 0,
  12775 																				"svTotal": 1,
  12776 																				"svChildren": {
  12777 																					"libc.so.1`__so_send": {
  12778 																						"svUnique": 1,
  12779 																						"svTotal": 1,
  12780 																						"svChildren": {}
  12781 																					}
  12782 																				}
  12783 																			}
  12784 																		}
  12785 																	}
  12786 																}
  12787 															}
  12788 														}
  12789 													},
  12790 													"postgres`SendRowDescriptionMessage": {
  12791 														"svUnique": 0,
  12792 														"svTotal": 6,
  12793 														"svChildren": {
  12794 															"postgres`appendBinaryStringInfo": {
  12795 																"svUnique": 1,
  12796 																"svTotal": 1,
  12797 																"svChildren": {}
  12798 															},
  12799 															"postgres`getBaseTypeAndTypmod": {
  12800 																"svUnique": 0,
  12801 																"svTotal": 1,
  12802 																"svChildren": {
  12803 																	"postgres`SearchCatCache": {
  12804 																		"svUnique": 0,
  12805 																		"svTotal": 1,
  12806 																		"svChildren": {
  12807 																			"postgres`CatalogCacheComputeHashValue": {
  12808 																				"svUnique": 1,
  12809 																				"svTotal": 1,
  12810 																				"svChildren": {}
  12811 																			}
  12812 																		}
  12813 																	}
  12814 																}
  12815 															},
  12816 															"postgres`pq_sendint": {
  12817 																"svUnique": 1,
  12818 																"svTotal": 4,
  12819 																"svChildren": {
  12820 																	"postgres`appendBinaryStringInfo": {
  12821 																		"svUnique": 2,
  12822 																		"svTotal": 3,
  12823 																		"svChildren": {
  12824 																			"postgres`enlargeStringInfo": {
  12825 																				"svUnique": 1,
  12826 																				"svTotal": 1,
  12827 																				"svChildren": {}
  12828 																			}
  12829 																		}
  12830 																	}
  12831 																}
  12832 															}
  12833 														}
  12834 													},
  12835 													"postgres`SetCurrentStatementStartTimestamp": {
  12836 														"svUnique": 0,
  12837 														"svTotal": 2,
  12838 														"svChildren": {
  12839 															"libc.so.1`gettimeofday": {
  12840 																"svUnique": 1,
  12841 																"svTotal": 1,
  12842 																"svChildren": {}
  12843 															},
  12844 															"postgres`0x4f6038": {
  12845 																"svUnique": 1,
  12846 																"svTotal": 1,
  12847 																"svChildren": {}
  12848 															}
  12849 														}
  12850 													},
  12851 													"postgres`WalSenderMain": {
  12852 														"svUnique": 0,
  12853 														"svTotal": 1,
  12854 														"svChildren": {
  12855 															"postgres`WaitLatchOrSocket": {
  12856 																"svUnique": 0,
  12857 																"svTotal": 1,
  12858 																"svChildren": {
  12859 																	"libc.so.1`__read": {
  12860 																		"svUnique": 1,
  12861 																		"svTotal": 1,
  12862 																		"svChildren": {}
  12863 																	}
  12864 																}
  12865 															}
  12866 														}
  12867 													},
  12868 													"postgres`check_variable_parameters": {
  12869 														"svUnique": 1,
  12870 														"svTotal": 1,
  12871 														"svChildren": {}
  12872 													},
  12873 													"postgres`finish_xact_command": {
  12874 														"svUnique": 0,
  12875 														"svTotal": 11,
  12876 														"svChildren": {
  12877 															"postgres`CommitTransactionCommand": {
  12878 																"svUnique": 0,
  12879 																"svTotal": 11,
  12880 																"svChildren": {
  12881 																	"postgres`AtEOXact_PgStat": {
  12882 																		"svUnique": 1,
  12883 																		"svTotal": 1,
  12884 																		"svChildren": {}
  12885 																	},
  12886 																	"postgres`CommitTransaction": {
  12887 																		"svUnique": 0,
  12888 																		"svTotal": 10,
  12889 																		"svChildren": {
  12890 																			"postgres`AtCommit_Memory": {
  12891 																				"svUnique": 0,
  12892 																				"svTotal": 1,
  12893 																				"svChildren": {
  12894 																					"postgres`MemoryContextDelete": {
  12895 																						"svUnique": 0,
  12896 																						"svTotal": 1,
  12897 																						"svChildren": {
  12898 																							"postgres`AllocSetDelete": {
  12899 																								"svUnique": 0,
  12900 																								"svTotal": 1,
  12901 																								"svChildren": {
  12902 																									"libumem.so.1`free": {
  12903 																										"svUnique": 0,
  12904 																										"svTotal": 1,
  12905 																										"svChildren": {
  12906 																											"libumem.so.1`process_free": {
  12907 																												"svUnique": 0,
  12908 																												"svTotal": 1,
  12909 																												"svChildren": {
  12910 																													"libc.so.1`___errno": {
  12911 																														"svUnique": 1,
  12912 																														"svTotal": 1,
  12913 																														"svChildren": {}
  12914 																													}
  12915 																												}
  12916 																											}
  12917 																										}
  12918 																									}
  12919 																								}
  12920 																							}
  12921 																						}
  12922 																					}
  12923 																				}
  12924 																			},
  12925 																			"postgres`PreCommit_Portals": {
  12926 																				"svUnique": 0,
  12927 																				"svTotal": 6,
  12928 																				"svChildren": {
  12929 																					"postgres`PortalDrop": {
  12930 																						"svUnique": 0,
  12931 																						"svTotal": 6,
  12932 																						"svChildren": {
  12933 																							"postgres`ExecutorFinish": {
  12934 																								"svUnique": 1,
  12935 																								"svTotal": 1,
  12936 																								"svChildren": {}
  12937 																							},
  12938 																							"postgres`PortalCleanup": {
  12939 																								"svUnique": 0,
  12940 																								"svTotal": 5,
  12941 																								"svChildren": {
  12942 																									"postgres`standard_ExecutorEnd": {
  12943 																										"svUnique": 0,
  12944 																										"svTotal": 5,
  12945 																										"svChildren": {
  12946 																											"postgres`ExecEndBitmapHeapScan": {
  12947 																												"svUnique": 0,
  12948 																												"svTotal": 1,
  12949 																												"svChildren": {
  12950 																													"postgres`ExecEndBitmapIndexScan": {
  12951 																														"svUnique": 0,
  12952 																														"svTotal": 1,
  12953 																														"svChildren": {
  12954 																															"postgres`index_endscan": {
  12955 																																"svUnique": 0,
  12956 																																"svTotal": 1,
  12957 																																"svChildren": {
  12958 																																	"postgres`FunctionCall1Coll": {
  12959 																																		"svUnique": 0,
  12960 																																		"svTotal": 1,
  12961 																																		"svChildren": {
  12962 																																			"postgres`btendscan": {
  12963 																																				"svUnique": 0,
  12964 																																				"svTotal": 1,
  12965 																																				"svChildren": {
  12966 																																					"libumem.so.1`free": {
  12967 																																						"svUnique": 0,
  12968 																																						"svTotal": 1,
  12969 																																						"svChildren": {
  12970 																																							"libumem.so.1`process_free": {
  12971 																																								"svUnique": 0,
  12972 																																								"svTotal": 1,
  12973 																																								"svChildren": {
  12974 																																									"libumem.so.1`umem_free": {
  12975 																																										"svUnique": 0,
  12976 																																										"svTotal": 1,
  12977 																																										"svChildren": {
  12978 																																											"libumem.so.1`umem_cache_free": {
  12979 																																												"svUnique": 1,
  12980 																																												"svTotal": 1,
  12981 																																												"svChildren": {}
  12982 																																											}
  12983 																																										}
  12984 																																									}
  12985 																																								}
  12986 																																							}
  12987 																																						}
  12988 																																					}
  12989 																																				}
  12990 																																			}
  12991 																																		}
  12992 																																	}
  12993 																																}
  12994 																															}
  12995 																														}
  12996 																													}
  12997 																												}
  12998 																											},
  12999 																											"postgres`ExecEndIndexScan": {
  13000 																												"svUnique": 0,
  13001 																												"svTotal": 3,
  13002 																												"svChildren": {
  13003 																													"postgres`index_endscan": {
  13004 																														"svUnique": 0,
  13005 																														"svTotal": 3,
  13006 																														"svChildren": {
  13007 																															"postgres`FunctionCall1Coll": {
  13008 																																"svUnique": 0,
  13009 																																"svTotal": 3,
  13010 																																"svChildren": {
  13011 																																	"postgres`btendscan": {
  13012 																																		"svUnique": 0,
  13013 																																		"svTotal": 2,
  13014 																																		"svChildren": {
  13015 																																			"libumem.so.1`free": {
  13016 																																				"svUnique": 0,
  13017 																																				"svTotal": 2,
  13018 																																				"svChildren": {
  13019 																																					"libumem.so.1`process_free": {
  13020 																																						"svUnique": 0,
  13021 																																						"svTotal": 2,
  13022 																																						"svChildren": {
  13023 																																							"libumem.so.1`umem_free": {
  13024 																																								"svUnique": 0,
  13025 																																								"svTotal": 2,
  13026 																																								"svChildren": {
  13027 																																									"libc.so.1`mutex_lock": {
  13028 																																										"svUnique": 1,
  13029 																																										"svTotal": 1,
  13030 																																										"svChildren": {}
  13031 																																									},
  13032 																																									"libumem.so.1`umem_cpu_reload": {
  13033 																																										"svUnique": 1,
  13034 																																										"svTotal": 1,
  13035 																																										"svChildren": {}
  13036 																																									}
  13037 																																								}
  13038 																																							}
  13039 																																						}
  13040 																																					}
  13041 																																				}
  13042 																																			}
  13043 																																		}
  13044 																																	},
  13045 																																	"postgres`pfree": {
  13046 																																		"svUnique": 1,
  13047 																																		"svTotal": 1,
  13048 																																		"svChildren": {}
  13049 																																	}
  13050 																																}
  13051 																															}
  13052 																														}
  13053 																													}
  13054 																												}
  13055 																											},
  13056 																											"postgres`ExecResetTupleTable": {
  13057 																												"svUnique": 0,
  13058 																												"svTotal": 1,
  13059 																												"svChildren": {
  13060 																													"postgres`ExecClearTuple": {
  13061 																														"svUnique": 1,
  13062 																														"svTotal": 1,
  13063 																														"svChildren": {}
  13064 																													}
  13065 																												}
  13066 																											}
  13067 																										}
  13068 																									}
  13069 																								}
  13070 																							}
  13071 																						}
  13072 																					}
  13073 																				}
  13074 																			},
  13075 																			"postgres`RecordTransactionCommit": {
  13076 																				"svUnique": 0,
  13077 																				"svTotal": 2,
  13078 																				"svChildren": {
  13079 																					"postgres`SyncRepWaitForLSN": {
  13080 																						"svUnique": 0,
  13081 																						"svTotal": 1,
  13082 																						"svChildren": {
  13083 																							"postgres`WaitLatchOrSocket": {
  13084 																								"svUnique": 0,
  13085 																								"svTotal": 1,
  13086 																								"svChildren": {
  13087 																									"libc.so.1`poll": {
  13088 																										"svUnique": 0,
  13089 																										"svTotal": 1,
  13090 																										"svChildren": {
  13091 																											"libc.so.1`__pollsys": {
  13092 																												"svUnique": 1,
  13093 																												"svTotal": 1,
  13094 																												"svChildren": {}
  13095 																											}
  13096 																										}
  13097 																									}
  13098 																								}
  13099 																							}
  13100 																						}
  13101 																					},
  13102 																					"postgres`XLogFlush": {
  13103 																						"svUnique": 0,
  13104 																						"svTotal": 1,
  13105 																						"svChildren": {
  13106 																							"postgres`XLogWrite": {
  13107 																								"svUnique": 0,
  13108 																								"svTotal": 1,
  13109 																								"svChildren": {
  13110 																									"libc.so.1`__write": {
  13111 																										"svUnique": 1,
  13112 																										"svTotal": 1,
  13113 																										"svChildren": {}
  13114 																									}
  13115 																								}
  13116 																							}
  13117 																						}
  13118 																					}
  13119 																				}
  13120 																			},
  13121 																			"postgres`ResourceOwnerRelease": {
  13122 																				"svUnique": 0,
  13123 																				"svTotal": 1,
  13124 																				"svChildren": {
  13125 																					"postgres`ResourceOwnerReleaseInternal": {
  13126 																						"svUnique": 0,
  13127 																						"svTotal": 1,
  13128 																						"svChildren": {
  13129 																							"postgres`ProcReleaseLocks": {
  13130 																								"svUnique": 0,
  13131 																								"svTotal": 1,
  13132 																								"svChildren": {
  13133 																									"postgres`LockReleaseAll": {
  13134 																										"svUnique": 0,
  13135 																										"svTotal": 1,
  13136 																										"svChildren": {
  13137 																											"postgres`RemoveLocalLock": {
  13138 																												"svUnique": 1,
  13139 																												"svTotal": 1,
  13140 																												"svChildren": {}
  13141 																											}
  13142 																										}
  13143 																									}
  13144 																								}
  13145 																							}
  13146 																						}
  13147 																					}
  13148 																				}
  13149 																			}
  13150 																		}
  13151 																	}
  13152 																}
  13153 															}
  13154 														}
  13155 													},
  13156 													"postgres`fmgr_info_cxt_security": {
  13157 														"svUnique": 1,
  13158 														"svTotal": 1,
  13159 														"svChildren": {}
  13160 													},
  13161 													"postgres`getTypeInputInfo": {
  13162 														"svUnique": 0,
  13163 														"svTotal": 1,
  13164 														"svChildren": {
  13165 															"postgres`SearchCatCache": {
  13166 																"svUnique": 1,
  13167 																"svTotal": 1,
  13168 																"svChildren": {}
  13169 															}
  13170 														}
  13171 													},
  13172 													"postgres`parse_analyze_varparams": {
  13173 														"svUnique": 0,
  13174 														"svTotal": 24,
  13175 														"svChildren": {
  13176 															"postgres`query_tree_walker": {
  13177 																"svUnique": 0,
  13178 																"svTotal": 2,
  13179 																"svChildren": {
  13180 																	"postgres`expression_tree_walker": {
  13181 																		"svUnique": 0,
  13182 																		"svTotal": 2,
  13183 																		"svChildren": {
  13184 																			"postgres`check_parameter_resolution_walker": {
  13185 																				"svUnique": 1,
  13186 																				"svTotal": 1,
  13187 																				"svChildren": {}
  13188 																			},
  13189 																			"postgres`expression_tree_walker": {
  13190 																				"svUnique": 1,
  13191 																				"svTotal": 1,
  13192 																				"svChildren": {}
  13193 																			}
  13194 																		}
  13195 																	}
  13196 																}
  13197 															},
  13198 															"postgres`transformStmt": {
  13199 																"svUnique": 0,
  13200 																"svTotal": 22,
  13201 																"svChildren": {
  13202 																	"postgres`coerce_to_specific_type": {
  13203 																		"svUnique": 1,
  13204 																		"svTotal": 1,
  13205 																		"svChildren": {}
  13206 																	},
  13207 																	"postgres`query_tree_walker": {
  13208 																		"svUnique": 0,
  13209 																		"svTotal": 1,
  13210 																		"svChildren": {
  13211 																			"postgres`assign_query_collations_walker": {
  13212 																				"svUnique": 0,
  13213 																				"svTotal": 1,
  13214 																				"svChildren": {
  13215 																					"postgres`assign_expr_collations": {
  13216 																						"svUnique": 0,
  13217 																						"svTotal": 1,
  13218 																						"svChildren": {
  13219 																							"postgres`assign_collations_walker": {
  13220 																								"svUnique": 0,
  13221 																								"svTotal": 1,
  13222 																								"svChildren": {
  13223 																									"postgres`expression_tree_walker": {
  13224 																										"svUnique": 0,
  13225 																										"svTotal": 1,
  13226 																										"svChildren": {
  13227 																											"postgres`assign_collations_walker": {
  13228 																												"svUnique": 0,
  13229 																												"svTotal": 1,
  13230 																												"svChildren": {
  13231 																													"postgres`expression_tree_walker": {
  13232 																														"svUnique": 0,
  13233 																														"svTotal": 1,
  13234 																														"svChildren": {
  13235 																															"postgres`expression_tree_walker": {
  13236 																																"svUnique": 0,
  13237 																																"svTotal": 1,
  13238 																																"svChildren": {
  13239 																																	"postgres`assign_collations_walker": {
  13240 																																		"svUnique": 0,
  13241 																																		"svTotal": 1,
  13242 																																		"svChildren": {
  13243 																																			"postgres`expression_tree_walker": {
  13244 																																				"svUnique": 0,
  13245 																																				"svTotal": 1,
  13246 																																				"svChildren": {
  13247 																																					"postgres`expression_tree_walker": {
  13248 																																						"svUnique": 0,
  13249 																																						"svTotal": 1,
  13250 																																						"svChildren": {
  13251 																																							"postgres`assign_collations_walker": {
  13252 																																								"svUnique": 0,
  13253 																																								"svTotal": 1,
  13254 																																								"svChildren": {
  13255 																																									"postgres`expression_tree_walker": {
  13256 																																										"svUnique": 0,
  13257 																																										"svTotal": 1,
  13258 																																										"svChildren": {
  13259 																																											"postgres`expression_tree_walker": {
  13260 																																												"svUnique": 0,
  13261 																																												"svTotal": 1,
  13262 																																												"svChildren": {
  13263 																																													"postgres`assign_collations_walker": {
  13264 																																														"svUnique": 0,
  13265 																																														"svTotal": 1,
  13266 																																														"svChildren": {
  13267 																																															"postgres`get_typcollation": {
  13268 																																																"svUnique": 0,
  13269 																																																"svTotal": 1,
  13270 																																																"svChildren": {
  13271 																																																	"postgres`SearchCatCache": {
  13272 																																																		"svUnique": 0,
  13273 																																																		"svTotal": 1,
  13274 																																																		"svChildren": {
  13275 																																																			"postgres`DirectFunctionCall1Coll": {
  13276 																																																				"svUnique": 1,
  13277 																																																				"svTotal": 1,
  13278 																																																				"svChildren": {}
  13279 																																																			}
  13280 																																																		}
  13281 																																																	}
  13282 																																																}
  13283 																																															}
  13284 																																														}
  13285 																																													}
  13286 																																												}
  13287 																																											}
  13288 																																										}
  13289 																																									}
  13290 																																								}
  13291 																																							}
  13292 																																						}
  13293 																																					}
  13294 																																				}
  13295 																																			}
  13296 																																		}
  13297 																																	}
  13298 																																}
  13299 																															}
  13300 																														}
  13301 																													}
  13302 																												}
  13303 																											}
  13304 																										}
  13305 																									}
  13306 																								}
  13307 																							}
  13308 																						}
  13309 																					}
  13310 																				}
  13311 																			}
  13312 																		}
  13313 																	},
  13314 																	"postgres`transformFromClause": {
  13315 																		"svUnique": 0,
  13316 																		"svTotal": 8,
  13317 																		"svChildren": {
  13318 																			"postgres`transformFromClauseItem": {
  13319 																				"svUnique": 0,
  13320 																				"svTotal": 8,
  13321 																				"svChildren": {
  13322 																					"postgres`addRangeTableEntry": {
  13323 																						"svUnique": 0,
  13324 																						"svTotal": 7,
  13325 																						"svChildren": {
  13326 																							"postgres`MemoryContextStrdup": {
  13327 																								"svUnique": 1,
  13328 																								"svTotal": 1,
  13329 																								"svChildren": {}
  13330 																							},
  13331 																							"postgres`buildRelationAliases.isra.0": {
  13332 																								"svUnique": 0,
  13333 																								"svTotal": 2,
  13334 																								"svChildren": {
  13335 																									"postgres`MemoryContextAllocZeroAligned": {
  13336 																										"svUnique": 1,
  13337 																										"svTotal": 1,
  13338 																										"svChildren": {}
  13339 																									},
  13340 																									"postgres`makeString": {
  13341 																										"svUnique": 0,
  13342 																										"svTotal": 1,
  13343 																										"svChildren": {
  13344 																											"postgres`MemoryContextAllocZeroAligned": {
  13345 																												"svUnique": 1,
  13346 																												"svTotal": 1,
  13347 																												"svChildren": {}
  13348 																											}
  13349 																										}
  13350 																									}
  13351 																								}
  13352 																							},
  13353 																							"postgres`parserOpenTable": {
  13354 																								"svUnique": 0,
  13355 																								"svTotal": 4,
  13356 																								"svChildren": {
  13357 																									"postgres`heap_openrv_extended": {
  13358 																										"svUnique": 0,
  13359 																										"svTotal": 4,
  13360 																										"svChildren": {
  13361 																											"postgres`RangeVarGetRelidExtended": {
  13362 																												"svUnique": 1,
  13363 																												"svTotal": 1,
  13364 																												"svChildren": {}
  13365 																											},
  13366 																											"postgres`relation_open": {
  13367 																												"svUnique": 0,
  13368 																												"svTotal": 2,
  13369 																												"svChildren": {
  13370 																													"postgres`RelationIdGetRelation": {
  13371 																														"svUnique": 0,
  13372 																														"svTotal": 2,
  13373 																														"svChildren": {
  13374 																															"postgres`ResourceOwnerEnlargeRelationRefs": {
  13375 																																"svUnique": 1,
  13376 																																"svTotal": 1,
  13377 																																"svChildren": {}
  13378 																															},
  13379 																															"postgres`hash_search_with_hash_value": {
  13380 																																"svUnique": 1,
  13381 																																"svTotal": 1,
  13382 																																"svChildren": {}
  13383 																															}
  13384 																														}
  13385 																													}
  13386 																												}
  13387 																											},
  13388 																											"postgres`relation_openrv_extended": {
  13389 																												"svUnique": 0,
  13390 																												"svTotal": 1,
  13391 																												"svChildren": {
  13392 																													"postgres`RangeVarGetRelidExtended": {
  13393 																														"svUnique": 0,
  13394 																														"svTotal": 1,
  13395 																														"svChildren": {
  13396 																															"postgres`LockRelationOid": {
  13397 																																"svUnique": 0,
  13398 																																"svTotal": 1,
  13399 																																"svChildren": {
  13400 																																	"postgres`LockAcquireExtended": {
  13401 																																		"svUnique": 0,
  13402 																																		"svTotal": 1,
  13403 																																		"svChildren": {
  13404 																																			"postgres`hash_search_with_hash_value": {
  13405 																																				"svUnique": 1,
  13406 																																				"svTotal": 1,
  13407 																																				"svChildren": {}
  13408 																																			}
  13409 																																		}
  13410 																																	}
  13411 																																}
  13412 																															}
  13413 																														}
  13414 																													}
  13415 																												}
  13416 																											}
  13417 																										}
  13418 																									}
  13419 																								}
  13420 																							}
  13421 																						}
  13422 																					},
  13423 																					"postgres`isLockedRefname": {
  13424 																						"svUnique": 1,
  13425 																						"svTotal": 1,
  13426 																						"svChildren": {}
  13427 																					}
  13428 																				}
  13429 																			}
  13430 																		}
  13431 																	},
  13432 																	"postgres`transformLimitClause": {
  13433 																		"svUnique": 0,
  13434 																		"svTotal": 1,
  13435 																		"svChildren": {
  13436 																			"postgres`coerce_to_specific_type": {
  13437 																				"svUnique": 0,
  13438 																				"svTotal": 1,
  13439 																				"svChildren": {
  13440 																					"postgres`coerce_to_target_type": {
  13441 																						"svUnique": 0,
  13442 																						"svTotal": 1,
  13443 																						"svChildren": {
  13444 																							"postgres`can_coerce_type": {
  13445 																								"svUnique": 0,
  13446 																								"svTotal": 1,
  13447 																								"svChildren": {
  13448 																									"postgres`find_coercion_pathway": {
  13449 																										"svUnique": 0,
  13450 																										"svTotal": 1,
  13451 																										"svChildren": {
  13452 																											"postgres`getBaseType": {
  13453 																												"svUnique": 0,
  13454 																												"svTotal": 1,
  13455 																												"svChildren": {
  13456 																													"postgres`getBaseTypeAndTypmod": {
  13457 																														"svUnique": 1,
  13458 																														"svTotal": 1,
  13459 																														"svChildren": {}
  13460 																													}
  13461 																												}
  13462 																											}
  13463 																										}
  13464 																									}
  13465 																								}
  13466 																							}
  13467 																						}
  13468 																					}
  13469 																				}
  13470 																			}
  13471 																		}
  13472 																	},
  13473 																	"postgres`transformTargetList": {
  13474 																		"svUnique": 0,
  13475 																		"svTotal": 6,
  13476 																		"svChildren": {
  13477 																			"postgres`ExpandColumnRefStar": {
  13478 																				"svUnique": 0,
  13479 																				"svTotal": 3,
  13480 																				"svChildren": {
  13481 																					"postgres`expandRelAttrs": {
  13482 																						"svUnique": 0,
  13483 																						"svTotal": 3,
  13484 																						"svChildren": {
  13485 																							"postgres`expandRTE": {
  13486 																								"svUnique": 1,
  13487 																								"svTotal": 2,
  13488 																								"svChildren": {
  13489 																									"postgres`expandTupleDesc.isra.1": {
  13490 																										"svUnique": 1,
  13491 																										"svTotal": 1,
  13492 																										"svChildren": {}
  13493 																									}
  13494 																								}
  13495 																							},
  13496 																							"postgres`markRTEForSelectPriv": {
  13497 																								"svUnique": 1,
  13498 																								"svTotal": 1,
  13499 																								"svChildren": {}
  13500 																							}
  13501 																						}
  13502 																					}
  13503 																				}
  13504 																			},
  13505 																			"postgres`transformTargetEntry": {
  13506 																				"svUnique": 0,
  13507 																				"svTotal": 3,
  13508 																				"svChildren": {
  13509 																					"postgres`transformExpr": {
  13510 																						"svUnique": 0,
  13511 																						"svTotal": 3,
  13512 																						"svChildren": {
  13513 																							"postgres`ParseFuncOrColumn": {
  13514 																								"svUnique": 0,
  13515 																								"svTotal": 3,
  13516 																								"svChildren": {
  13517 																									"postgres`func_get_detail": {
  13518 																										"svUnique": 0,
  13519 																										"svTotal": 3,
  13520 																										"svChildren": {
  13521 																											"postgres`FuncnameGetCandidates": {
  13522 																												"svUnique": 2,
  13523 																												"svTotal": 3,
  13524 																												"svChildren": {
  13525 																													"postgres`SearchCatCacheList": {
  13526 																														"svUnique": 0,
  13527 																														"svTotal": 1,
  13528 																														"svChildren": {
  13529 																															"postgres`ResourceOwnerEnlargeCatCacheListRefs": {
  13530 																																"svUnique": 0,
  13531 																																"svTotal": 1,
  13532 																																"svChildren": {
  13533 																																	"postgres`AllocSetAlloc": {
  13534 																																		"svUnique": 1,
  13535 																																		"svTotal": 1,
  13536 																																		"svChildren": {}
  13537 																																	}
  13538 																																}
  13539 																															}
  13540 																														}
  13541 																													}
  13542 																												}
  13543 																											}
  13544 																										}
  13545 																									}
  13546 																								}
  13547 																							}
  13548 																						}
  13549 																					}
  13550 																				}
  13551 																			}
  13552 																		}
  13553 																	},
  13554 																	"postgres`transformWhereClause": {
  13555 																		"svUnique": 0,
  13556 																		"svTotal": 5,
  13557 																		"svChildren": {
  13558 																			"postgres`transformExpr": {
  13559 																				"svUnique": 0,
  13560 																				"svTotal": 5,
  13561 																				"svChildren": {
  13562 																					"postgres`make_op": {
  13563 																						"svUnique": 0,
  13564 																						"svTotal": 3,
  13565 																						"svChildren": {
  13566 																							"postgres`make_fn_arguments": {
  13567 																								"svUnique": 0,
  13568 																								"svTotal": 1,
  13569 																								"svChildren": {
  13570 																									"postgres`coerce_type": {
  13571 																										"svUnique": 1,
  13572 																										"svTotal": 1,
  13573 																										"svChildren": {}
  13574 																									}
  13575 																								}
  13576 																							},
  13577 																							"postgres`new_list": {
  13578 																								"svUnique": 1,
  13579 																								"svTotal": 1,
  13580 																								"svChildren": {}
  13581 																							},
  13582 																							"postgres`oper": {
  13583 																								"svUnique": 0,
  13584 																								"svTotal": 1,
  13585 																								"svChildren": {
  13586 																									"postgres`find_oper_cache_entry": {
  13587 																										"svUnique": 0,
  13588 																										"svTotal": 1,
  13589 																										"svChildren": {
  13590 																											"postgres`hash_search": {
  13591 																												"svUnique": 1,
  13592 																												"svTotal": 1,
  13593 																												"svChildren": {}
  13594 																											}
  13595 																										}
  13596 																									}
  13597 																								}
  13598 																							}
  13599 																						}
  13600 																					},
  13601 																					"postgres`transformExpr": {
  13602 																						"svUnique": 0,
  13603 																						"svTotal": 2,
  13604 																						"svChildren": {
  13605 																							"postgres`transformExpr": {
  13606 																								"svUnique": 0,
  13607 																								"svTotal": 2,
  13608 																								"svChildren": {
  13609 																									"postgres`transformExpr": {
  13610 																										"svUnique": 0,
  13611 																										"svTotal": 2,
  13612 																										"svChildren": {
  13613 																											"postgres`transformExpr": {
  13614 																												"svUnique": 0,
  13615 																												"svTotal": 2,
  13616 																												"svChildren": {
  13617 																													"postgres`make_op": {
  13618 																														"svUnique": 0,
  13619 																														"svTotal": 2,
  13620 																														"svChildren": {
  13621 																															"postgres`oper": {
  13622 																																"svUnique": 0,
  13623 																																"svTotal": 2,
  13624 																																"svChildren": {
  13625 																																	"libc.so.1`strlcpy": {
  13626 																																		"svUnique": 1,
  13627 																																		"svTotal": 1,
  13628 																																		"svChildren": {}
  13629 																																	},
  13630 																																	"postgres`find_oper_cache_entry": {
  13631 																																		"svUnique": 0,
  13632 																																		"svTotal": 1,
  13633 																																		"svChildren": {
  13634 																																			"postgres`hash_search_with_hash_value": {
  13635 																																				"svUnique": 1,
  13636 																																				"svTotal": 1,
  13637 																																				"svChildren": {}
  13638 																																			}
  13639 																																		}
  13640 																																	}
  13641 																																}
  13642 																															}
  13643 																														}
  13644 																													}
  13645 																												}
  13646 																											}
  13647 																										}
  13648 																									}
  13649 																								}
  13650 																							}
  13651 																						}
  13652 																					}
  13653 																				}
  13654 																			}
  13655 																		}
  13656 																	}
  13657 																}
  13658 															}
  13659 														}
  13660 													},
  13661 													"postgres`pg_any_to_server": {
  13662 														"svUnique": 0,
  13663 														"svTotal": 1,
  13664 														"svChildren": {
  13665 															"postgres`pg_verify_mbstr": {
  13666 																"svUnique": 0,
  13667 																"svTotal": 1,
  13668 																"svChildren": {
  13669 																	"postgres`pg_verify_mbstr_len": {
  13670 																		"svUnique": 1,
  13671 																		"svTotal": 1,
  13672 																		"svChildren": {}
  13673 																	}
  13674 																}
  13675 															}
  13676 														}
  13677 													},
  13678 													"postgres`pg_parse_query": {
  13679 														"svUnique": 0,
  13680 														"svTotal": 18,
  13681 														"svChildren": {
  13682 															"postgres`raw_parser": {
  13683 																"svUnique": 0,
  13684 																"svTotal": 18,
  13685 																"svChildren": {
  13686 																	"postgres`base_yyparse": {
  13687 																		"svUnique": 9,
  13688 																		"svTotal": 17,
  13689 																		"svChildren": {
  13690 																			"postgres`base_yylex": {
  13691 																				"svUnique": 0,
  13692 																				"svTotal": 5,
  13693 																				"svChildren": {
  13694 																					"postgres`ScanKeywordLookup": {
  13695 																						"svUnique": 1,
  13696 																						"svTotal": 1,
  13697 																						"svChildren": {}
  13698 																					},
  13699 																					"postgres`core_yylex": {
  13700 																						"svUnique": 1,
  13701 																						"svTotal": 4,
  13702 																						"svChildren": {
  13703 																							"libc.so.1`strcmp": {
  13704 																								"svUnique": 1,
  13705 																								"svTotal": 1,
  13706 																								"svChildren": {}
  13707 																							},
  13708 																							"postgres`ScanKeywordLookup": {
  13709 																								"svUnique": 2,
  13710 																								"svTotal": 2,
  13711 																								"svChildren": {}
  13712 																							}
  13713 																						}
  13714 																					}
  13715 																				}
  13716 																			},
  13717 																			"postgres`lcons": {
  13718 																				"svUnique": 1,
  13719 																				"svTotal": 1,
  13720 																				"svChildren": {}
  13721 																			},
  13722 																			"postgres`makeColumnRef": {
  13723 																				"svUnique": 1,
  13724 																				"svTotal": 2,
  13725 																				"svChildren": {
  13726 																					"postgres`lcons": {
  13727 																						"svUnique": 0,
  13728 																						"svTotal": 1,
  13729 																						"svChildren": {
  13730 																							"postgres`new_list": {
  13731 																								"svUnique": 0,
  13732 																								"svTotal": 1,
  13733 																								"svChildren": {
  13734 																									"postgres`AllocSetAlloc": {
  13735 																										"svUnique": 1,
  13736 																										"svTotal": 1,
  13737 																										"svChildren": {}
  13738 																									}
  13739 																								}
  13740 																							}
  13741 																						}
  13742 																					}
  13743 																				}
  13744 																			}
  13745 																		}
  13746 																	},
  13747 																	"postgres`makeString": {
  13748 																		"svUnique": 1,
  13749 																		"svTotal": 1,
  13750 																		"svChildren": {}
  13751 																	}
  13752 																}
  13753 															}
  13754 														}
  13755 													},
  13756 													"postgres`pgstat_report_stat": {
  13757 														"svUnique": 0,
  13758 														"svTotal": 5,
  13759 														"svChildren": {
  13760 															"libc.so.1`gettimeofday": {
  13761 																"svUnique": 1,
  13762 																"svTotal": 1,
  13763 																"svChildren": {}
  13764 															},
  13765 															"postgres`pgstat_send": {
  13766 																"svUnique": 0,
  13767 																"svTotal": 4,
  13768 																"svChildren": {
  13769 																	"libsocket.so.1`send": {
  13770 																		"svUnique": 0,
  13771 																		"svTotal": 4,
  13772 																		"svChildren": {
  13773 																			"libc.so.1`__so_send": {
  13774 																				"svUnique": 4,
  13775 																				"svTotal": 4,
  13776 																				"svChildren": {}
  13777 																			}
  13778 																		}
  13779 																	}
  13780 																}
  13781 															}
  13782 														}
  13783 													},
  13784 													"postgres`pq_flush": {
  13785 														"svUnique": 0,
  13786 														"svTotal": 9,
  13787 														"svChildren": {
  13788 															"postgres`internal_flush": {
  13789 																"svUnique": 0,
  13790 																"svTotal": 9,
  13791 																"svChildren": {
  13792 																	"libc.so.1`_so_send": {
  13793 																		"svUnique": 1,
  13794 																		"svTotal": 1,
  13795 																		"svChildren": {}
  13796 																	},
  13797 																	"libsocket.so.1`send": {
  13798 																		"svUnique": 0,
  13799 																		"svTotal": 8,
  13800 																		"svChildren": {
  13801 																			"libc.so.1`__so_send": {
  13802 																				"svUnique": 8,
  13803 																				"svTotal": 8,
  13804 																				"svChildren": {}
  13805 																			}
  13806 																		}
  13807 																	}
  13808 																}
  13809 															}
  13810 														}
  13811 													},
  13812 													"postgres`pq_getbyte": {
  13813 														"svUnique": 0,
  13814 														"svTotal": 10,
  13815 														"svChildren": {
  13816 															"postgres`pq_recvbuf": {
  13817 																"svUnique": 0,
  13818 																"svTotal": 10,
  13819 																"svChildren": {
  13820 																	"postgres`client_read_ended": {
  13821 																		"svUnique": 1,
  13822 																		"svTotal": 1,
  13823 																		"svChildren": {}
  13824 																	},
  13825 																	"postgres`secure_read": {
  13826 																		"svUnique": 0,
  13827 																		"svTotal": 9,
  13828 																		"svChildren": {
  13829 																			"libsocket.so.1`recv": {
  13830 																				"svUnique": 0,
  13831 																				"svTotal": 9,
  13832 																				"svChildren": {
  13833 																					"libc.so.1`__so_recv": {
  13834 																						"svUnique": 9,
  13835 																						"svTotal": 9,
  13836 																						"svChildren": {}
  13837 																					}
  13838 																				}
  13839 																			}
  13840 																		}
  13841 																	}
  13842 																}
  13843 															}
  13844 														}
  13845 													},
  13846 													"postgres`pq_getmessage": {
  13847 														"svUnique": 0,
  13848 														"svTotal": 1,
  13849 														"svChildren": {
  13850 															"libc.so.1`sigsetjmp": {
  13851 																"svUnique": 1,
  13852 																"svTotal": 1,
  13853 																"svChildren": {}
  13854 															}
  13855 														}
  13856 													},
  13857 													"postgres`pq_getmsgbytes": {
  13858 														"svUnique": 1,
  13859 														"svTotal": 1,
  13860 														"svChildren": {}
  13861 													},
  13862 													"postgres`resetStringInfo": {
  13863 														"svUnique": 1,
  13864 														"svTotal": 1,
  13865 														"svChildren": {}
  13866 													}
  13867 												}
  13868 											},
  13869 											"postgres`SetCurrentStatementStartTimestamp": {
  13870 												"svUnique": 1,
  13871 												"svTotal": 1,
  13872 												"svChildren": {}
  13873 											},
  13874 											"postgres`pq_getmsgint": {
  13875 												"svUnique": 1,
  13876 												"svTotal": 1,
  13877 												"svChildren": {}
  13878 											}
  13879 										}
  13880 									},
  13881 									"postgres`StartChildProcess": {
  13882 										"svUnique": 0,
  13883 										"svTotal": 1,
  13884 										"svChildren": {
  13885 											"postgres`AuxiliaryProcessMain": {
  13886 												"svUnique": 0,
  13887 												"svTotal": 1,
  13888 												"svChildren": {
  13889 													"postgres`StartupProcessMain": {
  13890 														"svUnique": 0,
  13891 														"svTotal": 1,
  13892 														"svChildren": {
  13893 															"postgres`StartupXLOG": {
  13894 																"svUnique": 0,
  13895 																"svTotal": 1,
  13896 																"svChildren": {
  13897 																	"postgres`HandleStartupProcInterrupts": {
  13898 																		"svUnique": 0,
  13899 																		"svTotal": 1,
  13900 																		"svChildren": {
  13901 																			"postgres`PostmasterIsAlive": {
  13902 																				"svUnique": 0,
  13903 																				"svTotal": 1,
  13904 																				"svChildren": {
  13905 																					"libc.so.1`__read": {
  13906 																						"svUnique": 1,
  13907 																						"svTotal": 1,
  13908 																						"svChildren": {}
  13909 																					}
  13910 																				}
  13911 																			}
  13912 																		}
  13913 																	}
  13914 																}
  13915 															}
  13916 														}
  13917 													}
  13918 												}
  13919 											}
  13920 										}
  13921 									}
  13922 								}
  13923 							}
  13924 						}
  13925 					}
  13926 				}
  13927 			}
  13928 		}
  13929 	}
  13930 };
  13931 
  13932         /* BEGIN contents of icicle.js */
  13933         /*
  13934  * icicle.js: implements icicle visualization for stacks
  13935  */
  13936 
  13937 /* Configuration */
  13938 var svSvgWidth = null;		/* image width (null to auto-compute) */
  13939 var svSvgHeight = null;		/* image height (null to auto-compute) */
  13940 var svAxisLabelWidth = 45;	/* width of axis labels */
  13941 var svChartWidth = null;	/* width of chart part of image */
  13942 var svChartHeight = null;	/* height of chart part of image */
  13943 var svGrowDown = false;		/* if true, stacks are drawn growing down */
  13944 var svTransitionTime = 2000;	/* time for transition */
  13945 var svCornerPixels = 3;		/* radius of rounded corners */
  13946 var svTextPaddingLeft = 5;	/* padding-left on rectangle labels */
  13947 var svTextPaddingRight = 10;	/* pading-right on rectangle labels */
  13948 var svTextPaddingTop = '1.2em';	/* padding-top on rectangle labels */
  13949 var svColorMode = 'mono';	/* coloring mode */
  13950 var svDetailMode = 'popout';	/* detail display mode ("zoom" or "popout") */
  13951 
  13952 /* Program state */
  13953 var svRawData;			/* raw data, filled in by wrapper code */
  13954 var svTooltipBox;		/* tooltip box (D3 selection) */
  13955 var svPopoutBox;		/* popout detail box (D3 selection) */
  13956 var svFlameGraph;		/* main flame graph object */
  13957 var svContext = {
  13958 	'detailClose': svDetailClose,
  13959 	'detailOpen': svDetailOpen,
  13960 	'mouseout': function () {
  13961 		svTooltipBox.text('').style('opacity', null);
  13962 	},
  13963 	'mouseover': function (d, det) {
  13964 		var text, left, top;
  13965 
  13966 		/* escape the key */
  13967 		svTooltipBox.text(det['label']);
  13968 		text = svTooltipBox.html();
  13969 
  13970 		text = '<strong>' + text + '</strong><br />';
  13971 		text += '<strong>Top of stack</strong>: ' +
  13972 		    det['pctUnique'] + '% of all samples ' +
  13973 		    '(' + det['nunique'] + ' of ' +
  13974 		    det['nallsamples'] + ' total samples)<br />';
  13975 		text += '<strong>On stack</strong>: ' +
  13976 		    det['pctSamples'] + '% of all samples ' +
  13977 		    '(' + det['nsamples'] + ' of ' +
  13978 		    det['nallsamples'] + ' total samples)';
  13979 
  13980 		left = det['x'] + 'px';
  13981 		top = (det['y'] -
  13982 		    parseInt(svTooltipBox.style('height'), 10)) + 'px';
  13983 		svTooltipBox.html(text);
  13984 		svTooltipBox.style('left', left);
  13985 		svTooltipBox.style('top', top);
  13986 		svTooltipBox.style('opacity', 0.9);
  13987 	}
  13988 };
  13989 
  13990 window.onload = svInit;
  13991 
  13992 function svInit()
  13993 {
  13994 	svTooltipBox = d3.select('#svTooltip');
  13995 	svPopoutBox = d3.select('#svPopout');
  13996 
  13997 	svFillData(svRawData);
  13998 	svFlameGraph = new FlameGraph(d3.select('#chart'), svRawData,
  13999 	    svSvgWidth, svSvgHeight, svContext, {
  14000 	        'coloring': svColorMode,
  14001 		'growDown': svGrowDown,
  14002 		'axisLabels': true
  14003 	    });
  14004 }
  14005 
  14006 function svFillData(tree)
  14007 {
  14008 	var key, rem;
  14009 
  14010 	for (key in tree) {
  14011 		svFillData(tree[key].svChildren);
  14012 
  14013 		rem = tree[key].svUnique;
  14014 		if (rem > 0) {
  14015 			tree[key].svChildren[''] = {
  14016 			    'svSynthetic': true,
  14017 			    'svUnique': rem,
  14018 			    'svTotal': rem,
  14019 			    'svChildren': {}
  14020 			};
  14021 		}
  14022 	}
  14023 }
  14024 
  14025 function svColorMono(d, det)
  14026 {
  14027 	if (d.data.value.svSynthetic)
  14028 		return ('#ffffff');
  14029 
  14030 	var s = 20, splus = 80;
  14031 	var sratio;
  14032 
  14033 	/*
  14034 	 * This version colors the block based on its percentage contribution of
  14035 	 * overall time.
  14036 	 */
  14037 	sratio = d.data.value.svUnique / det['maxUnique'];
  14038 
  14039 	var rh = 24;
  14040 	var rs = (s + sratio * splus) / 100;
  14041 	var rv = 0.95;
  14042 	var rgb = convertHsvToRgb(rh, rs, rv);
  14043 	return ('rgb(' + rgb.join(',') + ')');
  14044 }
  14045 
  14046 function svDetailClose()
  14047 {
  14048 	if (svDetailMode != 'zoom') {
  14049 		svPopoutBox.html('');
  14050 		svPopoutBox.style('opacity', null);
  14051 		svPopoutBox.style('z-index', null);
  14052 	} else {
  14053 		svFlameGraph.zoomSet({ 'x': 0, 'dx': 1, 'y': 0 });
  14054 	}
  14055 }
  14056 
  14057 /*
  14058  * Input: "d", a D3 node from the layout, typically resembling:
  14059  *     parent: ...,  // parent D3 node
  14060  *     data: {
  14061  *         key: ..., // function name
  14062  *         value: {
  14063  *             svTotal: ...,
  14064  *             svUnique: ...,
  14065  *             svChildren: ...
  14066  *         }
  14067  *     }
  14068  * Output: an object describing the raw flame graph data, matching the form:
  14069  *     "": {
  14070  *         svTotal: ...
  14071  *         svUnique: ...
  14072  *         svChildren: {
  14073  *             key1: { // function name
  14074  *                 svTotal: ...
  14075  *                 svUnique: ...
  14076  *                 svChildren: ...
  14077  *             },
  14078  *             ...
  14079  *         }
  14080  *     }
  14081  */
  14082 function svMakeSubgraphData(d)
  14083 {
  14084 	/*
  14085 	 * First, construct everything from the current node to all of its
  14086 	 * leafs.
  14087 	 */
  14088 	var tree, oldtree;
  14089 
  14090 	tree = {};
  14091 	tree[d.data.key] = d.data.value;
  14092 
  14093 	while (d.parent !== undefined) {
  14094 		oldtree = tree;
  14095 		tree = {};
  14096 		tree[d.parent.data.key] = {
  14097 		    'svUnique': d.parent.data.value.svUnique,
  14098 		    'svTotal': d.parent.data.value.svTotal,
  14099 		    'svChildren': oldtree
  14100 		};
  14101 		d = d.parent;
  14102 	}
  14103 
  14104 	return (tree);
  14105 }
  14106 
  14107 function svDetailOpen(d)
  14108 {
  14109 	if (svDetailMode != 'zoom') {
  14110 		svPopoutBox.html('');
  14111 		/* jsl:ignore */
  14112 		new FlameGraph(svPopoutBox, svMakeSubgraphData(d), null, null,
  14113 		    svContext, {
  14114 			'coloring': svColorMode,
  14115 			'growDown': svGrowDown
  14116 		    });
  14117 		/* jsl:end */
  14118 		svPopoutBox.style('z-index', 1);
  14119 		svPopoutBox.style('opacity', 1);
  14120 	} else {
  14121 		svFlameGraph.zoomSet(d);
  14122 	}
  14123 }
  14124 
  14125 /*
  14126  * Build a flame graph rooted at the given "node" (a D3 selection) with the
  14127  * given "rawdata" tree.  The graph will have size defined by "pwidth" and
  14128  * "pheight".  "context" is used for notifications about UI actions.
  14129  */
  14130 function FlameGraph(node, rawdata, pwidth, pheight, context, options)
  14131 {
  14132 	var axiswidth, chartheight, rect, scale, nodeid, axis, data;
  14133 	var fg = this;
  14134 
  14135 	this.fg_context = context;
  14136 	this.fg_maxdepth = 0;
  14137 	this.fg_maxunique = 0;
  14138 	this.fg_depthsamples = [];
  14139 	this.computeDepth(rawdata, 0);
  14140 
  14141 	if (options.axisLabels)
  14142 		axiswidth = this.fg_axiswidth = svAxisLabelWidth;
  14143 	else
  14144 		axiswidth = this.fg_axiswidth = 0;
  14145 
  14146 	this.fg_svgwidth = pwidth !== null ? pwidth :
  14147 	    parseInt(node.style('width'), 10);
  14148 	this.fg_svgheight = pheight !== null ? pheight : 25 * this.fg_maxdepth;
  14149 	this.fg_chartwidth = this.fg_svgwidth - axiswidth;
  14150 	chartheight = this.fg_chartheight = this.fg_svgheight - axiswidth;
  14151 
  14152 	this.fg_xscale =
  14153 	    d3.scale.linear().range([0, this.fg_chartwidth]);
  14154 	this.fg_yscale =
  14155 	    d3.scale.linear().range([0, this.fg_chartheight]);
  14156 
  14157 	this.fg_svg = node.append('svg:svg');
  14158 	this.fg_svg.attr('width', this.fg_svgwidth);
  14159 	this.fg_svg.attr('height', this.fg_svgheight);
  14160 
  14161 	/* Create a background rectangle that resets the view when clicked. */
  14162 	rect = this.fg_svg.append('svg:rect');
  14163 	rect.attr('class', 'svBackground');
  14164 	rect.attr('width', this.fg_svgwidth);
  14165 	rect.attr('height', this.fg_svgheight);
  14166 	rect.attr('fill', '#ffffff');
  14167 	rect.on('click', this.detailClose.bind(this));
  14168 
  14169 	/* Configure the partition layout. */
  14170 	this.fg_part = d3.layout.partition();
  14171 	this.fg_part.children(
  14172 	    function (d) { return (d3.entries(d.value.svChildren)); });
  14173 	this.fg_part.value(function (d) { return (d.value.svTotal); });
  14174 	this.fg_part.sort(function (d1, d2) {
  14175 		return (d1.data.key.localeCompare(d2.data.key));
  14176 	});
  14177 
  14178 	/* Configure the color function. */
  14179 	if (options.coloring == 'random') {
  14180 		scale = d3.scale.category20c();
  14181 		this.fg_color = function (d) { return (scale(d.data.key)); };
  14182 	} else {
  14183 		this.fg_color = function (d) {
  14184 		    return (svColorMono(d, { 'maxUnique': fg.fg_maxunique }));
  14185 		};
  14186 	}
  14187 
  14188 	/* Configure the actual D3 components. */
  14189 	nodeid = this.fg_nodeid = function (d) {
  14190 		return (encodeURIComponent([
  14191 		    d.data.key,
  14192 		    fg.fg_yscale(d.y),
  14193 		    fg.fg_xscale(d.x) ].join('@')));
  14194 	};
  14195 	this.fg_rectwidth = function (d) { return (fg.fg_xscale(d.dx)); };
  14196 	this.fg_height = function (d) { return (fg.fg_yscale(d.dy)); };
  14197 	this.fg_textwidth = function (d) {
  14198 		return (Math.max(0, fg.fg_rectwidth(d) - svTextPaddingRight));
  14199 	};
  14200 	this.fg_x = function (d) {
  14201 	    return (fg.fg_xscale(d.x) + fg.fg_axiswidth); };
  14202 
  14203 	if (options.growDown)
  14204 		this.fg_y =
  14205 		    function (d) { return (fg.fg_yscale(d.y)); };
  14206 	else
  14207 		this.fg_y = function (d) {
  14208 		    return (chartheight - fg.fg_yscale(d.y) -
  14209 		        2 * fg.fg_height(d));
  14210 		};
  14211 
  14212 	data = this.fg_part(d3.entries(rawdata)[0]);
  14213 	this.fg_rects = this.fg_svg.selectAll('rect').data(data).
  14214 	    enter().append('svg:rect').
  14215 	    attr('class', function (d) {
  14216 		return (d.data.value.svSynthetic ?  'svBoxSynthetic' : 'svBox');
  14217 	    }).
  14218 	    attr('x', this.fg_x).
  14219 	    attr('y', this.fg_y).
  14220 	    attr('rx', svCornerPixels).
  14221 	    attr('ry', svCornerPixels).
  14222 	    attr('height', this.fg_height).
  14223 	    attr('width', this.fg_rectwidth).
  14224 	    attr('fill', this.fg_color).
  14225 	    on('click', this.detailOpen.bind(this)).
  14226 	    on('mouseover', this.mouseover.bind(this)).
  14227 	    on('mouseout', this.mouseout.bind(this));
  14228 	this.fg_clips = this.fg_svg.selectAll('clipPath').data(data).
  14229 	    enter().append('svg:clipPath').
  14230 	    attr('id', nodeid).
  14231 	    append('svg:rect').
  14232 	    attr('x', this.fg_x).
  14233 	    attr('y', this.fg_y).
  14234 	    attr('width', this.fg_textwidth).
  14235 	    attr('height', this.fg_height);
  14236 	this.fg_text = this.fg_svg.selectAll('text').data(data).
  14237 	    enter().append('text').
  14238 	    attr('class', 'svBoxLabel').
  14239 	    attr('x', this.fg_x).
  14240 	    attr('y', this.fg_y).
  14241 	    attr('dx', svTextPaddingLeft).
  14242 	    attr('dy', svTextPaddingTop).
  14243 	    attr('clip-path', function (d) {
  14244 		return ('url("#' + nodeid(d) + '")');
  14245 	    }).
  14246 	    on('click', this.detailOpen.bind(this)).
  14247 	    on('mouseover', this.mouseover.bind(this)).
  14248 	    on('mouseout', this.mouseout.bind(this)).
  14249 	    text(function (d) { return (d.data.key); });
  14250 
  14251 	if (options.axisLabels) {
  14252 		axis = this.fg_svg.append('text');
  14253 		axis.attr('class', 'svYAxisLabel');
  14254 		axis.attr('x', -this.fg_svgheight);
  14255 		axis.attr('dx', '8em');
  14256 		axis.attr('y', '30px');
  14257 		axis.attr('transform', 'rotate(-90)');
  14258 		axis.text('Call Stacks');
  14259 
  14260 		axis = this.fg_svg.append('text');
  14261 		axis.attr('class', 'svYAxisLabel');
  14262 		axis.attr('x', '30px');
  14263 		axis.attr('dx', '8em');
  14264 		/*
  14265 		 * Magic constants here:
  14266 		 *   30 is the height of the label (since we're specifying the
  14267 		 *   top coordinate), and 25 is the height of each block
  14268 		 *   (because there's an invisible row we want to cover up).
  14269 		 */
  14270 		axis.attr('y', this.fg_svgheight - 30 - 25);
  14271 		axis.attr('width', this.fg_svgwidth - 30);
  14272 		axis.text('Percentage of Samples');
  14273 	}
  14274 }
  14275 
  14276 FlameGraph.prototype.computeDepth = function (tree, depth)
  14277 {
  14278 	var key, rem;
  14279 
  14280 	if (depth > this.fg_maxdepth)
  14281 		this.fg_maxdepth = depth;
  14282 
  14283 	if (depth >= this.fg_depthsamples.length)
  14284 		this.fg_depthsamples[depth] = 0;
  14285 
  14286 	for (key in tree) {
  14287 		if (tree[key].svUnique > this.fg_maxunique)
  14288 			this.fg_maxunique = tree[key].svUnique;
  14289 		this.fg_depthsamples[depth] += tree[key].svTotal;
  14290 		this.computeDepth(tree[key].svChildren, depth + 1);
  14291 
  14292 		rem = tree[key].svUnique;
  14293 		if (rem > 0 && tree[key].svChildren[''] === undefined) {
  14294 			tree[key].svChildren[''] = {
  14295 			    'svSynthetic': true,
  14296 			    'svUnique': rem,
  14297 			    'svTotal': rem,
  14298 			    'svChildren': {}
  14299 			};
  14300 		}
  14301 	}
  14302 };
  14303 
  14304 FlameGraph.prototype.detailClose = function ()
  14305 {
  14306 	if (this.fg_context !== null)
  14307 		this.fg_context.detailClose();
  14308 };
  14309 
  14310 FlameGraph.prototype.detailOpen = function (d)
  14311 {
  14312 	if (!d.data.value.svSynthetic && this.fg_context !== null)
  14313 		this.fg_context.detailOpen(d);
  14314 };
  14315 
  14316 FlameGraph.prototype.mouseover = function (d)
  14317 {
  14318 	if (d.data.value.svSynthetic || this.fg_context === null)
  14319 		return;
  14320 
  14321 	var nsamples, nunique;
  14322 	var pctSamples, pctUnique;
  14323 	var detail;
  14324 	var fg = this;
  14325 
  14326 	nsamples = d.data.value.svTotal;
  14327 	pctSamples = (100 * nsamples / this.fg_depthsamples[0]).toFixed(1);
  14328 
  14329 	nunique = d.data.value.svUnique;
  14330 	pctUnique = (100 * nunique / this.fg_depthsamples[0]).toFixed(1);
  14331 
  14332 	detail = {
  14333 	    'label': d.data.key,
  14334 	    'nsamples': d.data.value.svTotal,
  14335 	    'nunique': d.data.value.svUnique,
  14336 	    'nallsamples': this.fg_depthsamples[0],
  14337 	    'pctSamples': pctSamples,
  14338 	    'pctUnique': pctUnique,
  14339 	    'x': d3.event.pageX,
  14340 	    'y': d3.event.pageY
  14341 	};
  14342 
  14343 	this.fg_hoverto = setTimeout(function () {
  14344 		fg.fg_hoverto = null;
  14345 		fg.fg_context.mouseover(d, detail);
  14346 	}, 500);
  14347 };
  14348 
  14349 FlameGraph.prototype.mouseout = function (d)
  14350 {
  14351 	if (this.fg_hoverto)
  14352 		clearTimeout(this.fg_hoverto);
  14353 	if (this.fg_context !== null)
  14354 		this.fg_context.mouseout(d);
  14355 };
  14356 
  14357 FlameGraph.prototype.zoomSet = function (cd)
  14358 {
  14359 	var fg = this;
  14360 
  14361 	this.fg_xscale.domain([cd.x, cd.x + cd.dx]);
  14362 	this.fg_rectwidth = function (d) {
  14363 		return (fg.fg_xscale(d.x + d.dx) - fg.fg_xscale(d.x));
  14364 	};
  14365 	this.fg_textwidth = function (d) {
  14366 		return (Math.max(0,
  14367 		    fg.fg_xscale(d.x + d.dx) -
  14368 		    fg.fg_xscale(d.x) - svTextPaddingRight));
  14369 	};
  14370 	this.fg_rects.transition().duration(svTransitionTime).
  14371 	    attr('x', this.fg_x).
  14372 	    attr('width', this.fg_rectwidth);
  14373 	this.fg_clips.transition().duration(svTransitionTime).
  14374 	    attr('x', this.fg_x).
  14375 	    attr('width', this.fg_textwidth);
  14376 	this.fg_text.transition().duration(svTransitionTime).
  14377 	    attr('x', this.fg_x);
  14378 };
  14379 
  14380 
  14381 /*
  14382  * This function is copied directly from lib/color.js.  It would be better if we
  14383  * could share code between Node.js and web JS.
  14384  */
  14385 function convertHsvToRgb(h, s, v)
  14386 {
  14387 	var r, g, b;
  14388 	var i;
  14389 	var f, p, q, t;
  14390 
  14391 	if (s === 0) {
  14392 		/*
  14393 		 * A saturation of 0.0 is achromatic (grey).
  14394 		 */
  14395 		r = g = b = v;
  14396 
  14397 		return ([ Math.round(r * 255), Math.round(g * 255),
  14398 		    Math.round(b * 255) ]);
  14399 	}
  14400 
  14401 	h /= 60; // sector 0 to 5
  14402 
  14403 	i = Math.floor(h);
  14404 	f = h - i; // fractional part of h
  14405 	p = v * (1 - s);
  14406 	q = v * (1 - s * f);
  14407 	t = v * (1 - s * (1 - f));
  14408 
  14409 	switch (i) {
  14410 		case 0:
  14411 			r = v;
  14412 			g = t;
  14413 			b = p;
  14414 			break;
  14415 
  14416 		case 1:
  14417 			r = q;
  14418 			g = v;
  14419 			b = p;
  14420 			break;
  14421 
  14422 		case 2:
  14423 			r = p;
  14424 			g = v;
  14425 			b = t;
  14426 			break;
  14427 
  14428 		case 3:
  14429 			r = p;
  14430 			g = q;
  14431 			b = v;
  14432 			break;
  14433 
  14434 		case 4:
  14435 			r = t;
  14436 			g = p;
  14437 			b = v;
  14438 			break;
  14439 
  14440 		default: // case 5:
  14441 			r = v;
  14442 			g = p;
  14443 			b = q;
  14444 			break;
  14445 	}
  14446 
  14447 	return ([ Math.round(r * 255),
  14448 	    Math.round(g * 255), Math.round(b * 255) ]);
  14449 }
  14450 
  14451         /* END contents of icicle.js */
  14452     </script>
  14453   </head>
  14454   <body>
  14455     <h1>Flame graph</h1>
  14456     <div id="info">
  14457       Hover over a block for summary information.  Click a block for details.
  14458       <a href="javascript:svDetailClose()">Reset view</a>
  14459       <div class="svTooltip" id="svTooltip"></div>
  14460     </div>
  14461     <div id="chart">
  14462       <div style="position: relative">
  14463       <div class="svPopout" id="svPopout">
  14464       </div>
  14465       </div>
  14466     </div>
  14467   </body>
  14468 </html>