Node-Red configuration
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  1. // https://d3js.org/d3-transition/ v3.0.1 Copyright 2010-2021 Mike Bostock
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('d3-dispatch'), require('d3-timer'), require('d3-interpolate'), require('d3-color'), require('d3-ease')) :
  4. typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-dispatch', 'd3-timer', 'd3-interpolate', 'd3-color', 'd3-ease'], factory) :
  5. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}, global.d3, global.d3, global.d3, global.d3, global.d3, global.d3));
  6. }(this, (function (exports, d3Selection, d3Dispatch, d3Timer, d3Interpolate, d3Color, d3Ease) { 'use strict';
  7. var emptyOn = d3Dispatch.dispatch("start", "end", "cancel", "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 > STARTED) throw new Error("too late; already running");
  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. if (o.state === RUNNING) {
  75. o.state = ENDED;
  76. o.timer.stop();
  77. o.on.call("interrupt", node, node.__data__, o.index, o.group);
  78. delete schedules[i];
  79. }
  80. // Cancel any pre-empted transitions.
  81. else if (+i < id) {
  82. o.state = ENDED;
  83. o.timer.stop();
  84. o.on.call("cancel", node, node.__data__, o.index, o.group);
  85. delete schedules[i];
  86. }
  87. }
  88. // Defer the first tick to end of the current frame; see d3/d3#1576.
  89. // Note the transition may be canceled after start and before the first tick!
  90. // Note this must be scheduled before the start event; see d3/d3-transition#16!
  91. // Assuming this is successful, subsequent callbacks go straight to tick.
  92. d3Timer.timeout(function() {
  93. if (self.state === STARTED) {
  94. self.state = RUNNING;
  95. self.timer.restart(tick, self.delay, self.time);
  96. tick(elapsed);
  97. }
  98. });
  99. // Dispatch the start event.
  100. // Note this must be done before the tween are initialized.
  101. self.state = STARTING;
  102. self.on.call("start", node, node.__data__, self.index, self.group);
  103. if (self.state !== STARTING) return; // interrupted
  104. self.state = STARTED;
  105. // Initialize the tween, deleting null tween.
  106. tween = new Array(n = self.tween.length);
  107. for (i = 0, j = -1; i < n; ++i) {
  108. if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) {
  109. tween[++j] = o;
  110. }
  111. }
  112. tween.length = j + 1;
  113. }
  114. function tick(elapsed) {
  115. var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1),
  116. i = -1,
  117. n = tween.length;
  118. while (++i < n) {
  119. tween[i].call(node, t);
  120. }
  121. // Dispatch the end event.
  122. if (self.state === ENDING) {
  123. self.on.call("end", node, node.__data__, self.index, self.group);
  124. stop();
  125. }
  126. }
  127. function stop() {
  128. self.state = ENDED;
  129. self.timer.stop();
  130. delete schedules[id];
  131. for (var i in schedules) return; // eslint-disable-line no-unused-vars
  132. delete node.__transition;
  133. }
  134. }
  135. function interrupt(node, name) {
  136. var schedules = node.__transition,
  137. schedule,
  138. active,
  139. empty = true,
  140. i;
  141. if (!schedules) return;
  142. name = name == null ? null : name + "";
  143. for (i in schedules) {
  144. if ((schedule = schedules[i]).name !== name) { empty = false; continue; }
  145. active = schedule.state > STARTING && schedule.state < ENDING;
  146. schedule.state = ENDED;
  147. schedule.timer.stop();
  148. schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group);
  149. delete schedules[i];
  150. }
  151. if (empty) delete node.__transition;
  152. }
  153. function selection_interrupt(name) {
  154. return this.each(function() {
  155. interrupt(this, name);
  156. });
  157. }
  158. function tweenRemove(id, name) {
  159. var tween0, tween1;
  160. return function() {
  161. var schedule = set(this, id),
  162. tween = schedule.tween;
  163. // If this node shared tween with the previous node,
  164. // just assign the updated shared tween and we’re done!
  165. // Otherwise, copy-on-write.
  166. if (tween !== tween0) {
  167. tween1 = tween0 = tween;
  168. for (var i = 0, n = tween1.length; i < n; ++i) {
  169. if (tween1[i].name === name) {
  170. tween1 = tween1.slice();
  171. tween1.splice(i, 1);
  172. break;
  173. }
  174. }
  175. }
  176. schedule.tween = tween1;
  177. };
  178. }
  179. function tweenFunction(id, name, value) {
  180. var tween0, tween1;
  181. if (typeof value !== "function") throw new Error;
  182. return function() {
  183. var schedule = set(this, id),
  184. tween = schedule.tween;
  185. // If this node shared tween with the previous node,
  186. // just assign the updated shared tween and we’re done!
  187. // Otherwise, copy-on-write.
  188. if (tween !== tween0) {
  189. tween1 = (tween0 = tween).slice();
  190. for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) {
  191. if (tween1[i].name === name) {
  192. tween1[i] = t;
  193. break;
  194. }
  195. }
  196. if (i === n) tween1.push(t);
  197. }
  198. schedule.tween = tween1;
  199. };
  200. }
  201. function transition_tween(name, value) {
  202. var id = this._id;
  203. name += "";
  204. if (arguments.length < 2) {
  205. var tween = get(this.node(), id).tween;
  206. for (var i = 0, n = tween.length, t; i < n; ++i) {
  207. if ((t = tween[i]).name === name) {
  208. return t.value;
  209. }
  210. }
  211. return null;
  212. }
  213. return this.each((value == null ? tweenRemove : tweenFunction)(id, name, value));
  214. }
  215. function tweenValue(transition, name, value) {
  216. var id = transition._id;
  217. transition.each(function() {
  218. var schedule = set(this, id);
  219. (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments);
  220. });
  221. return function(node) {
  222. return get(node, id).value[name];
  223. };
  224. }
  225. function interpolate(a, b) {
  226. var c;
  227. return (typeof b === "number" ? d3Interpolate.interpolateNumber
  228. : b instanceof d3Color.color ? d3Interpolate.interpolateRgb
  229. : (c = d3Color.color(b)) ? (b = c, d3Interpolate.interpolateRgb)
  230. : d3Interpolate.interpolateString)(a, b);
  231. }
  232. function attrRemove(name) {
  233. return function() {
  234. this.removeAttribute(name);
  235. };
  236. }
  237. function attrRemoveNS(fullname) {
  238. return function() {
  239. this.removeAttributeNS(fullname.space, fullname.local);
  240. };
  241. }
  242. function attrConstant(name, interpolate, value1) {
  243. var string00,
  244. string1 = value1 + "",
  245. interpolate0;
  246. return function() {
  247. var string0 = this.getAttribute(name);
  248. return string0 === string1 ? null
  249. : string0 === string00 ? interpolate0
  250. : interpolate0 = interpolate(string00 = string0, value1);
  251. };
  252. }
  253. function attrConstantNS(fullname, interpolate, value1) {
  254. var string00,
  255. string1 = value1 + "",
  256. interpolate0;
  257. return function() {
  258. var string0 = this.getAttributeNS(fullname.space, fullname.local);
  259. return string0 === string1 ? null
  260. : string0 === string00 ? interpolate0
  261. : interpolate0 = interpolate(string00 = string0, value1);
  262. };
  263. }
  264. function attrFunction(name, interpolate, value) {
  265. var string00,
  266. string10,
  267. interpolate0;
  268. return function() {
  269. var string0, value1 = value(this), string1;
  270. if (value1 == null) return void this.removeAttribute(name);
  271. string0 = this.getAttribute(name);
  272. string1 = value1 + "";
  273. return string0 === string1 ? null
  274. : string0 === string00 && string1 === string10 ? interpolate0
  275. : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
  276. };
  277. }
  278. function attrFunctionNS(fullname, interpolate, value) {
  279. var string00,
  280. string10,
  281. interpolate0;
  282. return function() {
  283. var string0, value1 = value(this), string1;
  284. if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
  285. string0 = this.getAttributeNS(fullname.space, fullname.local);
  286. string1 = value1 + "";
  287. return string0 === string1 ? null
  288. : string0 === string00 && string1 === string10 ? interpolate0
  289. : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
  290. };
  291. }
  292. function transition_attr(name, value) {
  293. var fullname = d3Selection.namespace(name), i = fullname === "transform" ? d3Interpolate.interpolateTransformSvg : interpolate;
  294. return this.attrTween(name, typeof value === "function"
  295. ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value))
  296. : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname)
  297. : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value));
  298. }
  299. function attrInterpolate(name, i) {
  300. return function(t) {
  301. this.setAttribute(name, i.call(this, t));
  302. };
  303. }
  304. function attrInterpolateNS(fullname, i) {
  305. return function(t) {
  306. this.setAttributeNS(fullname.space, fullname.local, i.call(this, t));
  307. };
  308. }
  309. function attrTweenNS(fullname, value) {
  310. var t0, i0;
  311. function tween() {
  312. var i = value.apply(this, arguments);
  313. if (i !== i0) t0 = (i0 = i) && attrInterpolateNS(fullname, i);
  314. return t0;
  315. }
  316. tween._value = value;
  317. return tween;
  318. }
  319. function attrTween(name, value) {
  320. var t0, i0;
  321. function tween() {
  322. var i = value.apply(this, arguments);
  323. if (i !== i0) t0 = (i0 = i) && attrInterpolate(name, i);
  324. return t0;
  325. }
  326. tween._value = value;
  327. return tween;
  328. }
  329. function transition_attrTween(name, value) {
  330. var key = "attr." + name;
  331. if (arguments.length < 2) return (key = this.tween(key)) && key._value;
  332. if (value == null) return this.tween(key, null);
  333. if (typeof value !== "function") throw new Error;
  334. var fullname = d3Selection.namespace(name);
  335. return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
  336. }
  337. function delayFunction(id, value) {
  338. return function() {
  339. init(this, id).delay = +value.apply(this, arguments);
  340. };
  341. }
  342. function delayConstant(id, value) {
  343. return value = +value, function() {
  344. init(this, id).delay = value;
  345. };
  346. }
  347. function transition_delay(value) {
  348. var id = this._id;
  349. return arguments.length
  350. ? this.each((typeof value === "function"
  351. ? delayFunction
  352. : delayConstant)(id, value))
  353. : get(this.node(), id).delay;
  354. }
  355. function durationFunction(id, value) {
  356. return function() {
  357. set(this, id).duration = +value.apply(this, arguments);
  358. };
  359. }
  360. function durationConstant(id, value) {
  361. return value = +value, function() {
  362. set(this, id).duration = value;
  363. };
  364. }
  365. function transition_duration(value) {
  366. var id = this._id;
  367. return arguments.length
  368. ? this.each((typeof value === "function"
  369. ? durationFunction
  370. : durationConstant)(id, value))
  371. : get(this.node(), id).duration;
  372. }
  373. function easeConstant(id, value) {
  374. if (typeof value !== "function") throw new Error;
  375. return function() {
  376. set(this, id).ease = value;
  377. };
  378. }
  379. function transition_ease(value) {
  380. var id = this._id;
  381. return arguments.length
  382. ? this.each(easeConstant(id, value))
  383. : get(this.node(), id).ease;
  384. }
  385. function easeVarying(id, value) {
  386. return function() {
  387. var v = value.apply(this, arguments);
  388. if (typeof v !== "function") throw new Error;
  389. set(this, id).ease = v;
  390. };
  391. }
  392. function transition_easeVarying(value) {
  393. if (typeof value !== "function") throw new Error;
  394. return this.each(easeVarying(this._id, value));
  395. }
  396. function transition_filter(match) {
  397. if (typeof match !== "function") match = d3Selection.matcher(match);
  398. for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
  399. for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
  400. if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
  401. subgroup.push(node);
  402. }
  403. }
  404. }
  405. return new Transition(subgroups, this._parents, this._name, this._id);
  406. }
  407. function transition_merge(transition) {
  408. if (transition._id !== this._id) throw new Error;
  409. for (var groups0 = this._groups, groups1 = transition._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
  410. for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
  411. if (node = group0[i] || group1[i]) {
  412. merge[i] = node;
  413. }
  414. }
  415. }
  416. for (; j < m0; ++j) {
  417. merges[j] = groups0[j];
  418. }
  419. return new Transition(merges, this._parents, this._name, this._id);
  420. }
  421. function start(name) {
  422. return (name + "").trim().split(/^|\s+/).every(function(t) {
  423. var i = t.indexOf(".");
  424. if (i >= 0) t = t.slice(0, i);
  425. return !t || t === "start";
  426. });
  427. }
  428. function onFunction(id, name, listener) {
  429. var on0, on1, sit = start(name) ? init : set;
  430. return function() {
  431. var schedule = sit(this, id),
  432. on = schedule.on;
  433. // If this node shared a dispatch with the previous node,
  434. // just assign the updated shared dispatch and we’re done!
  435. // Otherwise, copy-on-write.
  436. if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
  437. schedule.on = on1;
  438. };
  439. }
  440. function transition_on(name, listener) {
  441. var id = this._id;
  442. return arguments.length < 2
  443. ? get(this.node(), id).on.on(name)
  444. : this.each(onFunction(id, name, listener));
  445. }
  446. function removeFunction(id) {
  447. return function() {
  448. var parent = this.parentNode;
  449. for (var i in this.__transition) if (+i !== id) return;
  450. if (parent) parent.removeChild(this);
  451. };
  452. }
  453. function transition_remove() {
  454. return this.on("end.remove", removeFunction(this._id));
  455. }
  456. function transition_select(select) {
  457. var name = this._name,
  458. id = this._id;
  459. if (typeof select !== "function") select = d3Selection.selector(select);
  460. for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
  461. for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
  462. if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
  463. if ("__data__" in node) subnode.__data__ = node.__data__;
  464. subgroup[i] = subnode;
  465. schedule(subgroup[i], name, id, i, subgroup, get(node, id));
  466. }
  467. }
  468. }
  469. return new Transition(subgroups, this._parents, name, id);
  470. }
  471. function transition_selectAll(select) {
  472. var name = this._name,
  473. id = this._id;
  474. if (typeof select !== "function") select = d3Selection.selectorAll(select);
  475. for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
  476. for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  477. if (node = group[i]) {
  478. for (var children = select.call(node, node.__data__, i, group), child, inherit = get(node, id), k = 0, l = children.length; k < l; ++k) {
  479. if (child = children[k]) {
  480. schedule(child, name, id, k, children, inherit);
  481. }
  482. }
  483. subgroups.push(children);
  484. parents.push(node);
  485. }
  486. }
  487. }
  488. return new Transition(subgroups, parents, name, id);
  489. }
  490. var Selection = d3Selection.selection.prototype.constructor;
  491. function transition_selection() {
  492. return new Selection(this._groups, this._parents);
  493. }
  494. function styleNull(name, interpolate) {
  495. var string00,
  496. string10,
  497. interpolate0;
  498. return function() {
  499. var string0 = d3Selection.style(this, name),
  500. string1 = (this.style.removeProperty(name), d3Selection.style(this, name));
  501. return string0 === string1 ? null
  502. : string0 === string00 && string1 === string10 ? interpolate0
  503. : interpolate0 = interpolate(string00 = string0, string10 = string1);
  504. };
  505. }
  506. function styleRemove(name) {
  507. return function() {
  508. this.style.removeProperty(name);
  509. };
  510. }
  511. function styleConstant(name, interpolate, value1) {
  512. var string00,
  513. string1 = value1 + "",
  514. interpolate0;
  515. return function() {
  516. var string0 = d3Selection.style(this, name);
  517. return string0 === string1 ? null
  518. : string0 === string00 ? interpolate0
  519. : interpolate0 = interpolate(string00 = string0, value1);
  520. };
  521. }
  522. function styleFunction(name, interpolate, value) {
  523. var string00,
  524. string10,
  525. interpolate0;
  526. return function() {
  527. var string0 = d3Selection.style(this, name),
  528. value1 = value(this),
  529. string1 = value1 + "";
  530. if (value1 == null) string1 = value1 = (this.style.removeProperty(name), d3Selection.style(this, name));
  531. return string0 === string1 ? null
  532. : string0 === string00 && string1 === string10 ? interpolate0
  533. : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
  534. };
  535. }
  536. function styleMaybeRemove(id, name) {
  537. var on0, on1, listener0, key = "style." + name, event = "end." + key, remove;
  538. return function() {
  539. var schedule = set(this, id),
  540. on = schedule.on,
  541. listener = schedule.value[key] == null ? remove || (remove = styleRemove(name)) : undefined;
  542. // If this node shared a dispatch with the previous node,
  543. // just assign the updated shared dispatch and we’re done!
  544. // Otherwise, copy-on-write.
  545. if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener);
  546. schedule.on = on1;
  547. };
  548. }
  549. function transition_style(name, value, priority) {
  550. var i = (name += "") === "transform" ? d3Interpolate.interpolateTransformCss : interpolate;
  551. return value == null ? this
  552. .styleTween(name, styleNull(name, i))
  553. .on("end.style." + name, styleRemove(name))
  554. : typeof value === "function" ? this
  555. .styleTween(name, styleFunction(name, i, tweenValue(this, "style." + name, value)))
  556. .each(styleMaybeRemove(this._id, name))
  557. : this
  558. .styleTween(name, styleConstant(name, i, value), priority)
  559. .on("end.style." + name, null);
  560. }
  561. function styleInterpolate(name, i, priority) {
  562. return function(t) {
  563. this.style.setProperty(name, i.call(this, t), priority);
  564. };
  565. }
  566. function styleTween(name, value, priority) {
  567. var t, i0;
  568. function tween() {
  569. var i = value.apply(this, arguments);
  570. if (i !== i0) t = (i0 = i) && styleInterpolate(name, i, priority);
  571. return t;
  572. }
  573. tween._value = value;
  574. return tween;
  575. }
  576. function transition_styleTween(name, value, priority) {
  577. var key = "style." + (name += "");
  578. if (arguments.length < 2) return (key = this.tween(key)) && key._value;
  579. if (value == null) return this.tween(key, null);
  580. if (typeof value !== "function") throw new Error;
  581. return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
  582. }
  583. function textConstant(value) {
  584. return function() {
  585. this.textContent = value;
  586. };
  587. }
  588. function textFunction(value) {
  589. return function() {
  590. var value1 = value(this);
  591. this.textContent = value1 == null ? "" : value1;
  592. };
  593. }
  594. function transition_text(value) {
  595. return this.tween("text", typeof value === "function"
  596. ? textFunction(tweenValue(this, "text", value))
  597. : textConstant(value == null ? "" : value + ""));
  598. }
  599. function textInterpolate(i) {
  600. return function(t) {
  601. this.textContent = i.call(this, t);
  602. };
  603. }
  604. function textTween(value) {
  605. var t0, i0;
  606. function tween() {
  607. var i = value.apply(this, arguments);
  608. if (i !== i0) t0 = (i0 = i) && textInterpolate(i);
  609. return t0;
  610. }
  611. tween._value = value;
  612. return tween;
  613. }
  614. function transition_textTween(value) {
  615. var key = "text";
  616. if (arguments.length < 1) return (key = this.tween(key)) && key._value;
  617. if (value == null) return this.tween(key, null);
  618. if (typeof value !== "function") throw new Error;
  619. return this.tween(key, textTween(value));
  620. }
  621. function transition_transition() {
  622. var name = this._name,
  623. id0 = this._id,
  624. id1 = newId();
  625. for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
  626. for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  627. if (node = group[i]) {
  628. var inherit = get(node, id0);
  629. schedule(node, name, id1, i, group, {
  630. time: inherit.time + inherit.delay + inherit.duration,
  631. delay: 0,
  632. duration: inherit.duration,
  633. ease: inherit.ease
  634. });
  635. }
  636. }
  637. }
  638. return new Transition(groups, this._parents, name, id1);
  639. }
  640. function transition_end() {
  641. var on0, on1, that = this, id = that._id, size = that.size();
  642. return new Promise(function(resolve, reject) {
  643. var cancel = {value: reject},
  644. end = {value: function() { if (--size === 0) resolve(); }};
  645. that.each(function() {
  646. var schedule = set(this, id),
  647. on = schedule.on;
  648. // If this node shared a dispatch with the previous node,
  649. // just assign the updated shared dispatch and we’re done!
  650. // Otherwise, copy-on-write.
  651. if (on !== on0) {
  652. on1 = (on0 = on).copy();
  653. on1._.cancel.push(cancel);
  654. on1._.interrupt.push(cancel);
  655. on1._.end.push(end);
  656. }
  657. schedule.on = on1;
  658. });
  659. // The selection was empty, resolve end immediately
  660. if (size === 0) resolve();
  661. });
  662. }
  663. var id = 0;
  664. function Transition(groups, parents, name, id) {
  665. this._groups = groups;
  666. this._parents = parents;
  667. this._name = name;
  668. this._id = id;
  669. }
  670. function transition(name) {
  671. return d3Selection.selection().transition(name);
  672. }
  673. function newId() {
  674. return ++id;
  675. }
  676. var selection_prototype = d3Selection.selection.prototype;
  677. Transition.prototype = transition.prototype = {
  678. constructor: Transition,
  679. select: transition_select,
  680. selectAll: transition_selectAll,
  681. selectChild: selection_prototype.selectChild,
  682. selectChildren: selection_prototype.selectChildren,
  683. filter: transition_filter,
  684. merge: transition_merge,
  685. selection: transition_selection,
  686. transition: transition_transition,
  687. call: selection_prototype.call,
  688. nodes: selection_prototype.nodes,
  689. node: selection_prototype.node,
  690. size: selection_prototype.size,
  691. empty: selection_prototype.empty,
  692. each: selection_prototype.each,
  693. on: transition_on,
  694. attr: transition_attr,
  695. attrTween: transition_attrTween,
  696. style: transition_style,
  697. styleTween: transition_styleTween,
  698. text: transition_text,
  699. textTween: transition_textTween,
  700. remove: transition_remove,
  701. tween: transition_tween,
  702. delay: transition_delay,
  703. duration: transition_duration,
  704. ease: transition_ease,
  705. easeVarying: transition_easeVarying,
  706. end: transition_end,
  707. [Symbol.iterator]: selection_prototype[Symbol.iterator]
  708. };
  709. var defaultTiming = {
  710. time: null, // Set on use.
  711. delay: 0,
  712. duration: 250,
  713. ease: d3Ease.easeCubicInOut
  714. };
  715. function inherit(node, id) {
  716. var timing;
  717. while (!(timing = node.__transition) || !(timing = timing[id])) {
  718. if (!(node = node.parentNode)) {
  719. throw new Error(`transition ${id} not found`);
  720. }
  721. }
  722. return timing;
  723. }
  724. function selection_transition(name) {
  725. var id,
  726. timing;
  727. if (name instanceof Transition) {
  728. id = name._id, name = name._name;
  729. } else {
  730. id = newId(), (timing = defaultTiming).time = d3Timer.now(), name = name == null ? null : name + "";
  731. }
  732. for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
  733. for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
  734. if (node = group[i]) {
  735. schedule(node, name, id, i, group, timing || inherit(node, id));
  736. }
  737. }
  738. }
  739. return new Transition(groups, this._parents, name, id);
  740. }
  741. d3Selection.selection.prototype.interrupt = selection_interrupt;
  742. d3Selection.selection.prototype.transition = selection_transition;
  743. var root = [null];
  744. function active(node, name) {
  745. var schedules = node.__transition,
  746. schedule,
  747. i;
  748. if (schedules) {
  749. name = name == null ? null : name + "";
  750. for (i in schedules) {
  751. if ((schedule = schedules[i]).state > SCHEDULED && schedule.name === name) {
  752. return new Transition([[node]], root, name, +i);
  753. }
  754. }
  755. }
  756. return null;
  757. }
  758. exports.active = active;
  759. exports.interrupt = interrupt;
  760. exports.transition = transition;
  761. Object.defineProperty(exports, '__esModule', { value: true });
  762. })));