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.

995 lines
26 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. // https://d3js.org/d3-selection/ v1.3.2 Copyright 2018 Mike Bostock
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  4. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  5. (factory((global.d3 = global.d3 || {})));
  6. }(this, (function (exports) { 'use strict';
  7. var xhtml = "http://www.w3.org/1999/xhtml";
  8. var namespaces = {
  9. svg: "http://www.w3.org/2000/svg",
  10. xhtml: xhtml,
  11. xlink: "http://www.w3.org/1999/xlink",
  12. xml: "http://www.w3.org/XML/1998/namespace",
  13. xmlns: "http://www.w3.org/2000/xmlns/"
  14. };
  15. function namespace(name) {
  16. var prefix = name += "", i = prefix.indexOf(":");
  17. if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1);
  18. return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name;
  19. }
  20. function creatorInherit(name) {
  21. return function() {
  22. var document = this.ownerDocument,
  23. uri = this.namespaceURI;
  24. return uri === xhtml && document.documentElement.namespaceURI === xhtml
  25. ? document.createElement(name)
  26. : document.createElementNS(uri, name);
  27. };
  28. }
  29. function creatorFixed(fullname) {
  30. return function() {
  31. return this.ownerDocument.createElementNS(fullname.space, fullname.local);
  32. };
  33. }
  34. function creator(name) {
  35. var fullname = namespace(name);
  36. return (fullname.local
  37. ? creatorFixed
  38. : creatorInherit)(fullname);
  39. }
  40. function none() {}
  41. function selector(selector) {
  42. return selector == null ? none : function() {
  43. return this.querySelector(selector);
  44. };
  45. }
  46. function selection_select(select) {
  47. if (typeof select !== "function") select = selector(select);
  48. for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
  49. for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
  50. if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
  51. if ("__data__" in node) subnode.__data__ = node.__data__;
  52. subgroup[i] = subnode;
  53. }
  54. }
  55. }
  56. return new Selection(subgroups, this._parents);
  57. }
  58. function empty() {
  59. return [];
  60. }
  61. function selectorAll(selector) {
  62. return selector == null ? empty : function() {
  63. return this.querySelectorAll(selector);
  64. };
  65. }
  66. function selection_selectAll(select) {
  67. if (typeof select !== "function") select = selectorAll(select);
  68. for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
  69. for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  70. if (node = group[i]) {
  71. subgroups.push(select.call(node, node.__data__, i, group));
  72. parents.push(node);
  73. }
  74. }
  75. }
  76. return new Selection(subgroups, parents);
  77. }
  78. var matcher = function(selector) {
  79. return function() {
  80. return this.matches(selector);
  81. };
  82. };
  83. if (typeof document !== "undefined") {
  84. var element = document.documentElement;
  85. if (!element.matches) {
  86. var vendorMatches = element.webkitMatchesSelector
  87. || element.msMatchesSelector
  88. || element.mozMatchesSelector
  89. || element.oMatchesSelector;
  90. matcher = function(selector) {
  91. return function() {
  92. return vendorMatches.call(this, selector);
  93. };
  94. };
  95. }
  96. }
  97. var matcher$1 = matcher;
  98. function selection_filter(match) {
  99. if (typeof match !== "function") match = matcher$1(match);
  100. for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
  101. for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
  102. if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
  103. subgroup.push(node);
  104. }
  105. }
  106. }
  107. return new Selection(subgroups, this._parents);
  108. }
  109. function sparse(update) {
  110. return new Array(update.length);
  111. }
  112. function selection_enter() {
  113. return new Selection(this._enter || this._groups.map(sparse), this._parents);
  114. }
  115. function EnterNode(parent, datum) {
  116. this.ownerDocument = parent.ownerDocument;
  117. this.namespaceURI = parent.namespaceURI;
  118. this._next = null;
  119. this._parent = parent;
  120. this.__data__ = datum;
  121. }
  122. EnterNode.prototype = {
  123. constructor: EnterNode,
  124. appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
  125. insertBefore: function(child, next) { return this._parent.insertBefore(child, next); },
  126. querySelector: function(selector) { return this._parent.querySelector(selector); },
  127. querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); }
  128. };
  129. function constant(x) {
  130. return function() {
  131. return x;
  132. };
  133. }
  134. var keyPrefix = "$"; // Protect against keys like “__proto__”.
  135. function bindIndex(parent, group, enter, update, exit, data) {
  136. var i = 0,
  137. node,
  138. groupLength = group.length,
  139. dataLength = data.length;
  140. // Put any non-null nodes that fit into update.
  141. // Put any null nodes into enter.
  142. // Put any remaining data into enter.
  143. for (; i < dataLength; ++i) {
  144. if (node = group[i]) {
  145. node.__data__ = data[i];
  146. update[i] = node;
  147. } else {
  148. enter[i] = new EnterNode(parent, data[i]);
  149. }
  150. }
  151. // Put any non-null nodes that don’t fit into exit.
  152. for (; i < groupLength; ++i) {
  153. if (node = group[i]) {
  154. exit[i] = node;
  155. }
  156. }
  157. }
  158. function bindKey(parent, group, enter, update, exit, data, key) {
  159. var i,
  160. node,
  161. nodeByKeyValue = {},
  162. groupLength = group.length,
  163. dataLength = data.length,
  164. keyValues = new Array(groupLength),
  165. keyValue;
  166. // Compute the key for each node.
  167. // If multiple nodes have the same key, the duplicates are added to exit.
  168. for (i = 0; i < groupLength; ++i) {
  169. if (node = group[i]) {
  170. keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, group);
  171. if (keyValue in nodeByKeyValue) {
  172. exit[i] = node;
  173. } else {
  174. nodeByKeyValue[keyValue] = node;
  175. }
  176. }
  177. }
  178. // Compute the key for each datum.
  179. // If there a node associated with this key, join and add it to update.
  180. // If there is not (or the key is a duplicate), add it to enter.
  181. for (i = 0; i < dataLength; ++i) {
  182. keyValue = keyPrefix + key.call(parent, data[i], i, data);
  183. if (node = nodeByKeyValue[keyValue]) {
  184. update[i] = node;
  185. node.__data__ = data[i];
  186. nodeByKeyValue[keyValue] = null;
  187. } else {
  188. enter[i] = new EnterNode(parent, data[i]);
  189. }
  190. }
  191. // Add any remaining nodes that were not bound to data to exit.
  192. for (i = 0; i < groupLength; ++i) {
  193. if ((node = group[i]) && (nodeByKeyValue[keyValues[i]] === node)) {
  194. exit[i] = node;
  195. }
  196. }
  197. }
  198. function selection_data(value, key) {
  199. if (!value) {
  200. data = new Array(this.size()), j = -1;
  201. this.each(function(d) { data[++j] = d; });
  202. return data;
  203. }
  204. var bind = key ? bindKey : bindIndex,
  205. parents = this._parents,
  206. groups = this._groups;
  207. if (typeof value !== "function") value = constant(value);
  208. for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {
  209. var parent = parents[j],
  210. group = groups[j],
  211. groupLength = group.length,
  212. data = value.call(parent, parent && parent.__data__, j, parents),
  213. dataLength = data.length,
  214. enterGroup = enter[j] = new Array(dataLength),
  215. updateGroup = update[j] = new Array(dataLength),
  216. exitGroup = exit[j] = new Array(groupLength);
  217. bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
  218. // Now connect the enter nodes to their following update node, such that
  219. // appendChild can insert the materialized enter node before this node,
  220. // rather than at the end of the parent node.
  221. for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
  222. if (previous = enterGroup[i0]) {
  223. if (i0 >= i1) i1 = i0 + 1;
  224. while (!(next = updateGroup[i1]) && ++i1 < dataLength);
  225. previous._next = next || null;
  226. }
  227. }
  228. }
  229. update = new Selection(update, parents);
  230. update._enter = enter;
  231. update._exit = exit;
  232. return update;
  233. }
  234. function selection_exit() {
  235. return new Selection(this._exit || this._groups.map(sparse), this._parents);
  236. }
  237. function selection_merge(selection$$1) {
  238. 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) {
  239. for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
  240. if (node = group0[i] || group1[i]) {
  241. merge[i] = node;
  242. }
  243. }
  244. }
  245. for (; j < m0; ++j) {
  246. merges[j] = groups0[j];
  247. }
  248. return new Selection(merges, this._parents);
  249. }
  250. function selection_order() {
  251. for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) {
  252. for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
  253. if (node = group[i]) {
  254. if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
  255. next = node;
  256. }
  257. }
  258. }
  259. return this;
  260. }
  261. function selection_sort(compare) {
  262. if (!compare) compare = ascending;
  263. function compareNode(a, b) {
  264. return a && b ? compare(a.__data__, b.__data__) : !a - !b;
  265. }
  266. for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) {
  267. for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) {
  268. if (node = group[i]) {
  269. sortgroup[i] = node;
  270. }
  271. }
  272. sortgroup.sort(compareNode);
  273. }
  274. return new Selection(sortgroups, this._parents).order();
  275. }
  276. function ascending(a, b) {
  277. return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
  278. }
  279. function selection_call() {
  280. var callback = arguments[0];
  281. arguments[0] = this;
  282. callback.apply(null, arguments);
  283. return this;
  284. }
  285. function selection_nodes() {
  286. var nodes = new Array(this.size()), i = -1;
  287. this.each(function() { nodes[++i] = this; });
  288. return nodes;
  289. }
  290. function selection_node() {
  291. for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
  292. for (var group = groups[j], i = 0, n = group.length; i < n; ++i) {
  293. var node = group[i];
  294. if (node) return node;
  295. }
  296. }
  297. return null;
  298. }
  299. function selection_size() {
  300. var size = 0;
  301. this.each(function() { ++size; });
  302. return size;
  303. }
  304. function selection_empty() {
  305. return !this.node();
  306. }
  307. function selection_each(callback) {
  308. for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
  309. for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {
  310. if (node = group[i]) callback.call(node, node.__data__, i, group);
  311. }
  312. }
  313. return this;
  314. }
  315. function attrRemove(name) {
  316. return function() {
  317. this.removeAttribute(name);
  318. };
  319. }
  320. function attrRemoveNS(fullname) {
  321. return function() {
  322. this.removeAttributeNS(fullname.space, fullname.local);
  323. };
  324. }
  325. function attrConstant(name, value) {
  326. return function() {
  327. this.setAttribute(name, value);
  328. };
  329. }
  330. function attrConstantNS(fullname, value) {
  331. return function() {
  332. this.setAttributeNS(fullname.space, fullname.local, value);
  333. };
  334. }
  335. function attrFunction(name, value) {
  336. return function() {
  337. var v = value.apply(this, arguments);
  338. if (v == null) this.removeAttribute(name);
  339. else this.setAttribute(name, v);
  340. };
  341. }
  342. function attrFunctionNS(fullname, value) {
  343. return function() {
  344. var v = value.apply(this, arguments);
  345. if (v == null) this.removeAttributeNS(fullname.space, fullname.local);
  346. else this.setAttributeNS(fullname.space, fullname.local, v);
  347. };
  348. }
  349. function selection_attr(name, value) {
  350. var fullname = namespace(name);
  351. if (arguments.length < 2) {
  352. var node = this.node();
  353. return fullname.local
  354. ? node.getAttributeNS(fullname.space, fullname.local)
  355. : node.getAttribute(fullname);
  356. }
  357. return this.each((value == null
  358. ? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
  359. ? (fullname.local ? attrFunctionNS : attrFunction)
  360. : (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
  361. }
  362. function defaultView(node) {
  363. return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
  364. || (node.document && node) // node is a Window
  365. || node.defaultView; // node is a Document
  366. }
  367. function styleRemove(name) {
  368. return function() {
  369. this.style.removeProperty(name);
  370. };
  371. }
  372. function styleConstant(name, value, priority) {
  373. return function() {
  374. this.style.setProperty(name, value, priority);
  375. };
  376. }
  377. function styleFunction(name, value, priority) {
  378. return function() {
  379. var v = value.apply(this, arguments);
  380. if (v == null) this.style.removeProperty(name);
  381. else this.style.setProperty(name, v, priority);
  382. };
  383. }
  384. function selection_style(name, value, priority) {
  385. return arguments.length > 1
  386. ? this.each((value == null
  387. ? styleRemove : typeof value === "function"
  388. ? styleFunction
  389. : styleConstant)(name, value, priority == null ? "" : priority))
  390. : styleValue(this.node(), name);
  391. }
  392. function styleValue(node, name) {
  393. return node.style.getPropertyValue(name)
  394. || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
  395. }
  396. function propertyRemove(name) {
  397. return function() {
  398. delete this[name];
  399. };
  400. }
  401. function propertyConstant(name, value) {
  402. return function() {
  403. this[name] = value;
  404. };
  405. }
  406. function propertyFunction(name, value) {
  407. return function() {
  408. var v = value.apply(this, arguments);
  409. if (v == null) delete this[name];
  410. else this[name] = v;
  411. };
  412. }
  413. function selection_property(name, value) {
  414. return arguments.length > 1
  415. ? this.each((value == null
  416. ? propertyRemove : typeof value === "function"
  417. ? propertyFunction
  418. : propertyConstant)(name, value))
  419. : this.node()[name];
  420. }
  421. function classArray(string) {
  422. return string.trim().split(/^|\s+/);
  423. }
  424. function classList(node) {
  425. return node.classList || new ClassList(node);
  426. }
  427. function ClassList(node) {
  428. this._node = node;
  429. this._names = classArray(node.getAttribute("class") || "");
  430. }
  431. ClassList.prototype = {
  432. add: function(name) {
  433. var i = this._names.indexOf(name);
  434. if (i < 0) {
  435. this._names.push(name);
  436. this._node.setAttribute("class", this._names.join(" "));
  437. }
  438. },
  439. remove: function(name) {
  440. var i = this._names.indexOf(name);
  441. if (i >= 0) {
  442. this._names.splice(i, 1);
  443. this._node.setAttribute("class", this._names.join(" "));
  444. }
  445. },
  446. contains: function(name) {
  447. return this._names.indexOf(name) >= 0;
  448. }
  449. };
  450. function classedAdd(node, names) {
  451. var list = classList(node), i = -1, n = names.length;
  452. while (++i < n) list.add(names[i]);
  453. }
  454. function classedRemove(node, names) {
  455. var list = classList(node), i = -1, n = names.length;
  456. while (++i < n) list.remove(names[i]);
  457. }
  458. function classedTrue(names) {
  459. return function() {
  460. classedAdd(this, names);
  461. };
  462. }
  463. function classedFalse(names) {
  464. return function() {
  465. classedRemove(this, names);
  466. };
  467. }
  468. function classedFunction(names, value) {
  469. return function() {
  470. (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
  471. };
  472. }
  473. function selection_classed(name, value) {
  474. var names = classArray(name + "");
  475. if (arguments.length < 2) {
  476. var list = classList(this.node()), i = -1, n = names.length;
  477. while (++i < n) if (!list.contains(names[i])) return false;
  478. return true;
  479. }
  480. return this.each((typeof value === "function"
  481. ? classedFunction : value
  482. ? classedTrue
  483. : classedFalse)(names, value));
  484. }
  485. function textRemove() {
  486. this.textContent = "";
  487. }
  488. function textConstant(value) {
  489. return function() {
  490. this.textContent = value;
  491. };
  492. }
  493. function textFunction(value) {
  494. return function() {
  495. var v = value.apply(this, arguments);
  496. this.textContent = v == null ? "" : v;
  497. };
  498. }
  499. function selection_text(value) {
  500. return arguments.length
  501. ? this.each(value == null
  502. ? textRemove : (typeof value === "function"
  503. ? textFunction
  504. : textConstant)(value))
  505. : this.node().textContent;
  506. }
  507. function htmlRemove() {
  508. this.innerHTML = "";
  509. }
  510. function htmlConstant(value) {
  511. return function() {
  512. this.innerHTML = value;
  513. };
  514. }
  515. function htmlFunction(value) {
  516. return function() {
  517. var v = value.apply(this, arguments);
  518. this.innerHTML = v == null ? "" : v;
  519. };
  520. }
  521. function selection_html(value) {
  522. return arguments.length
  523. ? this.each(value == null
  524. ? htmlRemove : (typeof value === "function"
  525. ? htmlFunction
  526. : htmlConstant)(value))
  527. : this.node().innerHTML;
  528. }
  529. function raise() {
  530. if (this.nextSibling) this.parentNode.appendChild(this);
  531. }
  532. function selection_raise() {
  533. return this.each(raise);
  534. }
  535. function lower() {
  536. if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);
  537. }
  538. function selection_lower() {
  539. return this.each(lower);
  540. }
  541. function selection_append(name) {
  542. var create = typeof name === "function" ? name : creator(name);
  543. return this.select(function() {
  544. return this.appendChild(create.apply(this, arguments));
  545. });
  546. }
  547. function constantNull() {
  548. return null;
  549. }
  550. function selection_insert(name, before) {
  551. var create = typeof name === "function" ? name : creator(name),
  552. select = before == null ? constantNull : typeof before === "function" ? before : selector(before);
  553. return this.select(function() {
  554. return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
  555. });
  556. }
  557. function remove() {
  558. var parent = this.parentNode;
  559. if (parent) parent.removeChild(this);
  560. }
  561. function selection_remove() {
  562. return this.each(remove);
  563. }
  564. function selection_cloneShallow() {
  565. return this.parentNode.insertBefore(this.cloneNode(false), this.nextSibling);
  566. }
  567. function selection_cloneDeep() {
  568. return this.parentNode.insertBefore(this.cloneNode(true), this.nextSibling);
  569. }
  570. function selection_clone(deep) {
  571. return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
  572. }
  573. function selection_datum(value) {
  574. return arguments.length
  575. ? this.property("__data__", value)
  576. : this.node().__data__;
  577. }
  578. var filterEvents = {};
  579. exports.event = null;
  580. if (typeof document !== "undefined") {
  581. var element$1 = document.documentElement;
  582. if (!("onmouseenter" in element$1)) {
  583. filterEvents = {mouseenter: "mouseover", mouseleave: "mouseout"};
  584. }
  585. }
  586. function filterContextListener(listener, index, group) {
  587. listener = contextListener(listener, index, group);
  588. return function(event) {
  589. var related = event.relatedTarget;
  590. if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
  591. listener.call(this, event);
  592. }
  593. };
  594. }
  595. function contextListener(listener, index, group) {
  596. return function(event1) {
  597. var event0 = exports.event; // Events can be reentrant (e.g., focus).
  598. exports.event = event1;
  599. try {
  600. listener.call(this, this.__data__, index, group);
  601. } finally {
  602. exports.event = event0;
  603. }
  604. };
  605. }
  606. function parseTypenames(typenames) {
  607. return typenames.trim().split(/^|\s+/).map(function(t) {
  608. var name = "", i = t.indexOf(".");
  609. if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
  610. return {type: t, name: name};
  611. });
  612. }
  613. function onRemove(typename) {
  614. return function() {
  615. var on = this.__on;
  616. if (!on) return;
  617. for (var j = 0, i = -1, m = on.length, o; j < m; ++j) {
  618. if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) {
  619. this.removeEventListener(o.type, o.listener, o.capture);
  620. } else {
  621. on[++i] = o;
  622. }
  623. }
  624. if (++i) on.length = i;
  625. else delete this.__on;
  626. };
  627. }
  628. function onAdd(typename, value, capture) {
  629. var wrap = filterEvents.hasOwnProperty(typename.type) ? filterContextListener : contextListener;
  630. return function(d, i, group) {
  631. var on = this.__on, o, listener = wrap(value, i, group);
  632. if (on) for (var j = 0, m = on.length; j < m; ++j) {
  633. if ((o = on[j]).type === typename.type && o.name === typename.name) {
  634. this.removeEventListener(o.type, o.listener, o.capture);
  635. this.addEventListener(o.type, o.listener = listener, o.capture = capture);
  636. o.value = value;
  637. return;
  638. }
  639. }
  640. this.addEventListener(typename.type, listener, capture);
  641. o = {type: typename.type, name: typename.name, value: value, listener: listener, capture: capture};
  642. if (!on) this.__on = [o];
  643. else on.push(o);
  644. };
  645. }
  646. function selection_on(typename, value, capture) {
  647. var typenames = parseTypenames(typename + ""), i, n = typenames.length, t;
  648. if (arguments.length < 2) {
  649. var on = this.node().__on;
  650. if (on) for (var j = 0, m = on.length, o; j < m; ++j) {
  651. for (i = 0, o = on[j]; i < n; ++i) {
  652. if ((t = typenames[i]).type === o.type && t.name === o.name) {
  653. return o.value;
  654. }
  655. }
  656. }
  657. return;
  658. }
  659. on = value ? onAdd : onRemove;
  660. if (capture == null) capture = false;
  661. for (i = 0; i < n; ++i) this.each(on(typenames[i], value, capture));
  662. return this;
  663. }
  664. function customEvent(event1, listener, that, args) {
  665. var event0 = exports.event;
  666. event1.sourceEvent = exports.event;
  667. exports.event = event1;
  668. try {
  669. return listener.apply(that, args);
  670. } finally {
  671. exports.event = event0;
  672. }
  673. }
  674. function dispatchEvent(node, type, params) {
  675. var window = defaultView(node),
  676. event = window.CustomEvent;
  677. if (typeof event === "function") {
  678. event = new event(type, params);
  679. } else {
  680. event = window.document.createEvent("Event");
  681. if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
  682. else event.initEvent(type, false, false);
  683. }
  684. node.dispatchEvent(event);
  685. }
  686. function dispatchConstant(type, params) {
  687. return function() {
  688. return dispatchEvent(this, type, params);
  689. };
  690. }
  691. function dispatchFunction(type, params) {
  692. return function() {
  693. return dispatchEvent(this, type, params.apply(this, arguments));
  694. };
  695. }
  696. function selection_dispatch(type, params) {
  697. return this.each((typeof params === "function"
  698. ? dispatchFunction
  699. : dispatchConstant)(type, params));
  700. }
  701. var root = [null];
  702. function Selection(groups, parents) {
  703. this._groups = groups;
  704. this._parents = parents;
  705. }
  706. function selection() {
  707. return new Selection([[document.documentElement]], root);
  708. }
  709. Selection.prototype = selection.prototype = {
  710. constructor: Selection,
  711. select: selection_select,
  712. selectAll: selection_selectAll,
  713. filter: selection_filter,
  714. data: selection_data,
  715. enter: selection_enter,
  716. exit: selection_exit,
  717. merge: selection_merge,
  718. order: selection_order,
  719. sort: selection_sort,
  720. call: selection_call,
  721. nodes: selection_nodes,
  722. node: selection_node,
  723. size: selection_size,
  724. empty: selection_empty,
  725. each: selection_each,
  726. attr: selection_attr,
  727. style: selection_style,
  728. property: selection_property,
  729. classed: selection_classed,
  730. text: selection_text,
  731. html: selection_html,
  732. raise: selection_raise,
  733. lower: selection_lower,
  734. append: selection_append,
  735. insert: selection_insert,
  736. remove: selection_remove,
  737. clone: selection_clone,
  738. datum: selection_datum,
  739. on: selection_on,
  740. dispatch: selection_dispatch
  741. };
  742. function select(selector) {
  743. return typeof selector === "string"
  744. ? new Selection([[document.querySelector(selector)]], [document.documentElement])
  745. : new Selection([[selector]], root);
  746. }
  747. function create(name) {
  748. return select(creator(name).call(document.documentElement));
  749. }
  750. var nextId = 0;
  751. function local() {
  752. return new Local;
  753. }
  754. function Local() {
  755. this._ = "@" + (++nextId).toString(36);
  756. }
  757. Local.prototype = local.prototype = {
  758. constructor: Local,
  759. get: function(node) {
  760. var id = this._;
  761. while (!(id in node)) if (!(node = node.parentNode)) return;
  762. return node[id];
  763. },
  764. set: function(node, value) {
  765. return node[this._] = value;
  766. },
  767. remove: function(node) {
  768. return this._ in node && delete node[this._];
  769. },
  770. toString: function() {
  771. return this._;
  772. }
  773. };
  774. function sourceEvent() {
  775. var current = exports.event, source;
  776. while (source = current.sourceEvent) current = source;
  777. return current;
  778. }
  779. function point(node, event) {
  780. var svg = node.ownerSVGElement || node;
  781. if (svg.createSVGPoint) {
  782. var point = svg.createSVGPoint();
  783. point.x = event.clientX, point.y = event.clientY;
  784. point = point.matrixTransform(node.getScreenCTM().inverse());
  785. return [point.x, point.y];
  786. }
  787. var rect = node.getBoundingClientRect();
  788. return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
  789. }
  790. function mouse(node) {
  791. var event = sourceEvent();
  792. if (event.changedTouches) event = event.changedTouches[0];
  793. return point(node, event);
  794. }
  795. function selectAll(selector) {
  796. return typeof selector === "string"
  797. ? new Selection([document.querySelectorAll(selector)], [document.documentElement])
  798. : new Selection([selector == null ? [] : selector], root);
  799. }
  800. function touch(node, touches, identifier) {
  801. if (arguments.length < 3) identifier = touches, touches = sourceEvent().changedTouches;
  802. for (var i = 0, n = touches ? touches.length : 0, touch; i < n; ++i) {
  803. if ((touch = touches[i]).identifier === identifier) {
  804. return point(node, touch);
  805. }
  806. }
  807. return null;
  808. }
  809. function touches(node, touches) {
  810. if (touches == null) touches = sourceEvent().touches;
  811. for (var i = 0, n = touches ? touches.length : 0, points = new Array(n); i < n; ++i) {
  812. points[i] = point(node, touches[i]);
  813. }
  814. return points;
  815. }
  816. exports.create = create;
  817. exports.creator = creator;
  818. exports.local = local;
  819. exports.matcher = matcher$1;
  820. exports.mouse = mouse;
  821. exports.namespace = namespace;
  822. exports.namespaces = namespaces;
  823. exports.clientPoint = point;
  824. exports.select = select;
  825. exports.selectAll = selectAll;
  826. exports.selection = selection;
  827. exports.selector = selector;
  828. exports.selectorAll = selectorAll;
  829. exports.style = styleValue;
  830. exports.touch = touch;
  831. exports.touches = touches;
  832. exports.window = defaultView;
  833. exports.customEvent = customEvent;
  834. Object.defineProperty(exports, '__esModule', { value: true });
  835. })));