Source file src/cmd/vendor/github.com/google/pprof/third_party/d3/d3.go

     1  // D3.js is a JavaScript library for manipulating documents based on data.
     2  // https://github.com/d3/d3
     3  // See LICENSE file for license details
     4  // Custom build for pprof (https://github.com/spiermar/d3-pprof)
     5  
     6  package d3
     7  
     8  // JSSource returns the d3.js file
     9  const JSSource = `
    10  (function (global, factory) {
    11  	typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    12  	typeof define === 'function' && define.amd ? define(['exports'], factory) :
    13  	(factory((global.d3 = {})));
    14  }(this, (function (exports) { 'use strict';
    15  
    16  var xhtml = "http://www.w3.org/1999/xhtml";
    17  
    18  var namespaces = {
    19    svg: "http://www.w3.org/2000/svg",
    20    xhtml: xhtml,
    21    xlink: "http://www.w3.org/1999/xlink",
    22    xml: "http://www.w3.org/XML/1998/namespace",
    23    xmlns: "http://www.w3.org/2000/xmlns/"
    24  };
    25  
    26  var namespace = function(name) {
    27    var prefix = name += "", i = prefix.indexOf(":");
    28    if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1);
    29    return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name;
    30  };
    31  
    32  function creatorInherit(name) {
    33    return function() {
    34      var document = this.ownerDocument,
    35          uri = this.namespaceURI;
    36      return uri === xhtml && document.documentElement.namespaceURI === xhtml
    37          ? document.createElement(name)
    38          : document.createElementNS(uri, name);
    39    };
    40  }
    41  
    42  function creatorFixed(fullname) {
    43    return function() {
    44      return this.ownerDocument.createElementNS(fullname.space, fullname.local);
    45    };
    46  }
    47  
    48  var creator = function(name) {
    49    var fullname = namespace(name);
    50    return (fullname.local
    51        ? creatorFixed
    52        : creatorInherit)(fullname);
    53  };
    54  
    55  var matcher = function(selector) {
    56    return function() {
    57      return this.matches(selector);
    58    };
    59  };
    60  
    61  if (typeof document !== "undefined") {
    62    var element = document.documentElement;
    63    if (!element.matches) {
    64      var vendorMatches = element.webkitMatchesSelector
    65          || element.msMatchesSelector
    66          || element.mozMatchesSelector
    67          || element.oMatchesSelector;
    68      matcher = function(selector) {
    69        return function() {
    70          return vendorMatches.call(this, selector);
    71        };
    72      };
    73    }
    74  }
    75  
    76  var matcher$1 = matcher;
    77  
    78  var filterEvents = {};
    79  
    80  exports.event = null;
    81  
    82  if (typeof document !== "undefined") {
    83    var element$1 = document.documentElement;
    84    if (!("onmouseenter" in element$1)) {
    85      filterEvents = {mouseenter: "mouseover", mouseleave: "mouseout"};
    86    }
    87  }
    88  
    89  function filterContextListener(listener, index, group) {
    90    listener = contextListener(listener, index, group);
    91    return function(event) {
    92      var related = event.relatedTarget;
    93      if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
    94        listener.call(this, event);
    95      }
    96    };
    97  }
    98  
    99  function contextListener(listener, index, group) {
   100    return function(event1) {
   101      var event0 = exports.event; // Events can be reentrant (e.g., focus).
   102      exports.event = event1;
   103      try {
   104        listener.call(this, this.__data__, index, group);
   105      } finally {
   106        exports.event = event0;
   107      }
   108    };
   109  }
   110  
   111  function parseTypenames(typenames) {
   112    return typenames.trim().split(/^|\s+/).map(function(t) {
   113      var name = "", i = t.indexOf(".");
   114      if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
   115      return {type: t, name: name};
   116    });
   117  }
   118  
   119  function onRemove(typename) {
   120    return function() {
   121      var on = this.__on;
   122      if (!on) return;
   123      for (var j = 0, i = -1, m = on.length, o; j < m; ++j) {
   124        if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) {
   125          this.removeEventListener(o.type, o.listener, o.capture);
   126        } else {
   127          on[++i] = o;
   128        }
   129      }
   130      if (++i) on.length = i;
   131      else delete this.__on;
   132    };
   133  }
   134  
   135  function onAdd(typename, value, capture) {
   136    var wrap = filterEvents.hasOwnProperty(typename.type) ? filterContextListener : contextListener;
   137    return function(d, i, group) {
   138      var on = this.__on, o, listener = wrap(value, i, group);
   139      if (on) for (var j = 0, m = on.length; j < m; ++j) {
   140        if ((o = on[j]).type === typename.type && o.name === typename.name) {
   141          this.removeEventListener(o.type, o.listener, o.capture);
   142          this.addEventListener(o.type, o.listener = listener, o.capture = capture);
   143          o.value = value;
   144          return;
   145        }
   146      }
   147      this.addEventListener(typename.type, listener, capture);
   148      o = {type: typename.type, name: typename.name, value: value, listener: listener, capture: capture};
   149      if (!on) this.__on = [o];
   150      else on.push(o);
   151    };
   152  }
   153  
   154  var selection_on = function(typename, value, capture) {
   155    var typenames = parseTypenames(typename + ""), i, n = typenames.length, t;
   156  
   157    if (arguments.length < 2) {
   158      var on = this.node().__on;
   159      if (on) for (var j = 0, m = on.length, o; j < m; ++j) {
   160        for (i = 0, o = on[j]; i < n; ++i) {
   161          if ((t = typenames[i]).type === o.type && t.name === o.name) {
   162            return o.value;
   163          }
   164        }
   165      }
   166      return;
   167    }
   168  
   169    on = value ? onAdd : onRemove;
   170    if (capture == null) capture = false;
   171    for (i = 0; i < n; ++i) this.each(on(typenames[i], value, capture));
   172    return this;
   173  };
   174  
   175  function none() {}
   176  
   177  var selector = function(selector) {
   178    return selector == null ? none : function() {
   179      return this.querySelector(selector);
   180    };
   181  };
   182  
   183  var selection_select = function(select) {
   184    if (typeof select !== "function") select = selector(select);
   185  
   186    for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
   187      for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
   188        if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
   189          if ("__data__" in node) subnode.__data__ = node.__data__;
   190          subgroup[i] = subnode;
   191        }
   192      }
   193    }
   194  
   195    return new Selection(subgroups, this._parents);
   196  };
   197  
   198  function empty() {
   199    return [];
   200  }
   201  
   202  var selectorAll = function(selector) {
   203    return selector == null ? empty : function() {
   204      return this.querySelectorAll(selector);
   205    };
   206  };
   207  
   208  var selection_selectAll = function(select) {
   209    if (typeof select !== "function") select = selectorAll(select);
   210  
   211    for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
   212      for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
   213        if (node = group[i]) {
   214          subgroups.push(select.call(node, node.__data__, i, group));
   215          parents.push(node);
   216        }
   217      }
   218    }
   219  
   220    return new Selection(subgroups, parents);
   221  };
   222  
   223  var selection_filter = function(match) {
   224    if (typeof match !== "function") match = matcher$1(match);
   225  
   226    for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
   227      for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
   228        if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
   229          subgroup.push(node);
   230        }
   231      }
   232    }
   233  
   234    return new Selection(subgroups, this._parents);
   235  };
   236  
   237  var sparse = function(update) {
   238    return new Array(update.length);
   239  };
   240  
   241  var selection_enter = function() {
   242    return new Selection(this._enter || this._groups.map(sparse), this._parents);
   243  };
   244  
   245  function EnterNode(parent, datum) {
   246    this.ownerDocument = parent.ownerDocument;
   247    this.namespaceURI = parent.namespaceURI;
   248    this._next = null;
   249    this._parent = parent;
   250    this.__data__ = datum;
   251  }
   252  
   253  EnterNode.prototype = {
   254    constructor: EnterNode,
   255    appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
   256    insertBefore: function(child, next) { return this._parent.insertBefore(child, next); },
   257    querySelector: function(selector) { return this._parent.querySelector(selector); },
   258    querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); }
   259  };
   260  
   261  var constant = function(x) {
   262    return function() {
   263      return x;
   264    };
   265  };
   266  
   267  var keyPrefix = "$"; // Protect against keys like “__proto__”.
   268  
   269  function bindIndex(parent, group, enter, update, exit, data) {
   270    var i = 0,
   271        node,
   272        groupLength = group.length,
   273        dataLength = data.length;
   274  
   275    // Put any non-null nodes that fit into update.
   276    // Put any null nodes into enter.
   277    // Put any remaining data into enter.
   278    for (; i < dataLength; ++i) {
   279      if (node = group[i]) {
   280        node.__data__ = data[i];
   281        update[i] = node;
   282      } else {
   283        enter[i] = new EnterNode(parent, data[i]);
   284      }
   285    }
   286  
   287    // Put any non-null nodes that don’t fit into exit.
   288    for (; i < groupLength; ++i) {
   289      if (node = group[i]) {
   290        exit[i] = node;
   291      }
   292    }
   293  }
   294  
   295  function bindKey(parent, group, enter, update, exit, data, key) {
   296    var i,
   297        node,
   298        nodeByKeyValue = {},
   299        groupLength = group.length,
   300        dataLength = data.length,
   301        keyValues = new Array(groupLength),
   302        keyValue;
   303  
   304    // Compute the key for each node.
   305    // If multiple nodes have the same key, the duplicates are added to exit.
   306    for (i = 0; i < groupLength; ++i) {
   307      if (node = group[i]) {
   308        keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, group);
   309        if (keyValue in nodeByKeyValue) {
   310          exit[i] = node;
   311        } else {
   312          nodeByKeyValue[keyValue] = node;
   313        }
   314      }
   315    }
   316  
   317    // Compute the key for each datum.
   318    // If there a node associated with this key, join and add it to update.
   319    // If there is not (or the key is a duplicate), add it to enter.
   320    for (i = 0; i < dataLength; ++i) {
   321      keyValue = keyPrefix + key.call(parent, data[i], i, data);
   322      if (node = nodeByKeyValue[keyValue]) {
   323        update[i] = node;
   324        node.__data__ = data[i];
   325        nodeByKeyValue[keyValue] = null;
   326      } else {
   327        enter[i] = new EnterNode(parent, data[i]);
   328      }
   329    }
   330  
   331    // Add any remaining nodes that were not bound to data to exit.
   332    for (i = 0; i < groupLength; ++i) {
   333      if ((node = group[i]) && (nodeByKeyValue[keyValues[i]] === node)) {
   334        exit[i] = node;
   335      }
   336    }
   337  }
   338  
   339  var selection_data = function(value, key) {
   340    if (!value) {
   341      data = new Array(this.size()), j = -1;
   342      this.each(function(d) { data[++j] = d; });
   343      return data;
   344    }
   345  
   346    var bind = key ? bindKey : bindIndex,
   347        parents = this._parents,
   348        groups = this._groups;
   349  
   350    if (typeof value !== "function") value = constant(value);
   351  
   352    for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {
   353      var parent = parents[j],
   354          group = groups[j],
   355          groupLength = group.length,
   356          data = value.call(parent, parent && parent.__data__, j, parents),
   357          dataLength = data.length,
   358          enterGroup = enter[j] = new Array(dataLength),
   359          updateGroup = update[j] = new Array(dataLength),
   360          exitGroup = exit[j] = new Array(groupLength);
   361  
   362      bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
   363  
   364      // Now connect the enter nodes to their following update node, such that
   365      // appendChild can insert the materialized enter node before this node,
   366      // rather than at the end of the parent node.
   367      for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
   368        if (previous = enterGroup[i0]) {
   369          if (i0 >= i1) i1 = i0 + 1;
   370          while (!(next = updateGroup[i1]) && ++i1 < dataLength);
   371          previous._next = next || null;
   372        }
   373      }
   374    }
   375  
   376    update = new Selection(update, parents);
   377    update._enter = enter;
   378    update._exit = exit;
   379    return update;
   380  };
   381  
   382  var selection_exit = function() {
   383    return new Selection(this._exit || this._groups.map(sparse), this._parents);
   384  };
   385  
   386  var selection_merge = function(selection$$1) {
   387  
   388    for (var groups0 = this._groups, groups1 = selection$$1._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
   389      for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
   390        if (node = group0[i] || group1[i]) {
   391          merge[i] = node;
   392        }
   393      }
   394    }
   395  
   396    for (; j < m0; ++j) {
   397      merges[j] = groups0[j];
   398    }
   399  
   400    return new Selection(merges, this._parents);
   401  };
   402  
   403  var selection_order = function() {
   404  
   405    for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) {
   406      for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
   407        if (node = group[i]) {
   408          if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
   409          next = node;
   410        }
   411      }
   412    }
   413  
   414    return this;
   415  };
   416  
   417  var selection_sort = function(compare) {
   418    if (!compare) compare = ascending;
   419  
   420    function compareNode(a, b) {
   421      return a && b ? compare(a.__data__, b.__data__) : !a - !b;
   422    }
   423  
   424    for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) {
   425      for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) {
   426        if (node = group[i]) {
   427          sortgroup[i] = node;
   428        }
   429      }
   430      sortgroup.sort(compareNode);
   431    }
   432  
   433    return new Selection(sortgroups, this._parents).order();
   434  };
   435  
   436  function ascending(a, b) {
   437    return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
   438  }
   439  
   440  var selection_call = function() {
   441    var callback = arguments[0];
   442    arguments[0] = this;
   443    callback.apply(null, arguments);
   444    return this;
   445  };
   446  
   447  var selection_nodes = function() {
   448    var nodes = new Array(this.size()), i = -1;
   449    this.each(function() { nodes[++i] = this; });
   450    return nodes;
   451  };
   452  
   453  var selection_node = function() {
   454  
   455    for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
   456      for (var group = groups[j], i = 0, n = group.length; i < n; ++i) {
   457        var node = group[i];
   458        if (node) return node;
   459      }
   460    }
   461  
   462    return null;
   463  };
   464  
   465  var selection_size = function() {
   466    var size = 0;
   467    this.each(function() { ++size; });
   468    return size;
   469  };
   470  
   471  var selection_empty = function() {
   472    return !this.node();
   473  };
   474  
   475  var selection_each = function(callback) {
   476  
   477    for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
   478      for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {
   479        if (node = group[i]) callback.call(node, node.__data__, i, group);
   480      }
   481    }
   482  
   483    return this;
   484  };
   485  
   486  function attrRemove(name) {
   487    return function() {
   488      this.removeAttribute(name);
   489    };
   490  }
   491  
   492  function attrRemoveNS(fullname) {
   493    return function() {
   494      this.removeAttributeNS(fullname.space, fullname.local);
   495    };
   496  }
   497  
   498  function attrConstant(name, value) {
   499    return function() {
   500      this.setAttribute(name, value);
   501    };
   502  }
   503  
   504  function attrConstantNS(fullname, value) {
   505    return function() {
   506      this.setAttributeNS(fullname.space, fullname.local, value);
   507    };
   508  }
   509  
   510  function attrFunction(name, value) {
   511    return function() {
   512      var v = value.apply(this, arguments);
   513      if (v == null) this.removeAttribute(name);
   514      else this.setAttribute(name, v);
   515    };
   516  }
   517  
   518  function attrFunctionNS(fullname, value) {
   519    return function() {
   520      var v = value.apply(this, arguments);
   521      if (v == null) this.removeAttributeNS(fullname.space, fullname.local);
   522      else this.setAttributeNS(fullname.space, fullname.local, v);
   523    };
   524  }
   525  
   526  var selection_attr = function(name, value) {
   527    var fullname = namespace(name);
   528  
   529    if (arguments.length < 2) {
   530      var node = this.node();
   531      return fullname.local
   532          ? node.getAttributeNS(fullname.space, fullname.local)
   533          : node.getAttribute(fullname);
   534    }
   535  
   536    return this.each((value == null
   537        ? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
   538        ? (fullname.local ? attrFunctionNS : attrFunction)
   539        : (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
   540  };
   541  
   542  var defaultView = function(node) {
   543    return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
   544        || (node.document && node) // node is a Window
   545        || node.defaultView; // node is a Document
   546  };
   547  
   548  function styleRemove(name) {
   549    return function() {
   550      this.style.removeProperty(name);
   551    };
   552  }
   553  
   554  function styleConstant(name, value, priority) {
   555    return function() {
   556      this.style.setProperty(name, value, priority);
   557    };
   558  }
   559  
   560  function styleFunction(name, value, priority) {
   561    return function() {
   562      var v = value.apply(this, arguments);
   563      if (v == null) this.style.removeProperty(name);
   564      else this.style.setProperty(name, v, priority);
   565    };
   566  }
   567  
   568  var selection_style = function(name, value, priority) {
   569    return arguments.length > 1
   570        ? this.each((value == null
   571              ? styleRemove : typeof value === "function"
   572              ? styleFunction
   573              : styleConstant)(name, value, priority == null ? "" : priority))
   574        : styleValue(this.node(), name);
   575  };
   576  
   577  function styleValue(node, name) {
   578    return node.style.getPropertyValue(name)
   579        || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
   580  }
   581  
   582  function propertyRemove(name) {
   583    return function() {
   584      delete this[name];
   585    };
   586  }
   587  
   588  function propertyConstant(name, value) {
   589    return function() {
   590      this[name] = value;
   591    };
   592  }
   593  
   594  function propertyFunction(name, value) {
   595    return function() {
   596      var v = value.apply(this, arguments);
   597      if (v == null) delete this[name];
   598      else this[name] = v;
   599    };
   600  }
   601  
   602  var selection_property = function(name, value) {
   603    return arguments.length > 1
   604        ? this.each((value == null
   605            ? propertyRemove : typeof value === "function"
   606            ? propertyFunction
   607            : propertyConstant)(name, value))
   608        : this.node()[name];
   609  };
   610  
   611  function classArray(string) {
   612    return string.trim().split(/^|\s+/);
   613  }
   614  
   615  function classList(node) {
   616    return node.classList || new ClassList(node);
   617  }
   618  
   619  function ClassList(node) {
   620    this._node = node;
   621    this._names = classArray(node.getAttribute("class") || "");
   622  }
   623  
   624  ClassList.prototype = {
   625    add: function(name) {
   626      var i = this._names.indexOf(name);
   627      if (i < 0) {
   628        this._names.push(name);
   629        this._node.setAttribute("class", this._names.join(" "));
   630      }
   631    },
   632    remove: function(name) {
   633      var i = this._names.indexOf(name);
   634      if (i >= 0) {
   635        this._names.splice(i, 1);
   636        this._node.setAttribute("class", this._names.join(" "));
   637      }
   638    },
   639    contains: function(name) {
   640      return this._names.indexOf(name) >= 0;
   641    }
   642  };
   643  
   644  function classedAdd(node, names) {
   645    var list = classList(node), i = -1, n = names.length;
   646    while (++i < n) list.add(names[i]);
   647  }
   648  
   649  function classedRemove(node, names) {
   650    var list = classList(node), i = -1, n = names.length;
   651    while (++i < n) list.remove(names[i]);
   652  }
   653  
   654  function classedTrue(names) {
   655    return function() {
   656      classedAdd(this, names);
   657    };
   658  }
   659  
   660  function classedFalse(names) {
   661    return function() {
   662      classedRemove(this, names);
   663    };
   664  }
   665  
   666  function classedFunction(names, value) {
   667    return function() {
   668      (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
   669    };
   670  }
   671  
   672  var selection_classed = function(name, value) {
   673    var names = classArray(name + "");
   674  
   675    if (arguments.length < 2) {
   676      var list = classList(this.node()), i = -1, n = names.length;
   677      while (++i < n) if (!list.contains(names[i])) return false;
   678      return true;
   679    }
   680  
   681    return this.each((typeof value === "function"
   682        ? classedFunction : value
   683        ? classedTrue
   684        : classedFalse)(names, value));
   685  };
   686  
   687  function textRemove() {
   688    this.textContent = "";
   689  }
   690  
   691  function textConstant(value) {
   692    return function() {
   693      this.textContent = value;
   694    };
   695  }
   696  
   697  function textFunction(value) {
   698    return function() {
   699      var v = value.apply(this, arguments);
   700      this.textContent = v == null ? "" : v;
   701    };
   702  }
   703  
   704  var selection_text = function(value) {
   705    return arguments.length
   706        ? this.each(value == null
   707            ? textRemove : (typeof value === "function"
   708            ? textFunction
   709            : textConstant)(value))
   710        : this.node().textContent;
   711  };
   712  
   713  function htmlRemove() {
   714    this.innerHTML = "";
   715  }
   716  
   717  function htmlConstant(value) {
   718    return function() {
   719      this.innerHTML = value;
   720    };
   721  }
   722  
   723  function htmlFunction(value) {
   724    return function() {
   725      var v = value.apply(this, arguments);
   726      this.innerHTML = v == null ? "" : v;
   727    };
   728  }
   729  
   730  var selection_html = function(value) {
   731    return arguments.length
   732        ? this.each(value == null
   733            ? htmlRemove : (typeof value === "function"
   734            ? htmlFunction
   735            : htmlConstant)(value))
   736        : this.node().innerHTML;
   737  };
   738  
   739  function raise() {
   740    if (this.nextSibling) this.parentNode.appendChild(this);
   741  }
   742  
   743  var selection_raise = function() {
   744    return this.each(raise);
   745  };
   746  
   747  function lower() {
   748    if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);
   749  }
   750  
   751  var selection_lower = function() {
   752    return this.each(lower);
   753  };
   754  
   755  var selection_append = function(name) {
   756    var create = typeof name === "function" ? name : creator(name);
   757    return this.select(function() {
   758      return this.appendChild(create.apply(this, arguments));
   759    });
   760  };
   761  
   762  function constantNull() {
   763    return null;
   764  }
   765  
   766  var selection_insert = function(name, before) {
   767    var create = typeof name === "function" ? name : creator(name),
   768        select = before == null ? constantNull : typeof before === "function" ? before : selector(before);
   769    return this.select(function() {
   770      return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
   771    });
   772  };
   773  
   774  function remove() {
   775    var parent = this.parentNode;
   776    if (parent) parent.removeChild(this);
   777  }
   778  
   779  var selection_remove = function() {
   780    return this.each(remove);
   781  };
   782  
   783  var selection_datum = function(value) {
   784    return arguments.length
   785        ? this.property("__data__", value)
   786        : this.node().__data__;
   787  };
   788  
   789  function dispatchEvent(node, type, params) {
   790    var window = defaultView(node),
   791        event = window.CustomEvent;
   792  
   793    if (typeof event === "function") {
   794      event = new event(type, params);
   795    } else {
   796      event = window.document.createEvent("Event");
   797      if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
   798      else event.initEvent(type, false, false);
   799    }
   800  
   801    node.dispatchEvent(event);
   802  }
   803  
   804  function dispatchConstant(type, params) {
   805    return function() {
   806      return dispatchEvent(this, type, params);
   807    };
   808  }
   809  
   810  function dispatchFunction(type, params) {
   811    return function() {
   812      return dispatchEvent(this, type, params.apply(this, arguments));
   813    };
   814  }
   815  
   816  var selection_dispatch = function(type, params) {
   817    return this.each((typeof params === "function"
   818        ? dispatchFunction
   819        : dispatchConstant)(type, params));
   820  };
   821  
   822  var root = [null];
   823  
   824  function Selection(groups, parents) {
   825    this._groups = groups;
   826    this._parents = parents;
   827  }
   828  
   829  function selection() {
   830    return new Selection([[document.documentElement]], root);
   831  }
   832  
   833  Selection.prototype = selection.prototype = {
   834    constructor: Selection,
   835    select: selection_select,
   836    selectAll: selection_selectAll,
   837    filter: selection_filter,
   838    data: selection_data,
   839    enter: selection_enter,
   840    exit: selection_exit,
   841    merge: selection_merge,
   842    order: selection_order,
   843    sort: selection_sort,
   844    call: selection_call,
   845    nodes: selection_nodes,
   846    node: selection_node,
   847    size: selection_size,
   848    empty: selection_empty,
   849    each: selection_each,
   850    attr: selection_attr,
   851    style: selection_style,
   852    property: selection_property,
   853    classed: selection_classed,
   854    text: selection_text,
   855    html: selection_html,
   856    raise: selection_raise,
   857    lower: selection_lower,
   858    append: selection_append,
   859    insert: selection_insert,
   860    remove: selection_remove,
   861    datum: selection_datum,
   862    on: selection_on,
   863    dispatch: selection_dispatch
   864  };
   865  
   866  var select = function(selector) {
   867    return typeof selector === "string"
   868        ? new Selection([[document.querySelector(selector)]], [document.documentElement])
   869        : new Selection([[selector]], root);
   870  };
   871  
   872  function count(node) {
   873    var sum = 0,
   874        children = node.children,
   875        i = children && children.length;
   876    if (!i) sum = 1;
   877    else while (--i >= 0) sum += children[i].value;
   878    node.value = sum;
   879  }
   880  
   881  var node_count = function() {
   882    return this.eachAfter(count);
   883  };
   884  
   885  var node_each = function(callback) {
   886    var node = this, current, next = [node], children, i, n;
   887    do {
   888      current = next.reverse(), next = [];
   889      while (node = current.pop()) {
   890        callback(node), children = node.children;
   891        if (children) for (i = 0, n = children.length; i < n; ++i) {
   892          next.push(children[i]);
   893        }
   894      }
   895    } while (next.length);
   896    return this;
   897  };
   898  
   899  var node_eachBefore = function(callback) {
   900    var node = this, nodes = [node], children, i;
   901    while (node = nodes.pop()) {
   902      callback(node), children = node.children;
   903      if (children) for (i = children.length - 1; i >= 0; --i) {
   904        nodes.push(children[i]);
   905      }
   906    }
   907    return this;
   908  };
   909  
   910  var node_eachAfter = function(callback) {
   911    var node = this, nodes = [node], next = [], children, i, n;
   912    while (node = nodes.pop()) {
   913      next.push(node), children = node.children;
   914      if (children) for (i = 0, n = children.length; i < n; ++i) {
   915        nodes.push(children[i]);
   916      }
   917    }
   918    while (node = next.pop()) {
   919      callback(node);
   920    }
   921    return this;
   922  };
   923  
   924  var node_sum = function(value) {
   925    return this.eachAfter(function(node) {
   926      var sum = +value(node.data) || 0,
   927          children = node.children,
   928          i = children && children.length;
   929      while (--i >= 0) sum += children[i].value;
   930      node.value = sum;
   931    });
   932  };
   933  
   934  var node_sort = function(compare) {
   935    return this.eachBefore(function(node) {
   936      if (node.children) {
   937        node.children.sort(compare);
   938      }
   939    });
   940  };
   941  
   942  var node_path = function(end) {
   943    var start = this,
   944        ancestor = leastCommonAncestor(start, end),
   945        nodes = [start];
   946    while (start !== ancestor) {
   947      start = start.parent;
   948      nodes.push(start);
   949    }
   950    var k = nodes.length;
   951    while (end !== ancestor) {
   952      nodes.splice(k, 0, end);
   953      end = end.parent;
   954    }
   955    return nodes;
   956  };
   957  
   958  function leastCommonAncestor(a, b) {
   959    if (a === b) return a;
   960    var aNodes = a.ancestors(),
   961        bNodes = b.ancestors(),
   962        c = null;
   963    a = aNodes.pop();
   964    b = bNodes.pop();
   965    while (a === b) {
   966      c = a;
   967      a = aNodes.pop();
   968      b = bNodes.pop();
   969    }
   970    return c;
   971  }
   972  
   973  var node_ancestors = function() {
   974    var node = this, nodes = [node];
   975    while (node = node.parent) {
   976      nodes.push(node);
   977    }
   978    return nodes;
   979  };
   980  
   981  var node_descendants = function() {
   982    var nodes = [];
   983    this.each(function(node) {
   984      nodes.push(node);
   985    });
   986    return nodes;
   987  };
   988  
   989  var node_leaves = function() {
   990    var leaves = [];
   991    this.eachBefore(function(node) {
   992      if (!node.children) {
   993        leaves.push(node);
   994      }
   995    });
   996    return leaves;
   997  };
   998  
   999  var node_links = function() {
  1000    var root = this, links = [];
  1001    root.each(function(node) {
  1002      if (node !== root) { // Don’t include the root’s parent, if any.
  1003        links.push({source: node.parent, target: node});
  1004      }
  1005    });
  1006    return links;
  1007  };
  1008  
  1009  function hierarchy(data, children) {
  1010    var root = new Node(data),
  1011        valued = +data.value && (root.value = data.value),
  1012        node,
  1013        nodes = [root],
  1014        child,
  1015        childs,
  1016        i,
  1017        n;
  1018  
  1019    if (children == null) children = defaultChildren;
  1020  
  1021    while (node = nodes.pop()) {
  1022      if (valued) node.value = +node.data.value;
  1023      if ((childs = children(node.data)) && (n = childs.length)) {
  1024        node.children = new Array(n);
  1025        for (i = n - 1; i >= 0; --i) {
  1026          nodes.push(child = node.children[i] = new Node(childs[i]));
  1027          child.parent = node;
  1028          child.depth = node.depth + 1;
  1029        }
  1030      }
  1031    }
  1032  
  1033    return root.eachBefore(computeHeight);
  1034  }
  1035  
  1036  function node_copy() {
  1037    return hierarchy(this).eachBefore(copyData);
  1038  }
  1039  
  1040  function defaultChildren(d) {
  1041    return d.children;
  1042  }
  1043  
  1044  function copyData(node) {
  1045    node.data = node.data.data;
  1046  }
  1047  
  1048  function computeHeight(node) {
  1049    var height = 0;
  1050    do node.height = height;
  1051    while ((node = node.parent) && (node.height < ++height));
  1052  }
  1053  
  1054  function Node(data) {
  1055    this.data = data;
  1056    this.depth =
  1057    this.height = 0;
  1058    this.parent = null;
  1059  }
  1060  
  1061  Node.prototype = hierarchy.prototype = {
  1062    constructor: Node,
  1063    count: node_count,
  1064    each: node_each,
  1065    eachAfter: node_eachAfter,
  1066    eachBefore: node_eachBefore,
  1067    sum: node_sum,
  1068    sort: node_sort,
  1069    path: node_path,
  1070    ancestors: node_ancestors,
  1071    descendants: node_descendants,
  1072    leaves: node_leaves,
  1073    links: node_links,
  1074    copy: node_copy
  1075  };
  1076  
  1077  var roundNode = function(node) {
  1078    node.x0 = Math.round(node.x0);
  1079    node.y0 = Math.round(node.y0);
  1080    node.x1 = Math.round(node.x1);
  1081    node.y1 = Math.round(node.y1);
  1082  };
  1083  
  1084  var treemapDice = function(parent, x0, y0, x1, y1) {
  1085    var nodes = parent.children,
  1086        node,
  1087        i = -1,
  1088        n = nodes.length,
  1089        k = parent.value && (x1 - x0) / parent.value;
  1090  
  1091    while (++i < n) {
  1092      node = nodes[i], node.y0 = y0, node.y1 = y1;
  1093      node.x0 = x0, node.x1 = x0 += node.value * k;
  1094    }
  1095  };
  1096  
  1097  var partition = function() {
  1098    var dx = 1,
  1099        dy = 1,
  1100        padding = 0,
  1101        round = false;
  1102  
  1103    function partition(root) {
  1104      var n = root.height + 1;
  1105      root.x0 =
  1106      root.y0 = padding;
  1107      root.x1 = dx;
  1108      root.y1 = dy / n;
  1109      root.eachBefore(positionNode(dy, n));
  1110      if (round) root.eachBefore(roundNode);
  1111      return root;
  1112    }
  1113  
  1114    function positionNode(dy, n) {
  1115      return function(node) {
  1116        if (node.children) {
  1117          treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n);
  1118        }
  1119        var x0 = node.x0,
  1120            y0 = node.y0,
  1121            x1 = node.x1 - padding,
  1122            y1 = node.y1 - padding;
  1123        if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
  1124        if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
  1125        node.x0 = x0;
  1126        node.y0 = y0;
  1127        node.x1 = x1;
  1128        node.y1 = y1;
  1129      };
  1130    }
  1131  
  1132    partition.round = function(x) {
  1133      return arguments.length ? (round = !!x, partition) : round;
  1134    };
  1135  
  1136    partition.size = function(x) {
  1137      return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy];
  1138    };
  1139  
  1140    partition.padding = function(x) {
  1141      return arguments.length ? (padding = +x, partition) : padding;
  1142    };
  1143  
  1144    return partition;
  1145  };
  1146  
  1147  var ascending$1 = function(a, b) {
  1148    return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
  1149  };
  1150  
  1151  var bisector = function(compare) {
  1152    if (compare.length === 1) compare = ascendingComparator(compare);
  1153    return {
  1154      left: function(a, x, lo, hi) {
  1155        if (lo == null) lo = 0;
  1156        if (hi == null) hi = a.length;
  1157        while (lo < hi) {
  1158          var mid = lo + hi >>> 1;
  1159          if (compare(a[mid], x) < 0) lo = mid + 1;
  1160          else hi = mid;
  1161        }
  1162        return lo;
  1163      },
  1164      right: function(a, x, lo, hi) {
  1165        if (lo == null) lo = 0;
  1166        if (hi == null) hi = a.length;
  1167        while (lo < hi) {
  1168          var mid = lo + hi >>> 1;
  1169          if (compare(a[mid], x) > 0) hi = mid;
  1170          else lo = mid + 1;
  1171        }
  1172        return lo;
  1173      }
  1174    };
  1175  };
  1176  
  1177  function ascendingComparator(f) {
  1178    return function(d, x) {
  1179      return ascending$1(f(d), x);
  1180    };
  1181  }
  1182  
  1183  var ascendingBisect = bisector(ascending$1);
  1184  var bisectRight = ascendingBisect.right;
  1185  
  1186  var e10 = Math.sqrt(50);
  1187  var e5 = Math.sqrt(10);
  1188  var e2 = Math.sqrt(2);
  1189  
  1190  var ticks = function(start, stop, count) {
  1191    var reverse,
  1192        i = -1,
  1193        n,
  1194        ticks,
  1195        step;
  1196  
  1197    stop = +stop, start = +start, count = +count;
  1198    if (start === stop && count > 0) return [start];
  1199    if (reverse = stop < start) n = start, start = stop, stop = n;
  1200    if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
  1201  
  1202    if (step > 0) {
  1203      start = Math.ceil(start / step);
  1204      stop = Math.floor(stop / step);
  1205      ticks = new Array(n = Math.ceil(stop - start + 1));
  1206      while (++i < n) ticks[i] = (start + i) * step;
  1207    } else {
  1208      start = Math.floor(start * step);
  1209      stop = Math.ceil(stop * step);
  1210      ticks = new Array(n = Math.ceil(start - stop + 1));
  1211      while (++i < n) ticks[i] = (start - i) / step;
  1212    }
  1213  
  1214    if (reverse) ticks.reverse();
  1215  
  1216    return ticks;
  1217  };
  1218  
  1219  function tickIncrement(start, stop, count) {
  1220    var step = (stop - start) / Math.max(0, count),
  1221        power = Math.floor(Math.log(step) / Math.LN10),
  1222        error = step / Math.pow(10, power);
  1223    return power >= 0
  1224        ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
  1225        : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
  1226  }
  1227  
  1228  function tickStep(start, stop, count) {
  1229    var step0 = Math.abs(stop - start) / Math.max(0, count),
  1230        step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
  1231        error = step0 / step1;
  1232    if (error >= e10) step1 *= 10;
  1233    else if (error >= e5) step1 *= 5;
  1234    else if (error >= e2) step1 *= 2;
  1235    return stop < start ? -step1 : step1;
  1236  }
  1237  
  1238  var prefix = "$";
  1239  
  1240  function Map() {}
  1241  
  1242  Map.prototype = map$1.prototype = {
  1243    constructor: Map,
  1244    has: function(key) {
  1245      return (prefix + key) in this;
  1246    },
  1247    get: function(key) {
  1248      return this[prefix + key];
  1249    },
  1250    set: function(key, value) {
  1251      this[prefix + key] = value;
  1252      return this;
  1253    },
  1254    remove: function(key) {
  1255      var property = prefix + key;
  1256      return property in this && delete this[property];
  1257    },
  1258    clear: function() {
  1259      for (var property in this) if (property[0] === prefix) delete this[property];
  1260    },
  1261    keys: function() {
  1262      var keys = [];
  1263      for (var property in this) if (property[0] === prefix) keys.push(property.slice(1));
  1264      return keys;
  1265    },
  1266    values: function() {
  1267      var values = [];
  1268      for (var property in this) if (property[0] === prefix) values.push(this[property]);
  1269      return values;
  1270    },
  1271    entries: function() {
  1272      var entries = [];
  1273      for (var property in this) if (property[0] === prefix) entries.push({key: property.slice(1), value: this[property]});
  1274      return entries;
  1275    },
  1276    size: function() {
  1277      var size = 0;
  1278      for (var property in this) if (property[0] === prefix) ++size;
  1279      return size;
  1280    },
  1281    empty: function() {
  1282      for (var property in this) if (property[0] === prefix) return false;
  1283      return true;
  1284    },
  1285    each: function(f) {
  1286      for (var property in this) if (property[0] === prefix) f(this[property], property.slice(1), this);
  1287    }
  1288  };
  1289  
  1290  function map$1(object, f) {
  1291    var map = new Map;
  1292  
  1293    // Copy constructor.
  1294    if (object instanceof Map) object.each(function(value, key) { map.set(key, value); });
  1295  
  1296    // Index array by numeric index or specified key function.
  1297    else if (Array.isArray(object)) {
  1298      var i = -1,
  1299          n = object.length,
  1300          o;
  1301  
  1302      if (f == null) while (++i < n) map.set(i, object[i]);
  1303      else while (++i < n) map.set(f(o = object[i], i, object), o);
  1304    }
  1305  
  1306    // Convert object to map.
  1307    else if (object) for (var key in object) map.set(key, object[key]);
  1308  
  1309    return map;
  1310  }
  1311  
  1312  function Set() {}
  1313  
  1314  var proto = map$1.prototype;
  1315  
  1316  Set.prototype = set.prototype = {
  1317    constructor: Set,
  1318    has: proto.has,
  1319    add: function(value) {
  1320      value += "";
  1321      this[prefix + value] = value;
  1322      return this;
  1323    },
  1324    remove: proto.remove,
  1325    clear: proto.clear,
  1326    values: proto.keys,
  1327    size: proto.size,
  1328    empty: proto.empty,
  1329    each: proto.each
  1330  };
  1331  
  1332  function set(object, f) {
  1333    var set = new Set;
  1334  
  1335    // Copy constructor.
  1336    if (object instanceof Set) object.each(function(value) { set.add(value); });
  1337  
  1338    // Otherwise, assume it’s an array.
  1339    else if (object) {
  1340      var i = -1, n = object.length;
  1341      if (f == null) while (++i < n) set.add(object[i]);
  1342      else while (++i < n) set.add(f(object[i], i, object));
  1343    }
  1344  
  1345    return set;
  1346  }
  1347  
  1348  var array$1 = Array.prototype;
  1349  
  1350  var map$3 = array$1.map;
  1351  var slice$2 = array$1.slice;
  1352  
  1353  var define = function(constructor, factory, prototype) {
  1354    constructor.prototype = factory.prototype = prototype;
  1355    prototype.constructor = constructor;
  1356  };
  1357  
  1358  function extend(parent, definition) {
  1359    var prototype = Object.create(parent.prototype);
  1360    for (var key in definition) prototype[key] = definition[key];
  1361    return prototype;
  1362  }
  1363  
  1364  function Color() {}
  1365  
  1366  var darker = 0.7;
  1367  var brighter = 1 / darker;
  1368  
  1369  var reI = "\\s*([+-]?\\d+)\\s*";
  1370  var reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*";
  1371  var reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*";
  1372  var reHex3 = /^#([0-9a-f]{3})$/;
  1373  var reHex6 = /^#([0-9a-f]{6})$/;
  1374  var reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$");
  1375  var reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$");
  1376  var reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$");
  1377  var reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$");
  1378  var reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$");
  1379  var reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$");
  1380  
  1381  var named = {
  1382    aliceblue: 0xf0f8ff,
  1383    antiquewhite: 0xfaebd7,
  1384    aqua: 0x00ffff,
  1385    aquamarine: 0x7fffd4,
  1386    azure: 0xf0ffff,
  1387    beige: 0xf5f5dc,
  1388    bisque: 0xffe4c4,
  1389    black: 0x000000,
  1390    blanchedalmond: 0xffebcd,
  1391    blue: 0x0000ff,
  1392    blueviolet: 0x8a2be2,
  1393    brown: 0xa52a2a,
  1394    burlywood: 0xdeb887,
  1395    cadetblue: 0x5f9ea0,
  1396    chartreuse: 0x7fff00,
  1397    chocolate: 0xd2691e,
  1398    coral: 0xff7f50,
  1399    cornflowerblue: 0x6495ed,
  1400    cornsilk: 0xfff8dc,
  1401    crimson: 0xdc143c,
  1402    cyan: 0x00ffff,
  1403    darkblue: 0x00008b,
  1404    darkcyan: 0x008b8b,
  1405    darkgoldenrod: 0xb8860b,
  1406    darkgray: 0xa9a9a9,
  1407    darkgreen: 0x006400,
  1408    darkgrey: 0xa9a9a9,
  1409    darkkhaki: 0xbdb76b,
  1410    darkmagenta: 0x8b008b,
  1411    darkolivegreen: 0x556b2f,
  1412    darkorange: 0xff8c00,
  1413    darkorchid: 0x9932cc,
  1414    darkred: 0x8b0000,
  1415    darksalmon: 0xe9967a,
  1416    darkseagreen: 0x8fbc8f,
  1417    darkslateblue: 0x483d8b,
  1418    darkslategray: 0x2f4f4f,
  1419    darkslategrey: 0x2f4f4f,
  1420    darkturquoise: 0x00ced1,
  1421    darkviolet: 0x9400d3,
  1422    deeppink: 0xff1493,
  1423    deepskyblue: 0x00bfff,
  1424    dimgray: 0x696969,
  1425    dimgrey: 0x696969,
  1426    dodgerblue: 0x1e90ff,
  1427    firebrick: 0xb22222,
  1428    floralwhite: 0xfffaf0,
  1429    forestgreen: 0x228b22,
  1430    fuchsia: 0xff00ff,
  1431    gainsboro: 0xdcdcdc,
  1432    ghostwhite: 0xf8f8ff,
  1433    gold: 0xffd700,
  1434    goldenrod: 0xdaa520,
  1435    gray: 0x808080,
  1436    green: 0x008000,
  1437    greenyellow: 0xadff2f,
  1438    grey: 0x808080,
  1439    honeydew: 0xf0fff0,
  1440    hotpink: 0xff69b4,
  1441    indianred: 0xcd5c5c,
  1442    indigo: 0x4b0082,
  1443    ivory: 0xfffff0,
  1444    khaki: 0xf0e68c,
  1445    lavender: 0xe6e6fa,
  1446    lavenderblush: 0xfff0f5,
  1447    lawngreen: 0x7cfc00,
  1448    lemonchiffon: 0xfffacd,
  1449    lightblue: 0xadd8e6,
  1450    lightcoral: 0xf08080,
  1451    lightcyan: 0xe0ffff,
  1452    lightgoldenrodyellow: 0xfafad2,
  1453    lightgray: 0xd3d3d3,
  1454    lightgreen: 0x90ee90,
  1455    lightgrey: 0xd3d3d3,
  1456    lightpink: 0xffb6c1,
  1457    lightsalmon: 0xffa07a,
  1458    lightseagreen: 0x20b2aa,
  1459    lightskyblue: 0x87cefa,
  1460    lightslategray: 0x778899,
  1461    lightslategrey: 0x778899,
  1462    lightsteelblue: 0xb0c4de,
  1463    lightyellow: 0xffffe0,
  1464    lime: 0x00ff00,
  1465    limegreen: 0x32cd32,
  1466    linen: 0xfaf0e6,
  1467    magenta: 0xff00ff,
  1468    maroon: 0x800000,
  1469    mediumaquamarine: 0x66cdaa,
  1470    mediumblue: 0x0000cd,
  1471    mediumorchid: 0xba55d3,
  1472    mediumpurple: 0x9370db,
  1473    mediumseagreen: 0x3cb371,
  1474    mediumslateblue: 0x7b68ee,
  1475    mediumspringgreen: 0x00fa9a,
  1476    mediumturquoise: 0x48d1cc,
  1477    mediumvioletred: 0xc71585,
  1478    midnightblue: 0x191970,
  1479    mintcream: 0xf5fffa,
  1480    mistyrose: 0xffe4e1,
  1481    moccasin: 0xffe4b5,
  1482    navajowhite: 0xffdead,
  1483    navy: 0x000080,
  1484    oldlace: 0xfdf5e6,
  1485    olive: 0x808000,
  1486    olivedrab: 0x6b8e23,
  1487    orange: 0xffa500,
  1488    orangered: 0xff4500,
  1489    orchid: 0xda70d6,
  1490    palegoldenrod: 0xeee8aa,
  1491    palegreen: 0x98fb98,
  1492    paleturquoise: 0xafeeee,
  1493    palevioletred: 0xdb7093,
  1494    papayawhip: 0xffefd5,
  1495    peachpuff: 0xffdab9,
  1496    peru: 0xcd853f,
  1497    pink: 0xffc0cb,
  1498    plum: 0xdda0dd,
  1499    powderblue: 0xb0e0e6,
  1500    purple: 0x800080,
  1501    rebeccapurple: 0x663399,
  1502    red: 0xff0000,
  1503    rosybrown: 0xbc8f8f,
  1504    royalblue: 0x4169e1,
  1505    saddlebrown: 0x8b4513,
  1506    salmon: 0xfa8072,
  1507    sandybrown: 0xf4a460,
  1508    seagreen: 0x2e8b57,
  1509    seashell: 0xfff5ee,
  1510    sienna: 0xa0522d,
  1511    silver: 0xc0c0c0,
  1512    skyblue: 0x87ceeb,
  1513    slateblue: 0x6a5acd,
  1514    slategray: 0x708090,
  1515    slategrey: 0x708090,
  1516    snow: 0xfffafa,
  1517    springgreen: 0x00ff7f,
  1518    steelblue: 0x4682b4,
  1519    tan: 0xd2b48c,
  1520    teal: 0x008080,
  1521    thistle: 0xd8bfd8,
  1522    tomato: 0xff6347,
  1523    turquoise: 0x40e0d0,
  1524    violet: 0xee82ee,
  1525    wheat: 0xf5deb3,
  1526    white: 0xffffff,
  1527    whitesmoke: 0xf5f5f5,
  1528    yellow: 0xffff00,
  1529    yellowgreen: 0x9acd32
  1530  };
  1531  
  1532  define(Color, color, {
  1533    displayable: function() {
  1534      return this.rgb().displayable();
  1535    },
  1536    toString: function() {
  1537      return this.rgb() + "";
  1538    }
  1539  });
  1540  
  1541  function color(format) {
  1542    var m;
  1543    format = (format + "").trim().toLowerCase();
  1544    return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), new Rgb((m >> 8 & 0xf) | (m >> 4 & 0x0f0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1)) // #f00
  1545        : (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
  1546        : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
  1547        : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
  1548        : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
  1549        : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
  1550        : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
  1551        : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
  1552        : named.hasOwnProperty(format) ? rgbn(named[format])
  1553        : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
  1554        : null;
  1555  }
  1556  
  1557  function rgbn(n) {
  1558    return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
  1559  }
  1560  
  1561  function rgba(r, g, b, a) {
  1562    if (a <= 0) r = g = b = NaN;
  1563    return new Rgb(r, g, b, a);
  1564  }
  1565  
  1566  function rgbConvert(o) {
  1567    if (!(o instanceof Color)) o = color(o);
  1568    if (!o) return new Rgb;
  1569    o = o.rgb();
  1570    return new Rgb(o.r, o.g, o.b, o.opacity);
  1571  }
  1572  
  1573  function rgb(r, g, b, opacity) {
  1574    return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
  1575  }
  1576  
  1577  function Rgb(r, g, b, opacity) {
  1578    this.r = +r;
  1579    this.g = +g;
  1580    this.b = +b;
  1581    this.opacity = +opacity;
  1582  }
  1583  
  1584  define(Rgb, rgb, extend(Color, {
  1585    brighter: function(k) {
  1586      k = k == null ? brighter : Math.pow(brighter, k);
  1587      return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
  1588    },
  1589    darker: function(k) {
  1590      k = k == null ? darker : Math.pow(darker, k);
  1591      return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
  1592    },
  1593    rgb: function() {
  1594      return this;
  1595    },
  1596    displayable: function() {
  1597      return (0 <= this.r && this.r <= 255)
  1598          && (0 <= this.g && this.g <= 255)
  1599          && (0 <= this.b && this.b <= 255)
  1600          && (0 <= this.opacity && this.opacity <= 1);
  1601    },
  1602    toString: function() {
  1603      var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
  1604      return (a === 1 ? "rgb(" : "rgba(")
  1605          + Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", "
  1606          + Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", "
  1607          + Math.max(0, Math.min(255, Math.round(this.b) || 0))
  1608          + (a === 1 ? ")" : ", " + a + ")");
  1609    }
  1610  }));
  1611  
  1612  function hsla(h, s, l, a) {
  1613    if (a <= 0) h = s = l = NaN;
  1614    else if (l <= 0 || l >= 1) h = s = NaN;
  1615    else if (s <= 0) h = NaN;
  1616    return new Hsl(h, s, l, a);
  1617  }
  1618  
  1619  function hslConvert(o) {
  1620    if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
  1621    if (!(o instanceof Color)) o = color(o);
  1622    if (!o) return new Hsl;
  1623    if (o instanceof Hsl) return o;
  1624    o = o.rgb();
  1625    var r = o.r / 255,
  1626        g = o.g / 255,
  1627        b = o.b / 255,
  1628        min = Math.min(r, g, b),
  1629        max = Math.max(r, g, b),
  1630        h = NaN,
  1631        s = max - min,
  1632        l = (max + min) / 2;
  1633    if (s) {
  1634      if (r === max) h = (g - b) / s + (g < b) * 6;
  1635      else if (g === max) h = (b - r) / s + 2;
  1636      else h = (r - g) / s + 4;
  1637      s /= l < 0.5 ? max + min : 2 - max - min;
  1638      h *= 60;
  1639    } else {
  1640      s = l > 0 && l < 1 ? 0 : h;
  1641    }
  1642    return new Hsl(h, s, l, o.opacity);
  1643  }
  1644  
  1645  function hsl(h, s, l, opacity) {
  1646    return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
  1647  }
  1648  
  1649  function Hsl(h, s, l, opacity) {
  1650    this.h = +h;
  1651    this.s = +s;
  1652    this.l = +l;
  1653    this.opacity = +opacity;
  1654  }
  1655  
  1656  define(Hsl, hsl, extend(Color, {
  1657    brighter: function(k) {
  1658      k = k == null ? brighter : Math.pow(brighter, k);
  1659      return new Hsl(this.h, this.s, this.l * k, this.opacity);
  1660    },
  1661    darker: function(k) {
  1662      k = k == null ? darker : Math.pow(darker, k);
  1663      return new Hsl(this.h, this.s, this.l * k, this.opacity);
  1664    },
  1665    rgb: function() {
  1666      var h = this.h % 360 + (this.h < 0) * 360,
  1667          s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
  1668          l = this.l,
  1669          m2 = l + (l < 0.5 ? l : 1 - l) * s,
  1670          m1 = 2 * l - m2;
  1671      return new Rgb(
  1672        hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
  1673        hsl2rgb(h, m1, m2),
  1674        hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
  1675        this.opacity
  1676      );
  1677    },
  1678    displayable: function() {
  1679      return (0 <= this.s && this.s <= 1 || isNaN(this.s))
  1680          && (0 <= this.l && this.l <= 1)
  1681          && (0 <= this.opacity && this.opacity <= 1);
  1682    }
  1683  }));
  1684  
  1685  /* From FvD 13.37, CSS Color Module Level 3 */
  1686  function hsl2rgb(h, m1, m2) {
  1687    return (h < 60 ? m1 + (m2 - m1) * h / 60
  1688        : h < 180 ? m2
  1689        : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
  1690        : m1) * 255;
  1691  }
  1692  
  1693  var deg2rad = Math.PI / 180;
  1694  var rad2deg = 180 / Math.PI;
  1695  
  1696  var Kn = 18;
  1697  var Xn = 0.950470;
  1698  var Yn = 1;
  1699  var Zn = 1.088830;
  1700  var t0 = 4 / 29;
  1701  var t1 = 6 / 29;
  1702  var t2 = 3 * t1 * t1;
  1703  var t3 = t1 * t1 * t1;
  1704  
  1705  function labConvert(o) {
  1706    if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
  1707    if (o instanceof Hcl) {
  1708      var h = o.h * deg2rad;
  1709      return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
  1710    }
  1711    if (!(o instanceof Rgb)) o = rgbConvert(o);
  1712    var b = rgb2xyz(o.r),
  1713        a = rgb2xyz(o.g),
  1714        l = rgb2xyz(o.b),
  1715        x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn),
  1716        y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.0721750 * l) / Yn),
  1717        z = xyz2lab((0.0193339 * b + 0.1191920 * a + 0.9503041 * l) / Zn);
  1718    return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
  1719  }
  1720  
  1721  function lab(l, a, b, opacity) {
  1722    return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
  1723  }
  1724  
  1725  function Lab(l, a, b, opacity) {
  1726    this.l = +l;
  1727    this.a = +a;
  1728    this.b = +b;
  1729    this.opacity = +opacity;
  1730  }
  1731  
  1732  define(Lab, lab, extend(Color, {
  1733    brighter: function(k) {
  1734      return new Lab(this.l + Kn * (k == null ? 1 : k), this.a, this.b, this.opacity);
  1735    },
  1736    darker: function(k) {
  1737      return new Lab(this.l - Kn * (k == null ? 1 : k), this.a, this.b, this.opacity);
  1738    },
  1739    rgb: function() {
  1740      var y = (this.l + 16) / 116,
  1741          x = isNaN(this.a) ? y : y + this.a / 500,
  1742          z = isNaN(this.b) ? y : y - this.b / 200;
  1743      y = Yn * lab2xyz(y);
  1744      x = Xn * lab2xyz(x);
  1745      z = Zn * lab2xyz(z);
  1746      return new Rgb(
  1747        xyz2rgb( 3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB
  1748        xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z),
  1749        xyz2rgb( 0.0556434 * x - 0.2040259 * y + 1.0572252 * z),
  1750        this.opacity
  1751      );
  1752    }
  1753  }));
  1754  
  1755  function xyz2lab(t) {
  1756    return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
  1757  }
  1758  
  1759  function lab2xyz(t) {
  1760    return t > t1 ? t * t * t : t2 * (t - t0);
  1761  }
  1762  
  1763  function xyz2rgb(x) {
  1764    return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
  1765  }
  1766  
  1767  function rgb2xyz(x) {
  1768    return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
  1769  }
  1770  
  1771  function hclConvert(o) {
  1772    if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
  1773    if (!(o instanceof Lab)) o = labConvert(o);
  1774    var h = Math.atan2(o.b, o.a) * rad2deg;
  1775    return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
  1776  }
  1777  
  1778  function hcl(h, c, l, opacity) {
  1779    return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
  1780  }
  1781  
  1782  function Hcl(h, c, l, opacity) {
  1783    this.h = +h;
  1784    this.c = +c;
  1785    this.l = +l;
  1786    this.opacity = +opacity;
  1787  }
  1788  
  1789  define(Hcl, hcl, extend(Color, {
  1790    brighter: function(k) {
  1791      return new Hcl(this.h, this.c, this.l + Kn * (k == null ? 1 : k), this.opacity);
  1792    },
  1793    darker: function(k) {
  1794      return new Hcl(this.h, this.c, this.l - Kn * (k == null ? 1 : k), this.opacity);
  1795    },
  1796    rgb: function() {
  1797      return labConvert(this).rgb();
  1798    }
  1799  }));
  1800  
  1801  var A = -0.14861;
  1802  var B = +1.78277;
  1803  var C = -0.29227;
  1804  var D = -0.90649;
  1805  var E = +1.97294;
  1806  var ED = E * D;
  1807  var EB = E * B;
  1808  var BC_DA = B * C - D * A;
  1809  
  1810  function cubehelixConvert(o) {
  1811    if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
  1812    if (!(o instanceof Rgb)) o = rgbConvert(o);
  1813    var r = o.r / 255,
  1814        g = o.g / 255,
  1815        b = o.b / 255,
  1816        l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
  1817        bl = b - l,
  1818        k = (E * (g - l) - C * bl) / D,
  1819        s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1
  1820        h = s ? Math.atan2(k, bl) * rad2deg - 120 : NaN;
  1821    return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
  1822  }
  1823  
  1824  function cubehelix(h, s, l, opacity) {
  1825    return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
  1826  }
  1827  
  1828  function Cubehelix(h, s, l, opacity) {
  1829    this.h = +h;
  1830    this.s = +s;
  1831    this.l = +l;
  1832    this.opacity = +opacity;
  1833  }
  1834  
  1835  define(Cubehelix, cubehelix, extend(Color, {
  1836    brighter: function(k) {
  1837      k = k == null ? brighter : Math.pow(brighter, k);
  1838      return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
  1839    },
  1840    darker: function(k) {
  1841      k = k == null ? darker : Math.pow(darker, k);
  1842      return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
  1843    },
  1844    rgb: function() {
  1845      var h = isNaN(this.h) ? 0 : (this.h + 120) * deg2rad,
  1846          l = +this.l,
  1847          a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
  1848          cosh = Math.cos(h),
  1849          sinh = Math.sin(h);
  1850      return new Rgb(
  1851        255 * (l + a * (A * cosh + B * sinh)),
  1852        255 * (l + a * (C * cosh + D * sinh)),
  1853        255 * (l + a * (E * cosh)),
  1854        this.opacity
  1855      );
  1856    }
  1857  }));
  1858  
  1859  var constant$3 = function(x) {
  1860    return function() {
  1861      return x;
  1862    };
  1863  };
  1864  
  1865  function linear$1(a, d) {
  1866    return function(t) {
  1867      return a + t * d;
  1868    };
  1869  }
  1870  
  1871  function exponential(a, b, y) {
  1872    return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
  1873      return Math.pow(a + t * b, y);
  1874    };
  1875  }
  1876  
  1877  function hue(a, b) {
  1878    var d = b - a;
  1879    return d ? linear$1(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$3(isNaN(a) ? b : a);
  1880  }
  1881  
  1882  function gamma(y) {
  1883    return (y = +y) === 1 ? nogamma : function(a, b) {
  1884      return b - a ? exponential(a, b, y) : constant$3(isNaN(a) ? b : a);
  1885    };
  1886  }
  1887  
  1888  function nogamma(a, b) {
  1889    var d = b - a;
  1890    return d ? linear$1(a, d) : constant$3(isNaN(a) ? b : a);
  1891  }
  1892  
  1893  var interpolateRgb = (function rgbGamma(y) {
  1894    var color$$1 = gamma(y);
  1895  
  1896    function rgb$$1(start, end) {
  1897      var r = color$$1((start = rgb(start)).r, (end = rgb(end)).r),
  1898          g = color$$1(start.g, end.g),
  1899          b = color$$1(start.b, end.b),
  1900          opacity = nogamma(start.opacity, end.opacity);
  1901      return function(t) {
  1902        start.r = r(t);
  1903        start.g = g(t);
  1904        start.b = b(t);
  1905        start.opacity = opacity(t);
  1906        return start + "";
  1907      };
  1908    }
  1909  
  1910    rgb$$1.gamma = rgbGamma;
  1911  
  1912    return rgb$$1;
  1913  })(1);
  1914  
  1915  var array$2 = function(a, b) {
  1916    var nb = b ? b.length : 0,
  1917        na = a ? Math.min(nb, a.length) : 0,
  1918        x = new Array(nb),
  1919        c = new Array(nb),
  1920        i;
  1921  
  1922    for (i = 0; i < na; ++i) x[i] = interpolateValue(a[i], b[i]);
  1923    for (; i < nb; ++i) c[i] = b[i];
  1924  
  1925    return function(t) {
  1926      for (i = 0; i < na; ++i) c[i] = x[i](t);
  1927      return c;
  1928    };
  1929  };
  1930  
  1931  var date = function(a, b) {
  1932    var d = new Date;
  1933    return a = +a, b -= a, function(t) {
  1934      return d.setTime(a + b * t), d;
  1935    };
  1936  };
  1937  
  1938  var interpolateNumber = function(a, b) {
  1939    return a = +a, b -= a, function(t) {
  1940      return a + b * t;
  1941    };
  1942  };
  1943  
  1944  var object = function(a, b) {
  1945    var i = {},
  1946        c = {},
  1947        k;
  1948  
  1949    if (a === null || typeof a !== "object") a = {};
  1950    if (b === null || typeof b !== "object") b = {};
  1951  
  1952    for (k in b) {
  1953      if (k in a) {
  1954        i[k] = interpolateValue(a[k], b[k]);
  1955      } else {
  1956        c[k] = b[k];
  1957      }
  1958    }
  1959  
  1960    return function(t) {
  1961      for (k in i) c[k] = i[k](t);
  1962      return c;
  1963    };
  1964  };
  1965  
  1966  var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
  1967  var reB = new RegExp(reA.source, "g");
  1968  
  1969  function zero(b) {
  1970    return function() {
  1971      return b;
  1972    };
  1973  }
  1974  
  1975  function one(b) {
  1976    return function(t) {
  1977      return b(t) + "";
  1978    };
  1979  }
  1980  
  1981  var interpolateString = function(a, b) {
  1982    var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b
  1983        am, // current match in a
  1984        bm, // current match in b
  1985        bs, // string preceding current number in b, if any
  1986        i = -1, // index in s
  1987        s = [], // string constants and placeholders
  1988        q = []; // number interpolators
  1989  
  1990    // Coerce inputs to strings.
  1991    a = a + "", b = b + "";
  1992  
  1993    // Interpolate pairs of numbers in a & b.
  1994    while ((am = reA.exec(a))
  1995        && (bm = reB.exec(b))) {
  1996      if ((bs = bm.index) > bi) { // a string precedes the next number in b
  1997        bs = b.slice(bi, bs);
  1998        if (s[i]) s[i] += bs; // coalesce with previous string
  1999        else s[++i] = bs;
  2000      }
  2001      if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match
  2002        if (s[i]) s[i] += bm; // coalesce with previous string
  2003        else s[++i] = bm;
  2004      } else { // interpolate non-matching numbers
  2005        s[++i] = null;
  2006        q.push({i: i, x: interpolateNumber(am, bm)});
  2007      }
  2008      bi = reB.lastIndex;
  2009    }
  2010  
  2011    // Add remains of b.
  2012    if (bi < b.length) {
  2013      bs = b.slice(bi);
  2014      if (s[i]) s[i] += bs; // coalesce with previous string
  2015      else s[++i] = bs;
  2016    }
  2017  
  2018    // Special optimization for only a single match.
  2019    // Otherwise, interpolate each of the numbers and rejoin the string.
  2020    return s.length < 2 ? (q[0]
  2021        ? one(q[0].x)
  2022        : zero(b))
  2023        : (b = q.length, function(t) {
  2024            for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
  2025            return s.join("");
  2026          });
  2027  };
  2028  
  2029  var interpolateValue = function(a, b) {
  2030    var t = typeof b, c;
  2031    return b == null || t === "boolean" ? constant$3(b)
  2032        : (t === "number" ? interpolateNumber
  2033        : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString)
  2034        : b instanceof color ? interpolateRgb
  2035        : b instanceof Date ? date
  2036        : Array.isArray(b) ? array$2
  2037        : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
  2038        : interpolateNumber)(a, b);
  2039  };
  2040  
  2041  var interpolateRound = function(a, b) {
  2042    return a = +a, b -= a, function(t) {
  2043      return Math.round(a + b * t);
  2044    };
  2045  };
  2046  
  2047  var degrees = 180 / Math.PI;
  2048  
  2049  var identity$2 = {
  2050    translateX: 0,
  2051    translateY: 0,
  2052    rotate: 0,
  2053    skewX: 0,
  2054    scaleX: 1,
  2055    scaleY: 1
  2056  };
  2057  
  2058  var decompose = function(a, b, c, d, e, f) {
  2059    var scaleX, scaleY, skewX;
  2060    if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
  2061    if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
  2062    if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
  2063    if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
  2064    return {
  2065      translateX: e,
  2066      translateY: f,
  2067      rotate: Math.atan2(b, a) * degrees,
  2068      skewX: Math.atan(skewX) * degrees,
  2069      scaleX: scaleX,
  2070      scaleY: scaleY
  2071    };
  2072  };
  2073  
  2074  var cssNode;
  2075  var cssRoot;
  2076  var cssView;
  2077  var svgNode;
  2078  
  2079  function parseCss(value) {
  2080    if (value === "none") return identity$2;
  2081    if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
  2082    cssNode.style.transform = value;
  2083    value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
  2084    cssRoot.removeChild(cssNode);
  2085    value = value.slice(7, -1).split(",");
  2086    return decompose(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
  2087  }
  2088  
  2089  function parseSvg(value) {
  2090    if (value == null) return identity$2;
  2091    if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
  2092    svgNode.setAttribute("transform", value);
  2093    if (!(value = svgNode.transform.baseVal.consolidate())) return identity$2;
  2094    value = value.matrix;
  2095    return decompose(value.a, value.b, value.c, value.d, value.e, value.f);
  2096  }
  2097  
  2098  function interpolateTransform(parse, pxComma, pxParen, degParen) {
  2099  
  2100    function pop(s) {
  2101      return s.length ? s.pop() + " " : "";
  2102    }
  2103  
  2104    function translate(xa, ya, xb, yb, s, q) {
  2105      if (xa !== xb || ya !== yb) {
  2106        var i = s.push("translate(", null, pxComma, null, pxParen);
  2107        q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)});
  2108      } else if (xb || yb) {
  2109        s.push("translate(" + xb + pxComma + yb + pxParen);
  2110      }
  2111    }
  2112  
  2113    function rotate(a, b, s, q) {
  2114      if (a !== b) {
  2115        if (a - b > 180) b += 360; else if (b - a > 180) a += 360; // shortest path
  2116        q.push({i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: interpolateNumber(a, b)});
  2117      } else if (b) {
  2118        s.push(pop(s) + "rotate(" + b + degParen);
  2119      }
  2120    }
  2121  
  2122    function skewX(a, b, s, q) {
  2123      if (a !== b) {
  2124        q.push({i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: interpolateNumber(a, b)});
  2125      } else if (b) {
  2126        s.push(pop(s) + "skewX(" + b + degParen);
  2127      }
  2128    }
  2129  
  2130    function scale(xa, ya, xb, yb, s, q) {
  2131      if (xa !== xb || ya !== yb) {
  2132        var i = s.push(pop(s) + "scale(", null, ",", null, ")");
  2133        q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)});
  2134      } else if (xb !== 1 || yb !== 1) {
  2135        s.push(pop(s) + "scale(" + xb + "," + yb + ")");
  2136      }
  2137    }
  2138  
  2139    return function(a, b) {
  2140      var s = [], // string constants and placeholders
  2141          q = []; // number interpolators
  2142      a = parse(a), b = parse(b);
  2143      translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
  2144      rotate(a.rotate, b.rotate, s, q);
  2145      skewX(a.skewX, b.skewX, s, q);
  2146      scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
  2147      a = b = null; // gc
  2148      return function(t) {
  2149        var i = -1, n = q.length, o;
  2150        while (++i < n) s[(o = q[i]).i] = o.x(t);
  2151        return s.join("");
  2152      };
  2153    };
  2154  }
  2155  
  2156  var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)");
  2157  var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
  2158  
  2159  var rho = Math.SQRT2;
  2160  
  2161  function cubehelix$1(hue$$1) {
  2162    return (function cubehelixGamma(y) {
  2163      y = +y;
  2164  
  2165      function cubehelix$$1(start, end) {
  2166        var h = hue$$1((start = cubehelix(start)).h, (end = cubehelix(end)).h),
  2167            s = nogamma(start.s, end.s),
  2168            l = nogamma(start.l, end.l),
  2169            opacity = nogamma(start.opacity, end.opacity);
  2170        return function(t) {
  2171          start.h = h(t);
  2172          start.s = s(t);
  2173          start.l = l(Math.pow(t, y));
  2174          start.opacity = opacity(t);
  2175          return start + "";
  2176        };
  2177      }
  2178  
  2179      cubehelix$$1.gamma = cubehelixGamma;
  2180  
  2181      return cubehelix$$1;
  2182    })(1);
  2183  }
  2184  
  2185  cubehelix$1(hue);
  2186  var cubehelixLong = cubehelix$1(nogamma);
  2187  
  2188  var constant$4 = function(x) {
  2189    return function() {
  2190      return x;
  2191    };
  2192  };
  2193  
  2194  var number$1 = function(x) {
  2195    return +x;
  2196  };
  2197  
  2198  var unit = [0, 1];
  2199  
  2200  function deinterpolateLinear(a, b) {
  2201    return (b -= (a = +a))
  2202        ? function(x) { return (x - a) / b; }
  2203        : constant$4(b);
  2204  }
  2205  
  2206  function deinterpolateClamp(deinterpolate) {
  2207    return function(a, b) {
  2208      var d = deinterpolate(a = +a, b = +b);
  2209      return function(x) { return x <= a ? 0 : x >= b ? 1 : d(x); };
  2210    };
  2211  }
  2212  
  2213  function reinterpolateClamp(reinterpolate) {
  2214    return function(a, b) {
  2215      var r = reinterpolate(a = +a, b = +b);
  2216      return function(t) { return t <= 0 ? a : t >= 1 ? b : r(t); };
  2217    };
  2218  }
  2219  
  2220  function bimap(domain, range, deinterpolate, reinterpolate) {
  2221    var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
  2222    if (d1 < d0) d0 = deinterpolate(d1, d0), r0 = reinterpolate(r1, r0);
  2223    else d0 = deinterpolate(d0, d1), r0 = reinterpolate(r0, r1);
  2224    return function(x) { return r0(d0(x)); };
  2225  }
  2226  
  2227  function polymap(domain, range, deinterpolate, reinterpolate) {
  2228    var j = Math.min(domain.length, range.length) - 1,
  2229        d = new Array(j),
  2230        r = new Array(j),
  2231        i = -1;
  2232  
  2233    // Reverse descending domains.
  2234    if (domain[j] < domain[0]) {
  2235      domain = domain.slice().reverse();
  2236      range = range.slice().reverse();
  2237    }
  2238  
  2239    while (++i < j) {
  2240      d[i] = deinterpolate(domain[i], domain[i + 1]);
  2241      r[i] = reinterpolate(range[i], range[i + 1]);
  2242    }
  2243  
  2244    return function(x) {
  2245      var i = bisectRight(domain, x, 1, j) - 1;
  2246      return r[i](d[i](x));
  2247    };
  2248  }
  2249  
  2250  function copy(source, target) {
  2251    return target
  2252        .domain(source.domain())
  2253        .range(source.range())
  2254        .interpolate(source.interpolate())
  2255        .clamp(source.clamp());
  2256  }
  2257  
  2258  // deinterpolate(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
  2259  // reinterpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding domain value x in [a,b].
  2260  function continuous(deinterpolate, reinterpolate) {
  2261    var domain = unit,
  2262        range = unit,
  2263        interpolate$$1 = interpolateValue,
  2264        clamp = false,
  2265        piecewise,
  2266        output,
  2267        input;
  2268  
  2269    function rescale() {
  2270      piecewise = Math.min(domain.length, range.length) > 2 ? polymap : bimap;
  2271      output = input = null;
  2272      return scale;
  2273    }
  2274  
  2275    function scale(x) {
  2276      return (output || (output = piecewise(domain, range, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x);
  2277    }
  2278  
  2279    scale.invert = function(y) {
  2280      return (input || (input = piecewise(range, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate) : reinterpolate)))(+y);
  2281    };
  2282  
  2283    scale.domain = function(_) {
  2284      return arguments.length ? (domain = map$3.call(_, number$1), rescale()) : domain.slice();
  2285    };
  2286  
  2287    scale.range = function(_) {
  2288      return arguments.length ? (range = slice$2.call(_), rescale()) : range.slice();
  2289    };
  2290  
  2291    scale.rangeRound = function(_) {
  2292      return range = slice$2.call(_), interpolate$$1 = interpolateRound, rescale();
  2293    };
  2294  
  2295    scale.clamp = function(_) {
  2296      return arguments.length ? (clamp = !!_, rescale()) : clamp;
  2297    };
  2298  
  2299    scale.interpolate = function(_) {
  2300      return arguments.length ? (interpolate$$1 = _, rescale()) : interpolate$$1;
  2301    };
  2302  
  2303    return rescale();
  2304  }
  2305  
  2306  // Computes the decimal coefficient and exponent of the specified number x with
  2307  // significant digits p, where x is positive and p is in [1, 21] or undefined.
  2308  // For example, formatDecimal(1.23) returns ["123", 0].
  2309  var formatDecimal = function(x, p) {
  2310    if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity
  2311    var i, coefficient = x.slice(0, i);
  2312  
  2313    // The string returned by toExponential either has the form \d\.\d+e[-+]\d+
  2314    // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3).
  2315    return [
  2316      coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
  2317      +x.slice(i + 1)
  2318    ];
  2319  };
  2320  
  2321  var exponent = function(x) {
  2322    return x = formatDecimal(Math.abs(x)), x ? x[1] : NaN;
  2323  };
  2324  
  2325  var formatGroup = function(grouping, thousands) {
  2326    return function(value, width) {
  2327      var i = value.length,
  2328          t = [],
  2329          j = 0,
  2330          g = grouping[0],
  2331          length = 0;
  2332  
  2333      while (i > 0 && g > 0) {
  2334        if (length + g + 1 > width) g = Math.max(1, width - length);
  2335        t.push(value.substring(i -= g, i + g));
  2336        if ((length += g + 1) > width) break;
  2337        g = grouping[j = (j + 1) % grouping.length];
  2338      }
  2339  
  2340      return t.reverse().join(thousands);
  2341    };
  2342  };
  2343  
  2344  var formatNumerals = function(numerals) {
  2345    return function(value) {
  2346      return value.replace(/[0-9]/g, function(i) {
  2347        return numerals[+i];
  2348      });
  2349    };
  2350  };
  2351  
  2352  var formatDefault = function(x, p) {
  2353    x = x.toPrecision(p);
  2354  
  2355    out: for (var n = x.length, i = 1, i0 = -1, i1; i < n; ++i) {
  2356      switch (x[i]) {
  2357        case ".": i0 = i1 = i; break;
  2358        case "0": if (i0 === 0) i0 = i; i1 = i; break;
  2359        case "e": break out;
  2360        default: if (i0 > 0) i0 = 0; break;
  2361      }
  2362    }
  2363  
  2364    return i0 > 0 ? x.slice(0, i0) + x.slice(i1 + 1) : x;
  2365  };
  2366  
  2367  var prefixExponent;
  2368  
  2369  var formatPrefixAuto = function(x, p) {
  2370    var d = formatDecimal(x, p);
  2371    if (!d) return x + "";
  2372    var coefficient = d[0],
  2373        exponent = d[1],
  2374        i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
  2375        n = coefficient.length;
  2376    return i === n ? coefficient
  2377        : i > n ? coefficient + new Array(i - n + 1).join("0")
  2378        : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
  2379        : "0." + new Array(1 - i).join("0") + formatDecimal(x, Math.max(0, p + i - 1))[0]; // less than 1y!
  2380  };
  2381  
  2382  var formatRounded = function(x, p) {
  2383    var d = formatDecimal(x, p);
  2384    if (!d) return x + "";
  2385    var coefficient = d[0],
  2386        exponent = d[1];
  2387    return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
  2388        : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
  2389        : coefficient + new Array(exponent - coefficient.length + 2).join("0");
  2390  };
  2391  
  2392  var formatTypes = {
  2393    "": formatDefault,
  2394    "%": function(x, p) { return (x * 100).toFixed(p); },
  2395    "b": function(x) { return Math.round(x).toString(2); },
  2396    "c": function(x) { return x + ""; },
  2397    "d": function(x) { return Math.round(x).toString(10); },
  2398    "e": function(x, p) { return x.toExponential(p); },
  2399    "f": function(x, p) { return x.toFixed(p); },
  2400    "g": function(x, p) { return x.toPrecision(p); },
  2401    "o": function(x) { return Math.round(x).toString(8); },
  2402    "p": function(x, p) { return formatRounded(x * 100, p); },
  2403    "r": formatRounded,
  2404    "s": formatPrefixAuto,
  2405    "X": function(x) { return Math.round(x).toString(16).toUpperCase(); },
  2406    "x": function(x) { return Math.round(x).toString(16); }
  2407  };
  2408  
  2409  // [[fill]align][sign][symbol][0][width][,][.precision][type]
  2410  var re = /^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;
  2411  
  2412  function formatSpecifier(specifier) {
  2413    return new FormatSpecifier(specifier);
  2414  }
  2415  
  2416  formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
  2417  
  2418  function FormatSpecifier(specifier) {
  2419    if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
  2420  
  2421    var match,
  2422        fill = match[1] || " ",
  2423        align = match[2] || ">",
  2424        sign = match[3] || "-",
  2425        symbol = match[4] || "",
  2426        zero = !!match[5],
  2427        width = match[6] && +match[6],
  2428        comma = !!match[7],
  2429        precision = match[8] && +match[8].slice(1),
  2430        type = match[9] || "";
  2431  
  2432    // The "n" type is an alias for ",g".
  2433    if (type === "n") comma = true, type = "g";
  2434  
  2435    // Map invalid types to the default format.
  2436    else if (!formatTypes[type]) type = "";
  2437  
  2438    // If zero fill is specified, padding goes after sign and before digits.
  2439    if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "=";
  2440  
  2441    this.fill = fill;
  2442    this.align = align;
  2443    this.sign = sign;
  2444    this.symbol = symbol;
  2445    this.zero = zero;
  2446    this.width = width;
  2447    this.comma = comma;
  2448    this.precision = precision;
  2449    this.type = type;
  2450  }
  2451  
  2452  FormatSpecifier.prototype.toString = function() {
  2453    return this.fill
  2454        + this.align
  2455        + this.sign
  2456        + this.symbol
  2457        + (this.zero ? "0" : "")
  2458        + (this.width == null ? "" : Math.max(1, this.width | 0))
  2459        + (this.comma ? "," : "")
  2460        + (this.precision == null ? "" : "." + Math.max(0, this.precision | 0))
  2461        + this.type;
  2462  };
  2463  
  2464  var identity$3 = function(x) {
  2465    return x;
  2466  };
  2467  
  2468  var prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
  2469  
  2470  var formatLocale = function(locale) {
  2471    var group = locale.grouping && locale.thousands ? formatGroup(locale.grouping, locale.thousands) : identity$3,
  2472        currency = locale.currency,
  2473        decimal = locale.decimal,
  2474        numerals = locale.numerals ? formatNumerals(locale.numerals) : identity$3,
  2475        percent = locale.percent || "%";
  2476  
  2477    function newFormat(specifier) {
  2478      specifier = formatSpecifier(specifier);
  2479  
  2480      var fill = specifier.fill,
  2481          align = specifier.align,
  2482          sign = specifier.sign,
  2483          symbol = specifier.symbol,
  2484          zero = specifier.zero,
  2485          width = specifier.width,
  2486          comma = specifier.comma,
  2487          precision = specifier.precision,
  2488          type = specifier.type;
  2489  
  2490      // Compute the prefix and suffix.
  2491      // For SI-prefix, the suffix is lazily computed.
  2492      var prefix = symbol === "$" ? currency[0] : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
  2493          suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? percent : "";
  2494  
  2495      // What format function should we use?
  2496      // Is this an integer type?
  2497      // Can this type generate exponential notation?
  2498      var formatType = formatTypes[type],
  2499          maybeSuffix = !type || /[defgprs%]/.test(type);
  2500  
  2501      // Set the default precision if not specified,
  2502      // or clamp the specified precision to the supported range.
  2503      // For significant precision, it must be in [1, 21].
  2504      // For fixed precision, it must be in [0, 20].
  2505      precision = precision == null ? (type ? 6 : 12)
  2506          : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision))
  2507          : Math.max(0, Math.min(20, precision));
  2508  
  2509      function format(value) {
  2510        var valuePrefix = prefix,
  2511            valueSuffix = suffix,
  2512            i, n, c;
  2513  
  2514        if (type === "c") {
  2515          valueSuffix = formatType(value) + valueSuffix;
  2516          value = "";
  2517        } else {
  2518          value = +value;
  2519  
  2520          // Perform the initial formatting.
  2521          var valueNegative = value < 0;
  2522          value = formatType(Math.abs(value), precision);
  2523  
  2524          // If a negative value rounds to zero during formatting, treat as positive.
  2525          if (valueNegative && +value === 0) valueNegative = false;
  2526  
  2527          // Compute the prefix and suffix.
  2528          valuePrefix = (valueNegative ? (sign === "(" ? sign : "-") : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
  2529          valueSuffix = valueSuffix + (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + (valueNegative && sign === "(" ? ")" : "");
  2530  
  2531          // Break the formatted value into the integer “value” part that can be
  2532          // grouped, and fractional or exponential “suffix” part that is not.
  2533          if (maybeSuffix) {
  2534            i = -1, n = value.length;
  2535            while (++i < n) {
  2536              if (c = value.charCodeAt(i), 48 > c || c > 57) {
  2537                valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
  2538                value = value.slice(0, i);
  2539                break;
  2540              }
  2541            }
  2542          }
  2543        }
  2544  
  2545        // If the fill character is not "0", grouping is applied before padding.
  2546        if (comma && !zero) value = group(value, Infinity);
  2547  
  2548        // Compute the padding.
  2549        var length = valuePrefix.length + value.length + valueSuffix.length,
  2550            padding = length < width ? new Array(width - length + 1).join(fill) : "";
  2551  
  2552        // If the fill character is "0", grouping is applied after padding.
  2553        if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
  2554  
  2555        // Reconstruct the final output based on the desired alignment.
  2556        switch (align) {
  2557          case "<": value = valuePrefix + value + valueSuffix + padding; break;
  2558          case "=": value = valuePrefix + padding + value + valueSuffix; break;
  2559          case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break;
  2560          default: value = padding + valuePrefix + value + valueSuffix; break;
  2561        }
  2562  
  2563        return numerals(value);
  2564      }
  2565  
  2566      format.toString = function() {
  2567        return specifier + "";
  2568      };
  2569  
  2570      return format;
  2571    }
  2572  
  2573    function formatPrefix(specifier, value) {
  2574      var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)),
  2575          e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3,
  2576          k = Math.pow(10, -e),
  2577          prefix = prefixes[8 + e / 3];
  2578      return function(value) {
  2579        return f(k * value) + prefix;
  2580      };
  2581    }
  2582  
  2583    return {
  2584      format: newFormat,
  2585      formatPrefix: formatPrefix
  2586    };
  2587  };
  2588  
  2589  var locale;
  2590  
  2591  var formatPrefix;
  2592  
  2593  defaultLocale({
  2594    decimal: ".",
  2595    thousands: ",",
  2596    grouping: [3],
  2597    currency: ["$", ""]
  2598  });
  2599  
  2600  function defaultLocale(definition) {
  2601    locale = formatLocale(definition);
  2602    exports.format = locale.format;
  2603    formatPrefix = locale.formatPrefix;
  2604    return locale;
  2605  }
  2606  
  2607  var precisionFixed = function(step) {
  2608    return Math.max(0, -exponent(Math.abs(step)));
  2609  };
  2610  
  2611  var precisionPrefix = function(step, value) {
  2612    return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step)));
  2613  };
  2614  
  2615  var precisionRound = function(step, max) {
  2616    step = Math.abs(step), max = Math.abs(max) - step;
  2617    return Math.max(0, exponent(max) - exponent(step)) + 1;
  2618  };
  2619  
  2620  var tickFormat = function(domain, count, specifier) {
  2621    var start = domain[0],
  2622        stop = domain[domain.length - 1],
  2623        step = tickStep(start, stop, count == null ? 10 : count),
  2624        precision;
  2625    specifier = formatSpecifier(specifier == null ? ",f" : specifier);
  2626    switch (specifier.type) {
  2627      case "s": {
  2628        var value = Math.max(Math.abs(start), Math.abs(stop));
  2629        if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
  2630        return formatPrefix(specifier, value);
  2631      }
  2632      case "":
  2633      case "e":
  2634      case "g":
  2635      case "p":
  2636      case "r": {
  2637        if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
  2638        break;
  2639      }
  2640      case "f":
  2641      case "%": {
  2642        if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
  2643        break;
  2644      }
  2645    }
  2646    return exports.format(specifier);
  2647  };
  2648  
  2649  function linearish(scale) {
  2650    var domain = scale.domain;
  2651  
  2652    scale.ticks = function(count) {
  2653      var d = domain();
  2654      return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
  2655    };
  2656  
  2657    scale.tickFormat = function(count, specifier) {
  2658      return tickFormat(domain(), count, specifier);
  2659    };
  2660  
  2661    scale.nice = function(count) {
  2662      if (count == null) count = 10;
  2663  
  2664      var d = domain(),
  2665          i0 = 0,
  2666          i1 = d.length - 1,
  2667          start = d[i0],
  2668          stop = d[i1],
  2669          step;
  2670  
  2671      if (stop < start) {
  2672        step = start, start = stop, stop = step;
  2673        step = i0, i0 = i1, i1 = step;
  2674      }
  2675  
  2676      step = tickIncrement(start, stop, count);
  2677  
  2678      if (step > 0) {
  2679        start = Math.floor(start / step) * step;
  2680        stop = Math.ceil(stop / step) * step;
  2681        step = tickIncrement(start, stop, count);
  2682      } else if (step < 0) {
  2683        start = Math.ceil(start * step) / step;
  2684        stop = Math.floor(stop * step) / step;
  2685        step = tickIncrement(start, stop, count);
  2686      }
  2687  
  2688      if (step > 0) {
  2689        d[i0] = Math.floor(start / step) * step;
  2690        d[i1] = Math.ceil(stop / step) * step;
  2691        domain(d);
  2692      } else if (step < 0) {
  2693        d[i0] = Math.ceil(start * step) / step;
  2694        d[i1] = Math.floor(stop * step) / step;
  2695        domain(d);
  2696      }
  2697  
  2698      return scale;
  2699    };
  2700  
  2701    return scale;
  2702  }
  2703  
  2704  function linear() {
  2705    var scale = continuous(deinterpolateLinear, interpolateNumber);
  2706  
  2707    scale.copy = function() {
  2708      return copy(scale, linear());
  2709    };
  2710  
  2711    return linearish(scale);
  2712  }
  2713  
  2714  var t0$1 = new Date;
  2715  var t1$1 = new Date;
  2716  
  2717  function newInterval(floori, offseti, count, field) {
  2718  
  2719    function interval(date) {
  2720      return floori(date = new Date(+date)), date;
  2721    }
  2722  
  2723    interval.floor = interval;
  2724  
  2725    interval.ceil = function(date) {
  2726      return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date;
  2727    };
  2728  
  2729    interval.round = function(date) {
  2730      var d0 = interval(date),
  2731          d1 = interval.ceil(date);
  2732      return date - d0 < d1 - date ? d0 : d1;
  2733    };
  2734  
  2735    interval.offset = function(date, step) {
  2736      return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date;
  2737    };
  2738  
  2739    interval.range = function(start, stop, step) {
  2740      var range = [];
  2741      start = interval.ceil(start);
  2742      step = step == null ? 1 : Math.floor(step);
  2743      if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date
  2744      do range.push(new Date(+start)); while (offseti(start, step), floori(start), start < stop)
  2745      return range;
  2746    };
  2747  
  2748    interval.filter = function(test) {
  2749      return newInterval(function(date) {
  2750        if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1);
  2751      }, function(date, step) {
  2752        if (date >= date) {
  2753          if (step < 0) while (++step <= 0) {
  2754            while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty
  2755          } else while (--step >= 0) {
  2756            while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty
  2757          }
  2758        }
  2759      });
  2760    };
  2761  
  2762    if (count) {
  2763      interval.count = function(start, end) {
  2764        t0$1.setTime(+start), t1$1.setTime(+end);
  2765        floori(t0$1), floori(t1$1);
  2766        return Math.floor(count(t0$1, t1$1));
  2767      };
  2768  
  2769      interval.every = function(step) {
  2770        step = Math.floor(step);
  2771        return !isFinite(step) || !(step > 0) ? null
  2772            : !(step > 1) ? interval
  2773            : interval.filter(field
  2774                ? function(d) { return field(d) % step === 0; }
  2775                : function(d) { return interval.count(0, d) % step === 0; });
  2776      };
  2777    }
  2778  
  2779    return interval;
  2780  }
  2781  
  2782  var millisecond = newInterval(function() {
  2783    // noop
  2784  }, function(date, step) {
  2785    date.setTime(+date + step);
  2786  }, function(start, end) {
  2787    return end - start;
  2788  });
  2789  
  2790  // An optimized implementation for this simple case.
  2791  millisecond.every = function(k) {
  2792    k = Math.floor(k);
  2793    if (!isFinite(k) || !(k > 0)) return null;
  2794    if (!(k > 1)) return millisecond;
  2795    return newInterval(function(date) {
  2796      date.setTime(Math.floor(date / k) * k);
  2797    }, function(date, step) {
  2798      date.setTime(+date + step * k);
  2799    }, function(start, end) {
  2800      return (end - start) / k;
  2801    });
  2802  };
  2803  
  2804  var durationSecond$1 = 1e3;
  2805  var durationMinute$1 = 6e4;
  2806  var durationHour$1 = 36e5;
  2807  var durationDay$1 = 864e5;
  2808  var durationWeek$1 = 6048e5;
  2809  
  2810  var second = newInterval(function(date) {
  2811    date.setTime(Math.floor(date / durationSecond$1) * durationSecond$1);
  2812  }, function(date, step) {
  2813    date.setTime(+date + step * durationSecond$1);
  2814  }, function(start, end) {
  2815    return (end - start) / durationSecond$1;
  2816  }, function(date) {
  2817    return date.getUTCSeconds();
  2818  });
  2819  
  2820  var minute = newInterval(function(date) {
  2821    date.setTime(Math.floor(date / durationMinute$1) * durationMinute$1);
  2822  }, function(date, step) {
  2823    date.setTime(+date + step * durationMinute$1);
  2824  }, function(start, end) {
  2825    return (end - start) / durationMinute$1;
  2826  }, function(date) {
  2827    return date.getMinutes();
  2828  });
  2829  
  2830  var hour = newInterval(function(date) {
  2831    var offset = date.getTimezoneOffset() * durationMinute$1 % durationHour$1;
  2832    if (offset < 0) offset += durationHour$1;
  2833    date.setTime(Math.floor((+date - offset) / durationHour$1) * durationHour$1 + offset);
  2834  }, function(date, step) {
  2835    date.setTime(+date + step * durationHour$1);
  2836  }, function(start, end) {
  2837    return (end - start) / durationHour$1;
  2838  }, function(date) {
  2839    return date.getHours();
  2840  });
  2841  
  2842  var day = newInterval(function(date) {
  2843    date.setHours(0, 0, 0, 0);
  2844  }, function(date, step) {
  2845    date.setDate(date.getDate() + step);
  2846  }, function(start, end) {
  2847    return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute$1) / durationDay$1;
  2848  }, function(date) {
  2849    return date.getDate() - 1;
  2850  });
  2851  
  2852  function weekday(i) {
  2853    return newInterval(function(date) {
  2854      date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
  2855      date.setHours(0, 0, 0, 0);
  2856    }, function(date, step) {
  2857      date.setDate(date.getDate() + step * 7);
  2858    }, function(start, end) {
  2859      return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute$1) / durationWeek$1;
  2860    });
  2861  }
  2862  
  2863  var sunday = weekday(0);
  2864  var monday = weekday(1);
  2865  var tuesday = weekday(2);
  2866  var wednesday = weekday(3);
  2867  var thursday = weekday(4);
  2868  var friday = weekday(5);
  2869  var saturday = weekday(6);
  2870  
  2871  var month = newInterval(function(date) {
  2872    date.setDate(1);
  2873    date.setHours(0, 0, 0, 0);
  2874  }, function(date, step) {
  2875    date.setMonth(date.getMonth() + step);
  2876  }, function(start, end) {
  2877    return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
  2878  }, function(date) {
  2879    return date.getMonth();
  2880  });
  2881  
  2882  var year = newInterval(function(date) {
  2883    date.setMonth(0, 1);
  2884    date.setHours(0, 0, 0, 0);
  2885  }, function(date, step) {
  2886    date.setFullYear(date.getFullYear() + step);
  2887  }, function(start, end) {
  2888    return end.getFullYear() - start.getFullYear();
  2889  }, function(date) {
  2890    return date.getFullYear();
  2891  });
  2892  
  2893  // An optimized implementation for this simple case.
  2894  year.every = function(k) {
  2895    return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
  2896      date.setFullYear(Math.floor(date.getFullYear() / k) * k);
  2897      date.setMonth(0, 1);
  2898      date.setHours(0, 0, 0, 0);
  2899    }, function(date, step) {
  2900      date.setFullYear(date.getFullYear() + step * k);
  2901    });
  2902  };
  2903  
  2904  var utcMinute = newInterval(function(date) {
  2905    date.setUTCSeconds(0, 0);
  2906  }, function(date, step) {
  2907    date.setTime(+date + step * durationMinute$1);
  2908  }, function(start, end) {
  2909    return (end - start) / durationMinute$1;
  2910  }, function(date) {
  2911    return date.getUTCMinutes();
  2912  });
  2913  
  2914  var utcHour = newInterval(function(date) {
  2915    date.setUTCMinutes(0, 0, 0);
  2916  }, function(date, step) {
  2917    date.setTime(+date + step * durationHour$1);
  2918  }, function(start, end) {
  2919    return (end - start) / durationHour$1;
  2920  }, function(date) {
  2921    return date.getUTCHours();
  2922  });
  2923  
  2924  var utcDay = newInterval(function(date) {
  2925    date.setUTCHours(0, 0, 0, 0);
  2926  }, function(date, step) {
  2927    date.setUTCDate(date.getUTCDate() + step);
  2928  }, function(start, end) {
  2929    return (end - start) / durationDay$1;
  2930  }, function(date) {
  2931    return date.getUTCDate() - 1;
  2932  });
  2933  
  2934  function utcWeekday(i) {
  2935    return newInterval(function(date) {
  2936      date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7);
  2937      date.setUTCHours(0, 0, 0, 0);
  2938    }, function(date, step) {
  2939      date.setUTCDate(date.getUTCDate() + step * 7);
  2940    }, function(start, end) {
  2941      return (end - start) / durationWeek$1;
  2942    });
  2943  }
  2944  
  2945  var utcSunday = utcWeekday(0);
  2946  var utcMonday = utcWeekday(1);
  2947  var utcTuesday = utcWeekday(2);
  2948  var utcWednesday = utcWeekday(3);
  2949  var utcThursday = utcWeekday(4);
  2950  var utcFriday = utcWeekday(5);
  2951  var utcSaturday = utcWeekday(6);
  2952  
  2953  var utcMonth = newInterval(function(date) {
  2954    date.setUTCDate(1);
  2955    date.setUTCHours(0, 0, 0, 0);
  2956  }, function(date, step) {
  2957    date.setUTCMonth(date.getUTCMonth() + step);
  2958  }, function(start, end) {
  2959    return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
  2960  }, function(date) {
  2961    return date.getUTCMonth();
  2962  });
  2963  
  2964  var utcYear = newInterval(function(date) {
  2965    date.setUTCMonth(0, 1);
  2966    date.setUTCHours(0, 0, 0, 0);
  2967  }, function(date, step) {
  2968    date.setUTCFullYear(date.getUTCFullYear() + step);
  2969  }, function(start, end) {
  2970    return end.getUTCFullYear() - start.getUTCFullYear();
  2971  }, function(date) {
  2972    return date.getUTCFullYear();
  2973  });
  2974  
  2975  // An optimized implementation for this simple case.
  2976  utcYear.every = function(k) {
  2977    return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) {
  2978      date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k);
  2979      date.setUTCMonth(0, 1);
  2980      date.setUTCHours(0, 0, 0, 0);
  2981    }, function(date, step) {
  2982      date.setUTCFullYear(date.getUTCFullYear() + step * k);
  2983    });
  2984  };
  2985  
  2986  function localDate(d) {
  2987    if (0 <= d.y && d.y < 100) {
  2988      var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L);
  2989      date.setFullYear(d.y);
  2990      return date;
  2991    }
  2992    return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L);
  2993  }
  2994  
  2995  function utcDate(d) {
  2996    if (0 <= d.y && d.y < 100) {
  2997      var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L));
  2998      date.setUTCFullYear(d.y);
  2999      return date;
  3000    }
  3001    return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L));
  3002  }
  3003  
  3004  function newYear(y) {
  3005    return {y: y, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0};
  3006  }
  3007  
  3008  function formatLocale$1(locale) {
  3009    var locale_dateTime = locale.dateTime,
  3010        locale_date = locale.date,
  3011        locale_time = locale.time,
  3012        locale_periods = locale.periods,
  3013        locale_weekdays = locale.days,
  3014        locale_shortWeekdays = locale.shortDays,
  3015        locale_months = locale.months,
  3016        locale_shortMonths = locale.shortMonths;
  3017  
  3018    var periodRe = formatRe(locale_periods),
  3019        periodLookup = formatLookup(locale_periods),
  3020        weekdayRe = formatRe(locale_weekdays),
  3021        weekdayLookup = formatLookup(locale_weekdays),
  3022        shortWeekdayRe = formatRe(locale_shortWeekdays),
  3023        shortWeekdayLookup = formatLookup(locale_shortWeekdays),
  3024        monthRe = formatRe(locale_months),
  3025        monthLookup = formatLookup(locale_months),
  3026        shortMonthRe = formatRe(locale_shortMonths),
  3027        shortMonthLookup = formatLookup(locale_shortMonths);
  3028  
  3029    var formats = {
  3030      "a": formatShortWeekday,
  3031      "A": formatWeekday,
  3032      "b": formatShortMonth,
  3033      "B": formatMonth,
  3034      "c": null,
  3035      "d": formatDayOfMonth,
  3036      "e": formatDayOfMonth,
  3037      "f": formatMicroseconds,
  3038      "H": formatHour24,
  3039      "I": formatHour12,
  3040      "j": formatDayOfYear,
  3041      "L": formatMilliseconds,
  3042      "m": formatMonthNumber,
  3043      "M": formatMinutes,
  3044      "p": formatPeriod,
  3045      "Q": formatUnixTimestamp,
  3046      "s": formatUnixTimestampSeconds,
  3047      "S": formatSeconds,
  3048      "u": formatWeekdayNumberMonday,
  3049      "U": formatWeekNumberSunday,
  3050      "V": formatWeekNumberISO,
  3051      "w": formatWeekdayNumberSunday,
  3052      "W": formatWeekNumberMonday,
  3053      "x": null,
  3054      "X": null,
  3055      "y": formatYear,
  3056      "Y": formatFullYear,
  3057      "Z": formatZone,
  3058      "%": formatLiteralPercent
  3059    };
  3060  
  3061    var utcFormats = {
  3062      "a": formatUTCShortWeekday,
  3063      "A": formatUTCWeekday,
  3064      "b": formatUTCShortMonth,
  3065      "B": formatUTCMonth,
  3066      "c": null,
  3067      "d": formatUTCDayOfMonth,
  3068      "e": formatUTCDayOfMonth,
  3069      "f": formatUTCMicroseconds,
  3070      "H": formatUTCHour24,
  3071      "I": formatUTCHour12,
  3072      "j": formatUTCDayOfYear,
  3073      "L": formatUTCMilliseconds,
  3074      "m": formatUTCMonthNumber,
  3075      "M": formatUTCMinutes,
  3076      "p": formatUTCPeriod,
  3077      "Q": formatUnixTimestamp,
  3078      "s": formatUnixTimestampSeconds,
  3079      "S": formatUTCSeconds,
  3080      "u": formatUTCWeekdayNumberMonday,
  3081      "U": formatUTCWeekNumberSunday,
  3082      "V": formatUTCWeekNumberISO,
  3083      "w": formatUTCWeekdayNumberSunday,
  3084      "W": formatUTCWeekNumberMonday,
  3085      "x": null,
  3086      "X": null,
  3087      "y": formatUTCYear,
  3088      "Y": formatUTCFullYear,
  3089      "Z": formatUTCZone,
  3090      "%": formatLiteralPercent
  3091    };
  3092  
  3093    var parses = {
  3094      "a": parseShortWeekday,
  3095      "A": parseWeekday,
  3096      "b": parseShortMonth,
  3097      "B": parseMonth,
  3098      "c": parseLocaleDateTime,
  3099      "d": parseDayOfMonth,
  3100      "e": parseDayOfMonth,
  3101      "f": parseMicroseconds,
  3102      "H": parseHour24,
  3103      "I": parseHour24,
  3104      "j": parseDayOfYear,
  3105      "L": parseMilliseconds,
  3106      "m": parseMonthNumber,
  3107      "M": parseMinutes,
  3108      "p": parsePeriod,
  3109      "Q": parseUnixTimestamp,
  3110      "s": parseUnixTimestampSeconds,
  3111      "S": parseSeconds,
  3112      "u": parseWeekdayNumberMonday,
  3113      "U": parseWeekNumberSunday,
  3114      "V": parseWeekNumberISO,
  3115      "w": parseWeekdayNumberSunday,
  3116      "W": parseWeekNumberMonday,
  3117      "x": parseLocaleDate,
  3118      "X": parseLocaleTime,
  3119      "y": parseYear,
  3120      "Y": parseFullYear,
  3121      "Z": parseZone,
  3122      "%": parseLiteralPercent
  3123    };
  3124  
  3125    // These recursive directive definitions must be deferred.
  3126    formats.x = newFormat(locale_date, formats);
  3127    formats.X = newFormat(locale_time, formats);
  3128    formats.c = newFormat(locale_dateTime, formats);
  3129    utcFormats.x = newFormat(locale_date, utcFormats);
  3130    utcFormats.X = newFormat(locale_time, utcFormats);
  3131    utcFormats.c = newFormat(locale_dateTime, utcFormats);
  3132  
  3133    function newFormat(specifier, formats) {
  3134      return function(date) {
  3135        var string = [],
  3136            i = -1,
  3137            j = 0,
  3138            n = specifier.length,
  3139            c,
  3140            pad,
  3141            format;
  3142  
  3143        if (!(date instanceof Date)) date = new Date(+date);
  3144  
  3145        while (++i < n) {
  3146          if (specifier.charCodeAt(i) === 37) {
  3147            string.push(specifier.slice(j, i));
  3148            if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i);
  3149            else pad = c === "e" ? " " : "0";
  3150            if (format = formats[c]) c = format(date, pad);
  3151            string.push(c);
  3152            j = i + 1;
  3153          }
  3154        }
  3155  
  3156        string.push(specifier.slice(j, i));
  3157        return string.join("");
  3158      };
  3159    }
  3160  
  3161    function newParse(specifier, newDate) {
  3162      return function(string) {
  3163        var d = newYear(1900),
  3164            i = parseSpecifier(d, specifier, string += "", 0),
  3165            week, day$$1;
  3166        if (i != string.length) return null;
  3167  
  3168        // If a UNIX timestamp is specified, return it.
  3169        if ("Q" in d) return new Date(d.Q);
  3170  
  3171        // The am-pm flag is 0 for AM, and 1 for PM.
  3172        if ("p" in d) d.H = d.H % 12 + d.p * 12;
  3173  
  3174        // Convert day-of-week and week-of-year to day-of-year.
  3175        if ("V" in d) {
  3176          if (d.V < 1 || d.V > 53) return null;
  3177          if (!("w" in d)) d.w = 1;
  3178          if ("Z" in d) {
  3179            week = utcDate(newYear(d.y)), day$$1 = week.getUTCDay();
  3180            week = day$$1 > 4 || day$$1 === 0 ? utcMonday.ceil(week) : utcMonday(week);
  3181            week = utcDay.offset(week, (d.V - 1) * 7);
  3182            d.y = week.getUTCFullYear();
  3183            d.m = week.getUTCMonth();
  3184            d.d = week.getUTCDate() + (d.w + 6) % 7;
  3185          } else {
  3186            week = newDate(newYear(d.y)), day$$1 = week.getDay();
  3187            week = day$$1 > 4 || day$$1 === 0 ? monday.ceil(week) : monday(week);
  3188            week = day.offset(week, (d.V - 1) * 7);
  3189            d.y = week.getFullYear();
  3190            d.m = week.getMonth();
  3191            d.d = week.getDate() + (d.w + 6) % 7;
  3192          }
  3193        } else if ("W" in d || "U" in d) {
  3194          if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0;
  3195          day$$1 = "Z" in d ? utcDate(newYear(d.y)).getUTCDay() : newDate(newYear(d.y)).getDay();
  3196          d.m = 0;
  3197          d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day$$1 + 5) % 7 : d.w + d.U * 7 - (day$$1 + 6) % 7;
  3198        }
  3199  
  3200        // If a time zone is specified, all fields are interpreted as UTC and then
  3201        // offset according to the specified time zone.
  3202        if ("Z" in d) {
  3203          d.H += d.Z / 100 | 0;
  3204          d.M += d.Z % 100;
  3205          return utcDate(d);
  3206        }
  3207  
  3208        // Otherwise, all fields are in local time.
  3209        return newDate(d);
  3210      };
  3211    }
  3212  
  3213    function parseSpecifier(d, specifier, string, j) {
  3214      var i = 0,
  3215          n = specifier.length,
  3216          m = string.length,
  3217          c,
  3218          parse;
  3219  
  3220      while (i < n) {
  3221        if (j >= m) return -1;
  3222        c = specifier.charCodeAt(i++);
  3223        if (c === 37) {
  3224          c = specifier.charAt(i++);
  3225          parse = parses[c in pads ? specifier.charAt(i++) : c];
  3226          if (!parse || ((j = parse(d, string, j)) < 0)) return -1;
  3227        } else if (c != string.charCodeAt(j++)) {
  3228          return -1;
  3229        }
  3230      }
  3231  
  3232      return j;
  3233    }
  3234  
  3235    function parsePeriod(d, string, i) {
  3236      var n = periodRe.exec(string.slice(i));
  3237      return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1;
  3238    }
  3239  
  3240    function parseShortWeekday(d, string, i) {
  3241      var n = shortWeekdayRe.exec(string.slice(i));
  3242      return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
  3243    }
  3244  
  3245    function parseWeekday(d, string, i) {
  3246      var n = weekdayRe.exec(string.slice(i));
  3247      return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
  3248    }
  3249  
  3250    function parseShortMonth(d, string, i) {
  3251      var n = shortMonthRe.exec(string.slice(i));
  3252      return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
  3253    }
  3254  
  3255    function parseMonth(d, string, i) {
  3256      var n = monthRe.exec(string.slice(i));
  3257      return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
  3258    }
  3259  
  3260    function parseLocaleDateTime(d, string, i) {
  3261      return parseSpecifier(d, locale_dateTime, string, i);
  3262    }
  3263  
  3264    function parseLocaleDate(d, string, i) {
  3265      return parseSpecifier(d, locale_date, string, i);
  3266    }
  3267  
  3268    function parseLocaleTime(d, string, i) {
  3269      return parseSpecifier(d, locale_time, string, i);
  3270    }
  3271  
  3272    function formatShortWeekday(d) {
  3273      return locale_shortWeekdays[d.getDay()];
  3274    }
  3275  
  3276    function formatWeekday(d) {
  3277      return locale_weekdays[d.getDay()];
  3278    }
  3279  
  3280    function formatShortMonth(d) {
  3281      return locale_shortMonths[d.getMonth()];
  3282    }
  3283  
  3284    function formatMonth(d) {
  3285      return locale_months[d.getMonth()];
  3286    }
  3287  
  3288    function formatPeriod(d) {
  3289      return locale_periods[+(d.getHours() >= 12)];
  3290    }
  3291  
  3292    function formatUTCShortWeekday(d) {
  3293      return locale_shortWeekdays[d.getUTCDay()];
  3294    }
  3295  
  3296    function formatUTCWeekday(d) {
  3297      return locale_weekdays[d.getUTCDay()];
  3298    }
  3299  
  3300    function formatUTCShortMonth(d) {
  3301      return locale_shortMonths[d.getUTCMonth()];
  3302    }
  3303  
  3304    function formatUTCMonth(d) {
  3305      return locale_months[d.getUTCMonth()];
  3306    }
  3307  
  3308    function formatUTCPeriod(d) {
  3309      return locale_periods[+(d.getUTCHours() >= 12)];
  3310    }
  3311  
  3312    return {
  3313      format: function(specifier) {
  3314        var f = newFormat(specifier += "", formats);
  3315        f.toString = function() { return specifier; };
  3316        return f;
  3317      },
  3318      parse: function(specifier) {
  3319        var p = newParse(specifier += "", localDate);
  3320        p.toString = function() { return specifier; };
  3321        return p;
  3322      },
  3323      utcFormat: function(specifier) {
  3324        var f = newFormat(specifier += "", utcFormats);
  3325        f.toString = function() { return specifier; };
  3326        return f;
  3327      },
  3328      utcParse: function(specifier) {
  3329        var p = newParse(specifier, utcDate);
  3330        p.toString = function() { return specifier; };
  3331        return p;
  3332      }
  3333    };
  3334  }
  3335  
  3336  var pads = {"-": "", "_": " ", "0": "0"};
  3337  var numberRe = /^\s*\d+/;
  3338  var percentRe = /^%/;
  3339  var requoteRe = /[\\^$*+?|[\]().{}]/g;
  3340  
  3341  function pad(value, fill, width) {
  3342    var sign = value < 0 ? "-" : "",
  3343        string = (sign ? -value : value) + "",
  3344        length = string.length;
  3345    return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);
  3346  }
  3347  
  3348  function requote(s) {
  3349    return s.replace(requoteRe, "\\$&");
  3350  }
  3351  
  3352  function formatRe(names) {
  3353    return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i");
  3354  }
  3355  
  3356  function formatLookup(names) {
  3357    var map = {}, i = -1, n = names.length;
  3358    while (++i < n) map[names[i].toLowerCase()] = i;
  3359    return map;
  3360  }
  3361  
  3362  function parseWeekdayNumberSunday(d, string, i) {
  3363    var n = numberRe.exec(string.slice(i, i + 1));
  3364    return n ? (d.w = +n[0], i + n[0].length) : -1;
  3365  }
  3366  
  3367  function parseWeekdayNumberMonday(d, string, i) {
  3368    var n = numberRe.exec(string.slice(i, i + 1));
  3369    return n ? (d.u = +n[0], i + n[0].length) : -1;
  3370  }
  3371  
  3372  function parseWeekNumberSunday(d, string, i) {
  3373    var n = numberRe.exec(string.slice(i, i + 2));
  3374    return n ? (d.U = +n[0], i + n[0].length) : -1;
  3375  }
  3376  
  3377  function parseWeekNumberISO(d, string, i) {
  3378    var n = numberRe.exec(string.slice(i, i + 2));
  3379    return n ? (d.V = +n[0], i + n[0].length) : -1;
  3380  }
  3381  
  3382  function parseWeekNumberMonday(d, string, i) {
  3383    var n = numberRe.exec(string.slice(i, i + 2));
  3384    return n ? (d.W = +n[0], i + n[0].length) : -1;
  3385  }
  3386  
  3387  function parseFullYear(d, string, i) {
  3388    var n = numberRe.exec(string.slice(i, i + 4));
  3389    return n ? (d.y = +n[0], i + n[0].length) : -1;
  3390  }
  3391  
  3392  function parseYear(d, string, i) {
  3393    var n = numberRe.exec(string.slice(i, i + 2));
  3394    return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1;
  3395  }
  3396  
  3397  function parseZone(d, string, i) {
  3398    var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6));
  3399    return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1;
  3400  }
  3401  
  3402  function parseMonthNumber(d, string, i) {
  3403    var n = numberRe.exec(string.slice(i, i + 2));
  3404    return n ? (d.m = n[0] - 1, i + n[0].length) : -1;
  3405  }
  3406  
  3407  function parseDayOfMonth(d, string, i) {
  3408    var n = numberRe.exec(string.slice(i, i + 2));
  3409    return n ? (d.d = +n[0], i + n[0].length) : -1;
  3410  }
  3411  
  3412  function parseDayOfYear(d, string, i) {
  3413    var n = numberRe.exec(string.slice(i, i + 3));
  3414    return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1;
  3415  }
  3416  
  3417  function parseHour24(d, string, i) {
  3418    var n = numberRe.exec(string.slice(i, i + 2));
  3419    return n ? (d.H = +n[0], i + n[0].length) : -1;
  3420  }
  3421  
  3422  function parseMinutes(d, string, i) {
  3423    var n = numberRe.exec(string.slice(i, i + 2));
  3424    return n ? (d.M = +n[0], i + n[0].length) : -1;
  3425  }
  3426  
  3427  function parseSeconds(d, string, i) {
  3428    var n = numberRe.exec(string.slice(i, i + 2));
  3429    return n ? (d.S = +n[0], i + n[0].length) : -1;
  3430  }
  3431  
  3432  function parseMilliseconds(d, string, i) {
  3433    var n = numberRe.exec(string.slice(i, i + 3));
  3434    return n ? (d.L = +n[0], i + n[0].length) : -1;
  3435  }
  3436  
  3437  function parseMicroseconds(d, string, i) {
  3438    var n = numberRe.exec(string.slice(i, i + 6));
  3439    return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1;
  3440  }
  3441  
  3442  function parseLiteralPercent(d, string, i) {
  3443    var n = percentRe.exec(string.slice(i, i + 1));
  3444    return n ? i + n[0].length : -1;
  3445  }
  3446  
  3447  function parseUnixTimestamp(d, string, i) {
  3448    var n = numberRe.exec(string.slice(i));
  3449    return n ? (d.Q = +n[0], i + n[0].length) : -1;
  3450  }
  3451  
  3452  function parseUnixTimestampSeconds(d, string, i) {
  3453    var n = numberRe.exec(string.slice(i));
  3454    return n ? (d.Q = (+n[0]) * 1000, i + n[0].length) : -1;
  3455  }
  3456  
  3457  function formatDayOfMonth(d, p) {
  3458    return pad(d.getDate(), p, 2);
  3459  }
  3460  
  3461  function formatHour24(d, p) {
  3462    return pad(d.getHours(), p, 2);
  3463  }
  3464  
  3465  function formatHour12(d, p) {
  3466    return pad(d.getHours() % 12 || 12, p, 2);
  3467  }
  3468  
  3469  function formatDayOfYear(d, p) {
  3470    return pad(1 + day.count(year(d), d), p, 3);
  3471  }
  3472  
  3473  function formatMilliseconds(d, p) {
  3474    return pad(d.getMilliseconds(), p, 3);
  3475  }
  3476  
  3477  function formatMicroseconds(d, p) {
  3478    return formatMilliseconds(d, p) + "000";
  3479  }
  3480  
  3481  function formatMonthNumber(d, p) {
  3482    return pad(d.getMonth() + 1, p, 2);
  3483  }
  3484  
  3485  function formatMinutes(d, p) {
  3486    return pad(d.getMinutes(), p, 2);
  3487  }
  3488  
  3489  function formatSeconds(d, p) {
  3490    return pad(d.getSeconds(), p, 2);
  3491  }
  3492  
  3493  function formatWeekdayNumberMonday(d) {
  3494    var day$$1 = d.getDay();
  3495    return day$$1 === 0 ? 7 : day$$1;
  3496  }
  3497  
  3498  function formatWeekNumberSunday(d, p) {
  3499    return pad(sunday.count(year(d), d), p, 2);
  3500  }
  3501  
  3502  function formatWeekNumberISO(d, p) {
  3503    var day$$1 = d.getDay();
  3504    d = (day$$1 >= 4 || day$$1 === 0) ? thursday(d) : thursday.ceil(d);
  3505    return pad(thursday.count(year(d), d) + (year(d).getDay() === 4), p, 2);
  3506  }
  3507  
  3508  function formatWeekdayNumberSunday(d) {
  3509    return d.getDay();
  3510  }
  3511  
  3512  function formatWeekNumberMonday(d, p) {
  3513    return pad(monday.count(year(d), d), p, 2);
  3514  }
  3515  
  3516  function formatYear(d, p) {
  3517    return pad(d.getFullYear() % 100, p, 2);
  3518  }
  3519  
  3520  function formatFullYear(d, p) {
  3521    return pad(d.getFullYear() % 10000, p, 4);
  3522  }
  3523  
  3524  function formatZone(d) {
  3525    var z = d.getTimezoneOffset();
  3526    return (z > 0 ? "-" : (z *= -1, "+"))
  3527        + pad(z / 60 | 0, "0", 2)
  3528        + pad(z % 60, "0", 2);
  3529  }
  3530  
  3531  function formatUTCDayOfMonth(d, p) {
  3532    return pad(d.getUTCDate(), p, 2);
  3533  }
  3534  
  3535  function formatUTCHour24(d, p) {
  3536    return pad(d.getUTCHours(), p, 2);
  3537  }
  3538  
  3539  function formatUTCHour12(d, p) {
  3540    return pad(d.getUTCHours() % 12 || 12, p, 2);
  3541  }
  3542  
  3543  function formatUTCDayOfYear(d, p) {
  3544    return pad(1 + utcDay.count(utcYear(d), d), p, 3);
  3545  }
  3546  
  3547  function formatUTCMilliseconds(d, p) {
  3548    return pad(d.getUTCMilliseconds(), p, 3);
  3549  }
  3550  
  3551  function formatUTCMicroseconds(d, p) {
  3552    return formatUTCMilliseconds(d, p) + "000";
  3553  }
  3554  
  3555  function formatUTCMonthNumber(d, p) {
  3556    return pad(d.getUTCMonth() + 1, p, 2);
  3557  }
  3558  
  3559  function formatUTCMinutes(d, p) {
  3560    return pad(d.getUTCMinutes(), p, 2);
  3561  }
  3562  
  3563  function formatUTCSeconds(d, p) {
  3564    return pad(d.getUTCSeconds(), p, 2);
  3565  }
  3566  
  3567  function formatUTCWeekdayNumberMonday(d) {
  3568    var dow = d.getUTCDay();
  3569    return dow === 0 ? 7 : dow;
  3570  }
  3571  
  3572  function formatUTCWeekNumberSunday(d, p) {
  3573    return pad(utcSunday.count(utcYear(d), d), p, 2);
  3574  }
  3575  
  3576  function formatUTCWeekNumberISO(d, p) {
  3577    var day$$1 = d.getUTCDay();
  3578    d = (day$$1 >= 4 || day$$1 === 0) ? utcThursday(d) : utcThursday.ceil(d);
  3579    return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2);
  3580  }
  3581  
  3582  function formatUTCWeekdayNumberSunday(d) {
  3583    return d.getUTCDay();
  3584  }
  3585  
  3586  function formatUTCWeekNumberMonday(d, p) {
  3587    return pad(utcMonday.count(utcYear(d), d), p, 2);
  3588  }
  3589  
  3590  function formatUTCYear(d, p) {
  3591    return pad(d.getUTCFullYear() % 100, p, 2);
  3592  }
  3593  
  3594  function formatUTCFullYear(d, p) {
  3595    return pad(d.getUTCFullYear() % 10000, p, 4);
  3596  }
  3597  
  3598  function formatUTCZone() {
  3599    return "+0000";
  3600  }
  3601  
  3602  function formatLiteralPercent() {
  3603    return "%";
  3604  }
  3605  
  3606  function formatUnixTimestamp(d) {
  3607    return +d;
  3608  }
  3609  
  3610  function formatUnixTimestampSeconds(d) {
  3611    return Math.floor(+d / 1000);
  3612  }
  3613  
  3614  var locale$1;
  3615  var timeFormat;
  3616  var timeParse;
  3617  var utcFormat;
  3618  var utcParse;
  3619  
  3620  defaultLocale$1({
  3621    dateTime: "%x, %X",
  3622    date: "%-m/%-d/%Y",
  3623    time: "%-I:%M:%S %p",
  3624    periods: ["AM", "PM"],
  3625    days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
  3626    shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  3627    months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  3628    shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  3629  });
  3630  
  3631  function defaultLocale$1(definition) {
  3632    locale$1 = formatLocale$1(definition);
  3633    timeFormat = locale$1.format;
  3634    timeParse = locale$1.parse;
  3635    utcFormat = locale$1.utcFormat;
  3636    utcParse = locale$1.utcParse;
  3637    return locale$1;
  3638  }
  3639  
  3640  var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ";
  3641  
  3642  function formatIsoNative(date) {
  3643    return date.toISOString();
  3644  }
  3645  
  3646  var formatIso = Date.prototype.toISOString
  3647      ? formatIsoNative
  3648      : utcFormat(isoSpecifier);
  3649  
  3650  function parseIsoNative(string) {
  3651    var date = new Date(string);
  3652    return isNaN(date) ? null : date;
  3653  }
  3654  
  3655  var parseIso = +new Date("2000-01-01T00:00:00.000Z")
  3656      ? parseIsoNative
  3657      : utcParse(isoSpecifier);
  3658  
  3659  var colors = function(s) {
  3660    return s.match(/.{6}/g).map(function(x) {
  3661      return "#" + x;
  3662    });
  3663  };
  3664  
  3665  colors("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf");
  3666  
  3667  colors("393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6");
  3668  
  3669  colors("3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9");
  3670  
  3671  colors("1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5");
  3672  
  3673  cubehelixLong(cubehelix(300, 0.5, 0.0), cubehelix(-240, 0.5, 1.0));
  3674  
  3675  var warm = cubehelixLong(cubehelix(-100, 0.75, 0.35), cubehelix(80, 1.50, 0.8));
  3676  
  3677  var cool = cubehelixLong(cubehelix(260, 0.75, 0.35), cubehelix(80, 1.50, 0.8));
  3678  
  3679  var rainbow = cubehelix();
  3680  
  3681  function ramp(range) {
  3682    var n = range.length;
  3683    return function(t) {
  3684      return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
  3685    };
  3686  }
  3687  
  3688  ramp(colors("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
  3689  
  3690  var magma = ramp(colors("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));
  3691  
  3692  var inferno = ramp(colors("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4"));
  3693  
  3694  var plasma = ramp(colors("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
  3695  
  3696  function cubicInOut(t) {
  3697    return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
  3698  }
  3699  
  3700  var pi = Math.PI;
  3701  
  3702  var tau = 2 * Math.PI;
  3703  
  3704  var noop = {value: function() {}};
  3705  
  3706  function dispatch() {
  3707    for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
  3708      if (!(t = arguments[i] + "") || (t in _)) throw new Error("illegal type: " + t);
  3709      _[t] = [];
  3710    }
  3711    return new Dispatch(_);
  3712  }
  3713  
  3714  function Dispatch(_) {
  3715    this._ = _;
  3716  }
  3717  
  3718  function parseTypenames$1(typenames, types) {
  3719    return typenames.trim().split(/^|\s+/).map(function(t) {
  3720      var name = "", i = t.indexOf(".");
  3721      if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
  3722      if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t);
  3723      return {type: t, name: name};
  3724    });
  3725  }
  3726  
  3727  Dispatch.prototype = dispatch.prototype = {
  3728    constructor: Dispatch,
  3729    on: function(typename, callback) {
  3730      var _ = this._,
  3731          T = parseTypenames$1(typename + "", _),
  3732          t,
  3733          i = -1,
  3734          n = T.length;
  3735  
  3736      // If no callback was specified, return the callback of the given type and name.
  3737      if (arguments.length < 2) {
  3738        while (++i < n) if ((t = (typename = T[i]).type) && (t = get$1(_[t], typename.name))) return t;
  3739        return;
  3740      }
  3741  
  3742      // If a type was specified, set the callback for the given type and name.
  3743      // Otherwise, if a null callback was specified, remove callbacks of the given name.
  3744      if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
  3745      while (++i < n) {
  3746        if (t = (typename = T[i]).type) _[t] = set$3(_[t], typename.name, callback);
  3747        else if (callback == null) for (t in _) _[t] = set$3(_[t], typename.name, null);
  3748      }
  3749  
  3750      return this;
  3751    },
  3752    copy: function() {
  3753      var copy = {}, _ = this._;
  3754      for (var t in _) copy[t] = _[t].slice();
  3755      return new Dispatch(copy);
  3756    },
  3757    call: function(type, that) {
  3758      if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2];
  3759      if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
  3760      for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
  3761    },
  3762    apply: function(type, that, args) {
  3763      if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
  3764      for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
  3765    }
  3766  };
  3767  
  3768  function get$1(type, name) {
  3769    for (var i = 0, n = type.length, c; i < n; ++i) {
  3770      if ((c = type[i]).name === name) {
  3771        return c.value;
  3772      }
  3773    }
  3774  }
  3775  
  3776  function set$3(type, name, callback) {
  3777    for (var i = 0, n = type.length; i < n; ++i) {
  3778      if (type[i].name === name) {
  3779        type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
  3780        break;
  3781      }
  3782    }
  3783    if (callback != null) type.push({name: name, value: callback});
  3784    return type;
  3785  }
  3786  
  3787  var frame = 0;
  3788  var timeout = 0;
  3789  var interval = 0;
  3790  var pokeDelay = 1000;
  3791  var taskHead;
  3792  var taskTail;
  3793  var clockLast = 0;
  3794  var clockNow = 0;
  3795  var clockSkew = 0;
  3796  var clock = typeof performance === "object" && performance.now ? performance : Date;
  3797  var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
  3798  
  3799  function now() {
  3800    return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
  3801  }
  3802  
  3803  function clearNow() {
  3804    clockNow = 0;
  3805  }
  3806  
  3807  function Timer() {
  3808    this._call =
  3809    this._time =
  3810    this._next = null;
  3811  }
  3812  
  3813  Timer.prototype = timer.prototype = {
  3814    constructor: Timer,
  3815    restart: function(callback, delay, time) {
  3816      if (typeof callback !== "function") throw new TypeError("callback is not a function");
  3817      time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
  3818      if (!this._next && taskTail !== this) {
  3819        if (taskTail) taskTail._next = this;
  3820        else taskHead = this;
  3821        taskTail = this;
  3822      }
  3823      this._call = callback;
  3824      this._time = time;
  3825      sleep();
  3826    },
  3827    stop: function() {
  3828      if (this._call) {
  3829        this._call = null;
  3830        this._time = Infinity;
  3831        sleep();
  3832      }
  3833    }
  3834  };
  3835  
  3836  function timer(callback, delay, time) {
  3837    var t = new Timer;
  3838    t.restart(callback, delay, time);
  3839    return t;
  3840  }
  3841  
  3842  function timerFlush() {
  3843    now(); // Get the current time, if not already set.
  3844    ++frame; // Pretend we’ve set an alarm, if we haven’t already.
  3845    var t = taskHead, e;
  3846    while (t) {
  3847      if ((e = clockNow - t._time) >= 0) t._call.call(null, e);
  3848      t = t._next;
  3849    }
  3850    --frame;
  3851  }
  3852  
  3853  function wake() {
  3854    clockNow = (clockLast = clock.now()) + clockSkew;
  3855    frame = timeout = 0;
  3856    try {
  3857      timerFlush();
  3858    } finally {
  3859      frame = 0;
  3860      nap();
  3861      clockNow = 0;
  3862    }
  3863  }
  3864  
  3865  function poke() {
  3866    var now = clock.now(), delay = now - clockLast;
  3867    if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
  3868  }
  3869  
  3870  function nap() {
  3871    var t0, t1 = taskHead, t2, time = Infinity;
  3872    while (t1) {
  3873      if (t1._call) {
  3874        if (time > t1._time) time = t1._time;
  3875        t0 = t1, t1 = t1._next;
  3876      } else {
  3877        t2 = t1._next, t1._next = null;
  3878        t1 = t0 ? t0._next = t2 : taskHead = t2;
  3879      }
  3880    }
  3881    taskTail = t0;
  3882    sleep(time);
  3883  }
  3884  
  3885  function sleep(time) {
  3886    if (frame) return; // Soonest alarm already set, or will be.
  3887    if (timeout) timeout = clearTimeout(timeout);
  3888    var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
  3889    if (delay > 24) {
  3890      if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
  3891      if (interval) interval = clearInterval(interval);
  3892    } else {
  3893      if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
  3894      frame = 1, setFrame(wake);
  3895    }
  3896  }
  3897  
  3898  var timeout$1 = function(callback, delay, time) {
  3899    var t = new Timer;
  3900    delay = delay == null ? 0 : +delay;
  3901    t.restart(function(elapsed) {
  3902      t.stop();
  3903      callback(elapsed + delay);
  3904    }, delay, time);
  3905    return t;
  3906  };
  3907  
  3908  var emptyOn = dispatch("start", "end", "interrupt");
  3909  var emptyTween = [];
  3910  
  3911  var CREATED = 0;
  3912  var SCHEDULED = 1;
  3913  var STARTING = 2;
  3914  var STARTED = 3;
  3915  var RUNNING = 4;
  3916  var ENDING = 5;
  3917  var ENDED = 6;
  3918  
  3919  var schedule = function(node, name, id, index, group, timing) {
  3920    var schedules = node.__transition;
  3921    if (!schedules) node.__transition = {};
  3922    else if (id in schedules) return;
  3923    create(node, id, {
  3924      name: name,
  3925      index: index, // For context during callback.
  3926      group: group, // For context during callback.
  3927      on: emptyOn,
  3928      tween: emptyTween,
  3929      time: timing.time,
  3930      delay: timing.delay,
  3931      duration: timing.duration,
  3932      ease: timing.ease,
  3933      timer: null,
  3934      state: CREATED
  3935    });
  3936  };
  3937  
  3938  function init(node, id) {
  3939    var schedule = node.__transition;
  3940    if (!schedule || !(schedule = schedule[id]) || schedule.state > CREATED) throw new Error("too late");
  3941    return schedule;
  3942  }
  3943  
  3944  function set$2(node, id) {
  3945    var schedule = node.__transition;
  3946    if (!schedule || !(schedule = schedule[id]) || schedule.state > STARTING) throw new Error("too late");
  3947    return schedule;
  3948  }
  3949  
  3950  function get(node, id) {
  3951    var schedule = node.__transition;
  3952    if (!schedule || !(schedule = schedule[id])) throw new Error("too late");
  3953    return schedule;
  3954  }
  3955  
  3956  function create(node, id, self) {
  3957    var schedules = node.__transition,
  3958        tween;
  3959  
  3960    // Initialize the self timer when the transition is created.
  3961    // Note the actual delay is not known until the first callback!
  3962    schedules[id] = self;
  3963    self.timer = timer(schedule, 0, self.time);
  3964  
  3965    function schedule(elapsed) {
  3966      self.state = SCHEDULED;
  3967      self.timer.restart(start, self.delay, self.time);
  3968  
  3969      // If the elapsed delay is less than our first sleep, start immediately.
  3970      if (self.delay <= elapsed) start(elapsed - self.delay);
  3971    }
  3972  
  3973    function start(elapsed) {
  3974      var i, j, n, o;
  3975  
  3976      // If the state is not SCHEDULED, then we previously errored on start.
  3977      if (self.state !== SCHEDULED) return stop();
  3978  
  3979      for (i in schedules) {
  3980        o = schedules[i];
  3981        if (o.name !== self.name) continue;
  3982  
  3983        // While this element already has a starting transition during this frame,
  3984        // defer starting an interrupting transition until that transition has a
  3985        // chance to tick (and possibly end); see d3/d3-transition#54!
  3986        if (o.state === STARTED) return timeout$1(start);
  3987  
  3988        // Interrupt the active transition, if any.
  3989        // Dispatch the interrupt event.
  3990        if (o.state === RUNNING) {
  3991          o.state = ENDED;
  3992          o.timer.stop();
  3993          o.on.call("interrupt", node, node.__data__, o.index, o.group);
  3994          delete schedules[i];
  3995        }
  3996  
  3997        // Cancel any pre-empted transitions. No interrupt event is dispatched
  3998        // because the cancelled transitions never started. Note that this also
  3999        // removes this transition from the pending list!
  4000        else if (+i < id) {
  4001          o.state = ENDED;
  4002          o.timer.stop();
  4003          delete schedules[i];
  4004        }
  4005      }
  4006  
  4007      // Defer the first tick to end of the current frame; see d3/d3#1576.
  4008      // Note the transition may be canceled after start and before the first tick!
  4009      // Note this must be scheduled before the start event; see d3/d3-transition#16!
  4010      // Assuming this is successful, subsequent callbacks go straight to tick.
  4011      timeout$1(function() {
  4012        if (self.state === STARTED) {
  4013          self.state = RUNNING;
  4014          self.timer.restart(tick, self.delay, self.time);
  4015          tick(elapsed);
  4016        }
  4017      });
  4018  
  4019      // Dispatch the start event.
  4020      // Note this must be done before the tween are initialized.
  4021      self.state = STARTING;
  4022      self.on.call("start", node, node.__data__, self.index, self.group);
  4023      if (self.state !== STARTING) return; // interrupted
  4024      self.state = STARTED;
  4025  
  4026      // Initialize the tween, deleting null tween.
  4027      tween = new Array(n = self.tween.length);
  4028      for (i = 0, j = -1; i < n; ++i) {
  4029        if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) {
  4030          tween[++j] = o;
  4031        }
  4032      }
  4033      tween.length = j + 1;
  4034    }
  4035  
  4036    function tick(elapsed) {
  4037      var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1),
  4038          i = -1,
  4039          n = tween.length;
  4040  
  4041      while (++i < n) {
  4042        tween[i].call(null, t);
  4043      }
  4044  
  4045      // Dispatch the end event.
  4046      if (self.state === ENDING) {
  4047        self.on.call("end", node, node.__data__, self.index, self.group);
  4048        stop();
  4049      }
  4050    }
  4051  
  4052    function stop() {
  4053      self.state = ENDED;
  4054      self.timer.stop();
  4055      delete schedules[id];
  4056      for (var i in schedules) return; // eslint-disable-line no-unused-vars
  4057      delete node.__transition;
  4058    }
  4059  }
  4060  
  4061  var interrupt = function(node, name) {
  4062    var schedules = node.__transition,
  4063        schedule$$1,
  4064        active,
  4065        empty = true,
  4066        i;
  4067  
  4068    if (!schedules) return;
  4069  
  4070    name = name == null ? null : name + "";
  4071  
  4072    for (i in schedules) {
  4073      if ((schedule$$1 = schedules[i]).name !== name) { empty = false; continue; }
  4074      active = schedule$$1.state > STARTING && schedule$$1.state < ENDING;
  4075      schedule$$1.state = ENDED;
  4076      schedule$$1.timer.stop();
  4077      if (active) schedule$$1.on.call("interrupt", node, node.__data__, schedule$$1.index, schedule$$1.group);
  4078      delete schedules[i];
  4079    }
  4080  
  4081    if (empty) delete node.__transition;
  4082  };
  4083  
  4084  var selection_interrupt = function(name) {
  4085    return this.each(function() {
  4086      interrupt(this, name);
  4087    });
  4088  };
  4089  
  4090  function tweenRemove(id, name) {
  4091    var tween0, tween1;
  4092    return function() {
  4093      var schedule$$1 = set$2(this, id),
  4094          tween = schedule$$1.tween;
  4095  
  4096      // If this node shared tween with the previous node,
  4097      // just assign the updated shared tween and we’re done!
  4098      // Otherwise, copy-on-write.
  4099      if (tween !== tween0) {
  4100        tween1 = tween0 = tween;
  4101        for (var i = 0, n = tween1.length; i < n; ++i) {
  4102          if (tween1[i].name === name) {
  4103            tween1 = tween1.slice();
  4104            tween1.splice(i, 1);
  4105            break;
  4106          }
  4107        }
  4108      }
  4109  
  4110      schedule$$1.tween = tween1;
  4111    };
  4112  }
  4113  
  4114  function tweenFunction(id, name, value) {
  4115    var tween0, tween1;
  4116    if (typeof value !== "function") throw new Error;
  4117    return function() {
  4118      var schedule$$1 = set$2(this, id),
  4119          tween = schedule$$1.tween;
  4120  
  4121      // If this node shared tween with the previous node,
  4122      // just assign the updated shared tween and we’re done!
  4123      // Otherwise, copy-on-write.
  4124      if (tween !== tween0) {
  4125        tween1 = (tween0 = tween).slice();
  4126        for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) {
  4127          if (tween1[i].name === name) {
  4128            tween1[i] = t;
  4129            break;
  4130          }
  4131        }
  4132        if (i === n) tween1.push(t);
  4133      }
  4134  
  4135      schedule$$1.tween = tween1;
  4136    };
  4137  }
  4138  
  4139  var transition_tween = function(name, value) {
  4140    var id = this._id;
  4141  
  4142    name += "";
  4143  
  4144    if (arguments.length < 2) {
  4145      var tween = get(this.node(), id).tween;
  4146      for (var i = 0, n = tween.length, t; i < n; ++i) {
  4147        if ((t = tween[i]).name === name) {
  4148          return t.value;
  4149        }
  4150      }
  4151      return null;
  4152    }
  4153  
  4154    return this.each((value == null ? tweenRemove : tweenFunction)(id, name, value));
  4155  };
  4156  
  4157  function tweenValue(transition, name, value) {
  4158    var id = transition._id;
  4159  
  4160    transition.each(function() {
  4161      var schedule$$1 = set$2(this, id);
  4162      (schedule$$1.value || (schedule$$1.value = {}))[name] = value.apply(this, arguments);
  4163    });
  4164  
  4165    return function(node) {
  4166      return get(node, id).value[name];
  4167    };
  4168  }
  4169  
  4170  var interpolate = function(a, b) {
  4171    var c;
  4172    return (typeof b === "number" ? interpolateNumber
  4173        : b instanceof color ? interpolateRgb
  4174        : (c = color(b)) ? (b = c, interpolateRgb)
  4175        : interpolateString)(a, b);
  4176  };
  4177  
  4178  function attrRemove$1(name) {
  4179    return function() {
  4180      this.removeAttribute(name);
  4181    };
  4182  }
  4183  
  4184  function attrRemoveNS$1(fullname) {
  4185    return function() {
  4186      this.removeAttributeNS(fullname.space, fullname.local);
  4187    };
  4188  }
  4189  
  4190  function attrConstant$1(name, interpolate$$1, value1) {
  4191    var value00,
  4192        interpolate0;
  4193    return function() {
  4194      var value0 = this.getAttribute(name);
  4195      return value0 === value1 ? null
  4196          : value0 === value00 ? interpolate0
  4197          : interpolate0 = interpolate$$1(value00 = value0, value1);
  4198    };
  4199  }
  4200  
  4201  function attrConstantNS$1(fullname, interpolate$$1, value1) {
  4202    var value00,
  4203        interpolate0;
  4204    return function() {
  4205      var value0 = this.getAttributeNS(fullname.space, fullname.local);
  4206      return value0 === value1 ? null
  4207          : value0 === value00 ? interpolate0
  4208          : interpolate0 = interpolate$$1(value00 = value0, value1);
  4209    };
  4210  }
  4211  
  4212  function attrFunction$1(name, interpolate$$1, value) {
  4213    var value00,
  4214        value10,
  4215        interpolate0;
  4216    return function() {
  4217      var value0, value1 = value(this);
  4218      if (value1 == null) return void this.removeAttribute(name);
  4219      value0 = this.getAttribute(name);
  4220      return value0 === value1 ? null
  4221          : value0 === value00 && value1 === value10 ? interpolate0
  4222          : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
  4223    };
  4224  }
  4225  
  4226  function attrFunctionNS$1(fullname, interpolate$$1, value) {
  4227    var value00,
  4228        value10,
  4229        interpolate0;
  4230    return function() {
  4231      var value0, value1 = value(this);
  4232      if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
  4233      value0 = this.getAttributeNS(fullname.space, fullname.local);
  4234      return value0 === value1 ? null
  4235          : value0 === value00 && value1 === value10 ? interpolate0
  4236          : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
  4237    };
  4238  }
  4239  
  4240  var transition_attr = function(name, value) {
  4241    var fullname = namespace(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate;
  4242    return this.attrTween(name, typeof value === "function"
  4243        ? (fullname.local ? attrFunctionNS$1 : attrFunction$1)(fullname, i, tweenValue(this, "attr." + name, value))
  4244        : value == null ? (fullname.local ? attrRemoveNS$1 : attrRemove$1)(fullname)
  4245        : (fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, i, value + ""));
  4246  };
  4247  
  4248  function attrTweenNS(fullname, value) {
  4249    function tween() {
  4250      var node = this, i = value.apply(node, arguments);
  4251      return i && function(t) {
  4252        node.setAttributeNS(fullname.space, fullname.local, i(t));
  4253      };
  4254    }
  4255    tween._value = value;
  4256    return tween;
  4257  }
  4258  
  4259  function attrTween(name, value) {
  4260    function tween() {
  4261      var node = this, i = value.apply(node, arguments);
  4262      return i && function(t) {
  4263        node.setAttribute(name, i(t));
  4264      };
  4265    }
  4266    tween._value = value;
  4267    return tween;
  4268  }
  4269  
  4270  var transition_attrTween = function(name, value) {
  4271    var key = "attr." + name;
  4272    if (arguments.length < 2) return (key = this.tween(key)) && key._value;
  4273    if (value == null) return this.tween(key, null);
  4274    if (typeof value !== "function") throw new Error;
  4275    var fullname = namespace(name);
  4276    return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
  4277  };
  4278  
  4279  function delayFunction(id, value) {
  4280    return function() {
  4281      init(this, id).delay = +value.apply(this, arguments);
  4282    };
  4283  }
  4284  
  4285  function delayConstant(id, value) {
  4286    return value = +value, function() {
  4287      init(this, id).delay = value;
  4288    };
  4289  }
  4290  
  4291  var transition_delay = function(value) {
  4292    var id = this._id;
  4293  
  4294    return arguments.length
  4295        ? this.each((typeof value === "function"
  4296            ? delayFunction
  4297            : delayConstant)(id, value))
  4298        : get(this.node(), id).delay;
  4299  };
  4300  
  4301  function durationFunction(id, value) {
  4302    return function() {
  4303      set$2(this, id).duration = +value.apply(this, arguments);
  4304    };
  4305  }
  4306  
  4307  function durationConstant(id, value) {
  4308    return value = +value, function() {
  4309      set$2(this, id).duration = value;
  4310    };
  4311  }
  4312  
  4313  var transition_duration = function(value) {
  4314    var id = this._id;
  4315  
  4316    return arguments.length
  4317        ? this.each((typeof value === "function"
  4318            ? durationFunction
  4319            : durationConstant)(id, value))
  4320        : get(this.node(), id).duration;
  4321  };
  4322  
  4323  function easeConstant(id, value) {
  4324    if (typeof value !== "function") throw new Error;
  4325    return function() {
  4326      set$2(this, id).ease = value;
  4327    };
  4328  }
  4329  
  4330  var transition_ease = function(value) {
  4331    var id = this._id;
  4332  
  4333    return arguments.length
  4334        ? this.each(easeConstant(id, value))
  4335        : get(this.node(), id).ease;
  4336  };
  4337  
  4338  var transition_filter = function(match) {
  4339    if (typeof match !== "function") match = matcher$1(match);
  4340  
  4341    for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
  4342      for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
  4343        if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
  4344          subgroup.push(node);
  4345        }
  4346      }
  4347    }
  4348  
  4349    return new Transition(subgroups, this._parents, this._name, this._id);
  4350  };
  4351  
  4352  var transition_merge = function(transition$$1) {
  4353    if (transition$$1._id !== this._id) throw new Error;
  4354  
  4355    for (var groups0 = this._groups, groups1 = transition$$1._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
  4356      for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
  4357        if (node = group0[i] || group1[i]) {
  4358          merge[i] = node;
  4359        }
  4360      }
  4361    }
  4362  
  4363    for (; j < m0; ++j) {
  4364      merges[j] = groups0[j];
  4365    }
  4366  
  4367    return new Transition(merges, this._parents, this._name, this._id);
  4368  };
  4369  
  4370  function start(name) {
  4371    return (name + "").trim().split(/^|\s+/).every(function(t) {
  4372      var i = t.indexOf(".");
  4373      if (i >= 0) t = t.slice(0, i);
  4374      return !t || t === "start";
  4375    });
  4376  }
  4377  
  4378  function onFunction(id, name, listener) {
  4379    var on0, on1, sit = start(name) ? init : set$2;
  4380    return function() {
  4381      var schedule$$1 = sit(this, id),
  4382          on = schedule$$1.on;
  4383  
  4384      // If this node shared a dispatch with the previous node,
  4385      // just assign the updated shared dispatch and we’re done!
  4386      // Otherwise, copy-on-write.
  4387      if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
  4388  
  4389      schedule$$1.on = on1;
  4390    };
  4391  }
  4392  
  4393  var transition_on = function(name, listener) {
  4394    var id = this._id;
  4395  
  4396    return arguments.length < 2
  4397        ? get(this.node(), id).on.on(name)
  4398        : this.each(onFunction(id, name, listener));
  4399  };
  4400  
  4401  function removeFunction(id) {
  4402    return function() {
  4403      var parent = this.parentNode;
  4404      for (var i in this.__transition) if (+i !== id) return;
  4405      if (parent) parent.removeChild(this);
  4406    };
  4407  }
  4408  
  4409  var transition_remove = function() {
  4410    return this.on("end.remove", removeFunction(this._id));
  4411  };
  4412  
  4413  var transition_select = function(select) {
  4414    var name = this._name,
  4415        id = this._id;
  4416  
  4417    if (typeof select !== "function") select = selector(select);
  4418  
  4419    for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
  4420      for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
  4421        if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
  4422          if ("__data__" in node) subnode.__data__ = node.__data__;
  4423          subgroup[i] = subnode;
  4424          schedule(subgroup[i], name, id, i, subgroup, get(node, id));
  4425        }
  4426      }
  4427    }
  4428  
  4429    return new Transition(subgroups, this._parents, name, id);
  4430  };
  4431  
  4432  var transition_selectAll = function(select) {
  4433    var name = this._name,
  4434        id = this._id;
  4435  
  4436    if (typeof select !== "function") select = selectorAll(select);
  4437  
  4438    for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
  4439      for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  4440        if (node = group[i]) {
  4441          for (var children = select.call(node, node.__data__, i, group), child, inherit = get(node, id), k = 0, l = children.length; k < l; ++k) {
  4442            if (child = children[k]) {
  4443              schedule(child, name, id, k, children, inherit);
  4444            }
  4445          }
  4446          subgroups.push(children);
  4447          parents.push(node);
  4448        }
  4449      }
  4450    }
  4451  
  4452    return new Transition(subgroups, parents, name, id);
  4453  };
  4454  
  4455  var Selection$1 = selection.prototype.constructor;
  4456  
  4457  var transition_selection = function() {
  4458    return new Selection$1(this._groups, this._parents);
  4459  };
  4460  
  4461  function styleRemove$1(name, interpolate$$1) {
  4462    var value00,
  4463        value10,
  4464        interpolate0;
  4465    return function() {
  4466      var value0 = styleValue(this, name),
  4467          value1 = (this.style.removeProperty(name), styleValue(this, name));
  4468      return value0 === value1 ? null
  4469          : value0 === value00 && value1 === value10 ? interpolate0
  4470          : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
  4471    };
  4472  }
  4473  
  4474  function styleRemoveEnd(name) {
  4475    return function() {
  4476      this.style.removeProperty(name);
  4477    };
  4478  }
  4479  
  4480  function styleConstant$1(name, interpolate$$1, value1) {
  4481    var value00,
  4482        interpolate0;
  4483    return function() {
  4484      var value0 = styleValue(this, name);
  4485      return value0 === value1 ? null
  4486          : value0 === value00 ? interpolate0
  4487          : interpolate0 = interpolate$$1(value00 = value0, value1);
  4488    };
  4489  }
  4490  
  4491  function styleFunction$1(name, interpolate$$1, value) {
  4492    var value00,
  4493        value10,
  4494        interpolate0;
  4495    return function() {
  4496      var value0 = styleValue(this, name),
  4497          value1 = value(this);
  4498      if (value1 == null) value1 = (this.style.removeProperty(name), styleValue(this, name));
  4499      return value0 === value1 ? null
  4500          : value0 === value00 && value1 === value10 ? interpolate0
  4501          : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
  4502    };
  4503  }
  4504  
  4505  var transition_style = function(name, value, priority) {
  4506    var i = (name += "") === "transform" ? interpolateTransformCss : interpolate;
  4507    return value == null ? this
  4508            .styleTween(name, styleRemove$1(name, i))
  4509            .on("end.style." + name, styleRemoveEnd(name))
  4510        : this.styleTween(name, typeof value === "function"
  4511            ? styleFunction$1(name, i, tweenValue(this, "style." + name, value))
  4512            : styleConstant$1(name, i, value + ""), priority);
  4513  };
  4514  
  4515  function styleTween(name, value, priority) {
  4516    function tween() {
  4517      var node = this, i = value.apply(node, arguments);
  4518      return i && function(t) {
  4519        node.style.setProperty(name, i(t), priority);
  4520      };
  4521    }
  4522    tween._value = value;
  4523    return tween;
  4524  }
  4525  
  4526  var transition_styleTween = function(name, value, priority) {
  4527    var key = "style." + (name += "");
  4528    if (arguments.length < 2) return (key = this.tween(key)) && key._value;
  4529    if (value == null) return this.tween(key, null);
  4530    if (typeof value !== "function") throw new Error;
  4531    return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
  4532  };
  4533  
  4534  function textConstant$1(value) {
  4535    return function() {
  4536      this.textContent = value;
  4537    };
  4538  }
  4539  
  4540  function textFunction$1(value) {
  4541    return function() {
  4542      var value1 = value(this);
  4543      this.textContent = value1 == null ? "" : value1;
  4544    };
  4545  }
  4546  
  4547  var transition_text = function(value) {
  4548    return this.tween("text", typeof value === "function"
  4549        ? textFunction$1(tweenValue(this, "text", value))
  4550        : textConstant$1(value == null ? "" : value + ""));
  4551  };
  4552  
  4553  var transition_transition = function() {
  4554    var name = this._name,
  4555        id0 = this._id,
  4556        id1 = newId();
  4557  
  4558    for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
  4559      for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  4560        if (node = group[i]) {
  4561          var inherit = get(node, id0);
  4562          schedule(node, name, id1, i, group, {
  4563            time: inherit.time + inherit.delay + inherit.duration,
  4564            delay: 0,
  4565            duration: inherit.duration,
  4566            ease: inherit.ease
  4567          });
  4568        }
  4569      }
  4570    }
  4571  
  4572    return new Transition(groups, this._parents, name, id1);
  4573  };
  4574  
  4575  var id = 0;
  4576  
  4577  function Transition(groups, parents, name, id) {
  4578    this._groups = groups;
  4579    this._parents = parents;
  4580    this._name = name;
  4581    this._id = id;
  4582  }
  4583  
  4584  function transition(name) {
  4585    return selection().transition(name);
  4586  }
  4587  
  4588  function newId() {
  4589    return ++id;
  4590  }
  4591  
  4592  var selection_prototype = selection.prototype;
  4593  
  4594  Transition.prototype = transition.prototype = {
  4595    constructor: Transition,
  4596    select: transition_select,
  4597    selectAll: transition_selectAll,
  4598    filter: transition_filter,
  4599    merge: transition_merge,
  4600    selection: transition_selection,
  4601    transition: transition_transition,
  4602    call: selection_prototype.call,
  4603    nodes: selection_prototype.nodes,
  4604    node: selection_prototype.node,
  4605    size: selection_prototype.size,
  4606    empty: selection_prototype.empty,
  4607    each: selection_prototype.each,
  4608    on: transition_on,
  4609    attr: transition_attr,
  4610    attrTween: transition_attrTween,
  4611    style: transition_style,
  4612    styleTween: transition_styleTween,
  4613    text: transition_text,
  4614    remove: transition_remove,
  4615    tween: transition_tween,
  4616    delay: transition_delay,
  4617    duration: transition_duration,
  4618    ease: transition_ease
  4619  };
  4620  
  4621  var defaultTiming = {
  4622    time: null, // Set on use.
  4623    delay: 0,
  4624    duration: 250,
  4625    ease: cubicInOut
  4626  };
  4627  
  4628  function inherit(node, id) {
  4629    var timing;
  4630    while (!(timing = node.__transition) || !(timing = timing[id])) {
  4631      if (!(node = node.parentNode)) {
  4632        return defaultTiming.time = now(), defaultTiming;
  4633      }
  4634    }
  4635    return timing;
  4636  }
  4637  
  4638  var selection_transition = function(name) {
  4639    var id,
  4640        timing;
  4641  
  4642    if (name instanceof Transition) {
  4643      id = name._id, name = name._name;
  4644    } else {
  4645      id = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + "";
  4646    }
  4647  
  4648    for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
  4649      for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  4650        if (node = group[i]) {
  4651          schedule(node, name, id, i, group, timing || inherit(node, id));
  4652        }
  4653      }
  4654    }
  4655  
  4656    return new Transition(groups, this._parents, name, id);
  4657  };
  4658  
  4659  selection.prototype.interrupt = selection_interrupt;
  4660  selection.prototype.transition = selection_transition;
  4661  
  4662  exports.select = select;
  4663  exports.selection = selection;
  4664  exports.hierarchy = hierarchy;
  4665  exports.partition = partition;
  4666  exports.scaleLinear = linear;
  4667  exports.easeCubic = cubicInOut;
  4668  exports.ascending = ascending$1;
  4669  exports.map = map$1;
  4670  exports.transition = transition;
  4671  
  4672  Object.defineProperty(exports, '__esModule', { value: true });
  4673  
  4674  })));
  4675  `
  4676  

View as plain text