You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

4676 lines
132 KiB

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