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.

787 lines
22 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. // https://d3js.org/d3-transition/ v1.1.3 Copyright 2018 Mike Bostock
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-timer'), require('d3-color'), require('d3-interpolate'), require('d3-selection'), require('d3-ease')) :
  4. typeof define === 'function' && define.amd ? define(['exports', 'd3-dispatch', 'd3-timer', 'd3-color', 'd3-interpolate', 'd3-selection', 'd3-ease'], factory) :
  5. (factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3,global.d3,global.d3));
  6. }(this, (function (exports,d3Dispatch,d3Timer,d3Color,d3Interpolate,d3Selection,d3Ease) { 'use strict';
  7. var emptyOn = d3Dispatch.dispatch("start", "end", "interrupt");
  8. var emptyTween = [];
  9. var CREATED = 0;
  10. var SCHEDULED = 1;
  11. var STARTING = 2;
  12. var STARTED = 3;
  13. var RUNNING = 4;
  14. var ENDING = 5;
  15. var ENDED = 6;
  16. function schedule(node, name, id, index, group, timing) {
  17. var schedules = node.__transition;
  18. if (!schedules) node.__transition = {};
  19. else if (id in schedules) return;
  20. create(node, id, {
  21. name: name,
  22. index: index, // For context during callback.
  23. group: group, // For context during callback.
  24. on: emptyOn,
  25. tween: emptyTween,
  26. time: timing.time,
  27. delay: timing.delay,
  28. duration: timing.duration,
  29. ease: timing.ease,
  30. timer: null,
  31. state: CREATED
  32. });
  33. }
  34. function init(node, id) {
  35. var schedule = get(node, id);
  36. if (schedule.state > CREATED) throw new Error("too late; already scheduled");
  37. return schedule;
  38. }
  39. function set(node, id) {
  40. var schedule = get(node, id);
  41. if (schedule.state > STARTING) throw new Error("too late; already started");
  42. return schedule;
  43. }
  44. function get(node, id) {
  45. var schedule = node.__transition;
  46. if (!schedule || !(schedule = schedule[id])) throw new Error("transition not found");
  47. return schedule;
  48. }
  49. function create(node, id, self) {
  50. var schedules = node.__transition,
  51. tween;
  52. // Initialize the self timer when the transition is created.
  53. // Note the actual delay is not known until the first callback!
  54. schedules[id] = self;
  55. self.timer = d3Timer.timer(schedule, 0, self.time);
  56. function schedule(elapsed) {
  57. self.state = SCHEDULED;
  58. self.timer.restart(start, self.delay, self.time);
  59. // If the elapsed delay is less than our first sleep, start immediately.
  60. if (self.delay <= elapsed) start(elapsed - self.delay);
  61. }
  62. function start(elapsed) {
  63. var i, j, n, o;
  64. // If the state is not SCHEDULED, then we previously errored on start.
  65. if (self.state !== SCHEDULED) return stop();
  66. for (i in schedules) {
  67. o = schedules[i];
  68. if (o.name !== self.name) continue;
  69. // While this element already has a starting transition during this frame,
  70. // defer starting an interrupting transition until that transition has a
  71. // chance to tick (and possibly end); see d3/d3-transition#54!
  72. if (o.state === STARTED) return d3Timer.timeout(start);
  73. // Interrupt the active transition, if any.
  74. // Dispatch the interrupt event.
  75. if (o.state === RUNNING) {
  76. o.state = ENDED;
  77. o.timer.stop();
  78. o.on.call("interrupt", node, node.__data__, o.index, o.group);
  79. delete schedules[i];
  80. }
  81. // Cancel any pre-empted transitions. No interrupt event is dispatched
  82. // because the cancelled transitions never started. Note that this also
  83. // removes this transition from the pending list!
  84. else if (+i < id) {
  85. o.state = ENDED;
  86. o.timer.stop();
  87. delete schedules[i];
  88. }
  89. }
  90. // Defer the first tick to end of the current frame; see d3/d3#1576.
  91. // Note the transition may be canceled after start and before the first tick!
  92. // Note this must be scheduled before the start event; see d3/d3-transition#16!
  93. // Assuming this is successful, subsequent callbacks go straight to tick.
  94. d3Timer.timeout(function() {
  95. if (self.state === STARTED) {
  96. self.state = RUNNING;
  97. self.timer.restart(tick, self.delay, self.time);
  98. tick(elapsed);
  99. }
  100. });
  101. // Dispatch the start event.
  102. // Note this must be done before the tween are initialized.
  103. self.state = STARTING;
  104. self.on.call("start", node, node.__data__, self.index, self.group);
  105. if (self.state !== STARTING) return; // interrupted
  106. self.state = STARTED;
  107. // Initialize the tween, deleting null tween.
  108. tween = new Array(n = self.tween.length);
  109. for (i = 0, j = -1; i < n; ++i) {
  110. if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) {
  111. tween[++j] = o;
  112. }
  113. }
  114. tween.length = j + 1;
  115. }
  116. function tick(elapsed) {
  117. var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1),
  118. i = -1,
  119. n = tween.length;
  120. while (++i < n) {
  121. tween[i].call(null, t);
  122. }
  123. // Dispatch the end event.
  124. if (self.state === ENDING) {
  125. self.on.call("end", node, node.__data__, self.index, self.group);
  126. stop();
  127. }
  128. }
  129. function stop() {
  130. self.state = ENDED;
  131. self.timer.stop();
  132. delete schedules[id];
  133. for (var i in schedules) return; // eslint-disable-line no-unused-vars
  134. delete node.__transition;
  135. }
  136. }
  137. function interrupt(node, name) {
  138. var schedules = node.__transition,
  139. schedule$$1,
  140. active,
  141. empty = true,
  142. i;
  143. if (!schedules) return;
  144. name = name == null ? null : name + "";
  145. for (i in schedules) {
  146. if ((schedule$$1 = schedules[i]).name !== name) { empty = false; continue; }
  147. active = schedule$$1.state > STARTING && schedule$$1.state < ENDING;
  148. schedule$$1.state = ENDED;
  149. schedule$$1.timer.stop();
  150. if (active) schedule$$1.on.call("interrupt", node, node.__data__, schedule$$1.index, schedule$$1.group);
  151. delete schedules[i];
  152. }
  153. if (empty) delete node.__transition;
  154. }
  155. function selection_interrupt(name) {
  156. return this.each(function() {
  157. interrupt(this, name);
  158. });
  159. }
  160. function tweenRemove(id, name) {
  161. var tween0, tween1;
  162. return function() {
  163. var schedule$$1 = set(this, id),
  164. tween = schedule$$1.tween;
  165. // If this node shared tween with the previous node,
  166. // just assign the updated shared tween and we’re done!
  167. // Otherwise, copy-on-write.
  168. if (tween !== tween0) {
  169. tween1 = tween0 = tween;
  170. for (var i = 0, n = tween1.length; i < n; ++i) {
  171. if (tween1[i].name === name) {
  172. tween1 = tween1.slice();
  173. tween1.splice(i, 1);
  174. break;
  175. }
  176. }
  177. }
  178. schedule$$1.tween = tween1;
  179. };
  180. }
  181. function tweenFunction(id, name, value) {
  182. var tween0, tween1;
  183. if (typeof value !== "function") throw new Error;
  184. return function() {
  185. var schedule$$1 = set(this, id),
  186. tween = schedule$$1.tween;
  187. // If this node shared tween with the previous node,
  188. // just assign the updated shared tween and we’re done!
  189. // Otherwise, copy-on-write.
  190. if (tween !== tween0) {
  191. tween1 = (tween0 = tween).slice();
  192. for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) {
  193. if (tween1[i].name === name) {
  194. tween1[i] = t;
  195. break;
  196. }
  197. }
  198. if (i === n) tween1.push(t);
  199. }
  200. schedule$$1.tween = tween1;
  201. };
  202. }
  203. function transition_tween(name, value) {
  204. var id = this._id;
  205. name += "";
  206. if (arguments.length < 2) {
  207. var tween = get(this.node(), id).tween;
  208. for (var i = 0, n = tween.length, t; i < n; ++i) {
  209. if ((t = tween[i]).name === name) {
  210. return t.value;
  211. }
  212. }
  213. return null;
  214. }
  215. return this.each((value == null ? tweenRemove : tweenFunction)(id, name, value));
  216. }
  217. function tweenValue(transition, name, value) {
  218. var id = transition._id;
  219. transition.each(function() {
  220. var schedule$$1 = set(this, id);
  221. (schedule$$1.value || (schedule$$1.value = {}))[name] = value.apply(this, arguments);
  222. });
  223. return function(node) {
  224. return get(node, id).value[name];
  225. };
  226. }
  227. function interpolate(a, b) {
  228. var c;
  229. return (typeof b === "number" ? d3Interpolate.interpolateNumber
  230. : b instanceof d3Color.color ? d3Interpolate.interpolateRgb
  231. : (c = d3Color.color(b)) ? (b = c, d3Interpolate.interpolateRgb)
  232. : d3Interpolate.interpolateString)(a, b);
  233. }
  234. function attrRemove(name) {
  235. return function() {
  236. this.removeAttribute(name);
  237. };
  238. }
  239. function attrRemoveNS(fullname) {
  240. return function() {
  241. this.removeAttributeNS(fullname.space, fullname.local);
  242. };
  243. }
  244. function attrConstant(name, interpolate$$1, value1) {
  245. var value00,
  246. interpolate0;
  247. return function() {
  248. var value0 = this.getAttribute(name);
  249. return value0 === value1 ? null
  250. : value0 === value00 ? interpolate0
  251. : interpolate0 = interpolate$$1(value00 = value0, value1);
  252. };
  253. }
  254. function attrConstantNS(fullname, interpolate$$1, value1) {
  255. var value00,
  256. interpolate0;
  257. return function() {
  258. var value0 = this.getAttributeNS(fullname.space, fullname.local);
  259. return value0 === value1 ? null
  260. : value0 === value00 ? interpolate0
  261. : interpolate0 = interpolate$$1(value00 = value0, value1);
  262. };
  263. }
  264. function attrFunction(name, interpolate$$1, value) {
  265. var value00,
  266. value10,
  267. interpolate0;
  268. return function() {
  269. var value0, value1 = value(this);
  270. if (value1 == null) return void this.removeAttribute(name);
  271. value0 = this.getAttribute(name);
  272. return value0 === value1 ? null
  273. : value0 === value00 && value1 === value10 ? interpolate0
  274. : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
  275. };
  276. }
  277. function attrFunctionNS(fullname, interpolate$$1, value) {
  278. var value00,
  279. value10,
  280. interpolate0;
  281. return function() {
  282. var value0, value1 = value(this);
  283. if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
  284. value0 = this.getAttributeNS(fullname.space, fullname.local);
  285. return value0 === value1 ? null
  286. : value0 === value00 && value1 === value10 ? interpolate0
  287. : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
  288. };
  289. }
  290. function transition_attr(name, value) {
  291. var fullname = d3Selection.namespace(name), i = fullname === "transform" ? d3Interpolate.interpolateTransformSvg : interpolate;
  292. return this.attrTween(name, typeof value === "function"
  293. ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value))
  294. : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname)
  295. : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value + ""));
  296. }
  297. function attrTweenNS(fullname, value) {
  298. function tween() {
  299. var node = this, i = value.apply(node, arguments);
  300. return i && function(t) {
  301. node.setAttributeNS(fullname.space, fullname.local, i(t));
  302. };
  303. }
  304. tween._value = value;
  305. return tween;
  306. }
  307. function attrTween(name, value) {
  308. function tween() {
  309. var node = this, i = value.apply(node, arguments);
  310. return i && function(t) {
  311. node.setAttribute(name, i(t));
  312. };
  313. }
  314. tween._value = value;
  315. return tween;
  316. }
  317. function transition_attrTween(name, value) {
  318. var key = "attr." + name;
  319. if (arguments.length < 2) return (key = this.tween(key)) && key._value;
  320. if (value == null) return this.tween(key, null);
  321. if (typeof value !== "function") throw new Error;
  322. var fullname = d3Selection.namespace(name);
  323. return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
  324. }
  325. function delayFunction(id, value) {
  326. return function() {
  327. init(this, id).delay = +value.apply(this, arguments);
  328. };
  329. }
  330. function delayConstant(id, value) {
  331. return value = +value, function() {
  332. init(this, id).delay = value;
  333. };
  334. }
  335. function transition_delay(value) {
  336. var id = this._id;
  337. return arguments.length
  338. ? this.each((typeof value === "function"
  339. ? delayFunction
  340. : delayConstant)(id, value))
  341. : get(this.node(), id).delay;
  342. }
  343. function durationFunction(id, value) {
  344. return function() {
  345. set(this, id).duration = +value.apply(this, arguments);
  346. };
  347. }
  348. function durationConstant(id, value) {
  349. return value = +value, function() {
  350. set(this, id).duration = value;
  351. };
  352. }
  353. function transition_duration(value) {
  354. var id = this._id;
  355. return arguments.length
  356. ? this.each((typeof value === "function"
  357. ? durationFunction
  358. : durationConstant)(id, value))
  359. : get(this.node(), id).duration;
  360. }
  361. function easeConstant(id, value) {
  362. if (typeof value !== "function") throw new Error;
  363. return function() {
  364. set(this, id).ease = value;
  365. };
  366. }
  367. function transition_ease(value) {
  368. var id = this._id;
  369. return arguments.length
  370. ? this.each(easeConstant(id, value))
  371. : get(this.node(), id).ease;
  372. }
  373. function transition_filter(match) {
  374. if (typeof match !== "function") match = d3Selection.matcher(match);
  375. for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
  376. for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
  377. if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
  378. subgroup.push(node);
  379. }
  380. }
  381. }
  382. return new Transition(subgroups, this._parents, this._name, this._id);
  383. }
  384. function transition_merge(transition$$1) {
  385. if (transition$$1._id !== this._id) throw new Error;
  386. 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) {
  387. for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
  388. if (node = group0[i] || group1[i]) {
  389. merge[i] = node;
  390. }
  391. }
  392. }
  393. for (; j < m0; ++j) {
  394. merges[j] = groups0[j];
  395. }
  396. return new Transition(merges, this._parents, this._name, this._id);
  397. }
  398. function start(name) {
  399. return (name + "").trim().split(/^|\s+/).every(function(t) {
  400. var i = t.indexOf(".");
  401. if (i >= 0) t = t.slice(0, i);
  402. return !t || t === "start";
  403. });
  404. }
  405. function onFunction(id, name, listener) {
  406. var on0, on1, sit = start(name) ? init : set;
  407. return function() {
  408. var schedule$$1 = sit(this, id),
  409. on = schedule$$1.on;
  410. // If this node shared a dispatch with the previous node,
  411. // just assign the updated shared dispatch and we’re done!
  412. // Otherwise, copy-on-write.
  413. if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
  414. schedule$$1.on = on1;
  415. };
  416. }
  417. function transition_on(name, listener) {
  418. var id = this._id;
  419. return arguments.length < 2
  420. ? get(this.node(), id).on.on(name)
  421. : this.each(onFunction(id, name, listener));
  422. }
  423. function removeFunction(id) {
  424. return function() {
  425. var parent = this.parentNode;
  426. for (var i in this.__transition) if (+i !== id) return;
  427. if (parent) parent.removeChild(this);
  428. };
  429. }
  430. function transition_remove() {
  431. return this.on("end.remove", removeFunction(this._id));
  432. }
  433. function transition_select(select) {
  434. var name = this._name,
  435. id = this._id;
  436. if (typeof select !== "function") select = d3Selection.selector(select);
  437. for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
  438. for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
  439. if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
  440. if ("__data__" in node) subnode.__data__ = node.__data__;
  441. subgroup[i] = subnode;
  442. schedule(subgroup[i], name, id, i, subgroup, get(node, id));
  443. }
  444. }
  445. }
  446. return new Transition(subgroups, this._parents, name, id);
  447. }
  448. function transition_selectAll(select) {
  449. var name = this._name,
  450. id = this._id;
  451. if (typeof select !== "function") select = d3Selection.selectorAll(select);
  452. for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
  453. for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  454. if (node = group[i]) {
  455. for (var children = select.call(node, node.__data__, i, group), child, inherit = get(node, id), k = 0, l = children.length; k < l; ++k) {
  456. if (child = children[k]) {
  457. schedule(child, name, id, k, children, inherit);
  458. }
  459. }
  460. subgroups.push(children);
  461. parents.push(node);
  462. }
  463. }
  464. }
  465. return new Transition(subgroups, parents, name, id);
  466. }
  467. var Selection = d3Selection.selection.prototype.constructor;
  468. function transition_selection() {
  469. return new Selection(this._groups, this._parents);
  470. }
  471. function styleRemove(name, interpolate$$1) {
  472. var value00,
  473. value10,
  474. interpolate0;
  475. return function() {
  476. var value0 = d3Selection.style(this, name),
  477. value1 = (this.style.removeProperty(name), d3Selection.style(this, name));
  478. return value0 === value1 ? null
  479. : value0 === value00 && value1 === value10 ? interpolate0
  480. : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
  481. };
  482. }
  483. function styleRemoveEnd(name) {
  484. return function() {
  485. this.style.removeProperty(name);
  486. };
  487. }
  488. function styleConstant(name, interpolate$$1, value1) {
  489. var value00,
  490. interpolate0;
  491. return function() {
  492. var value0 = d3Selection.style(this, name);
  493. return value0 === value1 ? null
  494. : value0 === value00 ? interpolate0
  495. : interpolate0 = interpolate$$1(value00 = value0, value1);
  496. };
  497. }
  498. function styleFunction(name, interpolate$$1, value) {
  499. var value00,
  500. value10,
  501. interpolate0;
  502. return function() {
  503. var value0 = d3Selection.style(this, name),
  504. value1 = value(this);
  505. if (value1 == null) value1 = (this.style.removeProperty(name), d3Selection.style(this, name));
  506. return value0 === value1 ? null
  507. : value0 === value00 && value1 === value10 ? interpolate0
  508. : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
  509. };
  510. }
  511. function transition_style(name, value, priority) {
  512. var i = (name += "") === "transform" ? d3Interpolate.interpolateTransformCss : interpolate;
  513. return value == null ? this
  514. .styleTween(name, styleRemove(name, i))
  515. .on("end.style." + name, styleRemoveEnd(name))
  516. : this.styleTween(name, typeof value === "function"
  517. ? styleFunction(name, i, tweenValue(this, "style." + name, value))
  518. : styleConstant(name, i, value + ""), priority);
  519. }
  520. function styleTween(name, value, priority) {
  521. function tween() {
  522. var node = this, i = value.apply(node, arguments);
  523. return i && function(t) {
  524. node.style.setProperty(name, i(t), priority);
  525. };
  526. }
  527. tween._value = value;
  528. return tween;
  529. }
  530. function transition_styleTween(name, value, priority) {
  531. var key = "style." + (name += "");
  532. if (arguments.length < 2) return (key = this.tween(key)) && key._value;
  533. if (value == null) return this.tween(key, null);
  534. if (typeof value !== "function") throw new Error;
  535. return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
  536. }
  537. function textConstant(value) {
  538. return function() {
  539. this.textContent = value;
  540. };
  541. }
  542. function textFunction(value) {
  543. return function() {
  544. var value1 = value(this);
  545. this.textContent = value1 == null ? "" : value1;
  546. };
  547. }
  548. function transition_text(value) {
  549. return this.tween("text", typeof value === "function"
  550. ? textFunction(tweenValue(this, "text", value))
  551. : textConstant(value == null ? "" : value + ""));
  552. }
  553. function transition_transition() {
  554. var name = this._name,
  555. id0 = this._id,
  556. id1 = newId();
  557. for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
  558. for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  559. if (node = group[i]) {
  560. var inherit = get(node, id0);
  561. schedule(node, name, id1, i, group, {
  562. time: inherit.time + inherit.delay + inherit.duration,
  563. delay: 0,
  564. duration: inherit.duration,
  565. ease: inherit.ease
  566. });
  567. }
  568. }
  569. }
  570. return new Transition(groups, this._parents, name, id1);
  571. }
  572. var id = 0;
  573. function Transition(groups, parents, name, id) {
  574. this._groups = groups;
  575. this._parents = parents;
  576. this._name = name;
  577. this._id = id;
  578. }
  579. function transition(name) {
  580. return d3Selection.selection().transition(name);
  581. }
  582. function newId() {
  583. return ++id;
  584. }
  585. var selection_prototype = d3Selection.selection.prototype;
  586. Transition.prototype = transition.prototype = {
  587. constructor: Transition,
  588. select: transition_select,
  589. selectAll: transition_selectAll,
  590. filter: transition_filter,
  591. merge: transition_merge,
  592. selection: transition_selection,
  593. transition: transition_transition,
  594. call: selection_prototype.call,
  595. nodes: selection_prototype.nodes,
  596. node: selection_prototype.node,
  597. size: selection_prototype.size,
  598. empty: selection_prototype.empty,
  599. each: selection_prototype.each,
  600. on: transition_on,
  601. attr: transition_attr,
  602. attrTween: transition_attrTween,
  603. style: transition_style,
  604. styleTween: transition_styleTween,
  605. text: transition_text,
  606. remove: transition_remove,
  607. tween: transition_tween,
  608. delay: transition_delay,
  609. duration: transition_duration,
  610. ease: transition_ease
  611. };
  612. var defaultTiming = {
  613. time: null, // Set on use.
  614. delay: 0,
  615. duration: 250,
  616. ease: d3Ease.easeCubicInOut
  617. };
  618. function inherit(node, id) {
  619. var timing;
  620. while (!(timing = node.__transition) || !(timing = timing[id])) {
  621. if (!(node = node.parentNode)) {
  622. return defaultTiming.time = d3Timer.now(), defaultTiming;
  623. }
  624. }
  625. return timing;
  626. }
  627. function selection_transition(name) {
  628. var id,
  629. timing;
  630. if (name instanceof Transition) {
  631. id = name._id, name = name._name;
  632. } else {
  633. id = newId(), (timing = defaultTiming).time = d3Timer.now(), name = name == null ? null : name + "";
  634. }
  635. for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
  636. for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  637. if (node = group[i]) {
  638. schedule(node, name, id, i, group, timing || inherit(node, id));
  639. }
  640. }
  641. }
  642. return new Transition(groups, this._parents, name, id);
  643. }
  644. d3Selection.selection.prototype.interrupt = selection_interrupt;
  645. d3Selection.selection.prototype.transition = selection_transition;
  646. var root = [null];
  647. function active(node, name) {
  648. var schedules = node.__transition,
  649. schedule$$1,
  650. i;
  651. if (schedules) {
  652. name = name == null ? null : name + "";
  653. for (i in schedules) {
  654. if ((schedule$$1 = schedules[i]).state > SCHEDULED && schedule$$1.name === name) {
  655. return new Transition([[node]], root, name, +i);
  656. }
  657. }
  658. }
  659. return null;
  660. }
  661. exports.transition = transition;
  662. exports.active = active;
  663. exports.interrupt = interrupt;
  664. Object.defineProperty(exports, '__esModule', { value: true });
  665. })));