")
- ),
- u = 0,
- c = 0,
- l = !1,
- f = 0,
- h = 0,
- d = 0,
- p = 0,
- v = 0,
- y = 0,
- m = a || o ? "mousedown" : "dragstart";
- s.addEventListener(
- m,
- function (i) {
- var o, a;
- if (i.dataTransfer) {
- var g = new Image();
- (g.src =
- "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' %3E%3Cpath /%3E%3C/svg%3E"),
- null === (a = (o = i.dataTransfer).setDragImage) ||
- void 0 === a ||
- a.call(o, g, 0, 0);
- try {
- i.dataTransfer.setData(
- "text/html",
- "view-port-minimap"
- );
- } catch (t) {
- i.dataTransfer.setData("text", "view-port-minimap");
- }
- }
- if (((e.refresh = !1), i.target === s)) {
- var m = s.style;
- (f = parseInt(m.left, 10)),
- (h = parseInt(m.top, 10)),
- (d = parseInt(m.width, 10)),
- (p = parseInt(m.height, 10)),
- d > n[0] ||
- p > n[1] ||
- ((y = r.getZoom()),
- (v = t.get("ratio")),
- (l = !0),
- (u = i.clientX),
- (c = i.clientY));
- }
- },
- !1
- );
- var b = function (t) {
- if (
- l &&
- !Object(g.isNil)(t.clientX) &&
- !Object(g.isNil)(t.clientY)
- ) {
- var e = u - t.clientX,
- i = c - t.clientY;
- (f - e < 0 || f - e + d >= n[0]) && (e = 0),
- (h - i < 0 || h - i + p >= n[1]) && (i = 0),
- (h -= i),
- Hr(s, {
- left: "".concat((f -= e), "px"),
- top: "".concat(h, "px"),
- }),
- r.translate((e * y) / v, (i * y) / v),
- (u = t.clientX),
- (c = t.clientY);
- }
- };
- a || o || s.addEventListener("drag", b, !1);
- var x = function () {
- (l = !1), (e.refresh = !0);
- },
- w = a || o ? "mouseup" : "dragend";
- s.addEventListener(w, x, !1),
- i.addEventListener("mouseleave", x),
- i.addEventListener("mouseup", x),
- (a || o) && i.addEventListener("mousemove", b, !1),
- this.set("viewport", s),
- i.appendChild(s);
- }
- }),
- (e.prototype.updateViewport = function () {
- if (!this.destroyed) {
- var t = this.get("ratio"),
- e = this.get("totaldx"),
- n = this.get("totaldy"),
- r = this.get("graph"),
- i = this.get("size"),
- o = r.get("canvas").get("el"),
- a = r.get("width") || o.scrollWidth || 500,
- s = r.get("height") || o.scrollHeight || 500,
- u = r.getPointByCanvas(0, 0),
- c = r.getPointByCanvas(a, s),
- l = this.get("viewport");
- l || this.initViewport();
- var f = (c.x - u.x) * t,
- h = (c.y - u.y) * t,
- d = u.x * t + e,
- p = u.y * t + n,
- g = d + f,
- v = p + h;
- d < 0 && ((f += d), (d = 0)),
- g > i[0] && (f -= g - i[0]),
- p < 0 && ((h += p), (p = 0)),
- v > i[1] && (h -= v - i[1]),
- this.set("ratio", t),
- Hr(l, {
- left: "".concat(d, "px"),
- top: "".concat(p, "px"),
- width: "".concat(f, "px"),
- height: "".concat(h, "px"),
- });
- }
- }),
- (e.prototype.updateGraphShapes = function () {
- var t,
- e = this._cfgs.graph,
- n = this.get("canvas"),
- r = e.get("group");
- r.destroyed ||
- (n.clear(),
- this.get("hideEdge")
- ? ((t = n.addGroup()),
- r.get("children").forEach(function (e) {
- e.get("id").includes("-edge") || t.add(e.clone());
- }))
- : ((t = r.clone()).resetMatrix(), n.add(t)),
- "svg" === e.get("renderer") && this.updateVisible(t));
- }),
- (e.prototype.updateVisible = function (t) {
- var e = this;
- if (t.isGroup() || t.get("visible")) {
- var n = t.get("children");
- if (!n || !n.length) return;
- n.forEach(function (t) {
- t.get("visible") || t.hide(), e.updateVisible(t);
- });
- } else t.hide();
- }),
- (e.prototype.updateKeyShapes = function () {
- var t = this,
- e = this._cfgs.graph,
- n = this.get("canvas"),
- r = n.get("children")[0] || n.addGroup();
- this.get("hideEdge") ||
- Object(g.each)(e.getEdges(), function (e) {
- t.updateOneEdgeKeyShape(e, r);
- }),
- Object(g.each)(e.getNodes(), function (e) {
- t.updateOneNodeKeyShape(e, r);
- });
- var i = e.getCombos();
- if (i && i.length) {
- var o =
- r.find(function (t) {
- return "comboGroup" === t.get("name");
- }) || r.addGroup({ name: "comboGroup" });
- setTimeout(function () {
- t.destroyed ||
- (Object(g.each)(i, function (e) {
- t.updateOneComboKeyShape(e, o);
- }),
- null == o || o.sort(),
- null == o || o.toBack(),
- t.updateCanvas());
- }, 250);
- }
- this.clearDestroyedShapes();
- }),
- (e.prototype.updateOneComboKeyShape = function (t, e) {
- if (!this.destroyed) {
- var n = this.get("itemMap") || {},
- r = n[t.get("id")],
- i = t.getBBox(),
- o = t.get("keyShape").clone(),
- a = o.attr(),
- s = { x: i.centerX, y: i.centerY };
- r ? (s = Object.assign(a, s)) : ((r = o), e.add(r));
- var u = r.get("type");
- ("rect" !== u && "image" !== u) ||
- ((s.x = i.minX), (s.y = i.minY)),
- r.attr(s),
- t.isVisible() ? r.show() : r.hide(),
- (r.exist = !0);
- var c = t.getModel().depth;
- isNaN(c) || r.set("zIndex", c),
- (n[t.get("id")] = r),
- this.set("itemMap", n);
- }
- }),
- (e.prototype.updateOneNodeKeyShape = function (t, e) {
- var n = this.get("itemMap") || {},
- r = n[t.get("id")],
- i = t.getBBox(),
- o = t.get("keyShape").clone(),
- a = o.attr(),
- s = { x: i.centerX, y: i.centerY };
- r
- ? ((s = Object.assign(a, s)), r.toFront())
- : ((r = o), e.add(r));
- var u = r.get("type");
- ("rect" !== u && "image" !== u) ||
- ((s.x = i.minX), (s.y = i.minY)),
- r.attr(s),
- t.isVisible() ? r.show() : r.hide(),
- (r.exist = !0);
- var c = t.getModel().depth;
- isNaN(c) || r.set("zIndex", c),
- (n[t.get("id")] = r),
- this.set("itemMap", n);
- }),
- (e.prototype.updateDelegateShapes = function () {
- var t = this,
- e = this._cfgs.graph,
- n = this.get("canvas"),
- r = n.get("children")[0] || n.addGroup();
- this.get("hideEdge") ||
- Object(g.each)(e.getEdges(), function (e) {
- t.updateOneEdgeKeyShape(e, r);
- }),
- Object(g.each)(e.getNodes(), function (e) {
- t.updateOneNodeDelegateShape(e, r);
- });
- var i = e.getCombos();
- if (i && i.length) {
- var o =
- r.find(function (t) {
- return "comboGroup" === t.get("name");
- }) || r.addGroup({ name: "comboGroup" });
- setTimeout(function () {
- t.destroyed ||
- (Object(g.each)(i, function (e) {
- t.updateOneComboKeyShape(e, o);
- }),
- null == o || o.sort(),
- null == o || o.toBack(),
- t.updateCanvas());
- }, 250);
- }
- this.clearDestroyedShapes();
- }),
- (e.prototype.clearDestroyedShapes = function () {
- var t = this.get("itemMap") || {},
- e = Object.keys(t);
- if (e && 0 !== e.length)
- for (var n = e.length - 1; n >= 0; n--) {
- var r = t[e[n]],
- i = r.exist;
- (r.exist = !1), i || (r.remove(), delete t[e[n]]);
- }
- }),
- (e.prototype.updateOneEdgeKeyShape = function (t, e) {
- var n = this.get("itemMap") || {},
- r = n[t.get("id")];
- if (r) {
- var i = t.get("keyShape").attr("path");
- r.attr("path", i);
- } else (r = t.get("keyShape").clone()), e.add(r);
- t.isVisible() ? r.show() : r.hide(),
- (r.exist = !0),
- (n[t.get("id")] = r),
- this.set("itemMap", n);
- }),
- (e.prototype.updateOneNodeDelegateShape = function (t, e) {
- var n = this.get("delegateStyle"),
- r = this.get("itemMap") || {},
- i = r[t.get("id")],
- o = t.getBBox();
- if (i) {
- var a = {
- x: o.minX,
- y: o.minY,
- width: o.width,
- height: o.height,
- };
- i.attr(a), i.toFront();
- } else
- i = e.addShape("rect", {
- attrs: qi(
- { x: o.minX, y: o.minY, width: o.width, height: o.height },
- n
- ),
- name: "minimap-node-shape",
- });
- t.isVisible() ? i.show() : i.hide(),
- (i.exist = !0),
- (r[t.get("id")] = i),
- this.set("itemMap", r);
- }),
- (e.prototype.init = function () {
- this.initContainer(),
- this.get("graph").on(
- "afterupdateitem",
- this.handleUpdateCanvas
- ),
- this.get("graph").on(
- "afteritemstatechange",
- this.handleUpdateCanvas
- ),
- this.get("graph").on("afteradditem", this.handleUpdateCanvas),
- this.get("graph").on(
- "afterremoveitem",
- this.handleUpdateCanvas
- ),
- this.get("graph").on("afterrender", this.handleUpdateCanvas),
- this.get("graph").on("afterlayout", this.handleUpdateCanvas);
- }),
- (e.prototype.initContainer = function () {
- var t = this.get("graph"),
- e = this.get("size"),
- n = this.get("className"),
- r = this.get("container"),
- i = Vr(
- "
")
- );
- Object(g.isString)(r) && (r = document.getElementById(r)),
- r ? r.appendChild(i) : t.get("container").appendChild(i),
- this.set("container", i);
- var o,
- a = Vr(
- '
'
- );
- i.appendChild(a),
- a.addEventListener("dragenter", function (t) {
- t.preventDefault();
- }),
- a.addEventListener("dragover", function (t) {
- t.preventDefault();
- }),
- (o =
- "svg" === t.get("renderer")
- ? new _r.Canvas({ container: a, width: e[0], height: e[1] })
- : new Er.Canvas({
- container: a,
- width: e[0],
- height: e[1],
- })),
- this.set("canvas", o),
- this.updateCanvas();
- }),
- (e.prototype.updateCanvas = function () {
- if (!this.destroyed && this.get("refresh")) {
- var t = this.get("graph");
- if (!t.get("destroyed")) {
- this.get("viewportChange") &&
- (this.set("viewportChange", !1), this.updateViewport());
- var e = this.get("size"),
- n = this.get("canvas"),
- r = this.get("type"),
- i = this.get("padding");
- if (!n.destroyed) {
- switch (r) {
- case "default":
- this.updateGraphShapes();
- break;
- case "keyShape":
- this.updateKeyShapes();
- break;
- case "delegate":
- this.updateDelegateShapes();
- }
- var o = n.get("children")[0];
- if (o) {
- o.resetMatrix();
- var a = o.getCanvasBBox(),
- s = t.get("canvas").getCanvasBBox(),
- u = t.getZoom() || 1,
- c = s.width / u,
- l = s.height / u;
- Number.isFinite(a.width) &&
- ((c = Zi(a.width, c)), (l = Zi(a.height, l))),
- (c += 2 * i),
- (l += 2 * i);
- var f = Math.min(e[0] / c, e[1] / l),
- h = [1, 0, 0, 0, 1, 0, 0, 0, 1],
- d = 0,
- p = 0;
- Number.isFinite(a.minX) && (d = -a.minX),
- Number.isFinite(a.minY) && (p = -a.minY);
- var g = (e[0] - (c - 2 * i) * f) / 2,
- v = (e[1] - (l - 2 * i) * f) / 2;
- (h = Ki(h, [
- ["t", d, p],
- ["s", f, f],
- ["t", g, v],
- ])),
- o.setMatrix(h),
- this.set("ratio", f),
- this.set("totaldx", g + d * f),
- this.set("totaldy", v + p * f),
- this.set("dx", g),
- this.set("dy", v),
- this.updateViewport();
- }
- }
- }
- }
- }),
- (e.prototype.getCanvas = function () {
- return this.get("canvas");
- }),
- (e.prototype.getViewport = function () {
- return this.get("viewport");
- }),
- (e.prototype.getContainer = function () {
- return this.get("container");
- }),
- (e.prototype.destroy = function () {
- var t;
- null === (t = this.get("canvas")) || void 0 === t || t.destroy();
- var e = this.get("container");
- (null == e ? void 0 : e.parentNode) &&
- e.parentNode.removeChild(e);
- }),
- e
- );
- })(Fi),
- $i = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })();
- function Ji(t, e, n) {
- var r = t.x - e.x,
- i = t.y - e.y;
- return !n || Math.abs(r) > n || Math.abs(i) > n
- ? Math.sqrt(r * r + i * i)
- : n;
- }
- function to(t, e) {
- var n = (e.source.y - e.target.y) / (e.source.x - e.target.x),
- r = (n * n * e.source.x + n * (t.y - e.source.y) + t.x) / (n * n + 1);
- return { x: r, y: n * (r - e.source.x) + e.source.y };
- }
- var eo = (function (t) {
- function e(e) {
- return t.call(this, e) || this;
- }
- return (
- $i(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- edgeBundles: [],
- edgePoints: [],
- K: 0.1,
- lambda: 0.1,
- divisions: 1,
- divRate: 2,
- cycles: 6,
- iterations: 90,
- iterRate: 0.6666667,
- bundleThreshold: 0.6,
- eps: 1e-6,
- onLayoutEnd: function () {},
- onTick: function () {},
- };
- }),
- (e.prototype.init = function () {
- var t = this.get("graph"),
- e = this.get("onTick");
- this.set("tick", function () {
- e && e(), t.refreshPositions();
- });
- }),
- (e.prototype.bundling = function (t) {
- var e = this;
- if ((e.set("data", t), !e.isTicking())) {
- var n = t.edges || [],
- r = t.nodes || [],
- i = {},
- o = !1;
- if (
- (r.forEach(function (t) {
- (null !== t.x &&
- null !== !t.y &&
- void 0 !== t.x &&
- void 0 !== !t.y) ||
- (o = !0),
- (i[t.id] = t);
- }),
- o)
- )
- throw new Error(
- "please layout the graph or assign x and y for nodes first"
- );
- e.set("nodeIdMap", i);
- var a = e.get("divisions"),
- s = e.get("divRate"),
- u = e.divideEdges(a);
- e.set("edgePoints", u);
- var c = e.getEdgeBundles();
- e.set("edgeBundles", c);
- for (
- var l = e.get("cycles"),
- f = e.get("iterations"),
- h = e.get("iterRate"),
- d = e.get("lambda"),
- p = 0;
- p < l;
- p++
- ) {
- for (
- var g = function (t) {
- var r = [];
- n.forEach(function (t, n) {
- if (t.source !== t.target) {
- var o = i[t.source],
- s = i[t.target];
- r[n] = e.getEdgeForces(
- { source: o, target: s },
- n,
- a,
- d
- );
- for (var c = 0; c < a + 1; c++)
- (u[n][c].x += r[n][c].x),
- (u[n][c].y += r[n][c].y);
- }
- });
- },
- v = 0;
- v < f;
- v++
- )
- g();
- (d /= 2),
- (a *= s),
- (f *= h),
- (u = e.divideEdges(a)),
- e.set("edgePoints", u);
- }
- n.forEach(function (t, e) {
- t.source !== t.target &&
- ((t.type = "polyline"),
- (t.controlPoints = u[e].slice(1, u[e].length - 1)));
- }),
- e.get("graph").refresh();
- }
- }),
- (e.prototype.updateBundling = function (t) {
- var e = this,
- n = t.data;
- if (
- (n && e.set("data", n),
- e.get("ticking") && e.set("ticking", !1),
- Object.keys(t).forEach(function (n) {
- e.set(n, t[n]);
- }),
- t.onTick)
- ) {
- var r = this.get("graph");
- e.set("tick", function () {
- t.onTick(), r.refresh();
- });
- }
- e.bundling(n);
- }),
- (e.prototype.divideEdges = function (t) {
- var e = this,
- n = e.get("data").edges,
- r = e.get("nodeIdMap"),
- i = e.get("edgePoints");
- return (
- (i && void 0 !== i) || (i = []),
- n.forEach(function (n, o) {
- var a;
- (i[o] && void 0 !== i[o]) || (i[o] = []);
- var s = r[n.source],
- u = r[n.target];
- if (1 === t)
- i[o].push({ x: s.x, y: s.y }),
- i[o].push({ x: 0.5 * (s.x + u.x), y: 0.5 * (s.y + u.y) }),
- i[o].push({ x: u.x, y: u.y });
- else {
- var c =
- ((
- null === (a = i[o]) || void 0 === a
- ? void 0
- : a.length
- )
- ? e.getEdgeLength(i[o])
- : Ji({ x: s.x, y: s.y }, { x: u.x, y: u.y })) /
- (t + 1),
- l = c,
- f = [{ x: s.x, y: s.y }];
- i[o].forEach(function (t, e) {
- if (0 !== e) {
- for (var n = Ji(t, i[o][e - 1]); n > l; ) {
- var r = l / n,
- a = { x: i[o][e - 1].x, y: i[o][e - 1].y };
- (a.x += r * (t.x - i[o][e - 1].x)),
- (a.y += r * (t.y - i[o][e - 1].y)),
- f.push(a),
- (n -= l),
- (l = c);
- }
- l -= n;
- }
- }),
- f.push({ x: u.x, y: u.y }),
- (i[o] = f);
- }
- }),
- i
- );
- }),
- (e.prototype.getEdgeLength = function (t) {
- var e = 0;
- return (
- t.forEach(function (n, r) {
- 0 !== r && (e += Ji(n, t[r - 1]));
- }),
- e
- );
- }),
- (e.prototype.getEdgeBundles = function () {
- var t = this,
- e = t.get("data").edges || [],
- n = t.get("bundleThreshold"),
- r = t.get("nodeIdMap"),
- i = t.get("edgeBundles");
- return (
- i || (i = []),
- e.forEach(function (t, e) {
- (i[e] && void 0 !== i[e]) || (i[e] = []);
- }),
- e.forEach(function (o, a) {
- var s = r[o.source],
- u = r[o.target];
- e.forEach(function (e, o) {
- if (!(o <= a)) {
- var c = r[e.source],
- l = r[e.target];
- t.getBundleScore(
- { source: s, target: u },
- { source: c, target: l }
- ) >= n && (i[a].push(o), i[o].push(a));
- }
- });
- }),
- i
- );
- }),
- (e.prototype.getBundleScore = function (t, e) {
- return (
- (t.vx = t.target.x - t.source.x),
- (t.vy = t.target.y - t.source.y),
- (e.vx = e.target.x - e.source.x),
- (e.vy = e.target.y - e.source.y),
- (t.length = Ji(
- { x: t.source.x, y: t.source.y },
- { x: t.target.x, y: t.target.y }
- )),
- (e.length = Ji(
- { x: e.source.x, y: e.source.y },
- { x: e.target.x, y: e.target.y }
- )),
- this.getAngleScore(t, e) *
- this.getScaleScore(t, e) *
- this.getPositionScore(t, e) *
- this.getVisibilityScore(t, e)
- );
- }),
- (e.prototype.getAngleScore = function (t, e) {
- return (
- (function (t, e) {
- return t.x * e.x + t.y * e.y;
- })({ x: t.vx, y: t.vy }, { x: e.vx, y: e.vy }) /
- (t.length * e.length)
- );
- }),
- (e.prototype.getScaleScore = function (t, e) {
- var n = (t.length + e.length) / 2;
- return (
- 2 /
- (n / Math.min(t.length, e.length) +
- Math.max(t.length, e.length) / n)
- );
- }),
- (e.prototype.getPositionScore = function (t, e) {
- var n = (t.length + e.length) / 2;
- return (
- n /
- (n +
- Ji(
- {
- x: (t.source.x + t.target.x) / 2,
- y: (t.source.y + t.target.y) / 2,
- },
- {
- x: (e.source.x + e.target.x) / 2,
- y: (e.source.y + e.target.y) / 2,
- }
- ))
- );
- }),
- (e.prototype.getVisibilityScore = function (t, e) {
- var n = this.getEdgeVisibility(t, e),
- r = this.getEdgeVisibility(e, t);
- return n < r ? n : r;
- }),
- (e.prototype.getEdgeVisibility = function (t, e) {
- var n = to(e.source, t),
- r = to(e.target, t),
- i = { x: (n.x + r.x) / 2, y: (n.y + r.y) / 2 },
- o = {
- x: (t.source.x + t.target.x) / 2,
- y: (t.source.y + t.target.y) / 2,
- };
- return Math.max(0, 1 - (2 * Ji(i, o)) / Ji(n, r));
- }),
- (e.prototype.getEdgeForces = function (t, e, n, r) {
- for (
- var i = this.get("edgePoints"),
- o = this.get("K") / (Ji(t.source, t.target) * (n + 1)),
- a = [{ x: 0, y: 0 }],
- s = 1;
- s < n;
- s++
- ) {
- var u = { x: 0, y: 0 },
- c = this.getSpringForce(
- { pre: i[e][s - 1], cur: i[e][s], next: i[e][s + 1] },
- o
- ),
- l = this.getElectrostaticForce(s, e);
- (u.x = r * (c.x + l.x)), (u.y = r * (c.y + l.y)), a.push(u);
- }
- return a.push({ x: 0, y: 0 }), a;
- }),
- (e.prototype.getSpringForce = function (t, e) {
- var n = t.pre.x + t.next.x - 2 * t.cur.x,
- r = t.pre.y + t.next.y - 2 * t.cur.y;
- return { x: (n *= e), y: (r *= e) };
- }),
- (e.prototype.getElectrostaticForce = function (t, e) {
- var n = this.get("eps"),
- r = this.get("edgeBundles"),
- i = this.get("edgePoints"),
- o = r[e],
- a = { x: 0, y: 0 };
- return (
- o.forEach(function (r) {
- var o = {
- x: i[r][t].x - i[e][t].x,
- y: i[r][t].y - i[e][t].y,
- };
- if (Math.abs(o.x) > n || Math.abs(o.y) > n) {
- var s = 1 / Ji(i[r][t], i[e][t]);
- (a.x += o.x * s), (a.y += o.y * s);
- }
- }),
- a
- );
- }),
- (e.prototype.isTicking = function () {
- return this.get("ticking");
- }),
- (e.prototype.getSimulation = function () {
- return this.get("forceSimulation");
- }),
- (e.prototype.destroy = function () {
- this.get("ticking") && this.getSimulation().stop(),
- t.prototype.destroy.call(this);
- }),
- e
- );
- })(Fi),
- no = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })(),
- ro = function () {
- return (ro =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- io = {
- stroke: "#000",
- strokeOpacity: 0.8,
- lineWidth: 2,
- fillOpacity: 0.1,
- fill: "#ccc",
- },
- oo = (function (t) {
- function e(e) {
- return t.call(this, e) || this;
- }
- return (
- no(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- trigger: "mousemove",
- d: 1.5,
- r: 300,
- delegateStyle: Object(g.clone)(io),
- showLabel: !1,
- maxD: 5,
- minD: 0,
- scaleRBy: "unset",
- scaleDBy: "unset",
- showDPercent: !0,
- };
- }),
- (e.prototype.getEvents = function () {
- var t;
- switch (this.get("trigger")) {
- case "click":
- t = { click: "magnify" };
- break;
- case "drag":
- t = { click: "createDelegate" };
- break;
- default:
- t = { mousemove: "magnify" };
- }
- return t;
- }),
- (e.prototype.init = function () {
- var t = this.get("r");
- this.set("cachedMagnifiedModels", []),
- this.set("cachedOriginPositions", {}),
- this.set("r2", t * t);
- var e = this.get("d");
- this.set("molecularParam", (e + 1) * t);
- }),
- (e.prototype.createDelegate = function (t) {
- var e = this,
- n = this,
- r = n.get("delegate");
- (r && !r.destroyed) ||
- (n.magnify(t),
- (r = n.get("delegate")).on("dragstart", function (t) {
- n.set("delegateCenterDiff", {
- x: r.attr("x") - t.x,
- y: r.attr("y") - t.y,
- });
- }),
- r.on("drag", function (t) {
- n.magnify(t);
- }),
- "wheel" === this.get("scaleDBy") &&
- r.on("mousewheel", function (t) {
- e.scaleDByWheel(t);
- }),
- "wheel" === this.get("scaleRBy") &&
- r.on("mousewheel", function (t) {
- n.scaleRByWheel(t);
- }));
- }),
- (e.prototype.scaleRByWheel = function (t) {
- if (t && t.originalEvent) {
- t.preventDefault && t.preventDefault();
- var e,
- n = this.get("graph"),
- r = this.get("delegate"),
- i =
- (r ? { x: r.attr("x"), y: r.attr("y") } : void 0) ||
- n.getPointByClient(t.clientX, t.clientY);
- e = t.originalEvent.wheelDelta < 0 ? 0.95 : 1 / 0.95;
- var o = this.get("maxR"),
- a = this.get("minR"),
- s = this.get("r");
- ((s > (o || n.get("height")) && e > 1) ||
- (s < (a || 0.05 * n.get("height")) && e < 1)) &&
- (e = 1),
- (s *= e),
- this.set("r", s),
- this.set("r2", s * s);
- var u = this.get("d");
- this.set("molecularParam", (u + 1) * s),
- this.set("delegateCenterDiff", void 0),
- this.magnify(t, i);
- }
- }),
- (e.prototype.scaleRByDrag = function (t) {
- if (t) {
- var e,
- n = this.get("dragPrePos"),
- r = this.get("graph"),
- i = r.getPointByClient(t.clientX, t.clientY);
- e = t.x - n.x < 0 ? 0.95 : 1 / 0.95;
- var o = this.get("maxR"),
- a = this.get("minR"),
- s = this.get("r");
- ((s > (o || r.get("height")) && e > 1) ||
- (s < (a || 0.05 * r.get("height")) && e < 1)) &&
- (e = 1),
- (s *= e),
- this.set("r", s),
- this.set("r2", s * s);
- var u = this.get("d");
- this.set("molecularParam", (u + 1) * s),
- this.magnify(t, i),
- this.set("dragPrePos", { x: t.x, y: t.y });
- }
- }),
- (e.prototype.scaleDByWheel = function (t) {
- if (t || t.originalEvent) {
- t.preventDefault && t.preventDefault();
- var e = 0;
- e = t.originalEvent.wheelDelta < 0 ? -0.1 : 0.1;
- var n = this.get("d") + e,
- r = this.get("maxD"),
- i = this.get("minD");
- if (n < r && n > i) {
- this.set("d", n);
- var o = this.get("r");
- this.set("molecularParam", (n + 1) * o);
- var a = this.get("delegate"),
- s = a ? { x: a.attr("x"), y: a.attr("y") } : void 0;
- this.set("delegateCenterDiff", void 0), this.magnify(t, s);
- }
- }
- }),
- (e.prototype.scaleDByDrag = function (t) {
- var e = this.get("dragPrePos"),
- n = t.x - e.x > 0 ? 0.1 : -0.1,
- r = this.get("d") + n,
- i = this.get("maxD"),
- o = this.get("minD");
- if (r < i && r > o) {
- this.set("d", r);
- var a = this.get("r");
- this.set("molecularParam", (r + 1) * a), this.magnify(t);
- }
- this.set("dragPrePos", { x: t.x, y: t.y });
- }),
- (e.prototype.magnify = function (t, e) {
- this.restoreCache();
- var n = this.get("graph"),
- r = this.get("cachedMagnifiedModels"),
- i = this.get("cachedOriginPositions"),
- o = this.get("showLabel"),
- a = this.get("r"),
- s = this.get("r2"),
- u = this.get("d"),
- c = this.get("molecularParam"),
- l = n.getNodes(),
- f = l.length,
- h = e ? { x: e.x, y: e.y } : { x: t.x, y: t.y };
- !this.get("dragging") ||
- ("mousemove" !== this.get("trigger") &&
- "click" !== this.get("trigger")) ||
- (h = this.get("cacheCenter"));
- var d = this.get("delegateCenterDiff");
- d && ((h.x += d.x), (h.y += d.y)), this.updateDelegate(h, a);
- for (var p = 0; p < f; p++) {
- var g = l[p].getModel(),
- v = g.x,
- y = g.y;
- if (!isNaN(v) && !isNaN(y)) {
- var m = (v - h.x) * (v - h.x) + (y - h.y) * (y - h.y);
- if (!isNaN(m) && m < s && 0 !== m) {
- var b = Math.sqrt(m),
- x = (c * b) / (u * b + a),
- w = (v - h.x) / b,
- E = (y - h.y) / b;
- if (
- ((g.x = w * x + h.x),
- (g.y = E * x + h.y),
- i[g.id] || (i[g.id] = { x: v, y: y, texts: [] }),
- r.push(g),
- o && 2 * b < a)
- )
- for (
- var _ = l[p].getContainer().getChildren(),
- S = _.length,
- O = 0;
- O < S;
- O++
- ) {
- var M = _[O];
- "text" === M.get("type") &&
- (i[g.id].texts.push({
- visible: M.get("visible"),
- shape: M,
- }),
- M.set("visible", !0));
- }
- }
- }
- }
- n.refreshPositions();
- }),
- (e.prototype.restoreCache = function () {
- for (
- var t = this.get("cachedMagnifiedModels"),
- e = this.get("cachedOriginPositions"),
- n = t.length,
- r = 0;
- r < n;
- r++
- ) {
- var i = t[r],
- o = e[i.id];
- (i.x = o.x), (i.y = o.y);
- for (var a = o.texts.length, s = 0; s < a; s++) {
- var u = o.texts[s];
- u.shape.set("visible", u.visible);
- }
- }
- this.set("cachedMagnifiedModels", []),
- this.set("cachedOriginPositions", {});
- }),
- (e.prototype.updateParams = function (t) {
- var e = t.r,
- n = t.d,
- r = t.trigger,
- i = t.minD,
- o = t.maxD,
- a = t.minR,
- s = t.maxR,
- u = t.scaleDBy,
- c = t.scaleRBy;
- isNaN(t.r) || (this.set("r", e), this.set("r2", e * e)),
- isNaN(n) || this.set("d", n),
- isNaN(o) || this.set("maxD", o),
- isNaN(i) || this.set("minD", i),
- isNaN(s) || this.set("maxR", s),
- isNaN(a) || this.set("minR", a);
- var l,
- f = this.get("d"),
- h = this.get("r");
- (this.set("molecularParam", (f + 1) * h),
- ("mousemove" !== r && "click" !== r && "drag" !== r) ||
- this.set("trigger", r),
- "drag" === u || "wheel" === u || "unset" === u) &&
- (this.set("scaleDBy", u),
- this.get("delegate").remove(),
- this.get("delegate").destroy(),
- (l = this.get("dPercentText")) && (l.remove(), l.destroy()));
- ("drag" !== c && "wheel" !== c && "unset" !== c) ||
- (this.set("scaleRBy", c),
- this.get("delegate").remove(),
- this.get("delegate").destroy(),
- (l = this.get("dPercentText")) && (l.remove(), l.destroy()));
- }),
- (e.prototype.updateDelegate = function (t, e) {
- var n = this,
- r = this,
- i = r.get("graph"),
- o = r.get("delegate");
- if (!o || o.destroyed) {
- var a = i.get("group"),
- s = r.get("delegateStyle") || io;
- (o = a.addShape("circle", {
- attrs: ro({ r: e / 1.5, x: t.x, y: t.y }, s),
- name: "lens-shape",
- draggable: !0,
- })),
- "drag" !== this.get("trigger") &&
- ("wheel" === this.get("scaleRBy")
- ? o.on("mousewheel", function (t) {
- r.scaleRByWheel(t);
- })
- : "drag" === this.get("scaleRBy") &&
- (o.on("dragstart", function (t) {
- r.set("dragging", !0),
- r.set("cacheCenter", { x: t.x, y: t.y }),
- r.set("dragPrePos", { x: t.x, y: t.y });
- }),
- o.on("drag", function (t) {
- r.scaleRByDrag(t);
- }),
- o.on("dragend", function (t) {
- r.set("dragging", !1);
- })),
- "wheel" === this.get("scaleDBy")
- ? o.on("mousewheel", function (t) {
- n.scaleDByWheel(t);
- })
- : "drag" === this.get("scaleDBy") &&
- (o.on("dragstart", function (t) {
- r.set("dragging", !0),
- r.set("cacheCenter", { x: t.x, y: t.y }),
- r.set("dragPrePos", { x: t.x, y: t.y });
- }),
- o.on("drag", function (t) {
- n.scaleDByDrag(t);
- }),
- o.on("dragend", function (t) {
- r.set("dragging", !1);
- })));
- } else o.attr({ x: t.x, y: t.y, r: e / 1.5 });
- if (r.get("showDPercent")) {
- var u = Math.round(
- ((r.get("d") - r.get("minD")) /
- (r.get("maxD") - r.get("minD"))) *
- 100
- ),
- c = r.get("dPercentText"),
- l = t.y + e / 1.5 + 16;
- if (!c || c.destroyed)
- (c = i
- .get("group")
- .addShape("text", {
- attrs: {
- text: "".concat(u, "%"),
- x: t.x,
- y: l,
- fill: "#aaa",
- stroke: "#fff",
- lineWidth: 1,
- fontSize: 12,
- },
- })),
- r.set("dPercentText", c);
- else c.attr({ text: "".concat(u, "%"), x: t.x, y: l });
- }
- r.set("delegate", o);
- }),
- (e.prototype.clear = function () {
- var t = this.get("graph");
- this.restoreCache(), t.refreshPositions();
- var e = this.get("delegate");
- e && !e.destroyed && (e.remove(), e.destroy());
- var n = this.get("dPercentText");
- n && !n.destroyed && (n.remove(), n.destroy());
- }),
- (e.prototype.destroy = function () {
- this.clear();
- }),
- e
- );
- })(Fi),
- ao = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })();
- "undefined" != typeof document &&
- Xi()(
- "\n .g6-component-toolbar {\n position: absolute;\n list-style-type: none;\n padding: 6px;\n left: 0px;\n top: 0px;\n background-color: rgba(255, 255, 255, 0.9);\n border: 1px solid #e2e2e2;\n border-radius: 4px;\n font-size: 12px;\n color: #545454;\n margin: 0;\n }\n .g6-component-toolbar li {\n float: left;\n text-align: center;\n width: 35px;\n height: 24px;\n cursor: pointer;\n\t\tlist-style-type:none;\n list-style: none;\n margin-left: 0px;\n }\n .g6-component-toolbar li .icon {\n opacity: 0.7;\n }\n .g6-component-toolbar li .icon:hover {\n opacity: 1;\n }\n"
- );
- var so = (function (t) {
- function e(e) {
- return t.call(this, e) || this;
- }
- return (
- ao(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- handleClick: void 0,
- getContent: function (t) {
- return '\n
\n ';
- },
- zoomSensitivity: 2,
- };
- }),
- (e.prototype.init = function () {
- var t = this,
- e = this.get("graph"),
- n = this.get("getContent")(e),
- r = n;
- Object(g.isString)(n) && (r = Vr(n));
- var i = this.get("className");
- r.setAttribute("class", i || "g6-component-toolbar");
- var o = this.get("container");
- o || (o = this.get("graph").get("container")),
- Object(g.isString)(o) && (o = document.getElementById(o)),
- o.appendChild(r),
- this.set("toolBar", r);
- var a = this.get("handleClick");
- r.addEventListener("click", function (n) {
- var r = (function (t) {
- if (!t) return [];
- if (t.composedPath) return t.composedPath();
- for (var e = [], n = t.target; n; ) {
- if ((e.push(n), "HTML" === n.tagName))
- return e.push(document, window), e;
- n = n.parentElement;
- }
- return e;
- })(n).filter(function (t) {
- return "LI" === t.nodeName;
- });
- if (0 !== r.length) {
- var i = r[0].getAttribute("code");
- i && (a ? a(i, e) : t.handleDefaultOperator(i));
- }
- });
- var s = this.get("position");
- s &&
- Hr(r, {
- top: "".concat(s.y, "px"),
- left: "".concat(s.x, "px"),
- }),
- this.bindUndoRedo();
- }),
- (e.prototype.bindUndoRedo = function () {
- var t = this.get("graph"),
- e = document.querySelector(
- '.g6-component-toolbar li[code="undo"]'
- ),
- n = document.querySelector(
- '.g6-component-toolbar li[code="undo"] svg'
- ),
- r = document.querySelector(
- '.g6-component-toolbar li[code="redo"]'
- ),
- i = document.querySelector(
- '.g6-component-toolbar li[code="redo"] svg'
- );
- e &&
- n &&
- r &&
- i &&
- (e.setAttribute("style", "cursor: not-allowed"),
- n.setAttribute("style", "opacity: 0.4"),
- r.setAttribute("style", "cursor: not-allowed"),
- i.setAttribute("style", "opacity: 0.4"),
- t.on("stackchange", function (t) {
- var o = t.undoStack,
- a = t.redoStack,
- s = o.length,
- u = a.length;
- 0 === s
- ? (e.setAttribute("style", "cursor: not-allowed"),
- n.setAttribute("style", "opacity: 0.4"))
- : (e.removeAttribute("style"), n.removeAttribute("style")),
- 0 === u
- ? (r.setAttribute("style", "cursor: not-allowed"),
- i.setAttribute("style", "opacity: 0.4"))
- : (r.removeAttribute("style"),
- i.removeAttribute("style"));
- }));
- }),
- (e.prototype.undo = function () {
- var t = this.get("graph"),
- e = t.getUndoStack();
- if (e && 0 !== e.length) {
- var n = e.pop();
- if (n) {
- var r = n.action;
- t.pushStack(r, Object(g.clone)(n.data), "redo");
- var i = n.data.before;
- if (("add" === r && (i = n.data.after), !i)) return;
- switch (r) {
- case "visible":
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- var n = t.findById(e.id);
- e.visible ? t.showItem(n, !1) : t.hideItem(n, !1);
- });
- });
- break;
- case "render":
- case "update":
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- var n = t.findById(e.id);
- delete e.id,
- t.updateItem(n, e, !1),
- "combo" === n.getType() && t.updateCombo(n);
- });
- });
- break;
- case "changedata":
- t.changeData(i, !1);
- break;
- case "delete":
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- var n = e.itemType;
- delete e.itemType, t.addItem(n, e, !1);
- });
- });
- break;
- case "add":
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- t.removeItem(e.id, !1);
- });
- });
- break;
- case "updateComboTree":
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- t.updateComboTree(e.id, e.parentId, !1);
- });
- });
- break;
- case "createCombo":
- var o = n.data.after.combos,
- a = o[o.length - 1];
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- t.updateComboTree(e.id, e.parentId, !1);
- });
- }),
- t.removeItem(a.id, !1);
- break;
- case "uncombo":
- var s = i.combos[i.combos.length - 1],
- u = i.nodes
- .concat(i.combos)
- .map(function (t) {
- return t.id;
- })
- .filter(function (t) {
- return t !== s.id;
- });
- t.createCombo(s, u, !1);
- break;
- case "layout":
- t.updateLayout(i, void 0, void 0, !1);
- }
- }
- }
- }),
- (e.prototype.redo = function () {
- var t = this.get("graph"),
- e = t.getRedoStack();
- if (e && 0 !== e.length) {
- var n = e.pop();
- if (n) {
- var r = n.action,
- i = n.data.after;
- if (
- (t.pushStack(r, Object(g.clone)(n.data)),
- "delete" === r && (i = n.data.before),
- !i)
- )
- return;
- switch (r) {
- case "visible":
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- var n = t.findById(e.id);
- e.visible ? t.showItem(n, !1) : t.hideItem(n, !1);
- });
- });
- break;
- case "render":
- case "update":
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- var n = t.findById(e.id);
- delete e.id,
- t.updateItem(n, e, !1),
- "combo" === n.getType() && t.updateCombo(n);
- });
- });
- break;
- case "changedata":
- t.changeData(i, !1);
- break;
- case "delete":
- i.edges &&
- i.edges.forEach(function (e) {
- t.removeItem(e.id, !1);
- }),
- i.nodes &&
- i.nodes.forEach(function (e) {
- t.removeItem(e.id, !1);
- }),
- i.combos &&
- i.combos.forEach(function (e) {
- t.removeItem(e.id, !1);
- });
- break;
- case "add":
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- var n = e.itemType;
- delete e.itemType, t.addItem(n, e, !1);
- });
- });
- break;
- case "updateComboTree":
- Object.keys(i).forEach(function (e) {
- var n = i[e];
- n &&
- n.forEach(function (e) {
- t.updateComboTree(e.id, e.parentId, !1);
- });
- });
- break;
- case "createCombo":
- var o = i.combos[i.combos.length - 1];
- t.createCombo(
- o,
- o.children.map(function (t) {
- return t.id;
- }),
- !1
- );
- break;
- case "uncombo":
- var a = n.data.before.combos,
- s = a[a.length - 1];
- t.uncombo(s.id, !1);
- break;
- case "layout":
- t.updateLayout(i, void 0, void 0, !1);
- }
- }
- }
- }),
- (e.prototype.zoomOut = function () {
- var t = this.get("graph"),
- e = t.getZoom(),
- n = 1 / (1 - 0.05 * this.get("zoomSensitivity"));
- n * e > (this.get("maxZoom") || t.get("maxZoom")) ||
- t.zoomTo(e * n);
- }),
- (e.prototype.zoomIn = function () {
- var t = this.get("graph"),
- e = t.getZoom(),
- n = 1 - 0.05 * this.get("zoomSensitivity");
- n * e < (this.get("minZoom") || t.get("minZoom")) ||
- t.zoomTo(e * n);
- }),
- (e.prototype.realZoom = function () {
- this.get("graph").zoomTo(1);
- }),
- (e.prototype.autoZoom = function () {
- this.get("graph").fitView([20, 20]);
- }),
- (e.prototype.handleDefaultOperator = function (t) {
- switch (t) {
- case "redo":
- this.redo();
- break;
- case "undo":
- this.undo();
- break;
- case "zoomOut":
- this.zoomOut();
- break;
- case "zoomIn":
- this.zoomIn();
- break;
- case "realZoom":
- this.realZoom();
- break;
- case "autoZoom":
- this.autoZoom();
- }
- }),
- (e.prototype.destroy = function () {
- var t = this.get("toolBar");
- if (t) {
- var e = this.get("container");
- e || (e = this.get("graph").get("container")),
- Object(g.isString)(e) && (e = document.getElementById(e)),
- e.removeChild(t);
- }
- var n = this.get("handleClick");
- n && t.removeEventListener("click", n);
- }),
- e
- );
- })(Fi),
- uo = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })();
- "undefined" != typeof document &&
- Xi()(
- "\n .g6-component-tooltip {\n border: 1px solid #e2e2e2;\n border-radius: 4px;\n font-size: 12px;\n color: #545454;\n background-color: rgba(255, 255, 255, 0.9);\n padding: 10px 8px;\n box-shadow: rgb(174, 174, 174) 0px 0px 10px;\n }\n .tooltip-type {\n padding: 0;\n margin: 0;\n }\n .tooltip-id {\n color: #531dab;\n }\n"
- );
- var co = (function (t) {
- function e(e) {
- return t.call(this, e) || this;
- }
- return (
- uo(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- offsetX: 6,
- offsetY: 6,
- getContent: function (t) {
- return "\n
\n
ID:"
- )
- .concat(t.item.getID(), "\n ");
- },
- shouldBegin: function (t) {
- return !0;
- },
- itemTypes: ["node", "edge", "combo"],
- trigger: "mouseenter",
- fixToNode: void 0,
- };
- }),
- (e.prototype.getEvents = function () {
- return "click" === this.get("trigger")
- ? {
- "node:click": "onClick",
- "edge:click": "onClick",
- "combo:click": "onClick",
- "canvas:click": "onMouseLeave",
- afterremoveitem: "onMouseLeave",
- contextmenu: "onMouseLeave",
- drag: "onMouseLeave",
- }
- : {
- "node:mouseenter": "onMouseEnter",
- "node:mouseleave": "onMouseLeave",
- "node:mousemove": "onMouseMove",
- "edge:mouseenter": "onMouseEnter",
- "edge:mouseleave": "onMouseLeave",
- "edge:mousemove": "onMouseMove",
- "combo:mouseenter": "onMouseEnter",
- "combo:mouseleave": "onMouseLeave",
- "combo:mousemove": "onMouseMove",
- afterremoveitem: "onMouseLeave",
- contextmenu: "onMouseLeave",
- "node:drag": "onMouseLeave",
- };
- }),
- (e.prototype.init = function () {
- var t = this,
- e = t.get("className") || "g6-component-tooltip",
- n = Vr("
")),
- r = t.get("container");
- r || (r = t.get("graph").get("container")),
- Object(g.isString)(r) && (r = document.getElementById(r)),
- Hr(n, {
- position: "absolute",
- visibility: "hidden",
- display: "none",
- }),
- r.appendChild(n),
- "click" !== t.get("trigger") &&
- (n.addEventListener("mouseenter", function (t) {
- Hr(n, { visibility: "visible", display: "unset" });
- }),
- n.addEventListener("mouseleave", function (e) {
- t.hideTooltip();
- })),
- t.set("tooltip", n);
- }),
- (e.prototype.onClick = function (t) {
- var e = this.get("itemTypes");
- if (
- !t.item ||
- !t.item.getType ||
- -1 !== e.indexOf(t.item.getType())
- ) {
- var n = t.item,
- r = this.get("graph");
- this.currentTarget === n
- ? ((this.currentTarget = null),
- this.hideTooltip(),
- r.emit("tooltipchange", { item: t.item, action: "hide" }))
- : ((this.currentTarget = n),
- this.showTooltip(t),
- r.emit("tooltipchange", { item: t.item, action: "show" }));
- }
- }),
- (e.prototype.onMouseEnter = function (t) {
- var e = this.get("itemTypes");
- if (
- !t.item ||
- !t.item.getType ||
- -1 !== e.indexOf(t.item.getType())
- ) {
- var n = t.item,
- r = this.get("graph");
- (this.currentTarget = n),
- this.showTooltip(t),
- r.emit("tooltipchange", { item: t.item, action: "show" });
- }
- }),
- (e.prototype.onMouseMove = function (t) {
- var e = this.get("itemTypes");
- (t.item &&
- t.item.getType &&
- -1 === e.indexOf(t.item.getType())) ||
- (this.currentTarget &&
- t.item === this.currentTarget &&
- this.showTooltip(t));
- }),
- (e.prototype.onMouseLeave = function () {
- this.hideTooltip(),
- this.get("graph").emit("tooltipchange", {
- item: this.currentTarget,
- action: "hide",
- }),
- (this.currentTarget = null);
- }),
- (e.prototype.clearContainer = function () {
- var t = this.get("tooltip");
- t && (t.innerHTML = "");
- }),
- (e.prototype.showTooltip = function (t) {
- if (t.item) {
- var e = this.get("itemTypes");
- if (!t.item.getType || -1 !== e.indexOf(t.item.getType())) {
- var n = this.get("tooltip"),
- r = this.get("getContent")(t);
- Object(g.isString)(r)
- ? (n.innerHTML = r)
- : (this.clearContainer(), n.appendChild(r)),
- this.updatePosition(t);
- }
- }
- }),
- (e.prototype.hideTooltip = function () {
- var t = this.get("tooltip");
- t && Hr(t, { visibility: "hidden", display: "none" });
- }),
- (e.prototype.updatePosition = function (t) {
- var e = this.get("shouldBegin"),
- n = this.get("tooltip");
- if (e(t)) {
- var r = this.get("graph"),
- i = r.get("width"),
- o = r.get("height"),
- a = this.get("offsetX") || 0,
- s = this.get("offsetY") || 0,
- u = r.getPointByClient(t.clientX, t.clientY),
- c = this.get("fixToNode"),
- l = t.item;
- if (
- l.getType &&
- "node" === l.getType() &&
- c &&
- Object(g.isArray)(c) &&
- c.length >= 2
- ) {
- var f = l.getBBox();
- u = {
- x: f.minX + f.width * c[0],
- y: f.minY + f.height * c[1],
- };
- }
- var h = r.getCanvasByPoint(u.x, u.y),
- d = h.x,
- p = h.y,
- v = r.getContainer(),
- y = { x: d + v.offsetLeft + a, y: p + v.offsetTop + s };
- Hr(n, { visibility: "visible", display: "unset" });
- var m = n.getBoundingClientRect();
- d + m.width + a > i && (y.x -= m.width + a),
- p + m.height + s > o && (y.y -= m.height + s),
- Hr(n, {
- left: "".concat(y.x, "px"),
- top: "".concat(y.y, "px"),
- });
- } else Hr(n, { visibility: "hidden", display: "none" });
- }),
- (e.prototype.hide = function () {
- this.onMouseLeave();
- }),
- (e.prototype.destroy = function () {
- var t = this.get("tooltip");
- if (t) {
- var e = this.get("container");
- e || (e = this.get("graph").get("container")),
- Object(g.isString)(e) && (e = document.getElementById(e)),
- e.removeChild(t);
- }
- }),
- e
- );
- })(Fi),
- lo = {};
- function fo(t, e) {
- lo[t] = e;
- }
- var ho = (function () {
- function t(t) {
- (this.type = "base"),
- (this.isCategory = !1),
- (this.isLinear = !1),
- (this.isContinuous = !1),
- (this.isIdentity = !1),
- (this.values = []),
- (this.range = [0, 1]),
- (this.ticks = []),
- (this.__cfg__ = t),
- this.initCfg(),
- this.init();
- }
- return (
- (t.prototype.translate = function (t) {
- return t;
- }),
- (t.prototype.change = function (t) {
- Object(g.assign)(this.__cfg__, t), this.init();
- }),
- (t.prototype.clone = function () {
- return this.constructor(this.__cfg__);
- }),
- (t.prototype.getTicks = function () {
- var t = this;
- return Object(g.map)(this.ticks, function (e, n) {
- return Object(g.isObject)(e)
- ? e
- : { text: t.getText(e, n), tickValue: e, value: t.scale(e) };
- });
- }),
- (t.prototype.getText = function (t, e) {
- var n = this.formatter,
- r = n ? n(t, e) : t;
- return Object(g.isNil)(r) || !Object(g.isFunction)(r.toString)
- ? ""
- : r.toString();
- }),
- (t.prototype.getConfig = function (t) {
- return this.__cfg__[t];
- }),
- (t.prototype.init = function () {
- Object(g.assign)(this, this.__cfg__),
- this.setDomain(),
- Object(g.isEmpty)(this.getConfig("ticks")) &&
- (this.ticks = this.calculateTicks());
- }),
- (t.prototype.initCfg = function () {}),
- (t.prototype.setDomain = function () {}),
- (t.prototype.calculateTicks = function () {
- var t = this.tickMethod,
- e = [];
- if (Object(g.isString)(t)) {
- var n = lo[t];
- if (!n)
- throw new Error("There is no method to to calculate ticks!");
- e = n(this);
- } else Object(g.isFunction)(t) && (e = t(this));
- return e;
- }),
- (t.prototype.rangeMin = function () {
- return this.range[0];
- }),
- (t.prototype.rangeMax = function () {
- return this.range[1];
- }),
- (t.prototype.calcPercent = function (t, e, n) {
- return Object(g.isNumber)(t) ? (t - e) / (n - e) : NaN;
- }),
- (t.prototype.calcValue = function (t, e, n) {
- return e + t * (n - e);
- }),
- t
- );
- })(),
- po = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.type = "cat"), (e.isCategory = !0), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.buildIndexMap = function () {
- if (!this.translateIndexMap) {
- this.translateIndexMap = new Map();
- for (var t = 0; t < this.values.length; t++)
- this.translateIndexMap.set(this.values[t], t);
- }
- }),
- (e.prototype.translate = function (t) {
- this.buildIndexMap();
- var e = this.translateIndexMap.get(t);
- return void 0 === e && (e = Object(g.isNumber)(t) ? t : NaN), e;
- }),
- (e.prototype.scale = function (t) {
- var e = this.translate(t),
- n = this.calcPercent(e, this.min, this.max);
- return this.calcValue(n, this.rangeMin(), this.rangeMax());
- }),
- (e.prototype.invert = function (t) {
- var e = this.max - this.min,
- n = this.calcPercent(t, this.rangeMin(), this.rangeMax()),
- r = Math.round(e * n) + this.min;
- return r < this.min || r > this.max ? NaN : this.values[r];
- }),
- (e.prototype.getText = function (e) {
- for (var n = [], r = 1; r < arguments.length; r++)
- n[r - 1] = arguments[r];
- var i = e;
- return (
- Object(g.isNumber)(e) &&
- !this.values.includes(e) &&
- (i = this.values[i]),
- t.prototype.getText.apply(
- this,
- Object(p.__spreadArrays)([i], n)
- )
- );
- }),
- (e.prototype.initCfg = function () {
- this.tickMethod = "cat";
- }),
- (e.prototype.setDomain = function () {
- if (
- (Object(g.isNil)(this.getConfig("min")) && (this.min = 0),
- Object(g.isNil)(this.getConfig("max")))
- ) {
- var t = this.values.length;
- this.max = t > 1 ? t - 1 : t;
- }
- this.translateIndexMap && (this.translateIndexMap = void 0);
- }),
- e
- );
- })(ho),
- go =
- /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,
- vo = "[^\\s]+",
- yo = /\[([^]*?)\]/gm;
- function mo(t, e) {
- for (var n = [], r = 0, i = t.length; r < i; r++)
- n.push(t[r].substr(0, e));
- return n;
- }
- var bo = function (t) {
- return function (e, n) {
- var r = n[t]
- .map(function (t) {
- return t.toLowerCase();
- })
- .indexOf(e.toLowerCase());
- return r > -1 ? r : null;
- };
- };
- function xo(t) {
- for (var e = [], n = 1; n < arguments.length; n++)
- e[n - 1] = arguments[n];
- for (var r = 0, i = e; r < i.length; r++) {
- var o = i[r];
- for (var a in o) t[a] = o[a];
- }
- return t;
- }
- var wo = [
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday",
- ],
- Eo = [
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December",
- ],
- _o = mo(Eo, 3),
- So = {
- dayNamesShort: mo(wo, 3),
- dayNames: wo,
- monthNamesShort: _o,
- monthNames: Eo,
- amPm: ["am", "pm"],
- DoFn: function (t) {
- return (
- t +
- ["th", "st", "nd", "rd"][
- t % 10 > 3 ? 0 : ((t - (t % 10) != 10 ? 1 : 0) * t) % 10
- ]
- );
- },
- },
- Oo = xo({}, So),
- Mo = function (t) {
- return (Oo = xo(Oo, t));
- },
- ko = function (t) {
- return t.replace(/[|\\{()[^$+*?.-]/g, "\\$&");
- },
- Ao = function (t, e) {
- for (void 0 === e && (e = 2), t = String(t); t.length < e; )
- t = "0" + t;
- return t;
- },
- jo = {
- D: function (t) {
- return String(t.getDate());
- },
- DD: function (t) {
- return Ao(t.getDate());
- },
- Do: function (t, e) {
- return e.DoFn(t.getDate());
- },
- d: function (t) {
- return String(t.getDay());
- },
- dd: function (t) {
- return Ao(t.getDay());
- },
- ddd: function (t, e) {
- return e.dayNamesShort[t.getDay()];
- },
- dddd: function (t, e) {
- return e.dayNames[t.getDay()];
- },
- M: function (t) {
- return String(t.getMonth() + 1);
- },
- MM: function (t) {
- return Ao(t.getMonth() + 1);
- },
- MMM: function (t, e) {
- return e.monthNamesShort[t.getMonth()];
- },
- MMMM: function (t, e) {
- return e.monthNames[t.getMonth()];
- },
- YY: function (t) {
- return Ao(String(t.getFullYear()), 4).substr(2);
- },
- YYYY: function (t) {
- return Ao(t.getFullYear(), 4);
- },
- h: function (t) {
- return String(t.getHours() % 12 || 12);
- },
- hh: function (t) {
- return Ao(t.getHours() % 12 || 12);
- },
- H: function (t) {
- return String(t.getHours());
- },
- HH: function (t) {
- return Ao(t.getHours());
- },
- m: function (t) {
- return String(t.getMinutes());
- },
- mm: function (t) {
- return Ao(t.getMinutes());
- },
- s: function (t) {
- return String(t.getSeconds());
- },
- ss: function (t) {
- return Ao(t.getSeconds());
- },
- S: function (t) {
- return String(Math.round(t.getMilliseconds() / 100));
- },
- SS: function (t) {
- return Ao(Math.round(t.getMilliseconds() / 10), 2);
- },
- SSS: function (t) {
- return Ao(t.getMilliseconds(), 3);
- },
- a: function (t, e) {
- return t.getHours() < 12 ? e.amPm[0] : e.amPm[1];
- },
- A: function (t, e) {
- return t.getHours() < 12
- ? e.amPm[0].toUpperCase()
- : e.amPm[1].toUpperCase();
- },
- ZZ: function (t) {
- var e = t.getTimezoneOffset();
- return (
- (e > 0 ? "-" : "+") +
- Ao(100 * Math.floor(Math.abs(e) / 60) + (Math.abs(e) % 60), 4)
- );
- },
- Z: function (t) {
- var e = t.getTimezoneOffset();
- return (
- (e > 0 ? "-" : "+") +
- Ao(Math.floor(Math.abs(e) / 60), 2) +
- ":" +
- Ao(Math.abs(e) % 60, 2)
- );
- },
- },
- Co = function (t) {
- return +t - 1;
- },
- Io = [null, "\\d\\d?"],
- To = [null, vo],
- No = [
- "isPm",
- vo,
- function (t, e) {
- var n = t.toLowerCase();
- return n === e.amPm[0] ? 0 : n === e.amPm[1] ? 1 : null;
- },
- ],
- Po = [
- "timezoneOffset",
- "[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",
- function (t) {
- var e = (t + "").match(/([+-]|\d\d)/gi);
- if (e) {
- var n = 60 * +e[1] + parseInt(e[2], 10);
- return "+" === e[0] ? n : -n;
- }
- return 0;
- },
- ],
- Do = {
- D: ["day", "\\d\\d?"],
- DD: ["day", "\\d\\d"],
- Do: [
- "day",
- "\\d\\d?" + vo,
- function (t) {
- return parseInt(t, 10);
- },
- ],
- M: ["month", "\\d\\d?", Co],
- MM: ["month", "\\d\\d", Co],
- YY: [
- "year",
- "\\d\\d",
- function (t) {
- var e = +("" + new Date().getFullYear()).substr(0, 2);
- return +("" + (+t > 68 ? e - 1 : e) + t);
- },
- ],
- h: ["hour", "\\d\\d?", void 0, "isPm"],
- hh: ["hour", "\\d\\d", void 0, "isPm"],
- H: ["hour", "\\d\\d?"],
- HH: ["hour", "\\d\\d"],
- m: ["minute", "\\d\\d?"],
- mm: ["minute", "\\d\\d"],
- s: ["second", "\\d\\d?"],
- ss: ["second", "\\d\\d"],
- YYYY: ["year", "\\d{4}"],
- S: [
- "millisecond",
- "\\d",
- function (t) {
- return 100 * +t;
- },
- ],
- SS: [
- "millisecond",
- "\\d\\d",
- function (t) {
- return 10 * +t;
- },
- ],
- SSS: ["millisecond", "\\d{3}"],
- d: Io,
- dd: Io,
- ddd: To,
- dddd: To,
- MMM: ["month", vo, bo("monthNamesShort")],
- MMMM: ["month", vo, bo("monthNames")],
- a: No,
- A: No,
- ZZ: Po,
- Z: Po,
- },
- Lo = {
- default: "ddd MMM DD YYYY HH:mm:ss",
- shortDate: "M/D/YY",
- mediumDate: "MMM D, YYYY",
- longDate: "MMMM D, YYYY",
- fullDate: "dddd, MMMM D, YYYY",
- isoDate: "YYYY-MM-DD",
- isoDateTime: "YYYY-MM-DDTHH:mm:ssZ",
- shortTime: "HH:mm",
- mediumTime: "HH:mm:ss",
- longTime: "HH:mm:ss.SSS",
- },
- Ro = function (t) {
- return xo(Lo, t);
- },
- Bo = function (t, e, n) {
- if (
- (void 0 === e && (e = Lo.default),
- void 0 === n && (n = {}),
- "number" == typeof t && (t = new Date(t)),
- "[object Date]" !== Object.prototype.toString.call(t) ||
- isNaN(t.getTime()))
- )
- throw new Error("Invalid Date pass to format");
- var r = [];
- e = (e = Lo[e] || e).replace(yo, function (t, e) {
- return r.push(e), "@@@";
- });
- var i = xo(xo({}, Oo), n);
- return (e = e.replace(go, function (e) {
- return jo[e](t, i);
- })).replace(/@@@/g, function () {
- return r.shift();
- });
- };
- function Fo(t, e, n) {
- if ((void 0 === n && (n = {}), "string" != typeof e))
- throw new Error("Invalid format in fecha parse");
- if (((e = Lo[e] || e), t.length > 1e3)) return null;
- var r = {
- year: new Date().getFullYear(),
- month: 0,
- day: 1,
- hour: 0,
- minute: 0,
- second: 0,
- millisecond: 0,
- isPm: null,
- timezoneOffset: null,
- },
- i = [],
- o = [],
- a = e.replace(yo, function (t, e) {
- return o.push(ko(e)), "@@@";
- }),
- s = {},
- u = {};
- (a = ko(a).replace(go, function (t) {
- var e = Do[t],
- n = e[0],
- r = e[1],
- o = e[3];
- if (s[n])
- throw new Error(
- "Invalid format. " + n + " specified twice in format"
- );
- return (s[n] = !0), o && (u[o] = !0), i.push(e), "(" + r + ")";
- })),
- Object.keys(u).forEach(function (t) {
- if (!s[t])
- throw new Error(
- "Invalid format. " + t + " is required in specified format"
- );
- }),
- (a = a.replace(/@@@/g, function () {
- return o.shift();
- }));
- var c = t.match(new RegExp(a, "i"));
- if (!c) return null;
- for (var l, f = xo(xo({}, Oo), n), h = 1; h < c.length; h++) {
- var d = i[h - 1],
- p = d[0],
- g = d[2],
- v = g ? g(c[h], f) : +c[h];
- if (null == v) return null;
- r[p] = v;
- }
- if (
- (1 === r.isPm && null != r.hour && 12 != +r.hour
- ? (r.hour = +r.hour + 12)
- : 0 === r.isPm && 12 == +r.hour && (r.hour = 0),
- null == r.timezoneOffset)
- ) {
- l = new Date(
- r.year,
- r.month,
- r.day,
- r.hour,
- r.minute,
- r.second,
- r.millisecond
- );
- for (
- var y = [
- ["month", "getMonth"],
- ["day", "getDate"],
- ["hour", "getHours"],
- ["minute", "getMinutes"],
- ["second", "getSeconds"],
- ],
- m = ((h = 0), y.length);
- h < m;
- h++
- )
- if (s[y[h][0]] && r[y[h][0]] !== l[y[h][1]]()) return null;
- } else if (
- ((l = new Date(
- Date.UTC(
- r.year,
- r.month,
- r.day,
- r.hour,
- r.minute - r.timezoneOffset,
- r.second,
- r.millisecond
- )
- )),
- r.month > 11 ||
- r.month < 0 ||
- r.day > 31 ||
- r.day < 1 ||
- r.hour > 23 ||
- r.hour < 0 ||
- r.minute > 59 ||
- r.minute < 0 ||
- r.second > 59 ||
- r.second < 0)
- )
- return null;
- return l;
- }
- var zo = {
- format: Bo,
- parse: Fo,
- defaultI18n: So,
- setGlobalDateI18n: Mo,
- setGlobalDateMasks: Ro,
- };
- function Go(t, e) {
- return (d.format || zo.format)(t, e);
- }
- function Yo(t) {
- return (
- Object(g.isString)(t) &&
- (t =
- t.indexOf("T") > 0
- ? new Date(t).getTime()
- : new Date(t.replace(/-/gi, "/")).getTime()),
- Object(g.isDate)(t) && (t = t.getTime()),
- t
- );
- }
- var Uo = 36e5,
- Xo = 24 * Uo,
- Wo = 31 * Xo,
- Vo = [
- ["HH:mm:ss", 1e3],
- ["HH:mm:ss", 1e4],
- ["HH:mm:ss", 3e4],
- ["HH:mm", 6e4],
- ["HH:mm", 6e5],
- ["HH:mm", 18e5],
- ["HH", Uo],
- ["HH", 6 * Uo],
- ["HH", 12 * Uo],
- ["YYYY-MM-DD", Xo],
- ["YYYY-MM-DD", 4 * Xo],
- ["YYYY-WW", 7 * Xo],
- ["YYYY-MM", Wo],
- ["YYYY-MM", 4 * Wo],
- ["YYYY-MM", 6 * Wo],
- ["YYYY", 380 * Xo],
- ];
- function Ho(t, e, n) {
- var r,
- i =
- ((r = function (t) {
- return t[1];
- }),
- function (t, e, n, i) {
- for (
- var o = Object(g.isNil)(n) ? 0 : n,
- a = Object(g.isNil)(i) ? t.length : i;
- o < a;
-
- ) {
- var s = (o + a) >>> 1;
- r(t[s]) > e ? (a = s) : (o = s + 1);
- }
- return o;
- })(Vo, (e - t) / n) - 1,
- o = Vo[i];
- return (
- i < 0 ? (o = Vo[0]) : i >= Vo.length && (o = Object(g.last)(Vo)), o
- );
- }
- var qo = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.type = "timeCat"), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.translate = function (t) {
- t = Yo(t);
- var e = this.values.indexOf(t);
- return (
- -1 === e &&
- (e =
- Object(g.isNumber)(t) && t < this.values.length ? t : NaN),
- e
- );
- }),
- (e.prototype.getText = function (t, e) {
- var n = this.translate(t);
- if (n > -1) {
- var r = this.values[n],
- i = this.formatter;
- return (r = i ? i(r, e) : Go(r, this.mask));
- }
- return t;
- }),
- (e.prototype.initCfg = function () {
- (this.tickMethod = "time-cat"),
- (this.mask = "YYYY-MM-DD"),
- (this.tickCount = 7);
- }),
- (e.prototype.setDomain = function () {
- var e = this.values;
- Object(g.each)(e, function (t, n) {
- e[n] = Yo(t);
- }),
- e.sort(function (t, e) {
- return t - e;
- }),
- t.prototype.setDomain.call(this);
- }),
- e
- );
- })(po),
- Zo = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.isContinuous = !0), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.scale = function (t) {
- if (Object(g.isNil)(t)) return NaN;
- var e = this.rangeMin(),
- n = this.rangeMax();
- return this.max === this.min
- ? e
- : e + this.getScalePercent(t) * (n - e);
- }),
- (e.prototype.init = function () {
- t.prototype.init.call(this);
- var e = this.ticks,
- n = Object(g.head)(e),
- r = Object(g.last)(e);
- n < this.min && (this.min = n),
- r > this.max && (this.max = r),
- Object(g.isNil)(this.minLimit) || (this.min = n),
- Object(g.isNil)(this.maxLimit) || (this.max = r);
- }),
- (e.prototype.setDomain = function () {
- var t = Object(g.getRange)(this.values),
- e = t.min,
- n = t.max;
- Object(g.isNil)(this.min) && (this.min = e),
- Object(g.isNil)(this.max) && (this.max = n),
- this.min > this.max && ((this.min = e), (this.max = n));
- }),
- (e.prototype.calculateTicks = function () {
- var e = this,
- n = t.prototype.calculateTicks.call(this);
- return (
- this.nice ||
- (n = Object(g.filter)(n, function (t) {
- return t >= e.min && t <= e.max;
- })),
- n
- );
- }),
- (e.prototype.getScalePercent = function (t) {
- var e = this.max,
- n = this.min;
- return (t - n) / (e - n);
- }),
- (e.prototype.getInvertPercent = function (t) {
- return (
- (t - this.rangeMin()) / (this.rangeMax() - this.rangeMin())
- );
- }),
- e
- );
- })(ho),
- Ko = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.type = "linear"), (e.isLinear = !0), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.invert = function (t) {
- var e = this.getInvertPercent(t);
- return this.min + e * (this.max - this.min);
- }),
- (e.prototype.initCfg = function () {
- (this.tickMethod = "wilkinson-extended"), (this.nice = !1);
- }),
- e
- );
- })(Zo);
- function Qo(t, e) {
- var n = Math.E;
- return e >= 0
- ? Math.pow(n, Math.log(e) / t)
- : -1 * Math.pow(n, Math.log(-e) / t);
- }
- function $o(t, e) {
- return 1 === t ? 1 : Math.log(e) / Math.log(t);
- }
- function Jo(t, e, n) {
- Object(g.isNil)(n) && (n = Math.max.apply(null, t));
- var r = n;
- return (
- Object(g.each)(t, function (t) {
- t > 0 && t < r && (r = t);
- }),
- r === n && (r = n / e),
- r > 1 && (r = 1),
- r
- );
- }
- var ta = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.type = "log"), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.invert = function (t) {
- var e,
- n = this.base,
- r = $o(n, this.max),
- i = this.rangeMin(),
- o = this.rangeMax() - i,
- a = this.positiveMin;
- if (a) {
- if (0 === t) return 0;
- var s = (1 / (r - (e = $o(n, a / n)))) * o;
- if (t < s) return (t / s) * a;
- } else e = $o(n, this.min);
- var u = ((t - i) / o) * (r - e) + e;
- return Math.pow(n, u);
- }),
- (e.prototype.initCfg = function () {
- (this.tickMethod = "log"),
- (this.base = 10),
- (this.tickCount = 6),
- (this.nice = !0);
- }),
- (e.prototype.setDomain = function () {
- t.prototype.setDomain.call(this);
- var e = this.min;
- if (e < 0)
- throw new Error(
- "When you use log scale, the minimum value must be greater than zero!"
- );
- 0 === e &&
- (this.positiveMin = Jo(this.values, this.base, this.max));
- }),
- (e.prototype.getScalePercent = function (t) {
- var e = this.max,
- n = this.min;
- if (e === n) return 0;
- if (t <= 0) return 0;
- var r = this.base,
- i = this.positiveMin;
- return (
- i && (n = (1 * i) / r),
- t < i
- ? t / i / ($o(r, e) - $o(r, n))
- : ($o(r, t) - $o(r, n)) / ($o(r, e) - $o(r, n))
- );
- }),
- e
- );
- })(Zo),
- ea = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.type = "pow"), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.invert = function (t) {
- var e = this.getInvertPercent(t),
- n = this.exponent,
- r = Qo(n, this.max),
- i = Qo(n, this.min),
- o = e * (r - i) + i,
- a = o >= 0 ? 1 : -1;
- return Math.pow(o, n) * a;
- }),
- (e.prototype.initCfg = function () {
- (this.tickMethod = "pow"),
- (this.exponent = 2),
- (this.tickCount = 5),
- (this.nice = !0);
- }),
- (e.prototype.getScalePercent = function (t) {
- var e = this.max,
- n = this.min;
- if (e === n) return 0;
- var r = this.exponent;
- return (Qo(r, t) - Qo(r, n)) / (Qo(r, e) - Qo(r, n));
- }),
- e
- );
- })(Zo),
- na = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.type = "time"), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.getText = function (t, e) {
- var n = this.translate(t),
- r = this.formatter;
- return r ? r(n, e) : Go(n, this.mask);
- }),
- (e.prototype.scale = function (e) {
- var n = e;
- return (
- (Object(g.isString)(n) || Object(g.isDate)(n)) &&
- (n = this.translate(n)),
- t.prototype.scale.call(this, n)
- );
- }),
- (e.prototype.translate = function (t) {
- return Yo(t);
- }),
- (e.prototype.initCfg = function () {
- (this.tickMethod = "time-pretty"),
- (this.mask = "YYYY-MM-DD"),
- (this.tickCount = 7),
- (this.nice = !1);
- }),
- (e.prototype.setDomain = function () {
- var t = this.values,
- e = this.getConfig("min"),
- n = this.getConfig("max");
- if (
- ((Object(g.isNil)(e) && Object(g.isNumber)(e)) ||
- (this.min = this.translate(this.min)),
- (Object(g.isNil)(n) && Object(g.isNumber)(n)) ||
- (this.max = this.translate(this.max)),
- t && t.length)
- ) {
- var r = [],
- i = 1 / 0,
- o = i,
- a = 0;
- Object(g.each)(t, function (t) {
- var e = Yo(t);
- if (isNaN(e))
- throw new TypeError(
- "Invalid Time: " + t + " in time scale!"
- );
- i > e ? ((o = i), (i = e)) : o > e && (o = e),
- a < e && (a = e),
- r.push(e);
- }),
- t.length > 1 && (this.minTickInterval = o - i),
- Object(g.isNil)(e) && (this.min = i),
- Object(g.isNil)(n) && (this.max = a);
- }
- }),
- e
- );
- })(Ko),
- ra = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.type = "quantize"), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.invert = function (t) {
- var e = this.ticks,
- n = e.length,
- r = this.getInvertPercent(t),
- i = Math.floor(r * (n - 1));
- if (i >= n - 1) return Object(g.last)(e);
- if (i < 0) return Object(g.head)(e);
- var o = e[i],
- a = i / (n - 1);
- return o + ((r - a) / ((i + 1) / (n - 1) - a)) * (e[i + 1] - o);
- }),
- (e.prototype.initCfg = function () {
- (this.tickMethod = "r-pretty"),
- (this.tickCount = 5),
- (this.nice = !0);
- }),
- (e.prototype.calculateTicks = function () {
- var e = t.prototype.calculateTicks.call(this);
- return (
- this.nice ||
- (Object(g.last)(e) !== this.max && e.push(this.max),
- Object(g.head)(e) !== this.min && e.unshift(this.min)),
- e
- );
- }),
- (e.prototype.getScalePercent = function (t) {
- var e = this.ticks;
- if (t < Object(g.head)(e)) return 0;
- if (t > Object(g.last)(e)) return 1;
- var n = 0;
- return (
- Object(g.each)(e, function (e, r) {
- if (!(t >= e)) return !1;
- n = r;
- }),
- n / (e.length - 1)
- );
- }),
- e
- );
- })(Zo),
- ia = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.type = "quantile"), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.initCfg = function () {
- (this.tickMethod = "quantile"),
- (this.tickCount = 5),
- (this.nice = !0);
- }),
- e
- );
- })(ra),
- oa = {};
- function aa(t, e) {
- if (
- (function (t) {
- return oa[t];
- })(t)
- )
- throw new Error("type '" + t + "' existed.");
- oa[t] = e;
- }
- var sa = (function (t) {
- function e() {
- var e = (null !== t && t.apply(this, arguments)) || this;
- return (e.type = "identity"), (e.isIdentity = !0), e;
- }
- return (
- Object(p.__extends)(e, t),
- (e.prototype.calculateTicks = function () {
- return this.values;
- }),
- (e.prototype.scale = function (t) {
- return this.values[0] !== t && Object(g.isNumber)(t)
- ? t
- : this.range[0];
- }),
- (e.prototype.invert = function (t) {
- var e = this.range;
- return t < e[0] || t > e[1] ? NaN : this.values[0];
- }),
- e
- );
- })(ho);
- function ua(t) {
- var e = t.values,
- n = t.tickInterval,
- r = t.tickCount,
- i = t.showLast;
- if (Object(g.isNumber)(n)) {
- var o = Object(g.filter)(e, function (t, e) {
- return e % n == 0;
- }),
- a = Object(g.last)(e);
- return i && Object(g.last)(o) !== a && o.push(a), o;
- }
- var s = e.length,
- u = t.min,
- c = t.max;
- if (
- (Object(g.isNil)(u) && (u = 0),
- Object(g.isNil)(c) && (c = e.length - 1),
- !Object(g.isNumber)(r) || r >= s)
- )
- return e.slice(u, c + 1);
- if (r <= 0 || c <= 0) return [];
- for (
- var l = 1 === r ? s : Math.floor(s / (r - 1)), f = [], h = u, d = 0;
- d < r && !(h >= c);
- d++
- )
- (h = Math.min(u + d * l, c)),
- d === r - 1 && i ? f.push(e[c]) : f.push(e[h]);
- return f;
- }
- var ca = Math.sqrt(50),
- la = Math.sqrt(10),
- fa = Math.sqrt(2),
- ha = (function () {
- function t() {
- this._domain = [0, 1];
- }
- return (
- (t.prototype.domain = function (t) {
- return t
- ? ((this._domain = Array.from(t, Number)), this)
- : this._domain.slice();
- }),
- (t.prototype.nice = function (t) {
- var e, n;
- void 0 === t && (t = 5);
- var r,
- i = this._domain.slice(),
- o = 0,
- a = this._domain.length - 1,
- s = this._domain[o],
- u = this._domain[a];
- return (
- u < s &&
- ((s = (e = [u, s])[0]),
- (u = e[1]),
- (o = (n = [a, o])[0]),
- (a = n[1])),
- (r = da(s, u, t)) > 0
- ? (r = da(
- (s = Math.floor(s / r) * r),
- (u = Math.ceil(u / r) * r),
- t
- ))
- : r < 0 &&
- (r = da(
- (s = Math.ceil(s * r) / r),
- (u = Math.floor(u * r) / r),
- t
- )),
- r > 0
- ? ((i[o] = Math.floor(s / r) * r),
- (i[a] = Math.ceil(u / r) * r),
- this.domain(i))
- : r < 0 &&
- ((i[o] = Math.ceil(s * r) / r),
- (i[a] = Math.floor(u * r) / r),
- this.domain(i)),
- this
- );
- }),
- (t.prototype.ticks = function (t) {
- return (
- void 0 === t && (t = 5),
- (function (t, e, n) {
- var r,
- i,
- o,
- a,
- s = -1;
- if (((n = +n), (t = +t) === (e = +e) && n > 0)) return [t];
- (r = e < t) && ((i = t), (t = e), (e = i));
- if (0 === (a = da(t, e, n)) || !isFinite(a)) return [];
- if (a > 0)
- for (
- t = Math.ceil(t / a),
- e = Math.floor(e / a),
- o = new Array((i = Math.ceil(e - t + 1)));
- ++s < i;
-
- )
- o[s] = (t + s) * a;
- else
- for (
- t = Math.floor(t * a),
- e = Math.ceil(e * a),
- o = new Array((i = Math.ceil(t - e + 1)));
- ++s < i;
-
- )
- o[s] = (t - s) / a;
- r && o.reverse();
- return o;
- })(
- this._domain[0],
- this._domain[this._domain.length - 1],
- t || 5
- )
- );
- }),
- t
- );
- })();
- function da(t, e, n) {
- var r = (e - t) / Math.max(0, n),
- i = Math.floor(Math.log(r) / Math.LN10),
- o = r / Math.pow(10, i);
- return i >= 0
- ? (o >= ca ? 10 : o >= la ? 5 : o >= fa ? 2 : 1) * Math.pow(10, i)
- : -Math.pow(10, -i) / (o >= ca ? 10 : o >= la ? 5 : o >= fa ? 2 : 1);
- }
- function pa(t, e, n) {
- return (
- ("ceil" === n
- ? Math.ceil(t / e)
- : "floor" === n
- ? Math.floor(t / e)
- : Math.round(t / e)) * e
- );
- }
- function ga(t, e, n) {
- var r = pa(t, n, "floor"),
- i = pa(e, n, "ceil");
- (r = Object(g.fixedBase)(r, n)), (i = Object(g.fixedBase)(i, n));
- for (
- var o = [], a = Math.max((i - r) / (Math.pow(2, 12) - 1), n), s = r;
- s <= i;
- s += a
- ) {
- var u = Object(g.fixedBase)(s, a);
- o.push(u);
- }
- return { min: r, max: i, ticks: o };
- }
- function va(t, e, n) {
- var r,
- i = t.minLimit,
- o = t.maxLimit,
- a = t.min,
- s = t.max,
- u = t.tickCount,
- c = void 0 === u ? 5 : u,
- l = Object(g.isNil)(i) ? (Object(g.isNil)(e) ? a : e) : i,
- f = Object(g.isNil)(o) ? (Object(g.isNil)(n) ? s : n) : o;
- if ((l > f && ((f = (r = [l, f])[0]), (l = r[1])), c <= 2))
- return [l, f];
- for (var h = (f - l) / (c - 1), d = [], p = 0; p < c; p++)
- d.push(l + h * p);
- return d;
- }
- function ya(t) {
- return Math.abs(t) < 1e-15 ? t : parseFloat(t.toFixed(15));
- }
- var ma = [1, 5, 2, 2.5, 4, 3],
- ba = 100 * Number.EPSILON;
- function xa(t, e, n, r, i, o) {
- var a = Object(g.size)(e),
- s = Object(g.indexOf)(e, t),
- u = 0,
- c = (function (t, e) {
- return ((t % e) + e) % e;
- })(r, o);
- return (
- (c < ba || o - c < ba) && r <= 0 && i >= 0 && (u = 1),
- 1 - s / (a - 1) - n + u
- );
- }
- function wa(t, e, n) {
- var r = Object(g.size)(e);
- return 1 - Object(g.indexOf)(e, t) / (r - 1) - n + 1;
- }
- function Ea(t, e, n, r, i, o) {
- var a = (t - 1) / (o - i),
- s = (e - 1) / (Math.max(o, r) - Math.min(n, i));
- return 2 - Math.max(a / s, s / a);
- }
- function _a(t, e) {
- return t >= e ? 2 - (t - 1) / (e - 1) : 1;
- }
- function Sa(t, e, n, r) {
- var i = e - t;
- return (
- 1 -
- (0.5 * (Math.pow(e - r, 2) + Math.pow(t - n, 2))) /
- Math.pow(0.1 * i, 2)
- );
- }
- function Oa(t, e, n) {
- var r = e - t;
- if (n > r) {
- var i = (n - r) / 2;
- return 1 - Math.pow(i, 2) / Math.pow(0.1 * r, 2);
- }
- return 1;
- }
- function Ma(t, e, n, r, i, o) {
- void 0 === n && (n = 5),
- void 0 === r && (r = !0),
- void 0 === i && (i = ma),
- void 0 === o && (o = [0.25, 0.2, 0.5, 0.05]);
- var a = n < 0 ? 0 : Math.round(n);
- if (
- Number.isNaN(t) ||
- Number.isNaN(e) ||
- "number" != typeof t ||
- "number" != typeof e ||
- !a
- )
- return { min: 0, max: 0, ticks: [] };
- if (e - t < 1e-15 || 1 === a) return { min: t, max: e, ticks: [t] };
- if (e - t > 1e148) {
- var s = (e - t) / (E = n || 5);
- return {
- min: t,
- max: e,
- ticks: Array(E)
- .fill(null)
- .map(function (e, n) {
- return ya(t + s * n);
- }),
- };
- }
- for (
- var u = { score: -2, lmin: 0, lmax: 0, lstep: 0 }, c = 1;
- c < 1 / 0;
-
- ) {
- for (var l = 0; l < i.length; l += 1) {
- var f = i[l],
- h = wa(f, i, c);
- if (o[0] * h + o[1] + o[2] + o[3] < u.score) {
- c = 1 / 0;
- break;
- }
- for (var d = 2; d < 1 / 0; ) {
- var p = _a(d, a);
- if (o[0] * h + o[1] + o[2] * p + o[3] < u.score) break;
- for (
- var v = (e - t) / (d + 1) / c / f, y = Math.ceil(Math.log10(v));
- y < 1 / 0;
-
- ) {
- var m = c * f * Math.pow(10, y),
- b = Oa(t, e, m * (d - 1));
- if (o[0] * h + o[1] * b + o[2] * p + o[3] < u.score) break;
- var x = Math.floor(e / m) * c - (d - 1) * c,
- w = Math.ceil(t / m) * c;
- if (x <= w)
- for (var E = w - x, _ = 0; _ <= E; _ += 1) {
- var S = (x + _) * (m / c),
- O = S + m * (d - 1),
- M = m,
- k = xa(f, i, c, S, O, M),
- A = Sa(t, e, S, O),
- j = Ea(d, a, t, e, S, O),
- C = o[0] * k + o[1] * A + o[2] * j + 1 * o[3];
- C > u.score &&
- (!r || (S <= t && O >= e)) &&
- ((u.lmin = S),
- (u.lmax = O),
- (u.lstep = M),
- (u.score = C));
- }
- y += 1;
- }
- d += 1;
- }
- }
- c += 1;
- }
- var I = ya(u.lmax),
- T = ya(u.lmin),
- N = ya(u.lstep),
- P =
- Math.floor(
- (function (t) {
- return Math.round(1e12 * t) / 1e12;
- })((I - T) / N)
- ) + 1,
- D = new Array(P);
- D[0] = ya(T);
- for (l = 1; l < P; l++) D[l] = ya(D[l - 1] + N);
- return {
- min: Math.min(t, Object(g.head)(D)),
- max: Math.max(e, Object(g.last)(D)),
- ticks: D,
- };
- }
- function ka(t, e, n) {
- if ((void 0 === n && (n = 5), t === e))
- return { max: e, min: t, ticks: [t] };
- var r = n < 0 ? 0 : Math.round(n);
- if (0 === r) return { max: e, min: t, ticks: [] };
- var i = (e - t) / r,
- o = Math.pow(10, Math.floor(Math.log10(i))),
- a = o;
- 2 * o - i < 1.5 * (i - a) &&
- 5 * o - i < 2.75 * (i - (a = 2 * o)) &&
- 10 * o - i < 1.5 * (i - (a = 5 * o)) &&
- (a = 10 * o);
- for (
- var s = Math.ceil(e / a),
- u = Math.floor(t / a),
- c = Math.max(s * a, e),
- l = Math.min(u * a, t),
- f = Math.floor((c - l) / a) + 1,
- h = new Array(f),
- d = 0;
- d < f;
- d++
- )
- h[d] = ya(l + d * a);
- return { min: l, max: c, ticks: h };
- }
- function Aa(t, e) {
- var n = t.length * e;
- return 1 === e
- ? t[t.length - 1]
- : 0 === e
- ? t[0]
- : n % 1 != 0
- ? t[Math.ceil(n) - 1]
- : t.length % 2 == 0
- ? (t[n - 1] + t[n]) / 2
- : t[n];
- }
- function ja(t) {
- return new Date(t).getFullYear();
- }
- function Ca(t) {
- return new Date(t, 0, 1).getTime();
- }
- function Ia(t) {
- return new Date(t).getMonth();
- }
- function Ta(t, e) {
- return new Date(t, e, 1).getTime();
- }
- fo("cat", ua),
- fo("time-cat", function (t) {
- return ua(Object(p.__assign)({ showLast: !0 }, t));
- }),
- fo("wilkinson-extended", function (t) {
- var e = t.min,
- n = t.max,
- r = t.tickCount,
- i = t.nice,
- o = t.tickInterval,
- a = t.minLimit,
- s = t.maxLimit,
- u = Ma(e, n, r, i).ticks;
- return Object(g.isNil)(a) && Object(g.isNil)(s)
- ? o
- ? ga(e, n, o).ticks
- : u
- : va(t, Object(g.head)(u), Object(g.last)(u));
- }),
- fo("r-pretty", function (t) {
- var e = t.min,
- n = t.max,
- r = t.tickCount,
- i = t.tickInterval,
- o = t.minLimit,
- a = t.maxLimit,
- s = ka(e, n, r).ticks;
- return Object(g.isNil)(o) && Object(g.isNil)(a)
- ? i
- ? ga(e, n, i).ticks
- : s
- : va(t, Object(g.head)(s), Object(g.last)(s));
- }),
- fo("time", function (t) {
- var e = t.min,
- n = t.max,
- r = t.minTickInterval,
- i = t.tickInterval,
- o = t.tickCount;
- if (i) o = Math.ceil((n - e) / i);
- else {
- var a = (n - e) / (i = Ho(e, n, o)[1]) / o;
- a > 1 && (i *= Math.ceil(a)), r && i < r && (i = r);
- }
- i = Math.max(Math.floor((n - e) / (Math.pow(2, 12) - 1)), i);
- for (var s = [], u = e; u < n + i; u += i) s.push(u);
- return s;
- }),
- fo("time-pretty", function (t) {
- var e = t.min,
- n = t.max,
- r = t.minTickInterval,
- i = t.tickCount,
- o = t.tickInterval,
- a = [];
- o || ((o = (n - e) / i), r && o < r && (o = r)),
- (o = Math.max(Math.floor((n - e) / (Math.pow(2, 12) - 1)), o));
- var s = ja(e);
- if (o > 31536e6)
- for (
- var u = ja(n), c = Math.ceil(o / 31536e6), l = s;
- l <= u + c;
- l += c
- )
- a.push(Ca(l));
- else if (o > Wo) {
- var f = Math.ceil(o / Wo),
- h = Ia(e),
- d = (function (t, e) {
- var n = ja(t),
- r = ja(e),
- i = Ia(t);
- return 12 * (r - n) + ((Ia(e) - i) % 12);
- })(e, n);
- for (l = 0; l <= d + f; l += f) a.push(Ta(s, l + h));
- } else if (o > Xo) {
- var p = (b = new Date(e)).getFullYear(),
- g = b.getMonth(),
- v = b.getDate(),
- y = Math.ceil(o / Xo),
- m = (function (t, e) {
- return Math.ceil((e - t) / Xo);
- })(e, n);
- for (l = 0; l < m + y; l += y)
- a.push(new Date(p, g, v + l).getTime());
- } else if (o > Uo) {
- (p = (b = new Date(e)).getFullYear()),
- (g = b.getMonth()),
- (y = b.getDate());
- var b,
- x = b.getHours(),
- w = Math.ceil(o / Uo),
- E = (function (t, e) {
- return Math.ceil((e - t) / Uo);
- })(e, n);
- for (l = 0; l <= E + w; l += w)
- a.push(new Date(p, g, y, x + l).getTime());
- } else if (o > 6e4) {
- var _ = (function (t, e) {
- return Math.ceil((e - t) / 6e4);
- })(e, n),
- S = Math.ceil(o / 6e4);
- for (l = 0; l <= _ + S; l += S) a.push(e + 6e4 * l);
- } else {
- var O = o;
- O < 1e3 && (O = 1e3);
- var M = 1e3 * Math.floor(e / 1e3),
- k = Math.ceil((n - e) / 1e3),
- A = Math.ceil(O / 1e3);
- for (l = 0; l < k + A; l += A) a.push(M + 1e3 * l);
- }
- return (
- a.length >= 512 &&
- console.warn(
- "Notice: current ticks length(" +
- a.length +
- ') >= 512, may cause performance issues, even out of memory. Because of the configure "tickInterval"(in milliseconds, current is ' +
- o +
- ") is too small, increase the value to solve the problem!"
- ),
- a
- );
- }),
- fo("log", function (t) {
- var e,
- n = t.base,
- r = t.tickCount,
- i = t.min,
- o = t.max,
- a = t.values,
- s = $o(n, o);
- if (i > 0) e = Math.floor($o(n, i));
- else {
- var u = Jo(a, n, o);
- e = Math.floor($o(n, u));
- }
- for (
- var c = s - e, l = Math.ceil(c / r), f = [], h = e;
- h < s + l;
- h += l
- )
- f.push(Math.pow(n, h));
- return i <= 0 && f.unshift(0), f;
- }),
- fo("pow", function (t) {
- var e = t.exponent,
- n = t.tickCount,
- r = Math.ceil(Qo(e, t.max));
- return ka(Math.floor(Qo(e, t.min)), r, n).ticks.map(function (t) {
- var n = t >= 0 ? 1 : -1;
- return Math.pow(t, e) * n;
- });
- }),
- fo("quantile", function (t) {
- var e = t.tickCount,
- n = t.values;
- if (!n || !n.length) return [];
- for (
- var r = n.slice().sort(function (t, e) {
- return t - e;
- }),
- i = [],
- o = 0;
- o < e;
- o++
- ) {
- var a = o / (e - 1);
- i.push(Aa(r, a));
- }
- return i;
- }),
- fo("d3-linear", function (t) {
- var e = t.min,
- n = t.max,
- r = t.tickInterval,
- i = t.minLimit,
- o = t.maxLimit,
- a = (function (t) {
- var e = t.min,
- n = t.max,
- r = t.nice,
- i = t.tickCount,
- o = new ha();
- return o.domain([e, n]), r && o.nice(i), o.ticks(i);
- })(t);
- return Object(g.isNil)(i) && Object(g.isNil)(o)
- ? r
- ? ga(e, n, r).ticks
- : a
- : va(t, Object(g.head)(a), Object(g.last)(a));
- }),
- aa("cat", po),
- aa("category", po),
- aa("identity", sa),
- aa("linear", Ko),
- aa("log", ta),
- aa("pow", ea),
- aa("time", na),
- aa("timeCat", qo),
- aa("quantize", ra),
- aa("quantile", ia);
- var Na = function (t, e, n) {
- if (n || 2 === arguments.length)
- for (var r, i = 0, o = e.length; i < o; i++)
- (!r && i in e) ||
- (r || (r = Array.prototype.slice.call(e, 0, i)), (r[i] = e[i]));
- return t.concat(r || Array.prototype.slice.call(e));
- };
- function Pa(t) {
- return (function (t) {
- return Object(g.map)(t, function (t, e) {
- return [0 === e ? "M" : "L", t[0], t[1]];
- });
- })(t);
- }
- function Da(t, e, n, r) {
- void 0 === r && (r = !0);
- var i = new Ko({ values: t }),
- o = new po({
- values: Object(g.map)(t, function (t, e) {
- return e;
- }),
- }),
- a = Object(g.map)(t, function (t, r) {
- return [o.scale(r) * e, n - i.scale(t) * n];
- });
- return r
- ? (function (t) {
- if (t.length <= 2) return Pa(t);
- var e = [];
- Object(g.each)(t, function (t) {
- Object(g.isEqual)(t, e.slice(e.length - 2)) ||
- e.push(t[0], t[1]);
- });
- var n = Sn.a(e, !1),
- r = Object(g.head)(t),
- i = r[0],
- o = r[1];
- return n.unshift(["M", i, o]), n;
- })(a)
- : Pa(a);
- }
- function La(t, e, n, r) {
- void 0 === r && (r = 5);
- for (
- var i = new Ko({ values: t }),
- o = new po({
- values: Object(g.map)(t, function (t, e) {
- return e;
- }),
- }),
- a = Object(g.map)(t, function (t, r) {
- return [o.scale(r) * e, n - i.scale(t) * n];
- }),
- s = [],
- u = 0;
- u < a.length;
- u++
- ) {
- var c = a[u],
- l = Ba({ x: c[0], y: c[1], y0: n, size: r });
- s.push.apply(s, l);
- }
- return (function (t, e) {
- void 0 === e && (e = !0);
- var n = [],
- r = t[0];
- n.push(["M", r.x, r.y]);
- for (var i = 1, o = t.length; i < o; i++)
- n.push(["L", t[i].x, t[i].y]);
- e && (n.push(["L", r.x, r.y]), n.push(["z"]));
- return n;
- })(s);
- }
- function Ra(t, e, n, r) {
- var i = Na([], t, !0),
- o = (function (t, e) {
- var n = new Ko({ values: t }),
- r = Math.max(0, n.min);
- return e - n.scale(r) * e;
- })(r, n);
- return i.push(["L", e, o]), i.push(["L", 0, o]), i.push(["Z"]), i;
- }
- function Ba(t) {
- var e,
- n,
- r,
- i,
- o = t.x,
- a = t.y,
- s = t.y0,
- u = t.size;
- Object(g.isArray)(a) ? ((e = a[0]), (n = a[1])) : ((e = s), (n = a)),
- Object(g.isArray)(o)
- ? ((r = o[0]), (i = o[1]))
- : ((r = o - u / 2), (i = o + u / 2));
- var c = [
- { x: r, y: e },
- { x: r, y: n },
- ];
- return c.push({ x: i, y: n }, { x: i, y: e }), c;
- }
- var Fa = function () {
- return (Fa =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- za = { stroke: "#C5C5C5", strokeOpacity: 0.85 },
- Ga = { fill: "#CACED4", opacity: 0.85 },
- Ya = (function () {
- function t(t) {
- var e = t.x,
- n = void 0 === e ? 0 : e,
- r = t.y,
- i = void 0 === r ? 0 : r,
- o = t.width,
- a = void 0 === o ? 200 : o,
- s = t.height,
- u = void 0 === s ? 26 : s,
- c = t.smooth,
- l = void 0 === c || c,
- f = t.isArea,
- h = void 0 !== f && f,
- d = t.data,
- p = void 0 === d ? [] : d,
- g = t.lineStyle,
- v = t.areaStyle,
- y = t.group,
- m = t.interval,
- b = void 0 === m ? null : m;
- (this.group = y),
- (this.x = n),
- (this.y = i),
- (this.width = a),
- (this.height = u),
- (this.data = p),
- (this.smooth = l),
- (this.isArea = h),
- (this.lineStyle = Object.assign({}, za, g)),
- (this.areaStyle = Object.assign({}, Ga, v)),
- (this.intervalConfig = b),
- this.renderLine();
- }
- return (
- (t.prototype.renderLine = function () {
- var t = this,
- e = t.x,
- n = t.y,
- r = t.width,
- i = t.height,
- o = (t.barWidth, t.data),
- a = t.smooth,
- s = t.isArea,
- u = t.lineStyle,
- c = t.areaStyle,
- l = this.group.addGroup({ name: "trend-group" });
- if (o) {
- var f = Da(o, r, i, a);
- if (
- (l.addShape("path", {
- attrs: Fa({ path: f }, u),
- name: "trend-line",
- }),
- s)
- ) {
- var h = Ra(f, r, i, o);
- l.addShape("path", {
- attrs: Fa({ path: h }, c),
- name: "trend-area",
- });
- }
- }
- this.intervalConfig &&
- l.addShape("path", {
- attrs: Fa(
- {
- path: La(
- this.intervalConfig.data,
- r,
- i,
- this.intervalConfig.style.barWidth
- ),
- },
- this.intervalConfig.style
- ),
- name: "trend-interval",
- }),
- l.move(e, n);
- }),
- (t.prototype.destory = function () {
- this.group.destroy();
- }),
- t
- );
- })(),
- Ua = function () {
- return (Ua =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- Xa = {
- fill: "#1890ff",
- stroke: "#1890ff",
- type: "trend",
- radius: 2,
- opacity: 1,
- cursor: "ew-resize",
- highLightFill: "#0050b3",
- },
- Wa = {
- fill: "#fff",
- stroke: "#1890ff",
- radius: 2,
- opacity: 1,
- cursor: "ew-resize",
- },
- Va = (function () {
- function t(t) {
- var e = t.group,
- n = t.name,
- r = t.type,
- i = t.x,
- o = void 0 === i ? 0 : i,
- a = t.y,
- s = void 0 === a ? 0 : a,
- u = t.width,
- c = void 0 === u ? 2 : u,
- l = t.height,
- f = void 0 === l ? 24 : l,
- h = t.style,
- d = void 0 === h ? {} : h;
- (this.group = e),
- (this.name = n),
- (this.handleType = r),
- (this.x = o),
- (this.y = s),
- (this.width = c),
- (this.height = f),
- "trend" === r
- ? (this.style = Ua(Ua({}, Xa), d))
- : "simple" === r && (this.style = Ua(Ua({}, Wa), d)),
- this.renderHandle();
- }
- return (
- (t.prototype.setX = function (t) {
- this.setXY(t, void 0);
- }),
- (t.prototype.setY = function (t) {
- this.setXY(void 0, t);
- }),
- (t.prototype.setXY = function (t, e) {
- Object(g.isNumber)(t) && (this.x = t),
- Object(g.isNumber)(e) && (this.y = e),
- this.updateXY();
- }),
- (t.prototype.renderHandle = function () {
- var t = this.width,
- e = this.height,
- n = this.style,
- r = this.name,
- i = n.fill,
- o = n.stroke,
- a = n.radius,
- s = n.opacity,
- u = n.cursor;
- (this.handleGroup = this.group.addGroup()),
- "trend" === this.handleType
- ? ((this.verticalLine = this.handleGroup.addShape("rect", {
- attrs: {
- x: 0,
- y: 0,
- width: t,
- height: e,
- fill: i,
- stroke: o,
- radius: a,
- opacity: s,
- cursor: u,
- },
- name: "".concat(r, "-handler"),
- })),
- (this.topCircle = this.handleGroup.addShape("circle", {
- attrs: {
- x: t / 2,
- y: 0,
- r: 2 * t,
- fill: i,
- stroke: o,
- radius: a,
- opacity: s,
- cursor: u,
- lineAppendWidth: 12,
- },
- name: "".concat(r, "-handler"),
- })),
- (this.bottomCircle = this.handleGroup.addShape("circle", {
- attrs: {
- x: t / 2,
- y: e,
- r: 2 * t,
- fill: i,
- stroke: o,
- radius: a,
- opacity: s,
- cursor: u,
- },
- name: "".concat(r, "-handler"),
- })))
- : "simple" === this.handleType &&
- (this.topCircle = this.handleGroup.addShape("circle", {
- attrs: {
- x: t / 2,
- y: e / 2,
- r: 2 * t,
- fill: i,
- stroke: o,
- radius: a,
- opacity: s,
- cursor: u,
- lineWidth: 2,
- },
- name: "".concat(r, "-handler"),
- })),
- this.updateXY(),
- "trend" === this.handleType
- ? this.bindTrendEvents()
- : "simple" === this.handleType && this.bindSimpleEvents();
- }),
- (t.prototype.bindSimpleEvents = function () {
- var t = this,
- e = this.name;
- this.handleGroup.on(
- "".concat(e, "-handler:mouseenter"),
- function () {
- var e = t.style.highLightFill;
- t.topCircle.attr("fill", e);
- }
- ),
- this.handleGroup.on(
- "".concat(e, "-handler:mouseleave"),
- function () {
- var e = t.style.fill;
- t.topCircle.attr("fill", e);
- }
- );
- }),
- (t.prototype.bindTrendEvents = function () {
- var t = this,
- e = this.name;
- this.handleGroup.on(
- "".concat(e, "-handler:mouseenter"),
- function () {
- var e = t.style.highLightFill;
- t.verticalLine.attr("fill", e),
- t.topCircle.attr("fill", e),
- t.bottomCircle.attr("fill", e);
- }
- ),
- this.handleGroup.on(
- "".concat(e, "-handler:mouseleave"),
- function () {
- var e = t.style.fill;
- t.verticalLine.attr("fill", e),
- t.topCircle.attr("fill", e),
- t.bottomCircle.attr("fill", e);
- }
- );
- }),
- (t.prototype.show = function () {
- this.handleGroup.show();
- }),
- (t.prototype.hide = function () {
- this.handleGroup.hide();
- }),
- (t.prototype.updateXY = function () {
- this.handleGroup.setMatrix([1, 0, 0, 0, 1, 0, this.x, this.y, 1]);
- }),
- t
- );
- })(),
- Ha = function () {
- return (Ha =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- qa = (function () {
- function t(t) {
- (this.config = Object(g.deepMix)({}, t)), this.init();
- }
- return (
- (t.prototype.update = function (t) {
- (this.config = Object(g.deepMix)({}, this.config, t)),
- this.updateElement(),
- this.renderMarker();
- }),
- (t.prototype.init = function () {
- this.initElement(), this.renderMarker();
- }),
- (t.prototype.initElement = function () {
- var t = this.config,
- e = t.group,
- n = t.style,
- r = n.scale,
- i = void 0 === r ? 1 : r,
- o = n.offsetX,
- a = void 0 === o ? 0 : o,
- s = n.offsetY,
- u = void 0 === s ? 0 : s,
- c = this.config.x + a,
- l = this.config.y + u,
- f = e.addGroup({ name: "playPauseBtn" });
- (this.startMarkerGroup = f.addGroup({ name: "playPauseBtn" })),
- (this.circle = e.addShape("circle", {
- attrs: Ha({ x: c, y: l, r: this.config.r * i }, n),
- name: "playPauseBtn",
- })),
- (this.startMarker = this.startMarkerGroup.addShape("path", {
- attrs: {
- path: this.getStartMarkerPath(c, l, i),
- fill: n.stroke || "#aaa",
- },
- name: "start-marker",
- })),
- (this.pauseMarkerGroup = f.addGroup({ name: "playPauseBtn" }));
- var h = 0.25 * this.config.r * i,
- d = 0.5 * this.config.r * Math.sqrt(3) * i;
- (this.pauseLeftMarker = this.pauseMarkerGroup.addShape("rect", {
- attrs: {
- x: c - 0.375 * this.config.r * i,
- y: l - d / 2,
- width: h,
- height: d,
- fill: n.stroke || "#aaa",
- lineWidth: 0,
- },
- })),
- (this.pauseRightMarker = this.pauseMarkerGroup.addShape(
- "rect",
- {
- attrs: {
- x: c + (1 / 8) * this.config.r * i,
- y: l - d / 2,
- width: h,
- height: d,
- fill: n.stroke || "#aaa",
- lineWidth: 0,
- },
- }
- ));
- }),
- (t.prototype.updateElement = function () {
- var t = this.config.style,
- e = t.scale,
- n = void 0 === e ? 1 : e,
- r = t.offsetX,
- i = void 0 === r ? 0 : r,
- o = t.offsetY,
- a = void 0 === o ? 0 : o,
- s = this.config.x + i,
- u = this.config.y + a;
- this.circle.attr("x", s),
- this.circle.attr("y", u),
- this.circle.attr("r", this.config.r * n),
- this.startMarker.attr("path", this.getStartMarkerPath(s, u, n));
- var c = 0.25 * this.config.r * n,
- l = 0.5 * this.config.r * Math.sqrt(3) * n;
- this.pauseLeftMarker.attr("x", s - 0.375 * this.config.r * n),
- this.pauseLeftMarker.attr("y", u - l / 2),
- this.pauseLeftMarker.attr("width", c),
- this.pauseLeftMarker.attr("height", l),
- this.pauseRightMarker.attr(
- "x",
- s + (1 / 8) * this.config.r * n
- ),
- this.pauseRightMarker.attr("y", u - l / 2),
- this.pauseRightMarker.attr("width", c),
- this.pauseRightMarker.attr("height", l);
- }),
- (t.prototype.renderMarker = function () {
- this.config.isPlay
- ? (this.startMarkerGroup.hide(), this.pauseMarkerGroup.show())
- : (this.startMarkerGroup.show(), this.pauseMarkerGroup.hide());
- }),
- (t.prototype.getStartMarkerPath = function (t, e, n) {
- var r = 0.5 * this.config.r * Math.sqrt(3) * n;
- return [
- ["M", t - r / Math.sqrt(3) / 2, e - r / 2],
- ["L", t + r / Math.sqrt(3), e],
- ["L", t - r / Math.sqrt(3) / 2, e + r / 2],
- ];
- }),
- t
- );
- })(),
- Za = function () {
- return (Za =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- Ka = x.a.transform,
- Qa = { fill: "#aaa", fillOpacity: 0.35, stroke: "#aaa" },
- $a = { fill: "#fff" },
- Ja = { fill: "green" },
- ts = {
- pointer: { fill: "#aaa", lineWidth: 0 },
- scroller: {
- stroke: "#aaa",
- fill: "#aaa",
- lineWidth: 1,
- lineAppendWidth: 5,
- cursor: "pointer",
- },
- text: { fill: "#aaa", textBaseline: "top" },
- },
- es = {
- check: { stroke: "green", lineWidth: 3 },
- box: {
- fill: "#fff",
- stroke: "#aaa",
- lineWidth: 2,
- radius: 3,
- width: 12,
- height: 12,
- },
- text: { fill: "#aaa", fontSize: 12, textBaseline: "top" },
- },
- ns = {
- speed: 1,
- loop: !1,
- fill: "#fff",
- stroke: "#fff",
- hideTimeTypeController: !1,
- preBtnStyle: { fill: "#aaa", stroke: "#aaa" },
- nextBtnStyle: { fill: "#aaa", stroke: "#aaa" },
- playBtnStyle: { fill: "#aaa", stroke: "#aaa", fillOpacity: 0.05 },
- speedControllerStyle: ts,
- timeTypeControllerStyle: es,
- },
- rs = "single",
- is = "range",
- os = (function () {
- function t(t) {
- (this.controllerCfg = Object(g.deepMix)({}, ns, t)),
- (this.group = t.group),
- (this.controllerGroup = this.group.addGroup({
- name: "controller-group",
- })),
- (this.speedAxisY = []),
- (this.currentSpeed = this.controllerCfg.speed),
- (this.currentType = this.controllerCfg.defaultTimeType || is),
- (this.fontFamily = t.fontFamily || "Arial, sans-serif"),
- this.init();
- }
- return (
- (t.prototype.init = function () {
- this.renderPlayButton();
- }),
- (t.prototype.getNextMarkerPath = function (t, e, n) {
- return [
- ["M", t, e - n],
- ["L", t + n, e],
- ["L", t, e + n],
- ["Z", t, e - n],
- ["M", t, e],
- ["L", t - n, e - n],
- ["L", t - n, e + n],
- ["Z"],
- ];
- }),
- (t.prototype.getPreMarkerPath = function (t, e, n) {
- return [
- ["M", t, e - n],
- ["L", t - n, e],
- ["L", t, e + n],
- ["L", t, e - n],
- ["M", t, e],
- ["L", t + n, e - n],
- ["L", t + n, e + n],
- ["Z"],
- ];
- }),
- (t.prototype.renderPlayButton = function () {
- var t = this.controllerCfg,
- e = t.width,
- n = t.height,
- r = t.x,
- i = t.y,
- o = t.hideTimeTypeController,
- a = t.fill,
- s = void 0 === a ? "#aaa" : a,
- u = t.stroke,
- c = void 0 === u ? "green" : u,
- l = t.containerStyle,
- f = void 0 === l ? {} : l,
- h = Za(Za({}, Qa), t.playBtnStyle || {}),
- d = Za(Za({}, $a), t.preBtnStyle || {}),
- p = Za(Za({}, Ja), t.nextBtnStyle || {}),
- g = n / 2 - 5,
- v = i + 10,
- y = this.controllerGroup.addShape("rect", {
- attrs: Za(
- { x: r, y: v, width: e, height: n, stroke: c, fill: s },
- f
- ),
- name: "container-rect",
- });
- this.playButton
- ? this.playButton.update({ x: e / 2, y: v, r: g })
- : (this.playButton = new qa({
- group: this.controllerGroup,
- x: e / 2,
- y: v + g + 5,
- r: g,
- isPlay: this.isPlay,
- style: h,
- }));
- var m = d.offsetX || 0,
- b = d.offsetY || 0,
- x = (d.scale || 1) * g;
- this.controllerGroup.addShape("path", {
- attrs: Za(
- {
- path: this.getPreMarkerPath(
- e / 2 - 5 * g + m,
- v + g + 5 + b,
- 0.5 * x
- ),
- },
- d
- ),
- name: "preStepBtn",
- });
- var w = p.offsetX || 0,
- E = p.offsetY || 0,
- _ = (p.scale || 1) * g;
- this.controllerGroup.addShape("path", {
- attrs: Za(
- {
- path: this.getNextMarkerPath(
- e / 2 + 5 * g + w,
- v + g + 5 + E,
- 0.5 * _
- ),
- },
- p
- ),
- name: "nextStepBtn",
- }),
- y.toBack(),
- this.renderSpeedBtn(),
- o || this.renderToggleTime(),
- this.bindEvent();
- var S = this.controllerCfg.scale,
- O = void 0 === S ? 1 : S,
- M = this.controllerGroup.getCanvasBBox(),
- k = (M.maxX + M.minX) / 2,
- A = (M.maxY + M.minY) / 2,
- j = Ka(
- [1, 0, 0, 0, 1, 0, 0, 0, 1],
- [
- ["t", -k, -A],
- ["s", O, O],
- ["t", k, A],
- ]
- );
- this.controllerGroup.setMatrix(j);
- }),
- (t.prototype.renderSpeedBtn = function () {
- var t = this.controllerCfg,
- e = t.y,
- n = t.width,
- r = t.hideTimeTypeController,
- i = Za(
- Za({}, ts),
- this.controllerCfg.speedControllerStyle || {}
- ),
- o = i.scroller,
- a = void 0 === o ? {} : o,
- s = i.text,
- u = void 0 === s ? {} : s,
- c = i.pointer,
- l = void 0 === c ? {} : c,
- f = i.scale,
- h = void 0 === f ? 1 : f,
- d = i.offsetX,
- p = void 0 === d ? 0 : d,
- g = i.offsetY,
- v = void 0 === g ? 0 : g,
- y = this.controllerGroup.addGroup({ name: "speed-group" });
- this.speedGroup = y;
- var m = [],
- b = 5;
- this.speedAxisY = [19, 22, 26, 32, 39];
- for (var x = 0; x < 5; x++) {
- var w = e + this.speedAxisY[x],
- E = n - (r ? 50 : 110);
- y.addShape("line", {
- attrs: Za({ x1: E, x2: E + 15, y1: w, y2: w }, a),
- speed: b,
- name: "speed-rect",
- }),
- (this.speedAxisY[x] = w),
- m.push(b),
- (b -= 1);
- }
- (this.speedText = y.addShape("text", {
- attrs: Za(
- {
- x: n - (r ? 50 : 110) + 20,
- y: this.speedAxisY[0] + 4,
- text: "1.0X",
- fontFamily: this.fontFamily || "Arial, sans-serif",
- },
- u
- ),
- name: "speed-text",
- })),
- (this.speedPoint = y.addShape("path", {
- attrs: Za(
- {
- path: this.getPointerPath(n - (r ? 50 : 110), 0),
- matrix: [1, 0, 0, 0, 1, 0, 0, this.speedAxisY[4], 1],
- },
- l
- ),
- name: "speed-pointer",
- }));
- var _ = this.speedGroup.getCanvasBBox(),
- S = (_.maxX + _.minX) / 2,
- O = (_.maxY + _.minY) / 2,
- M = this.speedGroup.getMatrix() || [1, 0, 0, 0, 1, 0, 0, 0, 1];
- (M = Ka(M, [
- ["t", -S, -O],
- ["s", h, h],
- ["t", S + p * h, O + v * h],
- ])),
- this.speedGroup.setMatrix(M);
- }),
- (t.prototype.getPointerPath = function (t, e) {
- return [
- ["M", t, e],
- ["L", t - 10, e - 4],
- ["L", t - 10, e + 4],
- ["Z"],
- ];
- }),
- (t.prototype.renderToggleTime = function () {
- var t,
- e,
- n = this.controllerCfg,
- r = n.width,
- i = n.defaultTimeType,
- o = Za(
- Za({}, es),
- this.controllerCfg.timeTypeControllerStyle || {}
- ),
- a = o.scale,
- s = void 0 === a ? 1 : a,
- u = o.offsetX,
- c = void 0 === u ? 0 : u,
- l = o.offsetY,
- f = void 0 === l ? 0 : l,
- h = o.box,
- d = void 0 === h ? {} : h,
- p = o.check,
- g = void 0 === p ? {} : p,
- v = o.text,
- y = void 0 === v ? {} : v;
- this.toggleGroup = this.controllerGroup.addGroup({
- name: "toggle-group",
- });
- var m = i === rs;
- this.toggleGroup.addShape("rect", {
- attrs: Za({ x: r - 50, y: this.speedAxisY[0] + 3.5 }, d),
- isChecked: m,
- name: "toggle-model",
- }),
- (this.checkedIcon = this.toggleGroup.addShape("path", {
- attrs: Za(
- {
- path: [
- ["M", r - 50 + 3, this.speedAxisY[1] + 6],
- ["L", r - 50 + 7, this.speedAxisY[1] + 10],
- ["L", r - 50 + 12, this.speedAxisY[1] + 4],
- ],
- },
- g
- ),
- capture: !1,
- name: "check-icon",
- })),
- m || this.checkedIcon.hide(),
- (this.checkedText = this.toggleGroup.addShape("text", {
- attrs: Za(
- {
- text: m
- ? (null === (t = this.controllerCfg) || void 0 === t
- ? void 0
- : t.timeRangeControllerText) || "时间范围"
- : (null === (e = this.controllerCfg) || void 0 === e
- ? void 0
- : e.timePointControllerText) || "单一时间",
- x: r - 50 + 15,
- y: this.speedAxisY[0] + 4,
- fontFamily:
- ("undefined" != typeof window &&
- window
- .getComputedStyle(document.body, null)
- .getPropertyValue("font-family")) ||
- "Arial, sans-serif",
- },
- y
- ),
- name: "checked-text",
- }));
- var b = this.toggleGroup.getCanvasBBox(),
- x = (b.maxX + b.minX) / 2,
- w = (b.maxY + b.minY) / 2,
- E = this.toggleGroup.getMatrix() || [1, 0, 0, 0, 1, 0, 0, 0, 1];
- (E = Ka(E, [
- ["t", -x, -w],
- ["s", s, s],
- ["t", x + c * s, w + f * s],
- ])),
- this.toggleGroup.setMatrix(E);
- }),
- (t.prototype.bindEvent = function () {
- var t = this;
- this.speedGroup.on("speed-rect:click", function (e) {
- var n = e.target.attr("y1"),
- r = t.speedPoint.attr("matrix"),
- i = t.speedAxisY.indexOf(r[7] || 0),
- o = t.speedAxisY.indexOf(n),
- a = t.speedAxisY[o] - t.speedAxisY[i];
- (r = Ka(r, [["t", 0, a]])),
- t.speedPoint.setMatrix(r),
- (t.currentSpeed = t.speedAxisY.length - o),
- t.speedText.attr("text", "".concat(t.currentSpeed, ".0X")),
- t.group.emit("timebarConfigChanged", {
- speed: t.currentSpeed,
- type: t.currentType,
- });
- }),
- this.speedGroup.on("mousewheel", function (e) {
- e.preventDefault();
- var n = t.speedPoint.attr("matrix") || [
- 1, 0, 0, 0, 1, 0, 0, 0, 1,
- ],
- r = n[7],
- i = t.speedAxisY.indexOf(r);
- if (-1 === i) {
- var o = 1 / 0;
- t.speedAxisY.forEach(function (t, e) {
- var n = Math.abs(t - r);
- o > n && ((o = n), (i = e));
- });
- }
- i =
- e.originalEvent.deltaY > 0
- ? Math.max(0, i - 1)
- : Math.min(t.speedAxisY.length - 1, i + 1);
- var a = t.speedAxisY[i] - r;
- (n = Ka(n, [["t", 0, a]])),
- t.speedPoint.setMatrix(n),
- (t.currentSpeed = t.speedAxisY.length - i),
- t.speedText.attr("text", "".concat(t.currentSpeed, ".0X")),
- t.group.emit("timebarConfigChanged", {
- speed: t.currentSpeed,
- type: t.currentType,
- });
- }),
- this.toggleGroup &&
- this.toggleGroup.on("toggle-model:click", function (e) {
- var n,
- r,
- i = e.target.get("isChecked");
- i
- ? (t.checkedIcon.hide(),
- t.checkedText.attr(
- "text",
- (null === (r = t.controllerCfg) || void 0 === r
- ? void 0
- : r.timePointControllerText) || "单一时间"
- ),
- (t.currentType = is))
- : (t.checkedIcon.show(),
- t.checkedText.attr(
- "text",
- (null === (n = t.controllerCfg) || void 0 === n
- ? void 0
- : n.timeRangeControllerText) || "时间范围"
- ),
- (t.currentType = rs)),
- e.target.set("isChecked", !i),
- t.group.emit("timebarConfigChanged", {
- type: t.currentType,
- speed: t.currentSpeed,
- });
- });
- }),
- (t.prototype.destroy = function () {
- this.speedGroup.off("speed-rect:click"),
- this.toggleGroup &&
- (this.toggleGroup.off("toggle-model:click"),
- this.toggleGroup.destroy()),
- this.speedGroup.destroy();
- }),
- t
- );
- })(),
- as = function () {
- return (as =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- ss = x.a.transform,
- us = { fill: "#416180", opacity: 0.05 },
- cs = { fill: "#416180", opacity: 0.15, radius: 5 },
- ls = { fill: "#5B8FF9", opacity: 0.3, cursor: "grab" },
- fs = { width: 2, height: 24 },
- hs = { textBaseline: "middle", fill: "#000", opacity: 0.45 },
- ds = {
- textAlign: "center",
- textBaseline: "top",
- fill: "#607889",
- opacity: 0.35,
- },
- ps = { lineWidth: 1, stroke: "#ccc" },
- gs = (function () {
- function t(t) {
- var e = this;
- (this.prevX = 0),
- (this.onMouseDown = function (t) {
- return function (n) {
- e.currentHandler = t;
- var r = n.originalEvent;
- r.stopPropagation(),
- r.preventDefault(),
- (e.prevX = Object(g.get)(r, "touches.0.pageX", r.pageX));
- var i = e.canvas.get("container");
- i.addEventListener("mousemove", e.onMouseMove),
- i.addEventListener("mouseup", e.onMouseUp),
- i.addEventListener("mouseleave", e.onMouseUp),
- i.addEventListener("touchmove", e.onMouseMove),
- i.addEventListener("touchend", e.onMouseUp),
- i.addEventListener("touchcancel", e.onMouseUp);
- };
- }),
- (this.onMouseMove = function (t) {
- t.stopPropagation(), t.preventDefault();
- var n = Object(g.get)(t, "touches.0.pageX", t.pageX),
- r = n - e.prevX,
- i = e.adjustOffsetRange(r / e.width);
- e.updateStartEnd(i), e.updateUI(), (e.prevX = n);
- }),
- (this.onMouseUp = function () {
- e.currentHandler && (e.currentHandler = void 0);
- var t = e.canvas.get("container");
- t &&
- (t.removeEventListener("mousemove", e.onMouseMove),
- t.removeEventListener("mouseup", e.onMouseUp),
- t.removeEventListener("mouseleave", e.onMouseUp),
- t.removeEventListener("touchmove", e.onMouseMove),
- t.removeEventListener("touchend", e.onMouseUp),
- t.removeEventListener("touchcancel", e.onMouseUp));
- });
- var n = t.x,
- r = void 0 === n ? 0 : n,
- i = t.y,
- o = void 0 === i ? 0 : i,
- a = t.width,
- s = void 0 === a ? 100 : a,
- u = t.height,
- c = t.padding,
- l = void 0 === c ? 10 : c,
- f = t.trendCfg,
- h = t.controllerCfg,
- d = void 0 === h ? { speed: 1 } : h,
- p = t.backgroundStyle,
- v = void 0 === p ? {} : p,
- y = t.foregroundStyle,
- m = void 0 === y ? {} : y,
- b = t.handlerStyle,
- x = void 0 === b ? {} : b,
- w = t.textStyle,
- E = void 0 === w ? {} : w,
- _ = t.start,
- S = void 0 === _ ? 0 : _,
- O = t.end,
- M = void 0 === O ? 1 : O,
- k = t.minText,
- A = void 0 === k ? "" : k,
- j = t.maxText,
- C = void 0 === j ? "" : j,
- I = t.group,
- T = t.graph,
- N = t.canvas,
- P = t.tick,
- D =
- void 0 === P
- ? {
- tickLabelStyle: {},
- tickLineStyle: {},
- tickLabelFormatter: function (t) {
- return t;
- },
- ticks: [],
- }
- : P,
- L = t.type;
- (this.graph = T),
- (this.canvas = N),
- (this.group = I),
- (this.timeBarType = L),
- (this.x = r),
- (this.y = o),
- (this.width = s),
- (this.height = u),
- (this.padding = l),
- (this.ticks = D.ticks),
- (this.trendCfg = f),
- (this.controllerCfg = d),
- (this.currentSpeed = d.speed || 1),
- (this.tickLabelFormatter = D.tickLabelFormatter),
- "trend" === L
- ? (this.backgroundStyle = as(as({}, us), v))
- : "simple" === L && (this.backgroundStyle = as(as({}, cs), v)),
- (this.foregroundStyle = as(as({}, ls), m)),
- (this.handlerStyle = as(as({}, fs), x)),
- (this.textStyle = as(as({}, hs), E)),
- (this.tickLabelStyle = as(as({}, ds), D.tickLabelStyle)),
- (this.tickLineStyle = as(as({}, ps), D.tickLineStyle)),
- (this.currentMode = d.defaultTimeType || is),
- (this.start = S),
- (this.end = M),
- (this.minText = A),
- (this.maxText = C),
- (this.fontFamily =
- ("undefined" != typeof window &&
- window
- .getComputedStyle(document.body, null)
- .getPropertyValue("font-family")) ||
- "Arial, sans-serif"),
- this.renderSlider();
- }
- return (
- (t.prototype.update = function (t) {
- var e = t.x,
- n = t.y,
- r = t.width,
- i = t.height,
- o = t.minText,
- a = t.maxText,
- s = t.start,
- u = t.end;
- (this.start = Math.min(1, Math.max(s, 0))),
- (this.end = Math.min(1, Math.max(u, 0))),
- Object(g.assign)(this, {
- x: e,
- y: n,
- width: r,
- height: i,
- minText: o,
- maxText: a,
- }),
- this.updateUI();
- }),
- (t.prototype.setText = function (t, e) {
- this.minTextShape.attr("text", t),
- this.maxTextShape.attr("text", e);
- }),
- (t.prototype.renderSlider = function () {
- var t = this,
- e = this.width,
- n = this.height,
- r = this.timeBarType;
- if (
- "trend" === r &&
- Object(g.size)(Object(g.get)(this.trendCfg, "data"))
- ) {
- var i = new Ya(
- as(
- as(
- { x: this.x, y: this.y, width: e, height: n },
- this.trendCfg
- ),
- { group: this.group }
- )
- );
- this.trendComponent = i;
- }
- var o = this.group.addGroup({ name: "slider-group" });
- o.addShape("rect", {
- attrs: as(
- { x: 0, y: 0, width: e, height: n },
- this.backgroundStyle
- ),
- name: "background",
- });
- var a = this.group.addGroup();
- "trend" === r
- ? ((this.minTextShape = a.addShape("text", {
- attrs: as(
- {
- x: 0,
- y: n / 2 + this.y,
- textAlign: "right",
- text: this.minText,
- silent: !1,
- fontFamily: this.fontFamily || "Arial, sans-serif",
- stroke: "#fff",
- lineWidth: 5,
- },
- this.textStyle
- ),
- capture: !1,
- name: "min-text-shape",
- })),
- (this.maxTextShape = a.addShape("text", {
- attrs: as(
- {
- y: n / 2 + this.y,
- textAlign: "left",
- text: this.maxText,
- silent: !1,
- fontFamily: this.fontFamily || "Arial, sans-serif",
- stroke: "#fff",
- lineWidth: 5,
- },
- this.textStyle
- ),
- capture: !1,
- name: "max-text-shape",
- })))
- : ((this.minTextShape = a.addShape("text", {
- attrs: as(
- {
- x: 0,
- y: this.y - 10,
- textAlign: "center",
- text: this.minText,
- silent: !1,
- fontFamily: this.fontFamily || "Arial, sans-serif",
- stroke: "#fff",
- lineWidth: 5,
- },
- this.textStyle
- ),
- capture: !1,
- name: "min-text-shape",
- })),
- (this.maxTextShape = a.addShape("text", {
- attrs: as(
- {
- y: this.y - 10,
- textAlign: "center",
- text: this.maxText,
- silent: !1,
- fontFamily: this.fontFamily || "Arial, sans-serif",
- stroke: "#fff",
- lineWidth: 5,
- },
- this.textStyle
- ),
- capture: !1,
- name: "max-text-shape",
- }))),
- (this.foregroundShape = this.group
- .addGroup()
- .addShape("rect", {
- attrs: as(
- { x: 0, y: this.y, height: n },
- this.foregroundStyle
- ),
- name: "foreground-shape",
- })),
- this.foregroundShape.on("mousedown", function (t) {
- t.target.attr("cursor", "grabbing");
- }),
- this.foregroundShape.on("mouseup", function (e) {
- e.target.attr("cursor", t.foregroundStyle.cursor || "grab");
- });
- var s = Object(g.get)(this.handlerStyle, "width", 2),
- u = Object(g.get)(this.handlerStyle, "height", 24),
- c = this.group.addGroup({ name: "minHandlerShape" });
- this.minHandlerShape = new Va({
- name: "minHandlerShape",
- group: c,
- type: r,
- x: this.x,
- y: this.y,
- width: s,
- height: u,
- style: this.handlerStyle,
- });
- var l = this.group.addGroup({ name: "maxHandlerShape" });
- this.maxHandlerShape = new Va({
- name: "maxHandlerShape",
- group: l,
- type: r,
- x: this.x,
- y: this.y,
- width: s,
- height: u,
- style: this.handlerStyle,
- });
- var f = this.ticks,
- h = e / (f.length - 1);
- (this.tickPosList = []),
- this.textList &&
- this.textList.length &&
- this.textList.forEach(function (t) {
- t.destroy();
- });
- var d = -1 / 0,
- p = this.tickLabelStyle.rotate;
- delete this.tickLabelStyle.rotate,
- (this.textList = f.map(function (e, r) {
- var i;
- t.tickPosList.push(t.x + r * h),
- t.tickLabelFormatter
- ? ((i = t.tickLabelFormatter(e)),
- !Object(g.isString)(i) && i && (i = e.date))
- : (i = e.date);
- var o = t.x + r * h,
- a = t.y + n + 5,
- s = t.group.addShape("text", {
- attrs: as(
- {
- x: o,
- y: a,
- text: i,
- fontFamily: t.fontFamily || "Arial, sans-serif",
- },
- t.tickLabelStyle
- ),
- name: "tick-label",
- });
- if (Object(g.isNumber)(p) && r !== f.length - 1) {
- var u = ss(
- [1, 0, 0, 0, 1, 0, 0, 0, 1],
- [
- ["t", -o, -a],
- ["r", p],
- ["t", o - 5, a + 2],
- ]
- );
- s.attr({ textAlign: "left", matrix: u });
- }
- 0 === r
- ? s.attr({ textAlign: "left" })
- : r !== f.length - 1 && s.attr({ textAlign: "right" });
- var c = t.group.addShape("line", {
- attrs: as(
- {
- x1: t.x + r * h,
- y1: t.y + n + 2,
- x2: t.x + r * h,
- y2: t.y + n + 6,
- },
- t.tickLineStyle
- ),
- name: "tick-line",
- });
- c.toBack();
- var l = s.getBBox();
- return (
- l.minX > d
- ? (s.show(), c.show(), (d = l.minX + l.width + 10))
- : (s.hide(), c.hide()),
- s
- );
- })),
- (this.controllerBtnGroup = new os(
- as(
- {
- group: this.group,
- x: this.x,
- y: this.y + n + 25,
- width: e,
- height: 35,
- },
- this.controllerCfg
- )
- )),
- this.updateStartEnd(0),
- this.updateUI(),
- o.move(this.x, this.y),
- this.bindEvents(),
- this.currentMode === rs &&
- (this.minHandlerShape.hide(),
- this.foregroundShape.hide(),
- this.minTextShape.hide());
- }),
- (t.prototype.bindEvents = function () {
- var t = this,
- e = this.group.find(function (t) {
- return "minHandlerShape" === t.get("name");
- });
- e &&
- (e.on(
- "minHandlerShape-handler:mousedown",
- this.onMouseDown(this.minHandlerShape)
- ),
- e.on(
- "minHandlerShape-handler:touchstart",
- this.onMouseDown(this.minHandlerShape)
- ));
- var n = this.group.find(function (t) {
- return "maxHandlerShape" === t.get("name");
- });
- n &&
- (n.on(
- "maxHandlerShape-handler:mousedown",
- this.onMouseDown(this.maxHandlerShape)
- ),
- n.on(
- "maxHandlerShape-handler:touchstart",
- this.onMouseDown(this.maxHandlerShape)
- )),
- this.foregroundShape.on(
- "mousedown",
- this.onMouseDown(this.foregroundShape)
- ),
- this.foregroundShape.on(
- "touchstart",
- this.onMouseDown(this.foregroundShape)
- ),
- this.group.on("".concat("playPauseBtn", ":click"), function () {
- (t.isPlay = !t.isPlay),
- (t.currentHandler = t.maxHandlerShape),
- t.changePlayStatus();
- }),
- this.group.on("".concat("nextStepBtn", ":click"), function () {
- (t.currentHandler = t.maxHandlerShape),
- t.updateStartEnd(0.01),
- t.updateUI();
- }),
- this.group.on("".concat("preStepBtn", ":click"), function () {
- (t.currentHandler = t.maxHandlerShape),
- t.updateStartEnd(-0.01),
- t.updateUI();
- }),
- this.group.on("timebarConfigChanged", function (e) {
- var n = e.type,
- r = e.speed;
- (t.currentSpeed = r),
- (t.currentMode = n),
- n === rs
- ? (t.minHandlerShape.hide(),
- t.foregroundShape.hide(),
- t.minTextShape.hide())
- : n === is &&
- (t.minHandlerShape.show(),
- t.foregroundShape.show(),
- t.minTextShape.show());
- });
- }),
- (t.prototype.adjustTickIndex = function (t) {
- for (var e = 0; e < this.tickPosList.length - 1; e++)
- if (this.tickPosList[e] <= t && t <= this.tickPosList[e + 1])
- return Math.abs(this.tickPosList[e] - t) <
- Math.abs(t - this.tickPosList[e + 1])
- ? e
- : e + 1;
- return 0;
- }),
- (t.prototype.adjustOffsetRange = function (t) {
- switch (this.currentHandler) {
- case this.minHandlerShape:
- var e = 0 - this.start,
- n = 1 - this.start;
- return Math.min(n, Math.max(e, t));
- case this.maxHandlerShape:
- (e = 0 - this.end), (n = 1 - this.end);
- return Math.min(n, Math.max(e, t));
- case this.foregroundShape:
- (e = 0 - this.start), (n = 1 - this.end);
- return Math.min(n, Math.max(e, t));
- default:
- return 0;
- }
- }),
- (t.prototype.updateStartEnd = function (t) {
- var e = this.ticks[this.adjustTickIndex(this.start * this.width)],
- n = this.ticks[this.adjustTickIndex(this.end * this.width)];
- if (!this.currentHandler)
- return (
- (this.minText = this.tickLabelFormatter
- ? this.tickLabelFormatter(e)
- : null == e
- ? void 0
- : e.date),
- void (this.maxText = this.tickLabelFormatter
- ? this.tickLabelFormatter(n)
- : null == n
- ? void 0
- : n.date)
- );
- switch (this.currentHandler) {
- case this.minHandlerShape:
- (this.maxText = this.maxTextShape.attr("text")),
- (this.start += t),
- (this.minText = this.tickLabelFormatter
- ? this.tickLabelFormatter(e)
- : e.date);
- break;
- case this.maxHandlerShape:
- (this.minText = this.minTextShape.attr("text")),
- (this.end += t),
- (this.maxText = this.tickLabelFormatter
- ? this.tickLabelFormatter(n)
- : n.date);
- break;
- case this.foregroundShape:
- (this.start += t),
- (this.end += t),
- (this.minText = this.tickLabelFormatter
- ? this.tickLabelFormatter(e)
- : e.date),
- (this.maxText = this.tickLabelFormatter
- ? this.tickLabelFormatter(n)
- : n.date);
- }
- }),
- (t.prototype.updateUI = function () {
- var t = this;
- this.start < 0 && (this.start = 0),
- this.end > 1 && (this.end = 1);
- var e = this.x + this.start * this.width,
- n = this.x + this.end * this.width;
- this.foregroundShape.attr("x", e),
- this.foregroundShape.attr("width", n - e);
- var r = Object(g.get)(this.handlerStyle, "width", 2);
- this.setText(this.minText, this.maxText);
- var i = this.dodgeText([e, n]),
- o = i[0],
- a = i[1];
- this.minHandlerShape.setX(e - r / 2),
- Object(g.each)(o, function (e, n) {
- return t.minTextShape.attr(n, e);
- }),
- this.maxHandlerShape.setX(n - r / 2),
- Object(g.each)(a, function (e, n) {
- return t.maxTextShape.attr(n, e);
- }),
- this.currentMode === is
- ? this.graph.emit("valuechange", {
- value: [this.start, this.end].sort(),
- })
- : this.currentMode === rs &&
- this.graph.emit("valuechange", {
- value: [this.end, this.end],
- });
- }),
- (t.prototype.dodgeText = function (t) {
- var e,
- n,
- r = Object(g.get)(this.handlerStyle, "width", 2),
- i = this.minTextShape,
- o = this.maxTextShape,
- a = t[0],
- s = t[1],
- u = !1;
- a > s &&
- ((a = (e = [s, a])[0]),
- (s = e[1]),
- (i = (n = [o, i])[0]),
- (o = n[1]),
- (u = !0));
- var c = i.getBBox(),
- l = o.getBBox(),
- f = null,
- h = null;
- return (
- "trend" === this.timeBarType
- ? ((f =
- a - c.width < this.x + 2
- ? { x: a + r / 2 + 2, textAlign: "left" }
- : { x: a - r / 2 - 2, textAlign: "right" }),
- (h =
- s + l.width > this.x + this.width
- ? { x: s - r / 2 - 2, textAlign: "right" }
- : { x: s + r / 2 + 2, textAlign: "left" }))
- : "simple" === this.timeBarType &&
- ((f =
- i.attr("x") > c.width
- ? { x: a, textAlign: "center" }
- : { x: a, textAlign: "left" }),
- (h =
- o.attr("x") > this.width - l.width
- ? { x: s, textAlign: "right" }
- : { x: s, textAlign: "center" })),
- u ? [h, f] : [f, h]
- );
- }),
- (t.prototype.startPlay = function () {
- var t = this;
- return "undefined" != typeof window
- ? window.requestAnimationFrame(function () {
- var e = t,
- n = e.ticks,
- r = e.width,
- i = t.currentSpeed,
- o = r / n.length / ((1e3 * (10 - i)) / 60),
- a = t.adjustOffsetRange(o / t.width);
- t.updateStartEnd(a),
- t.updateUI(),
- t.isPlay && (t.playHandler = t.startPlay());
- })
- : void 0;
- }),
- (t.prototype.changePlayStatus = function (t) {
- void 0 === t && (t = !0),
- this.controllerBtnGroup.playButton.update({
- isPlay: this.isPlay,
- }),
- this.isPlay
- ? ((this.playHandler = this.startPlay()),
- this.graph.emit("timebarstartplay", null))
- : this.playHandler &&
- ("undefined" != typeof window &&
- window.cancelAnimationFrame(this.playHandler),
- t && this.graph.emit("timebarendplay", null));
- }),
- (t.prototype.destory = function () {
- this.graph.off("valuechange", function () {});
- var t = this.group,
- e = t.find(function (t) {
- return "minHandlerShape" === t.get("name");
- });
- e &&
- (e.off("minHandlerShape-handler:mousedown"),
- e.off("minHandlerShape-handler:touchstart"),
- e.destroy());
- var n = t.find(function (t) {
- return "maxHandlerShape" === t.get("name");
- });
- n &&
- (n.off("maxHandlerShape-handler:mousedown"),
- n.off("maxHandlerShape-handler:touchstart"),
- n.destroy()),
- this.foregroundShape.off("mousedown"),
- this.foregroundShape.off("touchstart"),
- this.foregroundShape.destroy(),
- t.off("".concat("playPauseBtn", ":click")),
- t.off("".concat("nextStepBtn", ":click")),
- t.off("".concat("preStepBtn", ":click")),
- t.off("timebarConfigChanged"),
- t.destroy(),
- this.trendComponent && this.trendComponent.destory();
- }),
- t
- );
- })(),
- vs = (function () {
- function t(t) {
- var e = t.x,
- n = void 0 === e ? 0 : e,
- r = t.y,
- i = void 0 === r ? 0 : r,
- o = t.container,
- a = t.text,
- s = t.padding,
- u = void 0 === s ? [4, 4, 4, 4] : s,
- c = t.className,
- l = void 0 === c ? "g6-component-timebar-tooltip" : c,
- f = t.backgroundColor,
- h = void 0 === f ? "#000" : f,
- d = t.textColor,
- p = void 0 === d ? "#fff" : d,
- g = t.opacity,
- v = void 0 === g ? 0.8 : g,
- y = t.fontSize,
- m = void 0 === y ? 12 : y;
- (this.container = o),
- (this.className = l),
- (this.backgroundColor = h),
- (this.textColor = p),
- (this.x = n),
- (this.y = i),
- (this.text = a),
- (this.padding = u),
- (this.opacity = v),
- (this.fontSize = m),
- this.render();
- }
- return (
- (t.prototype.render = function () {
- var t = this.className,
- e = (this.x, this.y, this.backgroundColor),
- n = this.textColor,
- r = this.text,
- i = this.padding,
- o = this.opacity,
- a = this.fontSize,
- s = this.container,
- u = Vr(
- "
')
- );
- Object(g.isString)(s) && (s = document.getElementById(s)),
- s.appendChild(u),
- (this.parentHeight = s.offsetHeight),
- (this.parentWidth = s.offsetWidth),
- Hr(u, { visibility: "hidden", top: 0, left: 0 });
- var c = Vr(
- "\n
")
- );
- (c.innerHTML = r), u.appendChild(c), (this.backgroundDOM = c);
- var l = Vr(
- "
"
- )
- );
- u.appendChild(l), (this.arrowDOM = l), (this.container = u);
- }),
- (t.prototype.show = function (t) {
- var e = t.text,
- n = t.x;
- t.y, t.clientX, t.clientY;
- this.backgroundDOM.innerHTML = e;
- var r = this.backgroundDOM.offsetWidth,
- i = this.backgroundDOM.offsetHeight,
- o = this.arrowDOM.offsetWidth,
- a = this.arrowDOM.offsetHeight;
- Hr(this.container, {
- top: "".concat(-i - a, "px"),
- left: "".concat(n, "px"),
- visibility: "visible",
- }),
- Hr(this.backgroundDOM, { marginLeft: "".concat(-r / 2, "px") }),
- Hr(this.arrowDOM, {
- marginLeft: "".concat(-o / 2, "px"),
- top: "".concat(i, "px"),
- });
- var s = n - r / 2,
- u = n + r / 2;
- s < 0
- ? Hr(this.backgroundDOM, {
- marginLeft: "".concat(-r / 2 - s, "px"),
- })
- : u > this.parentWidth &&
- Hr(this.backgroundDOM, {
- marginLeft: "".concat(
- -r / 2 - u + this.parentWidth + 12,
- "px"
- ),
- });
- }),
- (t.prototype.hide = function () {
- Hr(this.container, { top: 0, left: 0, visibility: "hidden" });
- }),
- t
- );
- })(),
- ys = function () {
- return (ys =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- ms = x.a.transform,
- bs = { fill: "#5B8FF9" },
- xs = { fill: "#e6e8e9" },
- ws = (function () {
- function t(t) {
- (this.frameCount = 0), (this.fontFamily = "Arial, sans-serif");
- var e = t.graph,
- n = t.canvas,
- r = t.group,
- i = t.width,
- o = t.height,
- a = t.padding,
- s = t.data,
- u = t.start,
- c = t.end,
- l = t.x,
- f = void 0 === l ? 0 : l,
- h = t.y,
- d = void 0 === h ? 0 : h,
- p = t.tickLabelFormatter,
- g = t.selectedTickStyle,
- v = void 0 === g ? bs : g,
- y = t.unselectedTickStyle,
- m = void 0 === y ? xs : y,
- b = t.tooltipBackgroundColor,
- x = t.tooltipFomatter,
- w = t.tickLabelStyle,
- E = t.controllerCfg,
- _ = void 0 === E ? { speed: 1 } : E;
- (this.graph = e),
- (this.group = r),
- (this.sliceGroup = r.addGroup({ name: "slice-group" })),
- (this.canvas = n),
- (this.width = i),
- (this.height = o),
- (this.padding = a),
- (this.data = s),
- (this.start = u),
- (this.end = c),
- (this.tickLabelFormatter = p),
- (this.tickLabelStyle = w || {}),
- (this.selectedTickStyle = v),
- (this.unselectedTickStyle = m),
- (this.controllerCfg = _),
- (this.currentSpeed = _.speed || 1),
- (this.x = f),
- (this.y = d),
- (this.tooltipBackgroundColor = b),
- (this.tooltipFomatter = x),
- (this.fontFamily =
- ("undefined" != typeof window &&
- window
- .getComputedStyle(document.body, null)
- .getPropertyValue("font-family")) ||
- "Arial, sans-serif"),
- this.renderSlices(),
- this.initEvent();
- }
- return (
- (t.prototype.renderSlices = function () {
- var t = this,
- e = this,
- n = e.width,
- r = e.height,
- i = e.padding,
- o = e.data,
- a = e.start,
- s = e.end,
- u = e.tickLabelFormatter,
- c = e.selectedTickStyle,
- l = e.unselectedTickStyle,
- f = e.tickLabelStyle,
- h = n - 2 * i,
- d = r - (3 * i + 4 + 10) - 2 * i,
- p = o.length,
- v = (h - 2 * (p - 1)) / p;
- this.tickWidth = v;
- var y = this.sliceGroup,
- m = [],
- b = [],
- x = Math.round(p * a),
- w = Math.round(p * s);
- (this.startTickRectId = x), (this.endTickRectId = w);
- var E = f.rotate;
- delete f.rotate,
- o.forEach(function (e, r) {
- var o = r >= x && r <= w ? c : l,
- a = y.addShape("rect", {
- attrs: ys(
- { x: i + r * (v + 2), y: i, width: v, height: d },
- o
- ),
- draggable: !0,
- name: "tick-rect-".concat(r),
- }),
- s = y.addShape("rect", {
- attrs: {
- x: i + r * v + (2 * (2 * r - 1)) / 2,
- y: i,
- width: 0 === r || r === p - 1 ? v + 1 : v + 2,
- height: d,
- fill: "#fff",
- opacity: 0,
- },
- draggable: !0,
- name: "pick-rect-".concat(r),
- });
- s.toFront();
- var h,
- _ = a.getBBox(),
- S = (_.minX + _.maxX) / 2;
- if (
- (m.push({
- rect: a,
- pickRect: s,
- value: e.date,
- x: S,
- y: _.minY,
- }),
- u
- ? ((h = u(e)),
- !Object(g.isString)(h) && h && (h = e.date))
- : r % Math.round(p / 10) == 0 && (h = e.date),
- h)
- ) {
- b.push(h);
- var O = _.maxY + 2 * i;
- y.addShape("line", {
- attrs: {
- stroke: "#BFBFBF",
- x1: S,
- y1: O,
- x2: S,
- y2: O + 4,
- },
- name: "tick-line",
- });
- var M = O + 4 + i,
- k = y.addShape("text", {
- attrs: ys(
- {
- fill: "#8c8c8c",
- stroke: "#fff",
- lineWidth: 1,
- x: S,
- y: M,
- textAlign: "center",
- text: h,
- textBaseline: "top",
- fontSize: 10,
- fontFamily: t.fontFamily || "Arial, sans-serif",
- },
- f
- ),
- capture: !1,
- name: "tick-label",
- }),
- A = k.getBBox();
- if (
- (A.maxX > n
- ? k.attr("textAlign", "right")
- : A.minX < 0 && k.attr("textAlign", "left"),
- Object(g.isNumber)(E) && 10 !== b.length)
- ) {
- var j = ms(
- [1, 0, 0, 0, 1, 0, 0, 0, 1],
- [
- ["t", -S, -M],
- ["r", E],
- ["t", S - 5, M + 2],
- ]
- );
- k.attr({ textAlign: "left", matrix: j });
- }
- 1 === b.length
- ? k.attr({ textAlign: "left" })
- : 10 === b.length && k.attr({ textAlign: "right" });
- }
- }),
- (this.tickRects = m);
- var _ = this.group;
- (this.currentSpeed = 1),
- (this.controllerBtnGroup = new os(
- ys(
- {
- group: _,
- x: this.x,
- y: this.y + r + 5,
- width: n,
- height: 40,
- hideTimeTypeController: !0,
- speed: this.currentSpeed,
- fontFamily: this.fontFamily || "Arial, sans-serif",
- },
- this.controllerCfg
- )
- ));
- }),
- (t.prototype.initEvent = function () {
- var t = this,
- e = this.sliceGroup;
- e.on("click", function (e) {
- var n = e.target;
- if ("rect" === n.get("type") && n.get("name")) {
- var r = parseInt(n.get("name").split("-")[2], 10);
- if (!isNaN(r)) {
- var i = t.tickRects,
- o = t.unselectedTickStyle;
- i.forEach(function (t) {
- t.rect.attr(o);
- });
- var a = t.selectedTickStyle;
- i[r].rect.attr(a),
- (t.startTickRectId = r),
- (t.endTickRectId = r);
- var s = r / i.length;
- t.graph.emit("valuechange", { value: [s, s] });
- }
- }
- }),
- e.on("dragstart", function (e) {
- var n = t.tickRects,
- r = t.unselectedTickStyle;
- n.forEach(function (t) {
- t.rect.attr(r);
- });
- var i = e.target,
- o = parseInt(i.get("name").split("-")[2], 10),
- a = t.selectedTickStyle;
- n[o].rect.attr(a), (t.startTickRectId = o);
- var s = o / n.length;
- t.graph.emit("valuechange", { value: [s, s] }),
- (t.dragging = !0);
- }),
- e.on("dragover", function (e) {
- if (t.dragging && "rect" === e.target.get("type")) {
- for (
- var n = parseInt(e.target.get("name").split("-")[2], 10),
- r = t.startTickRectId,
- i = t.tickRects,
- o = t.selectedTickStyle,
- a = t.unselectedTickStyle,
- s = 0;
- s < i.length;
- s++
- ) {
- var u = s >= r && s <= n ? o : a;
- i[s].rect.attr(u);
- }
- var c = i.length;
- t.endTickRectId = n;
- var l = r / c,
- f = n / c;
- t.graph.emit("valuechange", { value: [l, f] });
- }
- }),
- e.on("drop", function (e) {
- if (
- t.dragging &&
- ((t.dragging = !1), "rect" === e.target.get("type"))
- ) {
- var n = t.startTickRectId,
- r = parseInt(e.target.get("name").split("-")[2], 10);
- if (!(r < n)) {
- var i = t.selectedTickStyle,
- o = t.tickRects;
- o[r].rect.attr(i), (t.endTickRectId = r);
- var a = o.length,
- s = n / a,
- u = r / a;
- t.graph.emit("valuechange", { value: [s, u] });
- }
- }
- });
- var n = this.tooltipBackgroundColor,
- r = this.tooltipFomatter,
- i = this.canvas,
- o = new vs({
- container: i.get("container"),
- backgroundColor: n,
- }),
- a = this.tickRects;
- a.forEach(function (t) {
- var e = t.pickRect;
- e.on("mouseenter", function (t) {
- var e = t.target;
- if ("rect" === e.get("type")) {
- var n = parseInt(e.get("name").split("-")[2], 10),
- s = i.getClientByPoint(a[n].x, a[n].y);
- o.show({
- x: a[n].x,
- y: a[n].y,
- clientX: s.x,
- clientY: s.y,
- text: r ? r(a[n].value) : a[n].value,
- });
- }
- }),
- e.on("mouseleave", function (t) {
- o.hide();
- });
- });
- var s = this.group;
- s.on("".concat("playPauseBtn", ":click"), function () {
- (t.isPlay = !t.isPlay), t.changePlayStatus();
- }),
- s.on("".concat("nextStepBtn", ":click"), function () {
- t.updateStartEnd(1);
- }),
- s.on("".concat("preStepBtn", ":click"), function () {
- t.updateStartEnd(-1);
- }),
- s.on("timebarConfigChanged", function (e) {
- e.type;
- var n = e.speed;
- t.currentSpeed = n;
- });
- }),
- (t.prototype.changePlayStatus = function (t) {
- void 0 === t && (t = !0),
- this.controllerBtnGroup.playButton.update({
- isPlay: this.isPlay,
- }),
- this.isPlay
- ? ((this.playHandler = this.startPlay()),
- this.graph.emit("timebarstartplay", null))
- : this.playHandler &&
- ("undefined" != typeof window &&
- window.cancelAnimationFrame(this.playHandler),
- t && this.graph.emit("timebarendplay", null));
- }),
- (t.prototype.startPlay = function () {
- var t = this;
- return "undefined" != typeof window
- ? window.requestAnimationFrame(function () {
- var e = t.currentSpeed;
- t.frameCount % (60 / e) == 0 &&
- ((t.frameCount = 0), t.updateStartEnd(1)),
- t.frameCount++,
- t.isPlay && (t.playHandler = t.startPlay());
- })
- : void 0;
- }),
- (t.prototype.updateStartEnd = function (t) {
- var e = this.tickRects,
- n = e.length,
- r = this.unselectedTickStyle,
- i = this.selectedTickStyle,
- o = this.endTickRectId;
- if (
- (t > 0
- ? this.endTickRectId++
- : (e[this.endTickRectId].rect.attr(r), this.endTickRectId--),
- o !== this.startTickRectId)
- )
- this.endTickRectId < this.startTickRectId &&
- (this.startTickRectId = this.endTickRectId);
- else {
- for (
- var a = this.startTickRectId;
- a <= this.endTickRectId - 1;
- a++
- )
- e[a].rect.attr(r);
- this.startTickRectId = this.endTickRectId;
- }
- if (e[this.endTickRectId]) {
- e[this.endTickRectId].rect.attr(i);
- var s = this.startTickRectId / n,
- u = this.endTickRectId / n;
- this.graph.emit("valuechange", { value: [s, u] });
- }
- }),
- (t.prototype.destory = function () {
- var t = this.sliceGroup;
- t.off("click"),
- t.off("dragstart"),
- t.off("dragover"),
- t.off("drop"),
- this.tickRects.forEach(function (t) {
- var e = t.pickRect;
- e.off("mouseenter"), e.off("mouseleave");
- }),
- (this.tickRects.length = 0),
- t.off("".concat("playPauseBtn", ":click")),
- t.off("".concat("nextStepBtn", ":click")),
- t.off("".concat("preStepBtn", ":click")),
- t.off("timebarConfigChanged"),
- this.sliceGroup.destroy();
- }),
- t
- );
- })(),
- Es = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })(),
- _s = function () {
- return (_s =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- Ss = function (t, e) {
- var n = {};
- for (var r in t)
- Object.prototype.hasOwnProperty.call(t, r) &&
- e.indexOf(r) < 0 &&
- (n[r] = t[r]);
- if (null != t && "function" == typeof Object.getOwnPropertySymbols) {
- var i = 0;
- for (r = Object.getOwnPropertySymbols(t); i < r.length; i++)
- e.indexOf(r[i]) < 0 &&
- Object.prototype.propertyIsEnumerable.call(t, r[i]) &&
- (n[r[i]] = t[r[i]]);
- }
- return n;
- },
- Os = (function (t) {
- function e(e) {
- var n = t.call(this, e) || this;
- return (
- (n.afterrenderListener = function (t) {
- return n.filterData({});
- }),
- (n.valueChangeListener = Object(g.throttle)(
- function (t) {
- return n.filterData(t);
- },
- 200,
- { trailing: !0, leading: !0 }
- )),
- (n.changeData = function (t) {
- var e = n.get("graph");
- (n.cacheGraphData = e.get("data")), n.filterData({});
- }),
- n
- );
- }
- return (
- Es(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- container: null,
- className: "g6-component-timebar",
- padding: 10,
- type: "trend",
- trend: { data: [], isArea: !1, smooth: !0 },
- controllerCfg: { speed: 1, loop: !1 },
- slider: {
- start: 0.1,
- end: 0.9,
- minText: "min",
- maxText: "max",
- },
- tick: { start: 0.1, end: 0.9, data: [] },
- textStyle: {},
- filterEdge: !1,
- filterItemTypes: ["node"],
- containerCSS: {},
- };
- }),
- (e.prototype.initContainer = function () {
- var t,
- e,
- n = this.get("graph"),
- r = this._cfgs,
- i = r.width,
- o = r.height,
- a = this.get("className") || "g6-component-timebar",
- s = this.get("container"),
- u = this.get("graph").get("container");
- s
- ? (Object(g.isString)(s) && (s = document.getElementById(s)),
- (t = s))
- : Hr((t = Vr("
"))), {
- position: "relative",
- }),
- u.appendChild(t),
- this.set("timeBarContainer", t),
- (e =
- "SVG" === n.get("renderer")
- ? new _r.Canvas({ container: t, width: i, height: o })
- : new Er.Canvas({ container: t, width: i, height: o })),
- this.get("containerCSS") && Hr(t, this.get("containerCSS")),
- this.set("canvas", e);
- }),
- (e.prototype.init = function () {
- this.initContainer();
- var t = this.get("canvas").addGroup({ name: "timebar-group" });
- this.set("timeBarGroup", t), this.renderTrend(), this.initEvent();
- var e =
- ("undefined" != typeof window &&
- window
- .getComputedStyle(document.body, null)
- .getPropertyValue("font-family")) ||
- "Arial, sans-serif";
- this.set("fontFamily", e);
- }),
- (e.prototype.play = function () {
- this.togglePlay(!0);
- }),
- (e.prototype.pause = function () {
- this.togglePlay(!1);
- }),
- (e.prototype.togglePlay = function (t) {
- var e = this.get("timebar");
- e && ((e.isPlay = !!t), e.changePlayStatus());
- }),
- (e.prototype.renderTrend = function () {
- var t = this,
- e = this._cfgs,
- n = e.width,
- r = e.x,
- i = e.y,
- o = e.padding,
- a = e.type,
- s = e.trend,
- u = e.slider,
- c = e.controllerCfg,
- l = e.textStyle,
- f = e.tick,
- h = e.backgroundStyle,
- d = e.foregroundStyle,
- p = s.data,
- g = Ss(s, ["data"]),
- v = n - 2 * o,
- y = "trend" === a ? 26 : 4,
- m = this.get("graph"),
- b = this.get("timeBarGroup"),
- x = this.get("canvas"),
- w = null;
- if ("trend" === a || "simple" === a) {
- var E = this.get("getValue");
- w = new gs(
- _s(
- _s(
- {
- graph: m,
- canvas: x,
- group: b,
- type: a,
- x: r + o,
- y: "trend" === a ? i + o : i + o + 15,
- width: v,
- height: y,
- padding: o,
- backgroundStyle: h,
- foregroundStyle: d,
- trendCfg: _s(_s({}, g), {
- data: p.map(function (t) {
- return (null == E ? void 0 : E(t)) || t.value;
- }),
- }),
- },
- u
- ),
- {
- tick: {
- ticks: p,
- tickLabelFormatter: f.tickLabelFormatter,
- tickLabelStyle: f.tickLabelStyle,
- tickLineStyle: f.tickLineStyle,
- },
- handlerStyle: _s(_s({}, u.handlerStyle), {
- height: u.height || y,
- }),
- controllerCfg: c,
- textStyle: l,
- }
- )
- );
- } else
- "tick" === a &&
- (w = new ws(
- _s(
- {
- graph: m,
- canvas: x,
- group: b,
- x: r + o,
- y: i + o,
- width: n,
- height: 42,
- padding: 2,
- controllerCfg: c,
- },
- f
- )
- ));
- var _ = function e() {
- var n = t.get("timebar");
- (n.draggingHandler = !1),
- n.isPlay &&
- ((n.isPlay = !1),
- (n.currentHandler = n.maxHandlerShape),
- n.changePlayStatus()),
- document.removeEventListener("mouseup", e);
- };
- x.on("mousedown", function (t) {
- ("maxHandlerShape-handler" !== t.target.get("name") &&
- "minHandlerShape-handler" !== t.target.get("name") &&
- t.target !== w.foregroundShape) ||
- document.addEventListener("mouseup", _);
- }),
- this.set("timebar", w);
- }),
- (e.prototype.filterData = function (t) {
- var e,
- n = t.value;
- if (!n) {
- n = [];
- var r = this._cfgs.type;
- r && "trend" !== r && "simple" !== r
- ? "tick" === r &&
- ((n[0] = this._cfgs.tick.start),
- (n[1] = this._cfgs.tick.end))
- : ((n[0] = this._cfgs.slider.start),
- (n[1] = this._cfgs.slider.end));
- }
- var i = null,
- o = this._cfgs.type;
- if (
- ("trend" === o || "simple" === o
- ? (i = this._cfgs.trend.data)
- : "tick" === o && (i = this._cfgs.tick.data),
- i && 0 !== i.length)
- ) {
- var a = this.get("rangeChange"),
- s = this.get("graph"),
- u = Math.round(i.length * n[0]),
- c = Math.round(i.length * n[1]);
- (c = c >= i.length ? i.length - 1 : c),
- (u = u >= i.length ? i.length - 1 : u);
- var l =
- null === (e = this._cfgs.tick) || void 0 === e
- ? void 0
- : e.tickLabelFormatter,
- f = l ? l(i[u]) : i[u].date,
- h = l ? l(i[c]) : i[c].date;
- if ("tick" !== o) this.get("timebar").setText(f, h);
- if (a) a(s, f, h);
- else {
- (!this.cacheGraphData ||
- (this.cacheGraphData.nodes &&
- 0 === this.cacheGraphData.nodes.length)) &&
- (this.cacheGraphData = s.get("data"));
- var d = this.get("filterItemTypes"),
- p = this.get("changeData"),
- g = this.get("getDate"),
- v = this.get("shouldIgnore"),
- y = i[u].date,
- m = i[c].date;
- if (p || void 0 === p) {
- var b = this.cacheGraphData.nodes,
- x = this.cacheGraphData.edges,
- w = {},
- E = {};
- s.getNodes().forEach(function (t) {
- return (w[t.getID()] = !0);
- }),
- s.getEdges().forEach(function (t) {
- return (E[t.getID()] = !0);
- }),
- d.includes("node") &&
- (b.forEach(function (t) {
- var e = +((null == g ? void 0 : g(t)) || t.date),
- n =
- (e >= y && e <= m) ||
- (null == v
- ? void 0
- : v("node", t, { min: y, max: m })),
- r = w[t.id];
- r && !n
- ? (s.removeItem(t.id), (w[t.id] = !1))
- : !r && n && (s.addItem("node", t), (w[t.id] = !0));
- }),
- null == x ||
- x.forEach(function (t) {
- var e =
- (w[t.source] && w[t.target]) ||
- (null == v
- ? void 0
- : v("edge", t, { min: y, max: m })),
- n = !!s.findById(t.id);
- n && !e
- ? (s.removeItem(t.id), (E[t.id] = !1))
- : !n && e
- ? (s.addItem("edge", t), (E[t.id] = !0))
- : n || (E[t.id] = !1);
- })),
- (this.get("filterEdge") || d.includes("edge")) &&
- (null == x ||
- x.filter(function (t) {
- var e = +((null == g ? void 0 : g(t)) || t.date),
- n =
- (e >= y && e <= m) ||
- (null == v
- ? void 0
- : v("edge", t, { min: y, max: m })),
- r = w[t.source] && w[t.target],
- i = n && r,
- o = E[t.id];
- o && !i
- ? ((E[t.id] = !1), s.removeItem(t.id))
- : !o &&
- i &&
- ((E[t.id] = !0), s.addItem("edge", t));
- }));
- } else
- d.includes("node") &&
- s.getNodes().forEach(function (t) {
- var e = t.getModel();
- if (
- !(null == v
- ? void 0
- : v("node", e, { min: y, max: m }))
- ) {
- var n = +((null == g ? void 0 : g(e)) || e.date);
- n < y || n > m ? s.hideItem(t) : s.showItem(t);
- }
- }),
- (this.get("filterEdge") || d.includes("edge")) &&
- s.getEdges().forEach(function (t) {
- var e = t.getModel();
- if (
- !(null == v
- ? void 0
- : v("edge", e, {
- min: i[u].date,
- max: i[c].date,
- }))
- ) {
- var n = +((null == g ? void 0 : g(e)) || e.date);
- if (n < i[u].date || n > i[c].date) s.hideItem(t);
- else {
- var r = t.getSource().isVisible(),
- o = t.getTarget().isVisible();
- r && o && s.showItem(t);
- }
- }
- });
- }
- } else console.warn("请配置 TimeBar 组件的数据");
- }),
- (e.prototype.initEvent = function () {
- var t = this.get("graph");
- t.on("afterchangedata", this.changeData),
- t.on("afterrender", this.afterrenderListener),
- t.on("valuechange", this.valueChangeListener);
- }),
- (e.prototype.destroy = function () {
- var e = this.get("graph");
- e.off("afterchangedata", this.changeData),
- e.off("afterrender", this.afterrenderListener),
- e.off("valuechange", this.valueChangeListener);
- var n = this.get("timebar");
- n && n.destory && n.destory(), t.prototype.destroy.call(this);
- var r = this.get("timeBarContainer");
- if (r) {
- var i = this.get("container");
- i || (i = this.get("graph").get("container")),
- Object(g.isString)(i) && (i = document.getElementById(i)),
- i.removeChild(r);
- }
- }),
- e
- );
- })(Fi),
- Ms = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })(),
- ks = dr.applyMatrix;
- var As = (function (t) {
- function e(e) {
- return t.call(this, e) || this;
- }
- return (
- Ms(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- container: null,
- className: "g6-minimap",
- viewportClassName: "g6-minimap-viewport",
- width: 200,
- delegateStyle: { fill: "#40a9ff", stroke: "#096dd9" },
- refresh: !0,
- };
- }),
- (e.prototype.getEvents = function () {
- return {
- beforepaint: "updateViewport",
- beforeanimate: "disableRefresh",
- afteranimate: "enableRefresh",
- viewportchange: "disableOneRefresh",
- };
- }),
- (e.prototype.disableRefresh = function () {
- this.set("refresh", !1);
- }),
- (e.prototype.enableRefresh = function () {
- this.set("refresh", !0), this.updateCanvas();
- }),
- (e.prototype.disableOneRefresh = function () {
- this.set("viewportChange", !0);
- }),
- (e.prototype.initViewport = function () {
- var t = this,
- e = this._cfgs,
- n = e.graph;
- if (!this.destroyed) {
- var r = this.get("container");
- Object(g.isString)(r) && (r = document.getElementById(r));
- var i = Vr(
- "
"
- )
- ),
- o = 0,
- a = 0,
- s = !1,
- u = 0,
- c = 0,
- l = 0,
- f = 0,
- h = 0,
- d = 0;
- r.addEventListener(
- "mousedown",
- function (r) {
- if (((e.refresh = !1), r.target === i)) {
- var u = i.style;
- (l = parseInt(u.width, 10)), (f = parseInt(u.height, 10));
- var c = t.get("width"),
- p = t.get("height");
- l > c ||
- f > p ||
- ((d = n.getZoom()),
- (h = t.get("ratio")),
- (s = !0),
- (o = r.clientX),
- (a = r.clientY));
- }
- },
- !1
- ),
- r.addEventListener(
- "mousemove",
- function (e) {
- if (
- s &&
- !Object(g.isNil)(e.clientX) &&
- !Object(g.isNil)(e.clientY)
- ) {
- var r = t.get("width"),
- p = t.get("height"),
- v = i.style;
- (u = parseInt(v.left, 10)),
- (c = parseInt(v.top, 10)),
- (l = parseInt(v.width, 10)),
- (f = parseInt(v.height, 10));
- var y = o - e.clientX,
- m = a - e.clientY;
- u - y < 0 ? (y = u) : u - y + l >= r && (y = 0),
- c - m < 0 ? (m = c) : c - m + f >= p && (m = 0),
- (c -= m),
- Hr(i, {
- left: "".concat((u -= y), "px"),
- top: "".concat(c, "px"),
- }),
- n.translate((y * d) / h, (m * d) / h),
- (o = e.clientX),
- (a = e.clientY);
- }
- },
- !1
- ),
- r.addEventListener(
- "mouseleave",
- function () {
- (s = !1), (e.refresh = !0);
- },
- !1
- ),
- r.addEventListener(
- "mouseup",
- function () {
- (s = !1), (e.refresh = !0);
- },
- !1
- ),
- this.set("viewport", i),
- r.appendChild(i);
- }
- }),
- (e.prototype.updateViewport = function () {
- if (!this.destroyed) {
- var t = this.get("ratio"),
- e = this.get("width"),
- n = this.get("height"),
- r = this.get("graph"),
- i = r.get("width"),
- o = i / r.get("height"),
- a = r.getGroup(),
- s = a.getCanvasBBox(),
- u = [(s.minX + s.maxX) / 2, (s.minY + s.maxY) / 2],
- c = [s.maxX - s.minX, s.maxY - s.minY],
- l = {
- centerX: u[0],
- centerY: u[1],
- width: 0,
- height: 0,
- minX: 0,
- minY: 0,
- };
- s[0] / s[1] > o
- ? ((l.width = c[0]), (l.height = l.width / o))
- : ((l.height = c[1]), (l.width = l.height * o)),
- (l.minX = u[0] - l.width / 2),
- (l.minY = u[1] - l.height / 2);
- var f = a.getMatrix();
- f || (f = [1, 0, 0, 0, 1, 0, 0, 0, 1]);
- var h = x.b.invert([1, 0, 0, 0, 1, 0, 0, 0, 1], f),
- d = ks({ x: l.minX, y: l.minY }, h),
- p = r.getCanvasByPoint(d.x, d.y),
- g = this.get("viewport");
- g || this.initViewport();
- var v = i / l.width,
- y = v * e,
- m = v * n,
- b = (e * -p.x) / l.width,
- w = (n * -p.y) / l.height,
- E = b + y,
- _ = w + m;
- b < 0 && ((y += b), (b = 0)),
- E > e && (y -= E - e),
- w < 0 && ((m += w), (w = 0)),
- _ > n && (m -= _ - n),
- this.set("ratio", t),
- Hr(g, {
- left: "".concat(b, "px"),
- top: "".concat(w, "px"),
- width: "".concat(y, "px"),
- height: "".concat(m, "px"),
- });
- }
- }),
- (e.prototype.init = function () {
- this.initContainer();
- }),
- (e.prototype.initContainer = function () {
- var t = this.get("graph"),
- e = t.get("width"),
- n = t.get("height") / e,
- r = this.get("className"),
- i = this.get("container"),
- o = this.get("width"),
- a = this.get("height");
- o || a || (o = 200),
- o
- ? ((a = n * o), this.set("height", a))
- : ((o = (1 / n) * a), this.set("width", o));
- var s = Vr(
- "
"
- )
- );
- Object(g.isString)(i) && (i = document.getElementById(i)),
- i ? i.appendChild(s) : t.get("container").appendChild(s),
- this.set("container", s);
- var u = Vr(
- '
'
- );
- s.appendChild(u);
- var c = Vr(
- '
'
- );
- u.appendChild(c),
- this.set("containerDOM", u),
- this.set("containerSpan", c);
- var l = Vr(
- '

'
- )
- );
- this.set("imgDOM", l),
- this.updateImgSize(),
- c.appendChild(l),
- this.updateCanvas();
- }),
- (e.prototype.updateImgSize = function () {
- var t = this.get("imgDOM"),
- e = this.get("width"),
- n = this.get("height");
- t.onload = function () {
- var r = (function (t, e) {
- var n, r;
- if (t.naturalWidth)
- (n = t.naturalWidth), (r = t.naturalHeight);
- else {
- var i = new Image();
- (i.src = t.src),
- (i.onload = function () {
- e && e(i.width, i.height);
- });
- }
- return [n, r];
- })(t);
- r[0] > r[1] ? (t.width = e) : (t.height = n);
- };
- }),
- (e.prototype.updateCanvas = function () {
- if (this.get("refresh")) {
- var t = this.get("graph");
- if (!t.get("destroyed")) {
- this.get("viewportChange") &&
- (this.set("viewportChange", !1), this.updateViewport());
- var e =
- this.get("width") / t.get("canvas").getCanvasBBox().width;
- this.set("ratio", e), this.updateViewport();
- }
- }
- }),
- (e.prototype.getViewport = function () {
- return this.get("viewport");
- }),
- (e.prototype.getContainer = function () {
- return this.get("container");
- }),
- (e.prototype.updateGraphImg = function (t) {
- this.get("imgDOM").remove(), this.set("graphImg", t);
- var e = Vr(
- '

'
- )
- );
- this.set("imgDOM", e),
- (e.src = t),
- this.updateImgSize(),
- this.get("containerSpan").appendChild(e),
- this.updateCanvas();
- }),
- (e.prototype.destroy = function () {
- var t = this.get("container");
- t.parentNode.removeChild(t);
- }),
- e
- );
- })(Fi),
- js = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })(),
- Cs = function () {
- return (Cs =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- Is = dr.distance,
- Ts = {
- stroke: "#000",
- strokeOpacity: 0.8,
- lineWidth: 2,
- fillOpacity: 1,
- fill: "#fff",
- },
- Ns = (function (t) {
- function e(e) {
- return t.call(this, e) || this;
- }
- return (
- js(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- type: "both",
- trigger: "mousemove",
- r: 60,
- delegateStyle: Object(g.clone)(Ts),
- showLabel: "edge",
- scaleRBy: "wheel",
- };
- }),
- (e.prototype.getEvents = function () {
- var t;
- switch (this.get("trigger")) {
- case "click":
- t = { click: "filter" };
- break;
- case "drag":
- t = { click: "createDelegate" };
- break;
- default:
- t = { mousemove: "filter" };
- }
- return t;
- }),
- (e.prototype.init = function () {
- var t = this.get("showLabel"),
- e = "node" === t || "both" === t,
- n = "edge" === t || "both" === t;
- this.set("showNodeLabel", e),
- this.set("showEdgeLabel", n),
- this.get("shouldShow") ||
- this.set("shouldShow", function () {
- return !0;
- });
- }),
- (e.prototype.createDelegate = function (t) {
- var e = this,
- n = e.get("delegate");
- (n && !n.destroyed) ||
- (e.filter(t),
- (n = e.get("delegate")).on("dragstart", function (t) {}),
- n.on("drag", function (t) {
- e.filter(t);
- }),
- "wheel" === this.get("scaleRBy") &&
- n.on("mousewheel", function (t) {
- e.scaleRByWheel(t);
- }));
- }),
- (e.prototype.scaleRByWheel = function (t) {
- if (t && t.originalEvent) {
- t.preventDefault && t.preventDefault();
- var e,
- n = this.get("graph"),
- r = this.get("delegate");
- (r ? { x: r.attr("x"), y: r.attr("y") } : void 0) ||
- n.getPointByClient(t.clientX, t.clientY);
- e = t.originalEvent.wheelDelta < 0 ? 0.95 : 1 / 0.95;
- var i = this.get("maxR"),
- o = this.get("minR"),
- a = this.get("r");
- ((a > (i || n.get("height")) && e > 1) ||
- (a < (o || 0.05 * n.get("height")) && e < 1)) &&
- (e = 1),
- (a *= e),
- this.set("r", a),
- this.filter(t);
- }
- }),
- (e.prototype.filter = function (t) {
- var e = this.get("graph"),
- n = e.getNodes(),
- r = {},
- i = this.get("r"),
- o = this.get("type"),
- a = { x: t.x, y: t.y };
- this.updateDelegate(a, i);
- var s = this.get("shouldShow"),
- u = this.get("vShapes");
- u &&
- u.forEach(function (t) {
- t.remove(), t.destroy();
- }),
- (u = []),
- n.forEach(function (t) {
- var e = t.getModel(),
- n = e.x,
- o = e.y;
- Is({ x: n, y: o }, a) < i && (r[e.id] = t);
- });
- var c = e.getEdges(),
- l = [];
- c.forEach(function (t) {
- var e = t.getModel(),
- n = e.source,
- i = e.target;
- s(e) &&
- ("only-source" === o || "one" === o
- ? r[n] && !r[i] && l.push(t)
- : "only-target" === o || "one" === o
- ? r[i] && !r[n] && l.push(t)
- : "both" === o && r[n] && r[i] && l.push(t));
- });
- var f = this.get("showNodeLabel"),
- h = this.get("showEdgelabel"),
- d = e.get("group");
- l.forEach(function (t) {
- t.get("group")
- .get("children")
- .forEach(function (t) {
- var e = t.get("type"),
- n = d.addShape(e, { attrs: t.attr() });
- u.push(n), f && "text" === e && n.set("visible", !0);
- });
- }),
- Object.keys(r).forEach(function (t) {
- var e = r[t].get("group").clone();
- if ((d.add(e), u.push(e), h))
- for (var n = e.get("children"), i = 0; i < n.length; i++) {
- var o = n[i];
- "text" === o.get("type") && o.set("visible", !0);
- }
- }),
- this.set("vShapes", u);
- }),
- (e.prototype.updateParams = function (t) {
- var e = t.r,
- n = t.trigger,
- r = t.minR,
- i = t.maxR,
- o = t.scaleRBy,
- a = t.showLabel,
- s = t.shouldShow;
- if (
- (isNaN(t.r) || this.set("r", e),
- isNaN(i) || this.set("maxR", i),
- isNaN(r) || this.set("minR", r),
- ("mousemove" !== n && "click" !== n) || this.set("trigger", n),
- "wheel" === o || "unset" === o)
- ) {
- this.set("scaleRBy", o),
- this.get("delegate").remove(),
- this.get("delegate").destroy();
- var u = this.get("dPercentText");
- u && (u.remove(), u.destroy());
- }
- ("node" !== a && "both" !== a) || this.set("showNodeLabel", !0),
- ("edge" !== a && "both" !== a) || this.set("showEdgeLabel", !0),
- s && this.set("shouldShow", s);
- }),
- (e.prototype.updateDelegate = function (t, e) {
- var n = this,
- r = n.get("graph"),
- i = n.get("delegate");
- if (!i || i.destroyed) {
- var o = r.get("group"),
- a = n.get("delegateStyle") || Ts;
- (i = o.addShape("circle", {
- attrs: Cs({ r: e, x: t.x, y: t.y }, a),
- name: "lens-shape",
- draggable: !0,
- })),
- "drag" !== this.get("trigger") &&
- "wheel" === this.get("scaleRBy") &&
- i.on("mousewheel", function (t) {
- n.scaleRByWheel(t);
- });
- } else i.attr({ x: t.x, y: t.y, r: e });
- n.set("delegate", i);
- }),
- (e.prototype.clear = function () {
- var t = this.get("vShapes");
- t &&
- t.forEach(function (t) {
- t.remove(), t.destroy();
- }),
- (t = []),
- this.set("vShapes", t);
- var e = this.get("delegate");
- e && !e.destroyed && (e.remove(), e.destroy());
- }),
- (e.prototype.destroy = function () {
- this.clear();
- }),
- e
- );
- })(Fi),
- Ps = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })(),
- Ds = dr.pointLineDistance,
- Ls = { stroke: "#FA8C16", lineWidth: 1 },
- Rs = (function (t) {
- function e(e) {
- return t.call(this, e) || this;
- }
- return (
- Ps(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- line: Ls,
- itemAlignType: "center",
- tolerance: 5,
- horizontalLines: {},
- verticalLines: {},
- alignLines: [],
- };
- }),
- (e.prototype.init = function () {}),
- (e.prototype.getEvents = function () {
- return {
- "node:dragstart": "onDragStart",
- "node:drag": "onDrag",
- "node:dragend": "onDragEnd",
- };
- }),
- (e.prototype.onDragStart = function () {
- this.initBoxLine();
- }),
- (e.prototype.onDrag = function (t) {
- var e = t.item,
- n = (e.get("delegateShape") || e).getBBox(),
- r = e.getModel(),
- i = r.x - n.x,
- o = r.y - n.y;
- this.show(
- { x: n.minX + i, y: n.minY + o },
- { width: n.width, height: n.height }
- );
- }),
- (e.prototype.onDragEnd = function () {
- this.destory();
- }),
- (e.prototype.initBoxLine = function () {
- var t = this._cfgs,
- e = t.horizontalLines,
- n = t.verticalLines,
- r = t.itemAlignType;
- this.get("graph")
- .getNodes()
- .forEach(function (t) {
- var i = t.getBBox(),
- o = t.get("id");
- !0 === r || "horizontal" === r
- ? ((e["".concat(o, "tltr")] = [
- i.minX,
- i.minY,
- i.maxX,
- i.minY,
- t,
- ]),
- (e["".concat(o, "lcrc")] = [
- i.minX,
- i.centerY,
- i.maxX,
- i.centerY,
- t,
- ]),
- (e["".concat(o, "blbr")] = [
- i.minX,
- i.maxY,
- i.maxX,
- i.maxY,
- t,
- ]))
- : "center" === r &&
- (e["".concat(o, "lcrc")] = [
- i.minX,
- i.centerY,
- i.maxX,
- i.centerY,
- t,
- ]),
- !0 === r || "vertical" === r
- ? ((n["".concat(o, "tlbl")] = [
- i.minX,
- i.minY,
- i.minX,
- i.maxY,
- t,
- ]),
- (n["".concat(o, "tcbc")] = [
- i.centerX,
- i.minY,
- i.centerX,
- i.maxY,
- t,
- ]),
- (n["".concat(o, "trbr")] = [
- i.maxX,
- i.minY,
- i.maxX,
- i.maxY,
- t,
- ]))
- : "center" === r &&
- (n["".concat(o, "tcbc")] = [
- i.centerX,
- i.minY,
- i.centerX,
- i.maxY,
- t,
- ]);
- });
- }),
- (e.prototype.show = function (t, e) {
- var n = Object(g.mix)({}, t);
- return this.itemAlign(t, e, n), t;
- }),
- (e.prototype.itemAlign = function (t, e, n) {
- var r = this,
- i = this._cfgs,
- o = i.horizontalLines,
- a = i.verticalLines,
- s = i.tolerance,
- u = { x: n.x + e.width / 2, y: n.y },
- c = { x: n.x + e.width / 2, y: n.y + e.height / 2 },
- l = { x: n.x + e.width / 2, y: n.y + e.height },
- f = { x: n.x, y: n.y + e.height / 2 },
- h = { x: n.x + e.width, y: n.y + e.height / 2 },
- d = [],
- p = [],
- v = null;
- if (
- (this.clearAlignLine(),
- Object(g.each)(o, function (t) {
- t[4].isVisible &&
- (d.push(r.getLineDisObject(t, u)),
- d.push(r.getLineDisObject(t, c)),
- d.push(r.getLineDisObject(t, l)));
- }),
- Object(g.each)(a, function (t) {
- t[4].isVisible &&
- (p.push(r.getLineDisObject(t, f)),
- p.push(r.getLineDisObject(t, c)),
- p.push(r.getLineDisObject(t, h)));
- }),
- d.sort(function (t, e) {
- return t.dis - e.dis;
- }),
- p.sort(function (t, e) {
- return t.dis - e.dis;
- }),
- 0 !== d.length && d[0].dis < s)
- ) {
- (t.y = d[0].line[1] - d[0].point.y + n.y),
- (v = { type: "item", horizontals: [d[0]] });
- for (var y = 1; y < 3; y++)
- d[0].dis === d[y].dis && v.horizontals.push(d[y]);
- }
- if (0 !== p.length && p[0].dis < s) {
- (t.x = p[0].line[0] - p[0].point.x + n.x),
- v
- ? (v.verticals = [p[0]])
- : (v = { type: "item", verticals: [p[0]] });
- for (y = 1; y < 3; y++)
- p[0].dis === p[y].dis && v.verticals.push(p[y]);
- }
- v && ((v.bbox = e), this.addAlignLine(v));
- }),
- (e.prototype.addAlignLine = function (t) {
- var e = t.bbox,
- n = t.type,
- r = t.horizontals,
- i = t.verticals,
- o = this._cfgs,
- a = o.line,
- s = o.alignLines,
- u = this.get("graph").get("group");
- "item" === n &&
- (r &&
- Object(g.each)(r, function (t) {
- var n,
- r,
- i = t.line,
- o = t.point,
- c = (i[0] + i[2]) / 2;
- o.x < c
- ? ((n = o.x - e.width / 2), (r = Math.max(i[0], i[2])))
- : ((n = o.x + e.width / 2), (r = Math.min(i[0], i[2])));
- var l = Object(g.mix)(
- { x1: n, y1: i[1], x2: r, y2: i[1] },
- a
- ),
- f = u.addShape("line", { attrs: l, capture: !1 });
- s.push(f);
- }),
- i &&
- Object(g.each)(i, function (t) {
- var n,
- r,
- i = t.line,
- o = t.point,
- c = (i[1] + i[3]) / 2;
- o.y < c
- ? ((n = o.y - e.height / 2), (r = Math.max(i[1], i[3])))
- : ((n = o.y + e.height / 2), (r = Math.min(i[1], i[3])));
- var l = Object(g.mix)(
- { x1: i[0], y1: n, x2: i[0], y2: r },
- a
- ),
- f = u.addShape("line", { attrs: l, capture: !1 });
- s.push(f);
- }));
- }),
- (e.prototype.getLineDisObject = function (t, e) {
- return { line: t, point: e, dis: Ds(t, e) };
- }),
- (e.prototype.getContainer = function () {
- return this.get("container");
- }),
- (e.prototype.clearAlignLine = function () {
- var t = this._cfgs.alignLines;
- Object(g.each)(t, function (t) {
- t.remove();
- }),
- (t.length = 0);
- }),
- (e.prototype.destory = function () {
- var t = this._cfgs,
- e = t.horizontalLines,
- n = t.verticalLines;
- this.get("graph")
- .getNodes()
- .forEach(function (t) {
- var r = t.get("id");
- delete e["".concat(r, "tltr")],
- delete e["".concat(r, "lcrc")],
- delete e["".concat(r, "blbr")],
- delete n["".concat(r, "tlbl")],
- delete n["".concat(r, "tcbc")],
- delete n["".concat(r, "trbr")];
- }),
- this.clearAlignLine();
- }),
- e
- );
- })(Fi),
- Bs = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })(),
- Fs = function () {
- return (Fs =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- zs = ["click", "mouseenter"],
- Gs = (function (t) {
- function e(e) {
- return t.call(this, e) || this;
- }
- return (
- Bs(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- data: {},
- position: "top",
- padding: 8,
- margin: 8,
- offsetX: 0,
- offsetY: 0,
- layout: "horizontal",
- flipPage: !1,
- containerStyle: {},
- align: void 0,
- horiSep: 8,
- vertiSep: 8,
- filter: { enable: !1, trigger: "click" },
- };
- }),
- (e.prototype.init = function () {
- this.formatArray("padding"), this.formatArray("margin");
- var t = this.get("filter") || {};
- t.multiple &&
- "mouseenter" === t.trigger &&
- this.set("multiple", !1);
- var e = this.get("align");
- if (!e) {
- var n = this.get("position").split("-");
- n.includes("left") && (e = "left"),
- (e = n.includes("right") ? "right" : "center"),
- this.set("align", e);
- }
- var r = this.get("graph").get("container"),
- i = Vr(
- "
"
- );
- r.appendChild(i), this.set("container", i);
- var o = this.render();
- Hr(i, this.getContainerPos(o)), this.bindEvents();
- }),
- (e.prototype.getContainerPos = function (t) {
- void 0 === t && (t = [0, 0]);
- var e = this.get("graph"),
- n = this.get("offsetX"),
- r = this.get("offsetY"),
- i = this.get("margin"),
- o = this.get("position").split("-"),
- a = { top: 0, right: 1, bottom: 2, left: 3 },
- s = {
- left: (e.getWidth() - t[0]) / 2 + 0,
- top: (e.getHeight() - t[1]) / 2 + 0,
- };
- return (
- o.forEach(function (n) {
- var r = i[a[n]],
- o = n;
- switch (n) {
- case "top":
- case "left":
- r += 0;
- break;
- case "bottom":
- (r = e.getHeight() - t[1] - r + 0), (o = "top");
- break;
- default:
- (r = e.getWidth() - t[0] - r + 0), (o = "left");
- }
- s[o] = r;
- }),
- (s.top += r + e.getContainer().offsetTop),
- (s.left += n + e.getContainer().offsetLeft),
- Object.keys(s).forEach(function (t) {
- s[t] = "".concat(s[t], "px");
- }),
- s
- );
- }),
- (e.prototype.bindEvents = function () {
- var t = this,
- e = t.get("filter");
- if (e && e.enable) {
- var n = e.trigger || "click";
- zs.includes(n) ||
- (console.warn(
- "Trigger for legend filterling must be 'click' or 'mouseenter', 'click' will take effect by default."
- ),
- (n = "click"));
- var r = t.get("legendCanvas");
- "mouseenter" === n
- ? (r.on("node-container:mouseenter", function (e) {
- return t.filterData(e);
- }),
- r.on("node-container:mouseleave", function (e) {
- t.clearFilter(), t.clearActiveLegend();
- }))
- : (r.on("node-container:click", function (e) {
- return t.filterData(e);
- }),
- r.on("click", function (e) {
- e.target &&
- e.target.isCanvas &&
- e.target.isCanvas() &&
- (t.clearFilter(), t.clearActiveLegend());
- }));
- }
- }),
- (e.prototype.changeData = function (t) {
- this.set("data", t);
- var e = this.render();
- Hr(this.get("container"), this.getContainerPos(e));
- }),
- (e.prototype.activateLegend = function (t) {
- var e = this.get("filter");
- (null == e ? void 0 : e.multiple) || this.clearActiveLegend();
- var n = t.get("parent");
- n.get("active")
- ? (n.set("active", !1),
- this.findLegendItemsByState("active").length &&
- n.set("inactive", !0))
- : (n.set("inactive", !1), n.set("active", !0)),
- this.findLegendItemsByState("active").length
- ? this.findLegendItemsByState("active", "all", !1).forEach(
- function (t) {
- t.set("inactive", !0);
- }
- )
- : this.clearActiveLegend();
- var r = (null == e ? void 0 : e.legendStateStyles) || {},
- i = (null == r ? void 0 : r.inactive) || {
- opacity: 0.5,
- "text-shape": { opacity: 0.5 },
- },
- o = i["text-shape"] || {};
- this.findLegendItemsByState("inactive").forEach(function (t) {
- var e = t.get("children"),
- n = e[0],
- r = e[1];
- n.attr(Fs(Fs({}, n.get("oriAttrs")), i)),
- r.attr(Fs(Fs({}, r.get("oriAttrs")), o));
- });
- var a = (null == r ? void 0 : r.active) || {
- stroke: "#000",
- lineWidth: 2,
- "text-shape": { fontWeight: "bold" },
- },
- s = a["text-shape"] || {};
- this.findLegendItemsByState("active").forEach(function (t) {
- var e = t.get("children"),
- n = e[0],
- r = e[1];
- n.attr(Fs(Fs({}, n.get("oriAttrs")), a)),
- r.attr(Fs(Fs({}, r.get("oriAttrs")), s));
- });
- }),
- (e.prototype.findLegendItemsByState = function (t, e, n) {
- void 0 === e && (e = "all"), void 0 === n && (n = !0);
- var r = this.get("legendCanvas").find(function (t) {
- return "root" === t.get("name");
- }),
- i = r.find(function (t) {
- return "node-group" === t.get("name");
- }),
- o = r.find(function (t) {
- return "edge-group" === t.get("name");
- });
- return "node" === e
- ? i.get("children").filter(function (e) {
- return !!e.get(t) === n;
- })
- : "edge" === e
- ? o.get("children").filter(function (e) {
- return !!e.get(t) === n;
- })
- : i
- .get("children")
- .filter(function (e) {
- return !!e.get(t) === n;
- })
- .concat(
- o.get("children").filter(function (e) {
- return !!e.get(t) === n;
- })
- );
- }),
- (e.prototype.clearActiveLegend = function () {
- var t = this.get("legendCanvas").find(function (t) {
- return "root" === t.get("name");
- });
- [
- t.find(function (t) {
- return "node-group" === t.get("name");
- }),
- t.find(function (t) {
- return "edge-group" === t.get("name");
- }),
- ].forEach(function (t) {
- t.get("children").forEach(function (t) {
- t.set("active", !1), t.set("inactive", !1);
- var e = t.get("children"),
- n = e[0],
- r = e[1];
- n.attr(n.get("oriAttrs")), r.attr(r.get("oriAttrs"));
- });
- });
- }),
- (e.prototype.filterData = function (t) {
- var e = this.get("filter"),
- n = null == e ? void 0 : e.filterFunctions;
- if (e && n) {
- var r = this.get("legendCanvas"),
- i = this.get("graph"),
- o = e.graphActiveState || "active",
- a = e.graphInactiveState || "inactive",
- s = e.multiple;
- this.clearFilter(),
- s || this.clearActiveLegend(),
- this.activateLegend(t.target);
- var u = r.find(function (t) {
- return "root" === t.get("name");
- }),
- c = u.find(function (t) {
- return "node-group" === t.get("name");
- }),
- l = u.find(function (t) {
- return "edge-group" === t.get("name");
- }),
- f = c.get("children").filter(function (t) {
- return t.get("active");
- }),
- h = l.get("children").filter(function (t) {
- return t.get("active");
- }),
- d = 0,
- p = ["getNodes", "getEdges"];
- p.forEach(function (t) {
- i[t]().forEach(function (e) {
- var r = !1;
- ("getNodes" === t ? f : h).forEach(function (t) {
- var i = n[t.get("id")];
- r = r || i(e.getModel());
- }),
- r
- ? (i.setItemState(e, a, !1),
- i.setItemState(e, o, !0),
- d++)
- : (i.setItemState(e, o, !1), i.setItemState(e, a, !0));
- });
- }),
- d ||
- p.forEach(function (t) {
- i[t]().forEach(function (t) {
- i.clearItemStates(t, [a]);
- });
- });
- }
- }),
- (e.prototype.clearFilter = function () {
- var t = this.get("graph"),
- e = this.get("filter");
- if (e) {
- var n = e.graphActiveState || "active",
- r = e.graphInactiveState || "inactive";
- t.getNodes().forEach(function (e) {
- t.clearItemStates(e, [n, r]);
- }),
- t.getEdges().forEach(function (e) {
- t.clearItemStates(e, [n, r]);
- });
- }
- }),
- (e.prototype.render = function () {
- var t = this;
- this.processData();
- var e = this.get("legendCanvas");
- e
- ? e.clear()
- : (e = new Er.Canvas({
- container: this.get("container"),
- width: 200,
- height: 200,
- }));
- var n = e.addGroup({ name: "root" }),
- r = n.addGroup({ name: "node-group" }),
- i = n.addGroup({ name: "edge-group" });
- this.set("legendCanvas", e);
- var o = this.get("itemsData"),
- a = [r, i];
- ["nodes", "edges"].forEach(function (e, n) {
- o[e].forEach(function (r) {
- var i,
- o,
- s = a[n].addGroup({ id: r.id, name: "node-container" }),
- u = r.type,
- c = t.getShapeSize(r),
- l = c.width,
- f = c.height,
- h = c.r,
- d = t.getStyle(e.substr(0, 4), r);
- switch (r.type) {
- case "circle":
- o = { r: h, x: 0, y: 0 };
- break;
- case "rect":
- o = { width: l, height: f, x: -l / 2, y: -f / 2 };
- break;
- case "ellipse":
- (o = { rx: l, ry: f, x: 0, y: 0 }), (u = "ellipse");
- break;
- case "line":
- (o = { x1: -l / 2, y1: 0, x2: l / 2, y2: 0 }),
- (u = "line");
- break;
- case "quadratic":
- (o = {
- path: [
- ["M", -l / 2, 0],
- ["Q", 0, l / 2, l / 2, 0],
- ],
- }),
- (u = "path");
- break;
- case "cubic":
- (o = {
- path: [
- ["M", -l / 2, 0],
- ["C", -l / 6, l / 2, l / 6, -l / 2, l / 2, 0],
- ],
- }),
- (u = "path");
- break;
- case "diamond":
- (o = {
- path: [
- ["M", 0, -f],
- ["L", l, 0],
- ["L", 0, f],
- ["L", -l, 0],
- ["Z"],
- ],
- }),
- (u = "path");
- break;
- case "triangle":
- (o = {
- path: [["M", -l, f], ["L", 0, -f], ["L", l, f], ["Z"]],
- }),
- (u = "path");
- break;
- case "star":
- (o = { path: dr.getStarPath(3 * h, 1.2 * h) }),
- (u = "path");
- break;
- default:
- o = { r: h, x: 0, y: 0 };
- }
- var p = s.addShape(u, {
- attrs: Fs(Fs({}, o), d),
- name: "".concat(r.type, "-node-keyShape"),
- oriAttrs: Fs({ opacity: 1 }, d),
- });
- if (r.label) {
- var g = p.getBBox(),
- v =
- (null === (i = r.labelCfg) || void 0 === i
- ? void 0
- : i.style) || {},
- y = Fs(
- {
- textAlign: "begin",
- fontSize: 12,
- textBaseline: "middle",
- fill: "#000",
- opacity: 1,
- fontWeight: "normal",
- },
- v
- );
- s.addShape("text", {
- attrs: Fs({ x: g.maxX + 4, y: 0, text: r.label }, y),
- className: "legend-label",
- name: "".concat(r.type, "-node-text"),
- oriAttrs: y,
- });
- }
- });
- });
- var s,
- u = this.get("padding"),
- c = n.find(function (t) {
- return "title-container" === t.get("name");
- }),
- l = { height: 0, maxY: 0, width: 0 };
- if (this.get("title")) {
- c || (c = n.addGroup({ name: "title-container" }));
- var f = {
- fontSize: 20,
- fontFamily: "Arial",
- fontWeight: 300,
- textBaseline: "top",
- textAlign: "center",
- fill: "#000",
- x: 0,
- y: u[0],
- },
- h = this.get("titleConfig") || {},
- d = Object.assign(f, h.style || {});
- (s = c.addShape("text", {
- attrs: Fs({ text: this.get("title") }, d),
- })),
- (l = c.getCanvasBBox()),
- c.setMatrix([1, 0, 0, 0, 1, 0, h.offsetX, h.offsetY, 1]);
- }
- this.layoutItems();
- var p = n.getCanvasBBox(),
- g = r.getCanvasBBox(),
- v = g.minX < 0 ? Math.abs(g.minX) + u[3] : u[3],
- y =
- l.maxY < g.minY
- ? Math.abs(l.maxY - g.minY) + u[0]
- : l.maxY + u[0],
- m = [1, 0, 0, 0, 1, 0, v, y, 1];
- r.setMatrix(m);
- var b = [
- (p = n.getCanvasBBox()).minX + p.width + u[1],
- p.minY + p.height + u[2],
- ];
- if (s) {
- h = Fs(
- { position: "center", offsetX: 0, offsetY: 0 },
- this.get("titleConfig")
- );
- l = c.getCanvasBBox();
- var x = c.getMatrix() || [1, 0, 0, 0, 1, 0, 0, 0, 1];
- "center" === h.position
- ? (x[6] = b[0] / 2 + h.offsetX)
- : "right" === h.position
- ? ((x[6] = b[0] - u[3] + h.offsetX),
- s.attr({ textAlign: "right" }))
- : ((x[6] = u[3] + h.offsetX), s.attr({ textAlign: "left" })),
- c.setMatrix(x),
- (l = c.getCanvasBBox()),
- (m = [
- 1,
- 0,
- 0,
- 0,
- 1,
- 0,
- (v = g.minX < 0 ? Math.abs(g.minX) + u[3] : u[3]),
- (y =
- g.minY < l.maxY
- ? Math.abs(l.maxY - g.minY) + u[0]
- : l.maxY + u[0]),
- 1,
- ]),
- r.setMatrix(m);
- var w = [1, 0, 0, 0, 1, 0, v, y, 1];
- "vertical" === this.get("layout")
- ? (w[6] += g.maxX + this.get("horiSep"))
- : (w[7] += g.maxY + this.get("vertiSep")),
- i.setMatrix(w);
- } else {
- g = r.getCanvasBBox();
- var E = [1, 0, 0, 0, 1, 0, 0, 0, 1];
- "vertical" === this.get("layout")
- ? (E[6] += m[6] + g.maxX + this.get("horiSep"))
- : (E[7] += m[7] + g.maxY + this.get("vertiSep")),
- i.setMatrix(E);
- }
- (p = n.getCanvasBBox()),
- (g = r.getCanvasBBox()),
- (m = r.getMatrix() || [1, 0, 0, 0, 1, 0, 0, 0, 1]);
- var _ = i.getMatrix() || [1, 0, 0, 0, 1, 0, 0, 0, 1],
- S = i.getCanvasBBox();
- (b = [
- Math.max(g.width + m[6], S.width + _[6]) + u[1],
- Math.max(g.height + m[7], S.height + _[7]) + u[2],
- ]),
- e.changeSize(b[0], b[1]);
- var O = this.get("containerStyle"),
- M = n.getMatrix() || [1, 0, 0, 0, 1, 0, 0, 0, 1],
- k = dr.invertMatrix({ x: 0, y: 0 }, M);
- return (
- n
- .addShape("rect", {
- attrs: Fs(
- {
- x: k.x + (O.lineWidth || 1),
- y: k.y + (O.lineWidth || 1),
- width: b[0] - 2 * (O.lineWidth || 1),
- height: b[1] - 2 * (O.lineWidth || 1),
- fill: "#f00",
- stroke: "#000",
- lineWidth: 1,
- opacity: 0.5,
- },
- O
- ),
- name: "legend-back-rect",
- capture: !1,
- })
- .toBack(),
- b
- );
- }),
- (e.prototype.layoutItems = function () {
- var t = this.get("legendCanvas"),
- e = this.get("horiSep"),
- n = this.get("vertiSep"),
- r = this.get("layout"),
- i = this.get("align"),
- o = [0, 0],
- a = t.find(function (t) {
- return "root" === t.get("name");
- }),
- s = a.find(function (t) {
- return "node-group" === t.get("name");
- }),
- u = a.find(function (t) {
- return "edge-group" === t.get("name");
- }),
- c = { min: 0, max: -1 / 0 },
- l = -1 / 0;
- s.get("children").forEach(function (t, i) {
- 0 === i && (c.min = o[0]);
- var a = t.get("children")[0],
- s = t.getCanvasBBox(),
- u = a.getBBox(),
- f = u.width,
- h = u.height,
- d = 0,
- p = 0,
- g = 0;
- "vertical" === r
- ? ((p = o[1]),
- (g = o[0] + f / 2),
- (o[0] = g + s.height + n),
- (d = s.maxX + p + f / 2))
- : ((p = o[0] + f / 2),
- (g = o[1]),
- (o[0] = p + s.width + e),
- (d = s.maxY + g + h / 2)),
- o[0] > c.max && (c.max = o[0]),
- d > l && (l = d),
- t.setMatrix([1, 0, 0, 0, 1, 0, p, g, 1]);
- });
- var f = c.max - c.min,
- h = { min: 0, max: -1 / 0 },
- d = s.getCanvasBBox();
- (o[0] = 0),
- (o[1] = "vertical" === r ? d.maxX + e : d.maxY + n),
- u.get("children").forEach(function (t, i) {
- 0 === i && (h.min = o[0]);
- var a = t.get("children")[0],
- s = t.getCanvasBBox(),
- u = a.getBBox(),
- c = u.width,
- l = u.height,
- f = 0,
- d = 0;
- "vertical" === r
- ? ((f = o[1]),
- (d = o[0]),
- (o[0] = d + s.height + n),
- t.setMatrix([1, 0, 0, 0, 1, 0, 0, d + l / 2, 1]))
- : ((f = o[0]),
- (d = o[1]),
- (o[0] = f + s.width + e),
- t.setMatrix([1, 0, 0, 0, 1, 0, f + c / 2, 0, 1])),
- o[0] > h.max && (h.max = o[0]);
- });
- var p = h.max - h.min;
- if (i && "" !== i && "left" !== i) {
- var g = f - p,
- v = "center" === i ? Math.abs(g) / 2 : Math.abs(g);
- (g < 0 ? s : u).get("children").forEach(function (t) {
- var e = t.getMatrix() || [1, 0, 0, 0, 1, 0, 0, 0, 1];
- "vertical" === r ? (e[7] += v) : (e[6] += v), t.setMatrix(e);
- });
- }
- }),
- (e.prototype.processData = function () {
- var t = this.get("data"),
- e = { nodes: [], edges: [] };
- t.nodes &&
- (t.nodes.sort(function (t, e) {
- return t.order - e.order;
- }),
- t.nodes.forEach(function (t) {
- var n,
- r,
- i,
- o,
- a,
- s = t.size || [
- (null === (n = t.style) || void 0 === n
- ? void 0
- : n.width) ||
- (null === (r = t.style) || void 0 === r
- ? void 0
- : r.r) ||
- 8,
- (null === (i = t.style) || void 0 === i
- ? void 0
- : i.height) ||
- (null === (o = t.style) || void 0 === o
- ? void 0
- : o.r) ||
- 8,
- ],
- u =
- (null === (a = t.labelCfg) || void 0 === a
- ? void 0
- : a.style) || {};
- e.nodes.push({
- id: t.id || Object(g.uniqueId)(),
- type: t.type || "circle",
- style: Fs({}, t.style),
- order: t.order,
- label: t.label,
- itemType: "node",
- size: s,
- labelCfg: {
- position: "right",
- style: Fs({ fontFamily: "Arial" }, u),
- },
- });
- })),
- t.edges &&
- (t.edges.sort(function (t, e) {
- return t.order - e.order;
- }),
- t.edges.forEach(function (t) {
- var n,
- r,
- i = t.type || "line";
- "cubic-horizontal" === t.type && (i = "cubic");
- var o =
- (null === (n = t.labelCfg) || void 0 === n
- ? void 0
- : n.style) || {},
- a = t.size || [
- (null === (r = t.style) || void 0 === r
- ? void 0
- : r.width) || 8,
- 1,
- ];
- e.edges.push({
- id: t.id || Object(g.uniqueId)(),
- type: i,
- size: a,
- style: Fs(
- { lineWidth: Object(g.isArray)(a) ? a[1] : 1 },
- t.style
- ),
- order: t.order,
- label: t.label,
- itemType: "edge",
- labelCfg: {
- position: "right",
- style: Fs({ fontFamily: "Arial" }, o),
- },
- });
- })),
- this.set("itemsData", e);
- }),
- (e.prototype.getContainer = function () {
- return this.get("container");
- }),
- (e.prototype.formatArray = function (t) {
- var e = this.get(t);
- if (Object(g.isNumber)(e)) this.set(t, [e, e, e, e]);
- else if (Object(g.isArray)(e))
- switch (e.length) {
- case 0:
- this.set(t, [0, 0, 0, 0]);
- break;
- case 1:
- this.set(t, [e[0], e[0], e[0], e[0]]);
- break;
- case 2:
- this.set(t, [e[0], e[1], e[0], e[1]]);
- break;
- case 3:
- this.set(t, [e[0], e[1], e[2], e[1]]);
- }
- return this.get(t);
- }),
- (e.prototype.getShapeSize = function (t) {
- var e, n, r;
- return (
- t.size &&
- (Object(g.isArray)(t.size)
- ? ((e = t.size[0]),
- (n = t.size[1] || t.size[0]),
- (r = t.size[0] / 2))
- : Object(g.isNumber)(t.size) &&
- ((e = t.size), (n = t.size), (r = t.size / 2))),
- t.style &&
- (t.style.width && (e = t.style.width),
- t.style.height && (n = t.style.height),
- t.style.r && (r = t.style.r)),
- r || (r = 5),
- e || (e = r),
- n || (n = r),
- { width: e, height: n, r: r }
- );
- }),
- (e.prototype.getStyle = function (t, e) {
- return Fs(
- Fs(
- {},
- "node" === t
- ? { fill: "#ccc", lineWidth: 0 }
- : { stroke: "#000", lineWidth: 1 }
- ),
- e.style || {}
- );
- }),
- (e.prototype.destroy = function () {
- var t = this.get("legendCanvas");
- null == t || t.destroy();
- var e = this.get("graph").get("container"),
- n = this.get("container");
- e.removeChild(n);
- }),
- e
- );
- })(Fi),
- Ys = (function () {
- var t = function (e, n) {
- return (t =
- Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array &&
- function (t, e) {
- t.__proto__ = e;
- }) ||
- function (t, e) {
- for (var n in e)
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
- })(e, n);
- };
- return function (e, n) {
- if ("function" != typeof n && null !== n)
- throw new TypeError(
- "Class extends value " +
- String(n) +
- " is not a constructor or null"
- );
- function r() {
- this.constructor = e;
- }
- t(e, n),
- (e.prototype =
- null === n
- ? Object.create(n)
- : ((r.prototype = n.prototype), new r()));
- };
- })(),
- Us = function () {
- return (Us =
- Object.assign ||
- function (t) {
- for (var e, n = 1, r = arguments.length; n < r; n++)
- for (var i in (e = arguments[n]))
- Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
- return t;
- }).apply(this, arguments);
- },
- Xs = function (t, e) {
- var n = {};
- for (var r in t)
- Object.prototype.hasOwnProperty.call(t, r) &&
- e.indexOf(r) < 0 &&
- (n[r] = t[r]);
- if (null != t && "function" == typeof Object.getOwnPropertySymbols) {
- var i = 0;
- for (r = Object.getOwnPropertySymbols(t); i < r.length; i++)
- e.indexOf(r[i]) < 0 &&
- Object.prototype.propertyIsEnumerable.call(t, r[i]) &&
- (n[r[i]] = t[r[i]]);
- }
- return n;
- };
- "undefined" != typeof document &&
- Xi()(
- "\n .g6-annotation-container {\n background-color: rgba(255, 255, 255, 0.3);\n padding: 8px;\n }\n .g6-annotation-wrapper {\n background-color: #fff;\n box-shadow: 0 0 8px rgba(0, 0, 0, 0.85);\n }\n .g6-annotation-header-wapper {\n height: fit-content;\n width: 100%;\n background-color: #5B8FF9;\n display: inline-flex;\n cursor: move;\n }\n .g6-annotation-title {\n margin: 4px 40px 4px 8px;\n cursor: text;\n min-width: 32px;\n }\n .g6-annotation-collapse {\n margin: 4px;\n cursor: pointer;\n }\n .g6-annotation-expand {\n margin: 4px;\n cursor: pointer;\n }\n .g6-annotation-close {\n margin: 4px 8px 4px 0;\n cursor: pointer;\n }\n .g6-annotation-content {\n padding: 8px;\n width: fit-content;\n cursor: text;\n word-break: break-all;\n min-width: 32px;\n }\n .g6-annotation-title-input-wrapper {\n margin: 4px 40px 4px 8px;\n }\n .g6-annotation-content-input {\n height: 100%;\n word-break: break-all;\n }\n .g6-annotation-content-input-wrapper {\n margin: 8px;\n height: 100%;\n }\n"
- );
- var Ws = (function (t) {
- function e(e) {
- return t.call(this, e) || this;
- }
- return (
- Ys(e, t),
- (e.prototype.getDefaultCfgs = function () {
- return {
- trigger: "click",
- editable: !0,
- itemHighlightState: "highlight",
- linkHighlightStyle: { shadowColor: "#5B8FF9", shadowBlur: 10 },
- cardCfg: {
- minHeight: 60,
- width: "fit-content",
- height: "fit-content",
- collapseType: "minimize",
- closeType: "hide",
- borderRadius: 5,
- maxTitleLength: 20,
- },
- };
- }),
- (e.prototype.getEvents = function () {
- var t = {
- viewportchange: "updateLinks",
- afterlayout: "updateLinks",
- aftergraphrefreshposition: "updateLinks",
- afterupdateitem: "updateLink",
- afterchangedata: "onGraphDataChange",
- afteritemvisibilitychange: "onGraphItemVisibilityChange",
- };
- switch (this.get("trigger")) {
- case "click":
- t = Us(Us({}, t), {
- "node:click": "showAnnotation",
- "edge:click": "showAnnotation",
- });
- }
- return t;
- }),
- (e.prototype.getDOMContent = function (t) {
- if (!this.destroyed) {
- var e = t.collapsed,
- n = t.maxWidth,
- r = t.title,
- i = void 0 === r ? "" : r,
- o = t.content,
- a = void 0 === o ? "" : o,
- s = t.borderRadius,
- u = void 0 === s ? 5 : s,
- c = e
- ? "
+
"
- : "
-
",
- l = e
- ? ""
- : "
".concat(a, "
"),
- f = e
- ? "".concat(u, "px")
- : "".concat(u, "px ").concat(u, "px 0 0");
- return '
\n \n "
- )
- .concat(l, "\n
");
- }
- }),
- (e.prototype.init = function () {
- var t = this;
- if (!t.destroyed) {
- var e = t.get("graph").getContainer(),
- n = t.get("container");
- this.get("containerCfg")
- ? ((n = this.createContainer()), e.appendChild(n))
- : (n = e),
- this.set("container", n);
- var r = e.getBoundingClientRect(),
- i = new Er.Canvas({
- container: e,
- width: r.right - r.left,
- height: r.bottom - r.top,
- });
- Hr(i.get("el"), {
- position: "absolute",
- top: 0,
- left: 0,
- pointerEvents: "none",
- }),
- window.addEventListener(
- "resize",
- Object(g.debounce)(function () {
- return t.resizeCanvas(t);
- }, 100)
- );
- var o = i.addGroup({ id: "annotation-link-group" });
- t.set("linkGroup", o),
- t.set("canvas", i),
- t.get("getTitle") ||
- t.set("getTitle", function (t) {
- var e,
- n =
- (null === (e = null == t ? void 0 : t.getModel) ||
- void 0 === e
- ? void 0
- : e.call(t)) || {},
- r = n.label,
- i = n.id;
- return r || i || "-";
- }),
- t.get("getContent") ||
- t.set("getContent", function (t) {
- var e, n;
- if (!t) return "-";
- var r =
- (null === (e = t.getModel) || void 0 === e
- ? void 0
- : e.call(t)) || {},
- i = r.label,
- o = r.id,
- a =
- null === (n = t.getType) || void 0 === n
- ? void 0
- : n.call(t),
- s = a ? "".concat(a, ": ") : "";
- return "".concat(s).concat(i || o || "");
- });
- var a = t.get("defaultData");
- a && this.readData(a);
- }
- }),
- (e.prototype.createContainer = function () {
- var t = this;
- if (!this.destroyed) {
- var e = this.get("containerCfg"),
- n = this.get("graph"),
- r = n.getContainer(),
- i = r.getBoundingClientRect(),
- o = i.left,
- a = i.right,
- s = i.top,
- u = i.bottom - s,
- c = a - o,
- l = e.position,
- f = void 0 === l ? "top" : l,
- h = e.offsetX,
- d = void 0 === h ? 0 : h,
- p = e.offsetY,
- v = void 0 === p ? 0 : p,
- y = Xs(e, ["position", "offsetX", "offsetY"]),
- m = e.height,
- b = void 0 === m ? "fit-content" : m,
- x = e.width,
- w = void 0 === x ? n.getWidth() : x;
- "100%" === b && (b = u), "100%" === w && (w = c);
- var E = "unset",
- _ = "unset",
- S = {};
- switch (f) {
- case "right":
- (E = "".concat(u, "px")),
- ((S = { top: 0, right: 0 }).right += o + d),
- (S.top += s + v);
- break;
- case "bottom":
- (_ = "".concat(c, "px")),
- ((S = { bottom: 0, left: 0 }).left += o + d),
- (S.bottom += s + v);
- break;
- case "top":
- _ = "".concat(c, "px");
- case "left":
- E = "".concat(u, "px");
- default:
- ((S = { top: 0, left: 0 }).left += o + d), (S.top += s + v);
- }
- Object.keys(S).forEach(function (t) {
- S[t] = "".concat(S[t], "px");
- });
- var O = Vr(
- "
"
- )
- );
- return (
- Hr(
- O,
- Us(
- Us(
- {
- position: "absolute",
- display:
- "top" === f || "bottom" === f
- ? "inline-flex"
- : "unset",
- width: Object(g.isNumber)(w) ? "".concat(w, "px") : w,
- height: Object(g.isNumber)(b)
- ? "".concat(b, "px")
- : b,
- maxHeight: E,
- maxWidth: _,
- overflow: "scroll",
- },
- S
- ),
- y
- )
- ),
- r.appendChild(O),
- O.addEventListener("scroll", function (e) {
- t.updateLinks();
- }),
- O
- );
- }
- }),
- (e.prototype.resizeCanvas = function (t) {
- clearTimeout(t.resizeTimer),
- (t.resizeTimer = setTimeout(function () {
- if (t && !t.destroyed) {
- var e = t.get("container").getBoundingClientRect(),
- n = e.right - e.left,
- r = e.bottom - e.top;
- t.get("canvas").changeSize(n, r), t.updateOutsideCards(t);
- }
- }, 250));
- }),
- (e.prototype.updateOutsideCards = function (t) {
- var e = t || this,
- n = e.get("cardInfoMap") || {},
- r = e.get("graph"),
- i = r.getPointByCanvas(0, 0),
- o = r.getPointByCanvas(r.getWidth(), r.getHeight()),
- a = r.getClientByPoint(i.x, i.y),
- s = a.x,
- u = a.y,
- c = r.getClientByPoint(o.x, o.y),
- l = c.x,
- f = c.y;
- Object.values(n).forEach(function (t) {
- var e = t.card;
- if (e) {
- var n = e.style,
- r = Hs(n.left),
- i = Hs(n.top),
- o = e.getBoundingClientRect(),
- a = o.width,
- c = o.height,
- h = r,
- d = i;
- r + a > l - s && (h = l - s - a),
- r < 0 && (h = 0),
- i + c > f - u && (d = f - u - c),
- i < 0 && (d = 0),
- Hr(e, {
- left: "".concat(h, "px"),
- top: "".concat(d, "px"),
- });
- }
- }),
- e.updateLinks();
- }),
- (e.prototype.showAnnotation = function (t) {
- if (!this.destroyed) {
- var e = t.item;
- this.toggleAnnotation(e);
- }
- }),
- (e.prototype.hideCards = function () {
- var t = this;
- if (!t.destroyed) {
- var e = t.get("cardInfoMap") || {};
- Object.keys(e).forEach(function (e) {
- t.hideCard(e);
- });
- }
- }),
- (e.prototype.toggleAnnotation = function (t, e) {
- var n, r;
- void 0 === e && (e = {});
- if (!this.destroyed) {
- var i = this.get("cardInfoMap") || {},
- o = this.get("graph"),
- a = this.get("container"),
- s = this.get("containerCfg"),
- u = Object.assign({}, this.get("cardCfg") || {}, e),
- c = u.minHeight,
- l = u.minWidth,
- f = u.width,
- h = u.height,
- d = u.collapsed,
- p = void 0 !== d && d,
- v = u.x,
- y = u.y,
- m = u.title,
- b = u.content,
- x = u.maxTitleLength,
- w = u.defaultBegin,
- E = Xs(u, [
- "minHeight",
- "minWidth",
- "width",
- "height",
- "collapsed",
- "x",
- "y",
- "title",
- "content",
- "maxTitleLength",
- "defaultBegin",
- ]),
- _ = this.get("linkGroup"),
- S = this.get("rows") || [[]],
- O =
- null === (n = t.isCanvas) || void 0 === n
- ? void 0
- : n.call(t),
- M = O ? "canvas-annotation" : t.getID(),
- k = i[M] || {},
- A = k.card,
- j = k.link,
- C = k.x,
- I = k.y,
- T = k.title,
- N = k.content,
- P = this.get("getTitle"),
- D = this.get("getContent"),
- L =
- this.get("getContentPlaceholder") ||
- function () {
- return "";
- },
- R =
- this.get("getTitlePlaceHolder") ||
- function () {
- return "";
- },
- B = L(t),
- F = R(t),
- z = Vr(
- this.getDOMContent(
- Us(
- {
- itemId: M,
- collapsed: p,
- title:
- (null ===
- (r = T || m || (null == P ? void 0 : P(t))) ||
- void 0 === r
- ? void 0
- : r.substr(0, x)) || F,
- content: N || b || (null == D ? void 0 : D(t)) || B,
- },
- E
- )
- )
- ),
- G = Object(g.isNumber)(c) ? "".concat(c, "px") : c;
- Hr(z, {
- minHeight: p ? "unset" : G,
- minWidth: Object(g.isNumber)(l) ? "".concat(l, "px") : l,
- height: h,
- width: f,
- });
- var Y,
- U = !!A;
- if (
- (U
- ? (null == j || j.remove(!0), a.replaceChild(z, A))
- : a.appendChild(z),
- !s)
- ) {
- if (
- ((Y = a.getBoundingClientRect() || {}),
- void 0 !== v && void 0 !== y)
- )
- (C = v), (I = y);
- else if (!U && !O) {
- var X = Y.top,
- W = w || {},
- V = W.left,
- H = W.right,
- q = void 0 === H ? 16 : H,
- Z = W.top,
- K = void 0 === Z ? 8 : Z,
- Q = W.bottom,
- $ = q,
- J = K;
- isNaN(V) || ($ = a.scrollWidth - V),
- isNaN(Q) || (J = a.scrollHeight - Q);
- var tt = Object(g.isNumber)(l) ? l : 100;
- C = a.scrollWidth - z.scrollWidth - (S.length - 1) * tt - $;
- var et = S[S.length - 1],
- nt = (et[et.length - 1] || {}).bbox;
- I = (null == nt ? void 0 : nt.bottom) - X || J;
- }
- Hr(z, {
- position: "absolute",
- left: "".concat(C, "px"),
- top: "".concat(I, "px"),
- cusor: s ? "unset" : "move",
- });
- }
- this.bindListener(z, M);
- var rt = z.getBoundingClientRect();
- if (!O) {
- var it = Vs(t, rt, o, this.get("canvas")),
- ot = this.get("linkStyle");
- j = _.addShape("path", {
- attrs: Us(
- {
- lineWidth: 1,
- lineDash: [5, 5],
- stroke: "#ccc",
- path: it,
- },
- ot
- ),
- });
- }
- if (
- ((i[M] = Us(Us({}, i[M] || {}), {
- id: M,
- collapsed: p,
- card: z,
- link: j,
- x: C,
- y: I,
- cardBBox: rt,
- content: N || b,
- title: T || m,
- contentPlaceholder: B,
- titlePlaceholder: F,
- isCanvas: O,
- })),
- this.set("cardInfoMap", i),
- s)
- )
- this.updateCardPositionsInConatainer(), this.updateLinks();
- else {
- var at = !isNaN(v) && !isNaN(y);
- if (!U && !O && !at) {
- var st = Y.bottom,
- ut = void 0 === st ? 0 : st;
- X = Y.top;
- S[S.length - 1].push({ id: M, bbox: rt }),
- rt.top > ut - X - rt.height - 16 && S.push([]),
- this.set("rows", S);
- }
- }
- this.updateCardSize(M);
- var ct = this.get("onAnnotationChange");
- null == ct || ct(i[M], U ? "update" : "create");
- }
- }),
- (e.prototype.updateCardPositionsInConatainer = function () {
- if (!this.destroyed) {
- var t = this.get("cardInfoMap");
- if (t) {
- var e = this.get("container"),
- n = this.get("containerCfg").position,
- r = e.getBoundingClientRect().width,
- i = getComputedStyle(e),
- o = Hs(i.paddingLeft) + Hs(i.paddingRight);
- (r -= o),
- Object.values(t).forEach(function (t) {
- var e = t.card,
- i = e.getBoundingClientRect().width;
- switch (n) {
- case "right":
- Hr(e, {
- marginLeft: r ? "".concat(r - i, "px") : "0px",
- });
- break;
- case "top":
- case "bottom":
- Hr(e, { marginLeft: "8px" });
- }
- });
- }
- }
- }),
- (e.prototype.handleExpandCollapseCard = function (t) {
- if (!this.destroyed) {
- var e = this.get("graph"),
- n = this.get("cardInfoMap");
- if (n) {
- var r = n[t].collapsed,
- i = e.findById(t);
- if (i)
- "hide" !== this.get("cardCfg").collapseType || r
- ? this.toggleAnnotation(i, { collapsed: !r })
- : this.hideCard(t),
- (n[t] = Us(Us({}, n[t]), { collapsed: !r }));
- }
- }
- }),
- (e.prototype.hideCard = function (t) {
- if (!this.destroyed) {
- var e = this.get("cardInfoMap");
- if (e && e[t]) {
- var n = e[t],
- r = n.card,
- i = n.link;
- Hr(r, { display: "none" }),
- null == i || i.hide(),
- this.get("onAnnotationChange")(e[t], "hide");
- }
- }
- }),
- (e.prototype.removeCard = function (t) {
- if (!this.destroyed) {
- var e = this.get("cardInfoMap");
- if (e) {
- var n = e[t],
- r = n.card,
- i = n.link;
- this.get("container").removeChild(r),
- null == i || i.remove(!0),
- delete e[t],
- this.get("onAnnotationChange")(n, "remove");
- }
- }
- }),
- (e.prototype.bindListener = function (t, e) {
- var n = this;
- if (!this.destroyed) {
- t.addEventListener("mousemove", function (t) {
- var r;
- if (
- ("g6-annotation-collapse" === t.target.className
- ? (r = "collapse")
- : "g6-annotation-expand" === t.target.className
- ? (r = "expand")
- : "g6-annotation-close" === t.target.className &&
- (r = "close"),
- r)
- ) {
- var i = n.get("cardCfg").onMouseEnterIcon;
- (void 0 === i ? function () {} : i)(t, e, r);
- }
- }),
- t.addEventListener("mouseout", function (t) {
- var r;
- if (
- ("g6-annotation-collapse" === t.target.className
- ? (r = "collapse")
- : "g6-annotation-expand" === t.target.className
- ? (r = "expand")
- : "g6-annotation-close" === t.target.className &&
- (r = "close"),
- r)
- ) {
- var i = n.get("cardCfg").onMouseLeaveIcon;
- (void 0 === i ? function () {} : i)(t, e, r);
- }
- }),
- t.addEventListener("mouseenter", function (t) {
- var r = n.get("cardInfoMap");
- if (r) {
- var i = n.get("graph"),
- o = i.findById(e);
- if (o) {
- var a = n.get("itemHighlightState");
- i.setItemState(o, a, !0);
- }
- var s = r[e].link;
- if (s) {
- var u = n.get("linkHighlightStyle") || {};
- s.attr(u);
- }
- }
- }),
- t.addEventListener("mouseleave", function (t) {
- var r = n.get("cardInfoMap");
- if (r) {
- var i = n.get("graph"),
- o = i.findById(e);
- if (o) {
- var a = n.get("itemHighlightState");
- i.setItemState(o, a, !1);
- }
- var s = r[e].link;
- if (s) {
- var u = n.get("linkHighlightStyle") || {};
- Object.keys(u).forEach(function (t) {
- s.attr(t, void 0), s.attr(t, void 0);
- });
- var c = n.get("linkStyle");
- s.attr(c);
- }
- }
- }),
- t.addEventListener("click", function (t) {
- var r = (n.get("cardCfg") || {}).onClickIcon;
- if (
- "g6-annotation-collapse" === t.target.className ||
- "g6-annotation-expand" === t.target.className
- )
- "hide" === n.get("cardCfg").collapseType
- ? n.hideCard(e)
- : n.handleExpandCollapseCard(e),
- null == r ||
- r(
- t,
- e,
- "g6-annotation-collapse" === t.target.className
- ? "collapse"
- : "expand"
- );
- else if ("g6-annotation-close" === t.target.className) {
- "remove" === n.get("cardCfg").closeType
- ? n.removeCard(e)
- : n.hideCard(e),
- null == r || r(t, e, "close");
- }
- }),
- this.get("editable") &&
- t.addEventListener("dblclick", function (t) {
- var r = n.get("cardInfoMap"),
- i = (n.get("cardCfg") || {}).maxTitleLength,
- o = void 0 === i ? 20 : i;
- if (r) {
- var a = t.target,
- s = a.className;
- if (
- "g6-annotation-title" === s ||
- "g6-annotation-content" === s
- ) {
- var u =
- "g6-annotation-title" === s
- ? a.getBoundingClientRect()
- : a.parentNode.getBoundingClientRect(),
- c = u.width,
- l = u.height,
- f = getComputedStyle(a),
- h = Vr(
- "<"
- .concat(
- "g6-annotation-title" === s
- ? "input"
- : "textarea",
- ' class="'
- )
- .concat(
- s,
- '-input" type="textarea" style="width:'
- )
- .concat(c, "px; height: ")
- .concat(l, 'px; min-width: 16px;"/>')
- ),
- d = Vr(
- '
')
- );
- d.appendChild(h), a.parentNode.replaceChild(d, a);
- var p = r[e],
- g = p.contentPlaceholder,
- v = p.titlePlaceholder,
- y = p.content,
- m = p.title,
- b = y;
- "g6-annotation-title" === s
- ? ((h.name = "title"), (h.maxLength = o), (b = m))
- : (h.name = "content"),
- b
- ? ((h.innerHTML = a.innerHTML),
- (h.value = a.innerHTML))
- : (h.placeholder =
- "g6-annotation-title" === s ? v : g),
- h.focus(),
- h.addEventListener("blur", function (t) {
- h.value &&
- ((a.innerHTML = h.value),
- (p[h.name || "title"] = h.value)),
- d.parentNode.replaceChild(a, d),
- n.updateCardSize(e);
- var r = n.get("onAnnotationChange");
- null == r || r(p, "update");
- });
- }
- }
- });
- var r = [
- "g6-annotation-title",
- "g6-annotation-content",
- "g6-annotation-title-input",
- "g6-annotation-content-input",
- ];
- (t.draggable = !0),
- t.addEventListener("dragstart", function (e) {
- var i = e.target.className;
- if (!r.includes(i)) {
- var o = t.style;
- n.set("dragging", {
- card: t,
- x: e.clientX,
- y: e.clientY,
- left: Hs(o.left),
- top: Hs(o.top),
- });
- }
- }),
- t.addEventListener("drag", function (t) {
- t.preventDefault();
- var r = n.get("cardInfoMap");
- if (r) {
- var i = t.clientX,
- o = t.clientY,
- a = n.get("dragging");
- if (!isNaN(i) && !isNaN(o) && a) {
- var s = a.x,
- u = a.y,
- c = a.left,
- l = a.top,
- f = a.card,
- h = i - s,
- d = o - u;
- (c += h), (l += d);
- var p = n.get("graph"),
- g = p.getPointByCanvas(0, 0),
- v = p.getPointByCanvas(p.getWidth(), p.getHeight()),
- y = p.getClientByPoint(g.x, g.y),
- m = y.x,
- b = y.y,
- x = p.getClientByPoint(v.x, v.y),
- w = x.x,
- E = x.y,
- _ = f.getBoundingClientRect();
- ((c > w - m - (_.right - _.left) && h > 0) ||
- (c < 0 && h < 0)) &&
- (c -= h),
- ((l > E - b - (_.bottom - _.top) && d > 0) ||
- (l < 0 && d < 0)) &&
- (l -= d),
- Hr(f, {
- left: "".concat(c, "px"),
- top: "".concat(l, "px"),
- visibility: "hidden",
- }),
- (s = i),
- (u = o);
- var S = (r[e] || {}).link;
- if (S) {
- var O = p.findById(e);
- S.attr("path", Vs(O, _, p, n.get("canvas")));
- }
- n.set("dragging", {
- x: s,
- y: u,
- left: c,
- top: l,
- card: f,
- });
- }
- }
- });
- t.addEventListener("dragend", function (t) {
- var r = n.get("cardInfoMap");
- if (r) {
- var i = n.get("dragging");
- if (i) {
- var o = i.left,
- a = i.top,
- s = i.card;
- (r[e].x = o),
- (r[e].y = a),
- Hr(s, { visibility: "visible" }),
- n.set("dragging", !1);
- var u = n.get("rows");
- null == u ||
- u.forEach(function (t) {
- for (var n = t.length - 1; n >= 0; n--)
- t[n].id === e && t.splice(n, 1);
- });
- var c = n.get("onAnnotationChange");
- null == c || c(r[e], "update");
- }
- }
- });
- }
- }),
- (e.prototype.updateCardSize = function (t) {
- var e = this.get("cardInfoMap");
- if (e) {
- var n = e[t].card,
- r = n.getBoundingClientRect().width,
- i = n.getElementsByClassName("g6-annotation-title")[0];
- if (i) {
- var o = getComputedStyle(i),
- a = Hs(o.marginLeft),
- s = i.getBoundingClientRect().width;
- Hr(i, { marginRight: "".concat(r - a - 24 - 16 - s, "px") });
- }
- }
- }),
- (e.prototype.updateLink = function (t) {
- var e = t.item;
- if (e) {
- var n = this.get("cardInfoMap");
- if (n) {
- var r = this.get("canvas"),
- i = this.get("graph"),
- o = n[e.getID()] || {},
- a = o.link,
- s = o.card;
- if (a) {
- var u = Vs(e, s.getBoundingClientRect(), i, r);
- a.attr("path", u);
- }
- }
- }
- }),
- (e.prototype.updateLinks = function () {
- var t = this;
- if (!this.destroyed) {
- var e = this.get("cardInfoMap");
- if (e) {
- var n = this.get("graph");
- Object.values(e).forEach(function (e) {
- var r = e.id,
- i = n.findById(r);
- t.updateLink({ item: i });
- });
- }
- }
- }),
- (e.prototype.onGraphDataChange = function () {
- var t = this,
- e = this.get("cardInfoMap");
- if (e) {
- var n = this.get("graph");
- Object.values(e).forEach(function (e) {
- var r = e.id,
- i = e.card,
- o = e.isCanvas;
- if (i && !o && "none" !== i.style.display) {
- var a = n.findById(r);
- a && a.isVisible() ? t.toggleAnnotation(a) : t.hideCard(r);
- }
- });
- }
- }),
- (e.prototype.onGraphItemVisibilityChange = function (t) {
- var e = t.item,
- n = t.visible;
- if (e && !e.destroyed) {
- var r = this.get("cardInfoMap");
- if (r) {
- var i = e.getID();
- r[i] && (n || this.hideCard(i));
- }
- }
- }),
- (e.prototype.saveData = function (t) {
- void 0 === t && (t = !1);
- var e = this.get("cardInfoMap");
- if (e) {
- var n = this.get("graph"),
- r = this.get("getTitle"),
- i = this.get("getContent"),
- o = [];
- return (
- Object.values(e).forEach(function (e) {
- var a = e.title,
- s = e.content,
- u = e.x,
- c = e.y,
- l = e.id,
- f = e.collapsed,
- h = e.card;
- if (!h || "none" !== h.style.display || t) {
- var d = n.findById(l) || n.get("canvas");
- o.push({
- id: l,
- x: u,
- y: c,
- collapsed: f,
- title: a || (null == r ? void 0 : r(d)),
- content: s || (null == i ? void 0 : i(d)),
- visible: h && "none" !== h.style.display,
- });
- }
- }),
- o
- );
- }
- }),
- (e.prototype.readData = function (t) {
- var e = this,
- n = this.get("graph");
- t.forEach(function (t) {
- var r = t.id,
- i = t.x,
- o = t.y,
- a = t.title,
- s = t.content,
- u = t.collapsed,
- c = t.visible,
- l = n.findById(r);
- if (
- (l || "canvas-annotation" !== r || (l = n.get("canvas")), !l)
- ) {
- var f = e.get("cardInfoMap") || {};
- return (f[r] = t), void e.set("cardInfoMap", f);
- }
- e.toggleAnnotation(l, {
- x: i,
- y: o,
- title: a,
- content: s,
- collapsed: u,
- }),
- c || e.hideCard(r);
- });
- }),
- (e.prototype.clear = function () {
- var t = this.get("cardInfoMap");
- if (t) {
- var e = this.get("container");
- Object.values(t).forEach(function (t) {
- var n = t.card,
- r = t.link;
- e.removeChild(n), null == r || r.remove(!0);
- }),
- this.set("cardInfoMap", {});
- }
- }),
- (e.prototype.destroy = function () {
- var t;
- this.clear(),
- null === (t = this.get("canvas")) ||
- void 0 === t ||
- t.destroy();
- var e = this.get("graph");
- e &&
- !e.destroyed &&
- (this.get("containerCfg") &&
- e.getContainer().removeChild(this.get("container")),
- (this.destroyed = !0));
- }),
- e
- );
- })(Fi),
- Vs = function (t, e, n, r) {
- var i, o;
- if ("edge" === t.getType()) o = [t.getKeyShape().getPoint(0.5)];
- else {
- var a =
- null === (i = t.getKeyShape) || void 0 === i
- ? void 0
- : i.call(t).getBBox(),
- s = a.minX,
- u = a.minY,
- c = a.maxX,
- l = a.maxY,
- f = t.getModel(),
- h = f.x,
- d = f.y;
- o = {
- left: { x: (s += h), y: ((u += d) + (l += d)) / 2 },
- right: { x: (c += h), y: (u + l) / 2 },
- top: { x: (s + c) / 2, y: u },
- bottom: { x: (s + c) / 2, y: l },
- };
- }
- Object.keys(o).forEach(function (t) {
- var e = o[t],
- i = e.x,
- a = e.y,
- s = n.getClientByPoint(i, a);
- o[t] = r.getPointByClient(s.x, s.y);
- });
- var p = e.top,
- g = void 0 === p ? 0 : p,
- v = e.left,
- y = void 0 === v ? 0 : v,
- m = e.right,
- b = void 0 === m ? 0 : m,
- x = e.bottom,
- w = void 0 === x ? 0 : x,
- E = {
- left: r.getPointByClient(y, (g + w) / 2),
- right: r.getPointByClient(b, (g + w) / 2),
- top: r.getPointByClient((y + b) / 2, g),
- bottom: r.getPointByClient((y + b) / 2, w),
- };
- return (function (t, e) {
- var n,
- r,
- i = 1 / 0;
- Object.keys(t).forEach(function (o) {
- var a = t[o];
- Object.keys(e).forEach(function (t) {
- var s = e[t],
- u = a.x - s.x,
- c = a.y - s.y,
- l = u * u + c * c;
- i > l && ((i = l), (n = a), (r = s), [o, t]);
- });
- });
- var o = dr.getControlPoint(n, r, 0.5, 20);
- return [
- ["M", n.x, n.y],
- ["Q", o.x, o.y, r.x, r.y],
- ];
- })(o, E);
- },
- Hs = function (t) {
- return Number(t.replace(/\s+|px/gi, "")) || 0;
- },
- qs = {
- PluginBase: Fi,
- Menu: Vi,
- Grid: Yi,
- Minimap: Qi,
- Bundling: eo,
- ToolBar: so,
- Tooltip: co,
- Fisheye: oo,
- TimeBar: Os,
- ImageMinimap: As,
- EdgeFilterLens: Ns,
- SnapLine: Rs,
- Legend: Gs,
- Annotation: Ws,
- };
- vr(
- "circle",
- {
- options: {
- size: xr.defaultNode.size,
- style: {
- x: 0,
- y: 0,
- stroke: xr.defaultNode.style.stroke,
- fill: xr.defaultNode.style.fill,
- lineWidth: xr.defaultNode.style.lineWidth,
- },
- labelCfg: {
- style: {
- fill: xr.nodeLabel.style.fill,
- fontSize: xr.nodeLabel.style.fontSize,
- fontFamily: xr.windowFontFamily,
- },
- },
- linkPoints: {
- top: !1,
- right: !1,
- bottom: !1,
- left: !1,
- size: xr.defaultNode.linkPoints.size,
- lineWidth: xr.defaultNode.linkPoints.lineWidth,
- fill: xr.defaultNode.linkPoints.fill,
- stroke: xr.defaultNode.linkPoints.stroke,
- },
- icon: {
- show: !1,
- img: "https://gw.alipayobjects.com/zos/bmw-prod/5d015065-8505-4e7a-baec-976f81e3c41d.svg",
- width: 20,
- height: 20,
- },
- stateStyles: Object(p.__assign)({}, xr.nodeStateStyles),
- },
- shapeType: "circle",
- labelPosition: "center",
- drawShape: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).icon,
- r = void 0 === n ? {} : n,
- i = this.getShapeStyle(t),
- o = Object(g.deepMix)({}, r, t.icon),
- a = "".concat(this.type, "-keyShape"),
- s = e.addShape("circle", {
- attrs: i,
- className: a,
- name: a,
- draggable: !0,
- });
- e.shapeMap[a] = s;
- var u = o.width,
- c = o.height,
- l = o.show,
- f = o.text;
- if (l) {
- var h = "".concat(this.type, "-icon");
- e.shapeMap[h] = f
- ? e.addShape("text", {
- attrs: Object(p.__assign)(
- {
- x: 0,
- y: 0,
- fontSize: 12,
- fill: "#000",
- stroke: "#000",
- textBaseline: "middle",
- textAlign: "center",
- },
- o
- ),
- className: h,
- name: h,
- draggable: !0,
- })
- : e.addShape("image", {
- attrs: Object(p.__assign)({ x: -u / 2, y: -c / 2 }, o),
- className: h,
- name: h,
- draggable: !0,
- });
- }
- return this.drawLinkPoints(t, e), s;
- },
- drawLinkPoints: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).linkPoints;
- if (n) {
- var r = n || {},
- i = r.top,
- o = r.left,
- a = r.right,
- s = r.bottom,
- u = r.size,
- c = r.r,
- l = Object(p.__rest)(r, [
- "top",
- "left",
- "right",
- "bottom",
- "size",
- "r",
- ]),
- f = this.getSize(t)[0] / 2;
- if (o) {
- var h = "link-point-left";
- e.shapeMap[h] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: -f,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: h,
- name: h,
- isAnchorPoint: !0,
- });
- }
- if (a) {
- var d = "link-point-right";
- e.shapeMap[d] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: f,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: d,
- name: d,
- isAnchorPoint: !0,
- });
- }
- if (i) {
- var g = "link-point-top";
- e.shapeMap[g] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: -f,
- r: u / 2 || c || 5,
- }),
- className: g,
- name: g,
- isAnchorPoint: !0,
- });
- }
- if (s) {
- var v = "link-point-bottom";
- e.shapeMap[v] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: f,
- r: u / 2 || c || 5,
- }),
- className: v,
- name: v,
- isAnchorPoint: !0,
- });
- }
- }
- },
- getShapeStyle: function (t) {
- var e = (this.mergeStyle || this.getOptions(t)).style,
- n = { stroke: t.color },
- r = Object(g.deepMix)({}, e, n),
- i = this.getSize(t)[0] / 2;
- return Object(p.__assign)({ x: 0, y: 0, r: i }, r);
- },
- update: function (t, e, n) {
- var r = e.getContainer(),
- i = this.getSize(t),
- o = Object(p.__assign)({}, t.style);
- void 0 === t.style.stroke && t.color && (o.stroke = t.color),
- void 0 !== t.style.r || isNaN(i[0]) || (o.r = i[0] / 2),
- this.updateShape(t, e, o, !0, n),
- this.updateLinkPoints(t, r);
- },
- },
- "single-node"
- ),
- vr(
- "rect",
- {
- options: {
- size: [100, 30],
- style: {
- radius: 0,
- stroke: xr.defaultNode.style.stroke,
- fill: xr.defaultNode.style.fill,
- lineWidth: xr.defaultNode.style.lineWidth,
- },
- labelCfg: {
- style: {
- fill: xr.nodeLabel.style.fill,
- fontSize: xr.nodeLabel.style.fontSize,
- fontFamily: xr.windowFontFamily,
- },
- },
- linkPoints: {
- top: !1,
- right: !1,
- bottom: !1,
- left: !1,
- size: xr.defaultNode.linkPoints.size,
- lineWidth: xr.defaultNode.linkPoints.lineWidth,
- fill: xr.defaultNode.linkPoints.fill,
- stroke: xr.defaultNode.linkPoints.stroke,
- },
- icon: {
- show: !1,
- img: "https://gw.alipayobjects.com/zos/bmw-prod/5d015065-8505-4e7a-baec-976f81e3c41d.svg",
- width: 20,
- height: 20,
- },
- anchorPoints: [
- [0, 0.5],
- [1, 0.5],
- ],
- stateStyles: Object(p.__assign)({}, xr.nodeStateStyles),
- },
- shapeType: "rect",
- labelPosition: "center",
- drawShape: function (t, e) {
- var n = this.getShapeStyle(t),
- r = e.addShape("rect", {
- attrs: n,
- className: "".concat(this.type, "-keyShape"),
- name: "".concat(this.type, "-keyShape"),
- draggable: !0,
- });
- return (
- (e.shapeMap["".concat(this.type, "-keyShape")] = r),
- this.drawLinkPoints(t, e),
- r
- );
- },
- drawLinkPoints: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).linkPoints,
- r = void 0 === n ? {} : n,
- i = r.top,
- o = r.left,
- a = r.right,
- s = r.bottom,
- u = r.size,
- c = r.r,
- l = Object(p.__rest)(r, [
- "top",
- "left",
- "right",
- "bottom",
- "size",
- "r",
- ]),
- f = this.getSize(t),
- h = f[0],
- d = f[1];
- o &&
- (e.shapeMap["link-point-left"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: -h / 2,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: "link-point-left",
- name: "link-point-left",
- isAnchorPoint: !0,
- })),
- a &&
- (e.shapeMap["link-point-right"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: h / 2,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: "link-point-right",
- name: "link-point-right",
- isAnchorPoint: !0,
- })),
- i &&
- (e.shapeMap["link-point-top"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: -d / 2,
- r: u / 2 || c || 5,
- }),
- className: "link-point-top",
- name: "link-point-top",
- isAnchorPoint: !0,
- })),
- s &&
- (e.shapeMap["link-point-bottom"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: d / 2,
- r: u / 2 || c || 5,
- }),
- className: "link-point-bottom",
- name: "link-point-bottom",
- isAnchorPoint: !0,
- }));
- },
- getShapeStyle: function (t) {
- var e = (this.mergeStyle || this.getOptions(t)).style,
- n = { stroke: t.color },
- r = Object(g.mix)({}, e, n),
- i = this.getSize(t),
- o = r.width || i[0],
- a = r.height || i[1];
- return Object(p.__assign)(
- { x: -o / 2, y: -a / 2, width: o, height: a },
- r
- );
- },
- update: function (t, e, n) {
- var r = e.getContainer(),
- i = this.getOptions({}).style,
- o = this.getSize(t),
- a = e.get("keyShape");
- t.size ||
- ((o[0] = a.attr("width") || i.width),
- (o[1] = a.attr("height") || i.height));
- var s = {
- stroke: t.color,
- x: -o[0] / 2,
- y: -o[1] / 2,
- width: o[0],
- height: o[1],
- },
- u = Object(g.mix)({}, i, a.attr(), s);
- (u = Object(g.mix)(u, t.style)),
- this.updateShape(t, e, u, !1, n),
- this.updateLinkPoints(t, r);
- },
- },
- "single-node"
- ),
- vr(
- "ellipse",
- {
- options: {
- size: [80, 40],
- style: {
- x: 0,
- y: 0,
- stroke: xr.defaultNode.style.stroke,
- fill: xr.defaultNode.style.fill,
- lineWidth: xr.defaultNode.style.lineWidth,
- },
- labelCfg: {
- style: {
- fill: xr.nodeLabel.style.fill,
- fontSize: xr.nodeLabel.style.fontSize,
- fontFamily: xr.windowFontFamily,
- },
- },
- linkPoints: {
- top: !1,
- right: !1,
- bottom: !1,
- left: !1,
- size: xr.defaultNode.linkPoints.size,
- lineWidth: xr.defaultNode.linkPoints.lineWidth,
- fill: xr.defaultNode.linkPoints.fill,
- stroke: xr.defaultNode.linkPoints.stroke,
- },
- icon: {
- show: !1,
- img: "https://gw.alipayobjects.com/zos/bmw-prod/5d015065-8505-4e7a-baec-976f81e3c41d.svg",
- width: 20,
- height: 20,
- },
- stateStyles: Object(p.__assign)({}, xr.nodeStateStyles),
- },
- shapeType: "ellipse",
- labelPosition: "center",
- drawShape: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).icon,
- r = void 0 === n ? {} : n,
- i = this.getShapeStyle(t),
- o = e.addShape("ellipse", {
- attrs: i,
- className: "ellipse-keyShape",
- name: "ellipse-keyShape",
- draggable: !0,
- });
- e.shapeMap["ellipse-keyShape"] = o;
- var a = r.width,
- s = r.height,
- u = r.show,
- c = r.text;
- return (
- u &&
- (e.shapeMap["".concat(this.type, "-icon")] = c
- ? e.addShape("text", {
- attrs: Object(p.__assign)(
- {
- x: 0,
- y: 0,
- fontSize: 12,
- fill: "#000",
- stroke: "#000",
- textBaseline: "middle",
- textAlign: "center",
- },
- r
- ),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- })
- : e.addShape("image", {
- attrs: Object(p.__assign)({ x: -a / 2, y: -s / 2 }, r),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- })),
- this.drawLinkPoints(t, e),
- o
- );
- },
- drawLinkPoints: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).linkPoints,
- r = void 0 === n ? {} : n,
- i = r.top,
- o = r.left,
- a = r.right,
- s = r.bottom,
- u = r.size,
- c = r.r,
- l = Object(p.__rest)(r, [
- "top",
- "left",
- "right",
- "bottom",
- "size",
- "r",
- ]),
- f = this.getSize(t),
- h = f[0] / 2,
- d = f[1] / 2;
- o &&
- (e.shapeMap["link-point-left"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: -h,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: "link-point-left",
- name: "link-point-left",
- isAnchorPoint: !0,
- })),
- a &&
- (e.shapeMap["link-point-right"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: h,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: "link-point-right",
- name: "link-point-right",
- isAnchorPoint: !0,
- })),
- i &&
- (e.shapeMap["link-point-top"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: -d,
- r: u / 2 || c || 5,
- }),
- className: "link-point-top",
- name: "link-point-top",
- isAnchorPoint: !0,
- })),
- s &&
- (e.shapeMap["link-point-bottom"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: d,
- r: u / 2 || c || 5,
- }),
- className: "link-point-bottom",
- name: "link-point-bottom",
- isAnchorPoint: !0,
- }));
- },
- getShapeStyle: function (t) {
- var e = (this.mergeStyle || this.getOptions(t)).style,
- n = { stroke: t.color },
- r = Object(g.mix)({}, e, n),
- i = this.getSize(t),
- o = i[0] / 2,
- a = i[1] / 2;
- return Object(p.__assign)({ x: 0, y: 0, rx: o, ry: a }, r);
- },
- update: function (t, e, n) {
- var r = e.getContainer(),
- i = this.getOptions({}).style,
- o = this.getSize(t),
- a = { stroke: t.color, rx: o[0] / 2, ry: o[1] / 2 },
- s = e.get("keyShape"),
- u = Object(g.mix)({}, i, s.attr(), a);
- (u = Object(g.mix)(u, t.style)),
- this.updateShape(t, e, u, !0, n),
- this.updateLinkPoints(t, r);
- },
- },
- "single-node"
- ),
- vr(
- "diamond",
- {
- options: {
- size: [80, 80],
- style: {
- stroke: xr.defaultNode.style.stroke,
- fill: xr.defaultNode.style.fill,
- lineWidth: xr.defaultNode.style.lineWidth,
- },
- labelCfg: {
- style: {
- fill: xr.nodeLabel.style.fill,
- fontSize: xr.nodeLabel.style.fontSize,
- fontFamily: xr.windowFontFamily,
- },
- },
- linkPoints: {
- top: !1,
- right: !1,
- bottom: !1,
- left: !1,
- size: xr.defaultNode.linkPoints.size,
- lineWidth: xr.defaultNode.linkPoints.lineWidth,
- fill: xr.defaultNode.linkPoints.fill,
- stroke: xr.defaultNode.linkPoints.stroke,
- },
- icon: {
- show: !1,
- img: "https://gw.alipayobjects.com/zos/bmw-prod/5d015065-8505-4e7a-baec-976f81e3c41d.svg",
- width: 20,
- height: 20,
- },
- stateStyles: Object(p.__assign)({}, xr.nodeStateStyles),
- },
- shapeType: "diamond",
- labelPosition: "center",
- drawShape: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).icon,
- r = void 0 === n ? {} : n,
- i = this.getShapeStyle(t),
- o = e.addShape("path", {
- attrs: i,
- className: "".concat(this.type, "-keyShape"),
- name: "".concat(this.type, "-keyShape"),
- draggable: !0,
- });
- e.shapeMap["".concat(this.type, "-keyShape")] = o;
- var a = r.width,
- s = r.height,
- u = r.show,
- c = r.text;
- return (
- u &&
- (e.shapeMap["".concat(this.type, "-icon")] = c
- ? e.addShape("text", {
- attrs: Object(p.__assign)(
- {
- x: 0,
- y: 0,
- fontSize: 12,
- fill: "#000",
- stroke: "#000",
- textBaseline: "middle",
- textAlign: "center",
- },
- r
- ),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- })
- : e.addShape("image", {
- attrs: Object(p.__assign)({ x: -a / 2, y: -s / 2 }, r),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- })),
- this.drawLinkPoints(t, e),
- o
- );
- },
- drawLinkPoints: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).linkPoints,
- r = void 0 === n ? {} : n,
- i = r.top,
- o = r.left,
- a = r.right,
- s = r.bottom,
- u = r.size,
- c = r.r,
- l = Object(p.__rest)(r, [
- "top",
- "left",
- "right",
- "bottom",
- "size",
- "r",
- ]),
- f = this.getSize(t),
- h = f[0],
- d = f[1];
- o &&
- (e.shapeMap["link-point-left"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: -h / 2,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: "link-point-left",
- name: "link-point-left",
- isAnchorPoint: !0,
- })),
- a &&
- (e.shapeMap["link-point-right"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: h / 2,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: "link-point-right",
- name: "link-point-right",
- isAnchorPoint: !0,
- })),
- i &&
- (e.shapeMap["link-point-top"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: -d / 2,
- r: u / 2 || c || 5,
- }),
- className: "link-point-top",
- name: "link-point-top",
- isAnchorPoint: !0,
- })),
- s &&
- (e.shapeMap["link-point-bottom"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: d / 2,
- r: u / 2 || c || 5,
- }),
- className: "link-point-bottom",
- name: "link-point-bottom",
- isAnchorPoint: !0,
- }));
- },
- getPath: function (t) {
- var e = this.getSize(t),
- n = e[0],
- r = e[1];
- return [
- ["M", 0, -r / 2],
- ["L", n / 2, 0],
- ["L", 0, r / 2],
- ["L", -n / 2, 0],
- ["Z"],
- ];
- },
- getShapeStyle: function (t) {
- var e = (this.mergeStyle || this.getOptions(t)).style,
- n = { stroke: t.color },
- r = Object(g.mix)({}, e, n),
- i = this.getPath(t);
- return Object(p.__assign)({ path: i }, r);
- },
- update: function (t, e, n) {
- var r = e.getContainer(),
- i = this.getOptions({}).style,
- o = this.getPath(t),
- a = { stroke: t.color, path: o },
- s = e.get("keyShape"),
- u = Object(g.mix)({}, i, s.attr(), a);
- (u = Object(g.mix)(u, t.style)),
- this.updateShape(t, e, u, !0, n),
- this.updateLinkPoints(t, r);
- },
- },
- "single-node"
- ),
- vr(
- "triangle",
- {
- options: {
- size: 40,
- direction: "up",
- style: {
- stroke: xr.defaultNode.style.stroke,
- fill: xr.defaultNode.style.fill,
- lineWidth: xr.defaultNode.style.lineWidth,
- },
- labelCfg: {
- style: {
- fill: xr.nodeLabel.style.fill,
- fontSize: xr.nodeLabel.style.fontSize,
- },
- offset: 15,
- },
- linkPoints: {
- top: !1,
- right: !1,
- bottom: !1,
- left: !1,
- size: xr.defaultNode.linkPoints.size,
- lineWidth: xr.defaultNode.linkPoints.lineWidth,
- fill: xr.defaultNode.linkPoints.fill,
- stroke: xr.defaultNode.linkPoints.stroke,
- },
- icon: {
- show: !1,
- img: "https://gw.alipayobjects.com/zos/bmw-prod/5d015065-8505-4e7a-baec-976f81e3c41d.svg",
- width: 20,
- height: 20,
- offset: 6,
- },
- stateStyles: Object(p.__assign)({}, xr.nodeStateStyles),
- },
- shapeType: "triangle",
- labelPosition: "bottom",
- drawShape: function (t, e) {
- var n = this.mergeStyle || this.getOptions(t),
- r = n.icon,
- i = void 0 === r ? {} : r,
- o = n.direction,
- a = this.getShapeStyle(t),
- s = t.direction || o,
- u = e.addShape("path", {
- attrs: a,
- className: "".concat(this.type, "-keyShape"),
- name: "".concat(this.type, "-keyShape"),
- draggable: !0,
- });
- e.shapeMap["".concat(this.type, "-keyShape")] = u;
- var c = i.width,
- l = i.height,
- f = i.show,
- h = i.offset,
- d = i.text;
- if (f)
- if (d)
- e.shapeMap["".concat(this.type, "-icon")] = e.addShape(
- "text",
- {
- attrs: Object(p.__assign)(
- {
- x: 0,
- y: 0,
- fontSize: 12,
- fill: "#000",
- stroke: "#000",
- textBaseline: "middle",
- textAlign: "center",
- },
- i
- ),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- }
- );
- else {
- var g = -c / 2,
- v = -l / 2;
- ("up" !== s && "down" !== s) || (v += h),
- ("left" !== s && "right" !== s) || (g += h),
- (e.shapeMap["".concat(this.type, "-icon")] = e.addShape(
- "image",
- {
- attrs: Object(p.__assign)({ x: g, y: v }, i),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- }
- ));
- }
- return this.drawLinkPoints(t, e), u;
- },
- drawLinkPoints: function (t, e) {
- var n = this.mergeStyle || this.getOptions(t),
- r = n.linkPoints,
- i = void 0 === r ? {} : r,
- o = n.direction,
- a = t.direction || o,
- s = i.top,
- u = i.left,
- c = i.right,
- l = i.bottom,
- f = i.size,
- h = i.r,
- d = Object(p.__rest)(i, [
- "top",
- "left",
- "right",
- "bottom",
- "size",
- "r",
- ]),
- g = this.getSize(t)[0];
- if (u) {
- var v = null,
- y = g * Math.sin((1 / 3) * Math.PI),
- m = g * Math.sin((1 / 3) * Math.PI);
- "up" === a
- ? (v = [-m, y])
- : "down" === a
- ? (v = [-m, -y])
- : "left" === a && (v = [-m, m - y]),
- v &&
- (e.shapeMap["link-point-left"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, d), {
- x: v[0],
- y: v[1],
- r: f / 2 || h || 5,
- }),
- className: "link-point-left",
- name: "link-point-left",
- }));
- }
- if (c) {
- var b = null;
- (y = g * Math.sin((1 / 3) * Math.PI)),
- (m = g * Math.sin((1 / 3) * Math.PI));
- "up" === a
- ? (b = [m, y])
- : "down" === a
- ? (b = [m, -y])
- : "right" === a && (b = [m, m - y]),
- b &&
- (e.shapeMap["link-point-right"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, d), {
- x: b[0],
- y: b[1],
- r: f / 2 || h || 5,
- }),
- className: "link-point-right",
- name: "link-point-right",
- }));
- }
- if (s) {
- var x = null;
- (y = g * Math.sin((1 / 3) * Math.PI)),
- (m = g * Math.sin((1 / 3) * Math.PI));
- "up" === a
- ? (x = [m - y, -y])
- : "left" === a
- ? (x = [m, -y])
- : "right" === a && (x = [-m, -y]),
- x &&
- (e.shapeMap["link-point-top"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, d), {
- x: x[0],
- y: x[1],
- r: f / 2 || h || 5,
- }),
- className: "link-point-top",
- name: "link-point-top",
- }));
- }
- if (l) {
- var w = null;
- (y = g * Math.sin((1 / 3) * Math.PI)),
- (m = g * Math.sin((1 / 3) * Math.PI));
- "down" === a
- ? (w = [-m + y, y])
- : "left" === a
- ? (w = [m, y])
- : "right" === a && (w = [-m, y]),
- w &&
- (e.shapeMap["link-point-bottom"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, d), {
- x: w[0],
- y: w[1],
- r: f / 2 || h || 5,
- }),
- className: "link-point-bottom",
- name: "link-point-bottom",
- }));
- }
- },
- getPath: function (t) {
- var e = (this.mergeStyle || this.getOptions(t)).direction,
- n = t.direction || e,
- r = this.getSize(t)[0],
- i = r * Math.sin((1 / 3) * Math.PI),
- o = r * Math.sin((1 / 3) * Math.PI),
- a = [["M", -o, i], ["L", 0, -i], ["L", o, i], ["Z"]];
- return (
- "down" === n
- ? (a = [["M", -o, -i], ["L", o, -i], ["L", 0, i], ["Z"]])
- : "left" === n
- ? (a = [["M", -o, o - i], ["L", o, -o], ["L", o, o], ["Z"]])
- : "right" === n &&
- (a = [["M", o, o - i], ["L", -o, o], ["L", -o, -o], ["Z"]]),
- a
- );
- },
- getShapeStyle: function (t) {
- var e = (this.mergeStyle || this.getOptions(t)).style,
- n = { stroke: t.color },
- r = Object(g.mix)({}, e, n),
- i = this.getPath(t);
- return Object(p.__assign)({ path: i }, r);
- },
- update: function (t, e, n) {
- var r = e.getContainer(),
- i = this.getOptions({}).style,
- o = this.getPath(t),
- a = { stroke: t.color, path: o },
- s = e.get("keyShape"),
- u = Object(g.mix)({}, i, s.attr(), a);
- (u = Object(g.mix)(u, t.style)),
- this.updateShape(t, e, u, !0, n),
- this.updateLinkPoints(t, r);
- },
- updateLinkPoints: function (t, e) {
- var n = this.getOptions({}),
- r = n.linkPoints,
- i = n.direction,
- o = t.direction || i,
- a =
- e.shapeMap["link-point-left"] ||
- e.find(function (t) {
- return "link-point-left" === t.get("className");
- }),
- s =
- e.shapeMap["link-point-right"] ||
- e.find(function (t) {
- return "link-point-right" === t.get("className");
- }),
- u =
- e.shapeMap["link-point-top"] ||
- e.find(function (t) {
- return "link-point-top" === t.get("className");
- }),
- c =
- e.shapeMap["link-point-bottom"] ||
- e.find(function (t) {
- return "link-point-bottom" === t.get("className");
- }),
- l = r,
- f = a || s || u || c;
- f && (l = f.attr());
- var h = Object(g.mix)({}, l, t.linkPoints),
- d = h.fill,
- v = h.stroke,
- y = h.lineWidth,
- m = h.size / 2;
- m || (m = h.r);
- var b = t.linkPoints
- ? t.linkPoints
- : {
- left: void 0,
- right: void 0,
- top: void 0,
- bottom: void 0,
- },
- x = b.left,
- w = b.right,
- E = b.top,
- _ = b.bottom,
- S = this.getSize(t)[0],
- O = { r: m, fill: d, stroke: v, lineWidth: y },
- M = null,
- k = S * Math.sin((1 / 3) * Math.PI),
- A = S * Math.sin((1 / 3) * Math.PI);
- "up" === o
- ? (M = [-A, k])
- : "down" === o
- ? (M = [-A, -k])
- : "left" === o && (M = [-A, A - k]),
- M &&
- (a
- ? x || void 0 === x
- ? a.attr(
- Object(p.__assign)(Object(p.__assign)({}, O), {
- x: M[0],
- y: M[1],
- })
- )
- : (a.remove(), delete e.shapeMap["link-point-left"])
- : x &&
- (e.shapeMap["link-point-left"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, O), {
- x: M[0],
- y: M[1],
- }),
- className: "link-point-left",
- name: "link-point-left",
- isAnchorPoint: !0,
- })));
- var j = null;
- "up" === o
- ? (j = [A, k])
- : "down" === o
- ? (j = [A, -k])
- : "right" === o && (j = [A, A - k]),
- j &&
- (s
- ? w || void 0 === w
- ? s.attr(
- Object(p.__assign)(Object(p.__assign)({}, O), {
- x: j[0],
- y: j[1],
- })
- )
- : (s.remove(), delete e.shapeMap["link-point-right"])
- : w &&
- (e.shapeMap["link-point-right"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, O), {
- x: j[0],
- y: j[1],
- }),
- className: "link-point-right",
- name: "link-point-right",
- isAnchorPoint: !0,
- })));
- var C = null;
- "up" === o
- ? (C = [A - k, -k])
- : "left" === o
- ? (C = [A, -k])
- : "right" === o && (C = [-A, -k]),
- C &&
- (u
- ? E || void 0 === E
- ? u.attr(
- Object(p.__assign)(Object(p.__assign)({}, O), {
- x: C[0],
- y: C[1],
- })
- )
- : (u.remove(), delete e.shapeMap["link-point-top"])
- : E &&
- (e.shapeMap["link-point-top"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, O), {
- x: C[0],
- y: C[1],
- }),
- className: "link-point-top",
- name: "link-point-top",
- isAnchorPoint: !0,
- })));
- var I = null;
- "down" === o
- ? (I = [-A + k, k])
- : "left" === o
- ? (I = [A, k])
- : "right" === o && (I = [-A, k]),
- I &&
- (c
- ? _ || void 0 === _
- ? c.attr(
- Object(p.__assign)(Object(p.__assign)({}, O), {
- x: I[0],
- y: I[1],
- })
- )
- : (c.remove(), delete e.shapeMap["link-point-bottom"])
- : _ &&
- (e.shapeMap["link-point-bottom"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, O), {
- x: I[0],
- y: I[1],
- }),
- className: "link-point-bottom",
- name: "link-point-bottom",
- isAnchorPoint: !0,
- })));
- },
- },
- "single-node"
- ),
- vr(
- "modelRect",
- {
- options: {
- size: [185, 70],
- style: {
- radius: 5,
- stroke: "#69c0ff",
- fill: "#ffffff",
- lineWidth: xr.defaultNode.style.lineWidth,
- fillOpacity: 1,
- },
- labelCfg: {
- style: {
- fill: "#595959",
- fontSize: 14,
- fontFamily: xr.windowFontFamily,
- },
- offset: 30,
- },
- descriptionCfg: {
- style: {
- fontSize: 12,
- fill: "#bfbfbf",
- fontFamily: xr.windowFontFamily,
- },
- paddingTop: 0,
- },
- preRect: { show: !0, width: 4, fill: "#40a9ff", radius: 2 },
- linkPoints: {
- top: !1,
- right: !1,
- bottom: !1,
- left: !1,
- size: 10,
- lineWidth: 1,
- fill: "#72CC4A",
- stroke: "#72CC4A",
- },
- logoIcon: {
- show: !0,
- x: 0,
- y: 0,
- img: "https://gw.alipayobjects.com/zos/basement_prod/4f81893c-1806-4de4-aff3-9a6b266bc8a2.svg",
- width: 16,
- height: 16,
- offset: 0,
- },
- stateIcon: {
- show: !0,
- x: 0,
- y: 0,
- img: "https://gw.alipayobjects.com/zos/basement_prod/300a2523-67e0-4cbf-9d4a-67c077b40395.svg",
- width: 16,
- height: 16,
- offset: -5,
- },
- anchorPoints: [
- [0, 0.5],
- [1, 0.5],
- ],
- },
- shapeType: "modelRect",
- drawShape: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).preRect,
- r = void 0 === n ? {} : n,
- i = this.getShapeStyle(t),
- o = this.getSize(t),
- a = o[0],
- s = o[1],
- u = e.addShape("rect", {
- attrs: i,
- className: "".concat(this.type, "-keyShape"),
- name: "".concat(this.type, "-keyShape"),
- draggable: !0,
- });
- e.shapeMap["".concat(this.type, "-keyShape")] = u;
- var c = r.show,
- l = Object(p.__rest)(r, ["show"]);
- return (
- c &&
- (e.shapeMap["pre-rect"] = e.addShape("rect", {
- attrs: Object(p.__assign)(
- { x: -a / 2, y: -s / 2, height: s },
- l
- ),
- className: "pre-rect",
- name: "pre-rect",
- draggable: !0,
- })),
- this.drawLogoIcon(t, e),
- this.drawStateIcon(t, e),
- this.drawLinkPoints(t, e),
- u
- );
- },
- drawLogoIcon: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).logoIcon,
- r = void 0 === n ? {} : n,
- i = this.getSize(t)[0];
- if (r.show) {
- var o = r.width,
- a = r.height,
- s = r.x,
- u = r.y,
- c = r.offset,
- l = r.text,
- f = Object(p.__rest)(r, [
- "width",
- "height",
- "x",
- "y",
- "offset",
- "text",
- ]);
- e.shapeMap["rect-logo-icon"] = l
- ? e.addShape("text", {
- attrs: Object(p.__assign)(
- {
- x: 0,
- y: 0,
- fontSize: 12,
- fill: "#000",
- stroke: "#000",
- textBaseline: "middle",
- textAlign: "center",
- },
- f
- ),
- className: "rect-logo-icon",
- name: "rect-logo-icon",
- draggable: !0,
- })
- : e.addShape("image", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, f), {
- x: s || -i / 2 + o + c,
- y: u || -a / 2,
- width: o,
- height: a,
- }),
- className: "rect-logo-icon",
- name: "rect-logo-icon",
- draggable: !0,
- });
- }
- },
- drawStateIcon: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).stateIcon,
- r = void 0 === n ? {} : n,
- i = this.getSize(t)[0];
- if (r.show) {
- var o = r.width,
- a = r.height,
- s = r.x,
- u = r.y,
- c = r.offset,
- l = r.text,
- f = Object(p.__rest)(r, [
- "width",
- "height",
- "x",
- "y",
- "offset",
- "text",
- ]);
- e.shapeMap["rect-state-icon"] = l
- ? e.addShape("text", {
- attrs: Object(p.__assign)(
- {
- x: 0,
- y: 0,
- fontSize: 12,
- fill: "#000",
- stroke: "#000",
- textBaseline: "middle",
- textAlign: "center",
- },
- f
- ),
- className: "rect-state-icon",
- name: "rect-state-icon",
- draggable: !0,
- })
- : e.addShape("image", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, f), {
- x: s || i / 2 - o + c,
- y: u || -a / 2,
- width: o,
- height: a,
- }),
- className: "rect-state-icon",
- name: "rect-state-icon",
- draggable: !0,
- });
- }
- },
- drawLinkPoints: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).linkPoints,
- r = void 0 === n ? {} : n,
- i = r.top,
- o = r.left,
- a = r.right,
- s = r.bottom,
- u = r.size,
- c = r.r,
- l = Object(p.__rest)(r, [
- "top",
- "left",
- "right",
- "bottom",
- "size",
- "r",
- ]),
- f = this.getSize(t),
- h = f[0],
- d = f[1];
- o &&
- (e.shapeMap["link-point-left"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: -h / 2,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: "link-point-left",
- name: "link-point-left",
- isAnchorPoint: !0,
- })),
- a &&
- (e.shapeMap["link-point-right"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: h / 2,
- y: 0,
- r: u / 2 || c || 5,
- }),
- className: "link-point-right",
- name: "link-point-right",
- isAnchorPoint: !0,
- })),
- i &&
- (e.shapeMap["link-point-top"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: -d / 2,
- r: u / 2 || c || 5,
- }),
- className: "link-point-top",
- name: "link-point-top",
- isAnchorPoint: !0,
- })),
- s &&
- (e.shapeMap["link-point-bottom"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, l), {
- x: 0,
- y: d / 2,
- r: u / 2 || c || 5,
- }),
- className: "link-point-bottom",
- name: "link-point-bottom",
- isAnchorPoint: !0,
- }));
- },
- drawLabel: function (t, e) {
- var n = this.getOptions(t),
- r = n.labelCfg,
- i = void 0 === r ? {} : r,
- o = n.logoIcon,
- a = void 0 === o ? {} : o,
- s = n.descriptionCfg,
- u = void 0 === s ? {} : s,
- c = this.getSize(t)[0],
- l = null,
- f = a.show,
- h = a.width,
- d = -c / 2 + i.offset;
- f && (d = -c / 2 + h + i.offset);
- var v = i.style,
- y = u.style,
- m = u.paddingTop;
- return (
- Object(g.isString)(t.description)
- ? ((l = e.addShape("text", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, v), {
- x: d,
- y: -5,
- text: t.label,
- }),
- className: "text-shape",
- name: "text-shape",
- draggable: !0,
- labelRelated: !0,
- })),
- (e.shapeMap["text-shape"] = l),
- (e.shapeMap["rect-description"] = e.addShape("text", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, y), {
- x: d,
- y: 17 + (m || 0),
- text: t.description,
- }),
- className: "rect-description",
- name: "rect-description",
- draggable: !0,
- labelRelated: !0,
- })))
- : ((l = e.addShape("text", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, v), {
- x: d,
- y: 7,
- text: t.label,
- }),
- className: "text-shape",
- name: "text-shape",
- draggable: !0,
- labelRelated: !0,
- })),
- (e.shapeMap["text-shape"] = l)),
- l
- );
- },
- getShapeStyle: function (t) {
- var e = (this.mergeStyle || this.getOptions(t)).style,
- n = { stroke: t.color },
- r = Object(g.mix)({}, e, n),
- i = this.getSize(t),
- o = r.width || i[0],
- a = r.height || i[1];
- return Object(p.__assign)(
- { x: -o / 2, y: -a / 2, width: o, height: a },
- r
- );
- },
- update: function (t, e) {
- var n = this.mergeStyle || this.getOptions(t),
- r = n.style,
- i = void 0 === r ? {} : r,
- o = n.labelCfg,
- a = void 0 === o ? {} : o,
- s = n.descriptionCfg,
- u = void 0 === s ? {} : s,
- c = this.getSize(t),
- l = c[0],
- f = c[1];
- e.get("keyShape").attr(
- Object(p.__assign)(Object(p.__assign)({}, i), {
- x: -l / 2,
- y: -f / 2,
- width: l,
- height: f,
- })
- );
- var h = e.getContainer(),
- d =
- h.shapeMap["rect-logo-icon"] ||
- h.find(function (t) {
- return "rect-logo-icon" === t.get("className");
- }),
- v = d ? d.attr() : {},
- y = Object(g.mix)({}, v, t.logoIcon),
- m = y.width;
- void 0 === m && (m = this.options.logoIcon.width);
- var b = t.logoIcon ? t.logoIcon.show : void 0,
- x = a.offset,
- w = -l / 2 + m + x;
- b || void 0 === b || (w = -l / 2 + x);
- var E =
- h.shapeMap["node-label"] ||
- h.find(function (t) {
- return "node-label" === t.get("className");
- }),
- _ =
- h.shapeMap["rect-description"] ||
- h.find(function (t) {
- return "rect-description" === t.get("className");
- });
- if (t.label)
- if (E) {
- var S = t.labelCfg ? t.labelCfg.style : {},
- O = Object(g.mix)({}, E.attr(), S);
- t.label && (O.text = t.label),
- (O.x = w),
- Object(g.isString)(t.description) && (O.y = -5),
- _ && (_.resetMatrix(), _.attr({ x: w })),
- E.resetMatrix(),
- E.attr(O);
- } else
- h.shapeMap["node-label"] = h.addShape("text", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, a.style), {
- x: w,
- y: t.description ? -5 : 7,
- text: t.label,
- }),
- className: "node-label",
- name: "node-label",
- draggable: !0,
- labelRelated: !0,
- });
- if (Object(g.isString)(t.description)) {
- var M = u.paddingTop;
- if (_) {
- S = t.descriptionCfg ? t.descriptionCfg.style : {};
- var k = Object(g.mix)({}, _.attr(), S);
- Object(g.isString)(t.description) && (k.text = t.description),
- (k.x = w),
- _.resetMatrix(),
- _.attr(
- Object(p.__assign)(Object(p.__assign)({}, k), {
- y: 17 + (M || 0),
- })
- );
- } else
- h.shapeMap["rect-description"] = h.addShape("text", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, u.style), {
- x: w,
- y: 17 + (M || 0),
- text: t.description,
- }),
- className: "rect-description",
- name: "rect-description",
- draggable: !0,
- labelRelated: !0,
- });
- }
- var A =
- h.shapeMap["pre-rect"] ||
- h.find(function (t) {
- return "pre-rect" === t.get("className");
- });
- if (A && !A.destroyed) {
- var j = Object(g.mix)({}, A.attr(), t.preRect);
- A.attr(
- Object(p.__assign)(Object(p.__assign)({}, j), {
- x: -l / 2,
- y: -f / 2,
- height: f,
- })
- );
- }
- if (d && !d.destroyed)
- if (b || void 0 === b) {
- var C = y.width,
- I = y.height,
- T = y.x,
- N = y.y,
- P = y.offset,
- D = Object(p.__rest)(y, [
- "width",
- "height",
- "x",
- "y",
- "offset",
- ]);
- d.attr(
- Object(p.__assign)(Object(p.__assign)({}, D), {
- x: T || -l / 2 + C + P,
- y: N || -I / 2,
- width: C,
- height: I,
- })
- );
- } else d.remove(), delete h.shapeMap["pre-rect"];
- else b && this.drawLogoIcon(t, h);
- var L =
- h.shapeMap["rect-state-icon"] ||
- h.find(function (t) {
- return "rect-state-icon" === t.get("className");
- }),
- R = L ? L.attr() : {},
- B = Object(g.mix)({}, R, t.stateIcon);
- if (L) {
- B.show ||
- void 0 === B.show ||
- (L.remove(), delete h.shapeMap["rect-state-icon"]);
- var F = B.width,
- z = ((I = B.height), (T = B.x), (N = B.y), B.offset),
- G = Object(p.__rest)(B, [
- "width",
- "height",
- "x",
- "y",
- "offset",
- ]);
- L.attr(
- Object(p.__assign)(Object(p.__assign)({}, G), {
- x: T || l / 2 - F + z,
- y: N || -I / 2,
- width: F,
- height: I,
- })
- );
- } else B.show && this.drawStateIcon(t, h);
- this.updateLinkPoints(t, h);
- },
- getOptions: function (t, e) {
- return "move" === e
- ? t
- : Object(g.deepMix)(
- {},
- this.options,
- this.getCustomConfig(t) || {},
- t
- );
- },
- },
- "single-node"
- ),
- vr(
- "star",
- {
- options: {
- size: 60,
- style: {
- stroke: xr.defaultNode.style.stroke,
- fill: xr.defaultNode.style.fill,
- lineWidth: xr.defaultNode.style.lineWidth,
- },
- labelCfg: {
- style: {
- fill: xr.nodeLabel.style.fill,
- fontSize: xr.nodeLabel.style.fontSize,
- fontFamily: xr.windowFontFamily,
- },
- },
- linkPoints: {
- top: !1,
- right: !1,
- bottom: !1,
- left: !1,
- size: xr.defaultNode.linkPoints.size,
- lineWidth: xr.defaultNode.linkPoints.lineWidth,
- fill: xr.defaultNode.linkPoints.fill,
- stroke: xr.defaultNode.linkPoints.stroke,
- },
- icon: {
- show: !1,
- img: "https://gw.alipayobjects.com/zos/bmw-prod/5d015065-8505-4e7a-baec-976f81e3c41d.svg",
- width: 20,
- height: 20,
- },
- stateStyles: Object(p.__assign)({}, xr.nodeStateStyles),
- },
- shapeType: "star",
- labelPosition: "center",
- drawShape: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).icon,
- r = void 0 === n ? {} : n,
- i = this.getShapeStyle(t),
- o = e.addShape("path", {
- attrs: i,
- className: "".concat(this.type, "-keyShape"),
- name: "".concat(this.type, "-keyShape"),
- draggable: !0,
- });
- e.shapeMap["".concat(this.type, "-keyShape")] = o;
- var a = r.width,
- s = r.height,
- u = r.show,
- c = r.text;
- return (
- u &&
- (e.shapeMap["".concat(this.type, "-icon")] = c
- ? e.addShape("text", {
- attrs: Object(p.__assign)(
- {
- x: 0,
- y: 0,
- fontSize: 12,
- fill: "#000",
- stroke: "#000",
- textBaseline: "middle",
- textAlign: "center",
- },
- r
- ),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- })
- : e.addShape("image", {
- attrs: Object(p.__assign)({ x: -a / 2, y: -s / 2 }, r),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- })),
- this.drawLinkPoints(t, e),
- o
- );
- },
- drawLinkPoints: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).linkPoints,
- r = void 0 === n ? {} : n,
- i = r.top,
- o = r.left,
- a = r.right,
- s = r.leftBottom,
- u = r.rightBottom,
- c = r.size,
- l = r.r,
- f = Object(p.__rest)(r, [
- "top",
- "left",
- "right",
- "leftBottom",
- "rightBottom",
- "size",
- "r",
- ]),
- h = this.getSize(t)[0];
- if (a) {
- var d = Math.cos(0.1 * Math.PI) * h,
- g = Math.sin(0.1 * Math.PI) * h;
- e.shapeMap["link-point-right"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, f), {
- x: d,
- y: -g,
- r: c / 2 || l || 5,
- }),
- className: "link-point-right",
- name: "link-point-right",
- });
- }
- if (i) {
- (d = Math.cos(0.5 * Math.PI) * h),
- (g = Math.sin(0.5 * Math.PI) * h);
- e.shapeMap["link-point-top"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, f), {
- x: d,
- y: -g,
- r: c / 2 || l || 5,
- }),
- className: "link-point-top",
- name: "link-point-top",
- });
- }
- if (o) {
- (d = Math.cos(0.9 * Math.PI) * h),
- (g = Math.sin(0.9 * Math.PI) * h);
- e.shapeMap["link-point-left"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, f), {
- x: d,
- y: -g,
- r: c / 2 || l || 5,
- }),
- className: "link-point-left",
- name: "link-point-left",
- });
- }
- if (s) {
- (d = Math.cos(1.3 * Math.PI) * h),
- (g = Math.sin(1.3 * Math.PI) * h);
- e.shapeMap["link-point-bottom"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, f), {
- x: d,
- y: -g,
- r: c / 2 || l || 5,
- }),
- className: "link-point-left-bottom",
- name: "link-point-left-bottom",
- });
- }
- if (u) {
- (d = Math.cos(1.7 * Math.PI) * h),
- (g = Math.sin(1.7 * Math.PI) * h);
- e.shapeMap["link-point-right-bottom"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, f), {
- x: d,
- y: -g,
- r: c / 2 || l || 5,
- }),
- className: "link-point-right-bottom",
- name: "link-point-right-bottom",
- });
- }
- },
- getPath: function (t) {
- var e = this.getSize(t)[0],
- n = (3 * e) / 8,
- r = t.innerR || n;
- return dr.getStarPath(e, r);
- },
- getShapeStyle: function (t) {
- var e = (this.mergeStyle || this.getOptions(t)).style,
- n = { stroke: t.color },
- r = Object(g.mix)({}, e, n),
- i = this.getPath(t);
- return Object(p.__assign)({ path: i }, r);
- },
- update: function (t, e, n) {
- var r = e.getContainer(),
- i = this.getOptions({}).style,
- o = this.getPath(t),
- a = { stroke: t.color, path: o },
- s = e.get("keyShape"),
- u = Object(g.mix)({}, i, s.attr(), a);
- (u = Object(g.mix)(u, t.style)),
- this.updateShape(t, e, u, !0, n),
- this.updateLinkPoints(t, r);
- },
- updateLinkPoints: function (t, e) {
- var n = this.getOptions({}).linkPoints,
- r =
- e.shapeMap["link-point-left"] ||
- e.find(function (t) {
- return "link-point-left" === t.get("className");
- }),
- i =
- e.shapeMap["link-point-right"] ||
- e.find(function (t) {
- return "link-point-right" === t.get("className");
- }),
- o =
- e.shapeMap["link-point-top"] ||
- e.find(function (t) {
- return "link-point-top" === t.get("className");
- }),
- a =
- e.shapeMap["link-point-left-bottom"] ||
- e.find(function (t) {
- return "link-point-left-bottom" === t.get("className");
- }),
- s =
- e.shapeMap["link-point-left-bottom"] ||
- e.find(function (t) {
- return "link-point-right-bottom" === t.get("className");
- }),
- u = n,
- c = r || i || o || a || s;
- c && (u = c.attr());
- var l = Object(g.mix)({}, u, t.linkPoints),
- f = l.fill,
- h = l.stroke,
- d = l.lineWidth,
- v = l.size / 2;
- v || (v = l.r);
- var y = t.linkPoints
- ? t.linkPoints
- : {
- left: void 0,
- right: void 0,
- top: void 0,
- leftBottom: void 0,
- rightBottom: void 0,
- },
- m = y.left,
- b = y.right,
- x = y.top,
- w = y.leftBottom,
- E = y.rightBottom,
- _ = this.getSize(t)[0],
- S = { r: v, fill: f, stroke: h, lineWidth: d },
- O = Math.cos(0.1 * Math.PI) * _,
- M = Math.sin(0.1 * Math.PI) * _;
- i
- ? b || void 0 === b
- ? i.attr(
- Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- })
- )
- : (i.remove(), delete e.shapeMap["link-point-right"])
- : b &&
- (e.shapeMap["link-point-right"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- }),
- className: "link-point-right",
- name: "link-point-right",
- isAnchorPoint: !0,
- })),
- (O = Math.cos(0.5 * Math.PI) * _),
- (M = Math.sin(0.5 * Math.PI) * _),
- o
- ? x || void 0 === x
- ? o.attr(
- Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- })
- )
- : (o.remove(), delete e.shapeMap["link-point-top"])
- : x &&
- (e.shapeMap["link-point-top"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- }),
- className: "link-point-top",
- name: "link-point-top",
- isAnchorPoint: !0,
- })),
- (O = Math.cos(0.9 * Math.PI) * _),
- (M = Math.sin(0.9 * Math.PI) * _),
- r
- ? m || void 0 === m
- ? r.attr(
- Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- })
- )
- : (r.remove(), delete e.shapeMap["link-point-left"])
- : m &&
- (e.shapeMap["link-point-left"] = e.addShape("circle", {
- attrs: Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- }),
- className: "link-point-left",
- name: "link-point-left",
- isAnchorPoint: !0,
- })),
- (O = Math.cos(1.3 * Math.PI) * _),
- (M = Math.sin(1.3 * Math.PI) * _),
- a
- ? w || void 0 === w
- ? a.attr(
- Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- })
- )
- : (a.remove(), delete e.shapeMap["link-point-left-bottom"])
- : w &&
- (e.shapeMap["link-point-left-bottom"] = e.addShape(
- "circle",
- {
- attrs: Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- }),
- className: "link-point-left-bottom",
- name: "link-point-left-bottom",
- isAnchorPoint: !0,
- }
- )),
- (O = Math.cos(1.7 * Math.PI) * _),
- (M = Math.sin(1.7 * Math.PI) * _),
- s
- ? E || void 0 === E
- ? s.attr(
- Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- })
- )
- : (s.remove(), delete e.shapeMap["link-point-right-bottom"])
- : E &&
- (e.shapeMap["link-point-right-bottom"] = e.addShape(
- "circle",
- {
- attrs: Object(p.__assign)(Object(p.__assign)({}, S), {
- x: O,
- y: -M,
- }),
- className: "link-point-right-bottom",
- name: "link-point-right-bottom",
- isAnchorPoint: !0,
- }
- ));
- },
- },
- "single-node"
- );
- var Zs = dr.defaultSubjectColors;
- vr(
- "donut",
- {
- options: {
- size: xr.defaultNode.size,
- style: {
- x: 0,
- y: 0,
- stroke: xr.defaultNode.style.stroke,
- fill: xr.defaultNode.style.fill,
- lineWidth: xr.defaultNode.style.lineWidth,
- },
- labelCfg: {
- style: {
- fill: xr.nodeLabel.style.fill,
- fontSize: xr.nodeLabel.style.fontSize,
- fontFamily: xr.windowFontFamily,
- },
- },
- linkPoints: {
- top: !1,
- right: !1,
- bottom: !1,
- left: !1,
- size: xr.defaultNode.linkPoints.size,
- lineWidth: xr.defaultNode.linkPoints.lineWidth,
- fill: xr.defaultNode.linkPoints.fill,
- stroke: xr.defaultNode.linkPoints.stroke,
- },
- icon: {
- show: !1,
- img: "https://gw.alipayobjects.com/zos/bmw-prod/5d015065-8505-4e7a-baec-976f81e3c41d.svg",
- width: 20,
- height: 20,
- },
- stateStyles: Object(p.__assign)({}, xr.nodeStateStyles),
- },
- shapeType: "circle",
- labelPosition: "center",
- drawShape: function (t, e) {
- var n = (this.mergeStyle || this.getOptions(t)).icon,
- r = void 0 === n ? {} : n,
- i = this.getShapeStyle(t),
- o = Object(g.deepMix)({}, r, t.icon),
- a = e.addShape("circle", {
- attrs: i,
- className: "".concat(this.type, "-keyShape"),
- draggable: !0,
- name: "".concat(this.type, "-keyShape"),
- });
- e.shapeMap["".concat(this.type, "-keyShape")] = a;
- var s = o.width,
- u = o.height,
- c = o.show,
- l = o.text;
- return (
- c &&
- (e.shapeMap["".concat(this.type, "-icon")] = l
- ? e.addShape("text", {
- attrs: Object(p.__assign)(
- {
- x: 0,
- y: 0,
- fontSize: 12,
- fill: "#000",
- stroke: "#000",
- textBaseline: "middle",
- textAlign: "center",
- },
- o
- ),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- })
- : e.addShape("image", {
- attrs: Object(p.__assign)({ x: -s / 2, y: -u / 2 }, o),
- className: "".concat(this.type, "-icon"),
- name: "".concat(this.type, "-icon"),
- draggable: !0,
- })),
- Ks(t, e, a),
- this.drawLinkPoints(t, e),
- a
- );
- },
- updateShape: function (t, e, n, r, i) {
- var o = e.get("keyShape");
- o.attr(Object(p.__assign)({}, n)),
- $s(t, e, o),
- this.updateLabel(t, e, i),
- r && this.updateIcon(t, e);
- },
- },
- "circle"
- );
- var Ks = function (t, e, n) {
- var r = t.donutAttrs,
- i = void 0 === r ? {} : r,
- o = t.donutColorMap,
- a = void 0 === o ? {} : o,
- s = Object.keys(i).length;
- if (i && s > 1) {
- var u = Js(i, a),
- c = u.configs,
- l = u.totalValue;
- if (l) {
- var f = tu(n),
- h = f.lineWidth,
- d = f.arcR,
- p = [d, 0],
- g = 0;
- if (1 === s)
- return void Qs(e, {
- arcR: d,
- arcBegin: p,
- beginAngle: g,
- config: c[0],
- fanIndex: 0,
- lineWidth: h,
- totalValue: l,
- drawWhole: !0,
- });
- for (var v = 0; v < c.length; v++) {
- var y = Qs(e, {
- arcR: d,
- arcBegin: p,
- beginAngle: g,
- config: c[v],
- fanIndex: v,
- lineWidth: h,
- totalValue: l,
- });
- if (y.shouldEnd) return;
- (p = y.arcBegin), (g = y.beginAngle);
- }
- }
- }
- },
- Qs = function (t, e) {
- var n,
- r,
- i,
- o = e.arcR,
- a = e.arcBegin,
- s = e.beginAngle,
- u = e.config,
- c = e.fanIndex,
- l = e.lineWidth,
- f = e.totalValue,
- h = e.drawWhole,
- d = void 0 !== h && h,
- p = e.updateShape,
- g = void 0 === p ? void 0 : p,
- v = u.value / f;
- if (v < 0.001)
- return { beginAngle: s, arcBegin: a, shape: void 0, shouldEnd: !1 };
- if (d || v > 0.999) (n = [o, 1e-4]), (i = 1);
- else {
- var y = v * Math.PI * 2;
- (r = s + y),
- (n = [o * Math.cos(r), -o * Math.sin(r)]),
- (i = y > Math.PI ? 1 : 0);
- }
- var m = {
- path: [
- ["M", a[0], a[1]],
- ["A", o, o, 0, i, 0, n[0], n[1]],
- ["L", n[0], n[1]],
- ],
- stroke:
- u.color ||
- (null == g ? void 0 : g.attr("stroke")) ||
- Zs[c % Zs.length],
- lineWidth: l,
- };
- return (
- g
- ? g.attr(m)
- : (t.shapeMap["".concat("fan-shape-").concat(c)] = t.addShape(
- "path",
- {
- attrs: m,
- name: "".concat("fan-shape-").concat(c),
- draggable: !0,
- }
- )),
- {
- beginAngle: r,
- arcBegin: n,
- shape: t.shapeMap["".concat("fan-shape-").concat(c)],
- shouldEnd: d || v > 0.999,
- }
- );
- },
- $s = function (t, e, n) {
- var r = t.donutAttrs,
- i = t.donutColorMap,
- o = void 0 === i ? {} : i,
- a = {},
- s = e.getContainer();
- if (r) {
- var u = Js(r, o),
- c = u.configs,
- l = u.totalValue;
- if (l)
- for (
- var f = tu(n),
- h = f.lineWidth,
- d = f.arcR,
- p = [d, 0],
- g = 0,
- v = 0;
- v < c.length;
- v++
- ) {
- var y = "".concat("fan-shape-").concat(v),
- m = Qs(s, {
- arcR: d,
- arcBegin: p,
- beginAngle: g,
- config: c[v],
- fanIndex: v,
- lineWidth: h,
- totalValue: l,
- drawWhole: 1 === c.length,
- updateShape: s.shapeMap[y],
- });
- if ((m.shape && (a[y] = !0), m.shouldEnd)) break;
- (p = m.arcBegin), (g = m.beginAngle);
- }
- }
- Object.keys(s.shapeMap)
- .filter(function (t) {
- return t.includes("fan-shape-");
- })
- .forEach(function (t) {
- a[t] || (s.shapeMap[t].remove(!0), delete s.shapeMap[t]);
- });
- },
- Js = function (t, e) {
- var n = 0,
- r = [];
- return (
- Object.keys(t).forEach(function (i) {
- var o = +t[i];
- isNaN(o) || (r.push({ key: i, value: o, color: e[i] }), (n += o));
- }),
- { totalValue: n, configs: r }
- );
- },
- tu = function (t) {
- var e = t.attr("r"),
- n = 0.6 * e;
- return { lineWidth: e - n, arcR: (e + n) / 2 };
- },
- eu = function (t) {
- var e = t.x,
- n = t.y;
- return {
- x: e,
- y: n,
- centerX: e,
- centerY: n,
- minX: e,
- minY: n,
- maxX: e,
- maxY: n,
- height: 0,
- width: 0,
- };
- },
- nu = function (t) {
- for (var e = [], n = {}, r = t.length - 1; r >= 0; r--) {
- var i = t[r];
- (i.id = "".concat(i.x, "|||").concat(i.y)),
- n[i.id] || ((n[i.id] = i), e.push(i));
- }
- return e;
- },
- ru = function (t) {
- return nu(t);
- },
- iu = function (t, e) {
- return t.width || t.height
- ? {
- centerX: t.centerX,
- centerY: t.centerY,
- minX: t.minX - e,
- minY: t.minY - e,
- maxX: t.maxX + e,
- maxY: t.maxY + e,
- height: t.height + 2 * e,
- width: t.width + 2 * e,
- }
- : t;
- },
- ou = function (t, e, n) {
- var r = (function (t, e) {
- var n = Math.abs(t.x - e.centerX),
- r = Math.abs(t.y - e.centerY);
- return 0 === n && 0 === r ? 0 : n / e.width > r / e.height;
- })(e, t);
- if (0 === r) {
- var i = t.centerX,
- o = t.centerY;
- return (
- n.y < e.y
- ? (o = t.minY)
- : n.x > e.x
- ? (i = t.maxX)
- : n.x < e.x
- ? (i = t.minX)
- : n.x === e.x && (o = t.maxY),
- { x: i, y: o }
- );
- }
- return r
- ? { x: e.x > t.centerX ? t.maxX : t.minX, y: e.y }
- : { x: e.x, y: e.y > t.centerY ? t.maxY : t.minY };
- },
- au = function (t, e) {
- var n = Math.min(t.minX, e.minX),
- r = Math.min(t.minY, e.minY),
- i = Math.max(t.maxX, e.maxX),
- o = Math.max(t.maxY, e.maxY);
- return {
- centerX: (n + i) / 2,
- centerY: (r + o) / 2,
- minX: n,
- minY: r,
- maxX: i,
- maxY: o,
- height: o - r,
- width: i - n,
- };
- },
- su = function (t) {
- return [
- { x: t.minX, y: t.minY },
- { x: t.maxX, y: t.minY },
- { x: t.maxX, y: t.maxY },
- { x: t.minX, y: t.maxY },
- ];
- },
- uu = function (t, e) {
- var n = t.x,
- r = t.y;
- return n < e.minX || n > e.maxX || r < e.minY || r > e.maxY;
- },
- cu = function (t, e) {
- return Math.abs(t.x - e.x) + Math.abs(t.y - e.y);
- },
- lu = function (t, e, n, r, i) {
- return (
- cu(t, e) +
- cu(t, n) +
- (function (t, e) {
- var n = 0;
- return (
- e.forEach(function (e) {
- e && (t.x === e.x && (n += -2), t.y === e.y && (n += -2));
- }),
- n
- );
- })(t, [e, n, r, i])
- );
- },
- fu = function t(e, n, r, i, o) {
- void 0 === o && (o = 0),
- e.unshift(n[i]),
- r[i] && r[i] !== i && o <= 100 && t(e, n, r, r[i], o + 1);
- },
- hu = function (t, e, n, r) {
- var i = n.x - t.x,
- o = n.y - t.y,
- a = r.x - t.x,
- s = r.y - t.y,
- u = n.x - e.x,
- c = n.y - e.y,
- l = r.x - e.x,
- f = r.y - e.y;
- return (
- (i * s - o * a) * (u * f - c * l) <= 0 &&
- (i * c - o * u) * (a * f - s * l) <= 0
- );
- },
- du = function (t, e, n) {
- if (n.width || n.height) {
- var r = su(n),
- i = r[0],
- o = r[1],
- a = r[2],
- s = r[3];
- return (
- hu(t, e, i, o) ||
- hu(t, e, i, s) ||
- hu(t, e, o, a) ||
- hu(t, e, a, s)
- );
- }
- return !1;
- },
- pu = function (t, e, n, r) {
- var i = [];
- return (
- t.forEach(function (t) {
- if (t !== e && (t.x === e.x || t.y === e.y)) {
- if (du(t, e, n) || du(t, e, r)) return;
- i.push(t);
- }
- }),
- nu(i)
- );
- },
- gu = function (t, e) {
- var n = [],
- r = t[0];
- return (
- n.push("M".concat(r.x, " ").concat(r.y)),
- t.forEach(function (r, i) {
- var o = t[i + 1],
- a = t[i + 2];
- if (o && a)
- if (
- (function (t, e, n) {
- return !(
- (t.x === e.x && e.x === n.x) ||
- (t.y === e.y && e.y === n.y)
- );
- })(r, o, a)
- ) {
- var s = (function (t, e, n, r) {
- var i = cu(t, e),
- o = cu(n, e);
- return (
- i < r && (r = i),
- o < r && (r = o),
- [
- {
- x: e.x - (r / i) * (e.x - t.x),
- y: e.y - (r / i) * (e.y - t.y),
- },
- {
- x: e.x - (r / o) * (e.x - n.x),
- y: e.y - (r / o) * (e.y - n.y),
- },
- ]
- );
- })(r, o, a, e),
- u = s[0],
- c = s[1];
- n.push("L".concat(u.x, " ").concat(u.y)),
- n.push(
- "Q"
- .concat(o.x, " ")
- .concat(o.y, " ")
- .concat(c.x, " ")
- .concat(c.y)
- ),
- n.push("L".concat(c.x, " ").concat(c.y));
- } else n.push("L".concat(o.x, " ").concat(o.y));
- else o && n.push("L".concat(o.x, " ").concat(o.y));
- }),
- n.join("")
- );
- },
- vu = function (t, e, n, r, i) {
- var o, a;
- if (n && n.getType())
- if ("combo" === n.getType()) {
- var s = n.getKeyShape().getBBox();
- if (s) {
- var u = n.getModel(),
- c = u.x,
- l = u.y;
- ((o = {
- x: c,
- y: l,
- width: s.width,
- height: s.height,
- minX: s.minX + c,
- maxX: s.maxX + c,
- minY: s.minY + l,
- maxY: s.maxY + l,
- }).centerX = (o.minX + o.maxX) / 2),
- (o.centerY = (o.minY + o.maxY) / 2);
- } else o = eu(t);
- } else o = n && n.getBBox();
- else o = eu(t);
- if (r && r.getType())
- if ("combo" === r.getType()) {
- var f = r.getKeyShape().getBBox();
- if (f) {
- var h = r.getModel(),
- d = h.x,
- p = h.y;
- ((a = {
- x: d,
- y: p,
- width: f.width,
- height: f.height,
- minX: f.minX + d,
- maxX: f.maxX + d,
- minY: f.minY + p,
- maxY: f.maxY + p,
- }).centerX = (a.minX + a.maxX) / 2),
- (a.centerY = (a.minY + a.maxY) / 2);
- } else a = eu(e);
- } else a = r && r.getBBox();
- else a = eu(e);
- var g = iu(o, i),
- v = iu(a, i),
- y = ou(g, t, e),
- m = ou(v, e, t),
- b = (function (t) {
- void 0 === t && (t = []);
- var e = [],
- n = [];
- t.forEach(function (t) {
- e.push(t.x), n.push(t.y);
- });
- var r = Math.min.apply(Math, e),
- i = Math.max.apply(Math, e),
- o = Math.min.apply(Math, n),
- a = Math.max.apply(Math, n);
- return {
- centerX: (r + i) / 2,
- centerY: (o + a) / 2,
- maxX: i,
- maxY: a,
- minX: r,
- minY: o,
- height: a - o,
- width: i - r,
- };
- })([y, m]),
- x = au(g, b),
- w = au(v, b),
- E = [];
- E = E.concat(su(x)).concat(su(w));
- var _ = { x: (t.x + e.x) / 2, y: (t.y + e.y) / 2 };
- [b, x, w].forEach(function (t) {
- E = E.concat(
- (function (t, e) {
- return (function (t, e) {
- return e < t.minX || e > t.maxX
- ? []
- : [
- { x: e, y: t.minY },
- { x: e, y: t.maxY },
- ];
- })(t, e.x).concat(
- (function (t, e) {
- return e < t.minY || e > t.maxY
- ? []
- : [
- { x: t.minX, y: e },
- { x: t.maxX, y: e },
- ];
- })(t, e.y)
- );
- })(t, _).filter(function (t) {
- return uu(t, g) && uu(t, v);
- })
- );
- }),
- [
- { x: y.x, y: m.y },
- { x: m.x, y: y.y },
- ].forEach(function (t) {
- uu(t, g) && uu(t, v) && E.push(t);
- }),
- E.unshift(y),
- E.push(m);
- var S = (function (t, e, n, r, i, o, a) {
- var s,
- u = [],
- c = (((s = {})[e.id] = e), s),
- l = {},
- f = {},
- h = {};
- (f[e.id] = 0), (h[e.id] = lu(e, n, e));
- var d = new yu();
- d.add({ id: e.id, value: h[e.id] });
- var p,
- g = {};
- for (
- t.forEach(function (t) {
- g[t.id] = t;
- });
- Object.keys(c).length;
-
- ) {
- var v = d.minId(!1);
- if (!v) break;
- if ((p = c[v]) === n) {
- var y = [];
- return fu(y, g, l, n.id), y;
- }
- delete c[p.id], d.remove(p.id), u.push(p);
- var m = pu(t, p, r, i);
- m.forEach(function (t) {
- if (-1 === u.indexOf(t)) {
- var r = t.id;
- c[r] || (c[r] = t);
- var i = h[p.id] + cu(p, t);
- (f[r] && i >= f[r]) ||
- ((l[r] = p.id),
- (f[r] = i),
- (h[r] = f[r] + lu(t, n, e, o, a))),
- d.add({ id: r, value: h[r] });
- }
- });
- }
- return [e, n];
- })((E = nu(E)), y, m, o, a, t, e);
- return S.unshift(t), S.push(e), ru(S);
- },
- yu = (function () {
- function t() {
- (this.arr = []), (this.map = {}), (this.arr = []), (this.map = {});
- }
- return (
- (t.prototype._innerAdd = function (t, e) {
- for (var n = [0, e - 1]; n[1] - n[0] > 1; ) {
- var r = Math.floor((n[0] + n[1]) / 2);
- if (this.arr[r].value > t.value) n[1] = r;
- else {
- if (!(this.arr[r].value < t.value))
- return this.arr.splice(r, 0, t), void (this.map[t.id] = !0);
- n[0] = r;
- }
- }
- this.arr.splice(n[1], 0, t), (this.map[t.id] = !0);
- }),
- (t.prototype.add = function (t) {
- delete this.map[t.id];
- var e = this.arr.length;
- return e
- ? this.arr[e - 1].value < t.value
- ? (this.arr.push(t), void (this.map[t.id] = !0))
- : void this._innerAdd(t, e)
- : (this.arr.push(t), void (this.map[t.id] = !0));
- }),
- (t.prototype.remove = function (t) {
- this.map[t] && delete this.map[t];
- }),
- (t.prototype._clearAndGetMinId = function () {
- for (var t, e = this.arr.length - 1; e >= 0; e--)
- this.map[this.arr[e].id]
- ? (t = this.arr[e].id)
- : this.arr.splice(e, 1);
- return t;
- }),
- (t.prototype._findFirstId = function () {
- for (; this.arr.length; ) {
- var t = this.arr.shift();
- if (this.map[t.id]) return t.id;
- }
- }),
- (t.prototype.minId = function (t) {
- return t ? this._clearAndGetMinId() : this._findFirstId();
- }),
- t
- );
- })(),
- mu = {
- offset: 20,
- maxAllowedDirectionChange: Math.PI / 2,
- maximumLoops: 2e3,
- gridSize: 10,
- directions: [
- { stepX: 1, stepY: 0 },
- { stepX: -1, stepY: 0 },
- { stepX: 0, stepY: 1 },
- { stepX: 0, stepY: -1 },
- ],
- get penalties() {
- return { 0: 0, 45: this.gridSize / 2, 90: this.gridSize / 2 };
- },
- distFunc: function (t, e) {
- return Math.abs(t.x - e.x) + Math.abs(t.y - e.y);
- },
- fallbackRoute: function (t, e, n, r, i) {
- return ru(vu(t, e, n, r, i.offset));
- },
- },
- bu =
- (Math.PI,
- function (t, e) {
- var n = Math.round(Math.abs(t / e));
- return n < 0 ? 0 : (t < 0 ? -1 : 1) * n;
- }),
- xu = function (t, e) {
- var n = e.x - t.x,
- r = e.y - t.y;
- return n || r ? Math.atan2(r, n) : 0;
- },
- wu = function (t, e) {
- var n = Math.abs(t - e);
- return n > Math.PI ? 2 * Math.PI - n : n;
- },
- Eu = function (t, e, n) {
- for (var r = 1 / 0, i = 0, o = e.length; i < o; i++) {
- var a = n(t, e[i]);
- a < r && (r = a);
- }
- return r;
- },
- _u = function (t, e, n, r, i) {
- var o = [];
- if (!n) return [t];
- var a = i.directions,
- s = i.offset,
- u = n.getBBox(),
- c = e.x > u.minX && e.x < u.maxX && e.y > u.minY && e.y < u.maxY,
- l = iu(u, s);
- for (var f in l) l[f] = bu(l[f], i.gridSize);
- if (c) {
- for (var h = 0, d = a; h < d.length; h++) {
- var p = d[h],
- g = [
- [
- { x: l.minX, y: l.minY },
- { x: l.maxX, y: l.minY },
- ],
- [
- { x: l.minX, y: l.minY },
- { x: l.minX, y: l.maxY },
- ],
- [
- { x: l.maxX, y: l.minY },
- { x: l.maxX, y: l.maxY },
- ],
- [
- { x: l.minX, y: l.maxY },
- { x: l.maxX, y: l.maxY },
- ],
- ];
- for (f = 0; f < 4; f++) {
- var v = g[f],
- y = dr.getLineIntersect(
- t,
- { x: t.x + p.stepX * l.width, y: t.y + p.stepY * l.height },
- v[0],
- v[1]
- );
- y &&
- !du(t, y, u) &&
- ((y.id = "".concat(y.x, "|||").concat(y.y)), o.push(y));
- }
- }
- return o;
- }
- var m = ou(l, t, r);
- return (m.id = "".concat(m.x, "|||").concat(m.y)), [m];
- },
- Su = function (t, e, n, r) {
- var i = xu(t, e),
- o = n[t.id];
- if (!o) {
- var a = xu(r, t);
- return wu(a, i);
- }
- var s = xu({ x: o.x, y: o.y }, t);
- return wu(s, i);
- },
- Ou = function (t, e, n, r, i, o, a) {
- var s = [r],
- u = r,
- c = t.id,
- l = t.x,
- f = t.y,
- h = { x: l, y: f, id: c };
- Su(h, o, e, n) &&
- ((u = {
- x: o.x === r.x ? r.x : h.x * a,
- y: o.y === r.y ? r.y : h.y * a,
- }),
- s.unshift(u));
- for (var d = e[c]; d && d.id !== c; ) {
- var p = { x: l, y: f, id: c },
- g = { x: d.x, y: d.y, id: d.id };
- Su(g, p, e, n) &&
- ((u = {
- x: g.x === p.x ? u.x : g.x * a,
- y: g.y === p.y ? u.y : g.y * a,
- }),
- s.unshift(u)),
- (l = g.x),
- (f = g.y),
- (d = e[(c = g.id)]);
- }
- return (
- (s[0].x = l === n.x ? i.x : u.x),
- (s[0].y = f === n.y ? i.y : u.y),
- s.unshift(i),
- s
- );
- },
- Mu = function (t, e, n, r, i) {
- if (isNaN(t.x) || isNaN(e.x)) return [];
- var o = Object(g.deepMix)(mu, i);
- o.obstacles = o.obstacles || [];
- var a = o.penalties,
- s = o.gridSize,
- u = (function (t, e, n) {
- var r = {};
- return (
- t.forEach(function (t) {
- if (t)
- for (
- var i = iu(t.getBBox(), n), o = bu(i.minX, e);
- o <= bu(i.maxX, e);
- o += 1
- )
- for (var a = bu(i.minY, e); a <= bu(i.maxY, e); a += 1)
- r["".concat(o, "|||").concat(a)] = !0;
- }),
- r
- );
- })(o.obstacles.concat([n, r]), s, o.offset),
- c = { x: bu(t.x, s), y: bu(t.y, s) },
- l = { x: bu(e.x, s), y: bu(e.y, s) };
- (t.id = "".concat(c.x, "|||").concat(c.y)),
- (e.id = "".concat(l.x, "|||").concat(l.y));
- var f = _u(c, t, n, l, o),
- h = _u(l, e, r, c, o);
- f.forEach(function (t) {
- delete u[t.id];
- }),
- h.forEach(function (t) {
- delete u[t.id];
- });
- for (
- var d = {}, p = {}, v = {}, y = {}, m = {}, b = new yu(), x = 0;
- x < f.length;
- x++
- ) {
- var w = f[x];
- (d[w.id] = w),
- (y[w.id] = 0),
- (m[w.id] = Eu(w, h, o.distFunc)),
- b.add({ id: w.id, value: m[w.id] });
- }
- var E,
- _,
- S,
- O,
- M,
- k,
- A = o.maximumLoops,
- j = 1 / 0,
- C = {};
- for (
- h.forEach(function (t) {
- C["".concat(t.x, "|||").concat(t.y)] = !0;
- }),
- Object.keys(d).forEach(function (t) {
- var e = d[t].id;
- m[e] <= j && ((j = m[e]), (E = d[e]));
- });
- Object.keys(d).length > 0 && A > 0;
-
- ) {
- var I = b.minId((A + 1) % 30 == 0);
- if (!I) break;
- if (((E = d[I]), C["".concat(E.x, "|||").concat(E.y)]))
- return Ou(E, v, c, e, t, l, s);
- delete d[E.id], b.remove(E.id), (p[E.id] = !0);
- for (x = 0; x < o.directions.length; x++) {
- _ = o.directions[x];
- var T = ""
- .concat(Math.round(E.x) + _.stepX, "|||")
- .concat(Math.round(E.y) + _.stepY);
- if (
- ((S = { x: E.x + _.stepX, y: E.y + _.stepY, id: T }),
- !p[T] &&
- !((k = Su(E, S, v, c)) > o.maxAllowedDirectionChange || u[T]))
- ) {
- d[T] || (d[T] = S);
- var N = a[k];
- (O = o.distFunc(E, S) + (isNaN(N) ? s : N)), (M = y[E.id] + O);
- var P = y[T];
- (P && M >= P) ||
- ((v[T] = E),
- (y[T] = M),
- (m[T] = M + Eu(S, h, o.distFunc)),
- b.add({ id: T, value: m[T] }));
- }
- }
- A -= 1;
- }
- return o.fallbackRoute(t, e, n, r, o);
- };
- yr(
- "polyline",
- {
- options: {
- color: xr.defaultEdge.color,
- size: xr.defaultEdge.size,
- style: {
- radius: 0,
- offset: 15,
- x: 0,
- y: 0,
- stroke: xr.defaultEdge.style.stroke,
- lineAppendWidth: xr.defaultEdge.style.lineAppendWidth,
- },
- labelCfg: {
- style: {
- fill: xr.edgeLabel.style.fill,
- fontSize: xr.edgeLabel.style.fontSize,
- fontFamily: xr.windowFontFamily,
- },
- },
- routeCfg: {
- obstacles: [],
- maxAllowedDirectionChange: Math.PI,
- maximumLoops: 500,
- gridSize: 10,
- },
- stateStyles: Object(p.__assign)({}, xr.edgeStateStyles),
- },
- shapeType: "polyline",
- labelPosition: "center",
- drawShape: function (t, e) {
- var n = this.getShapeStyle(t);
- 0 === n.radius && delete n.radius;
- var r = e.addShape("path", {
- className: "edge-shape",
- name: "edge-shape",
- attrs: n,
- });
- return (e.shapeMap["edge-shape"] = r), r;
- },
- getShapeStyle: function (t) {
- var e = this.options.style,
- n = { stroke: t.color },
- r = Object(g.mix)({}, e, n, t.style);
- (t = this.getPathPoints(t)),
- (this.radius = r.radius),
- (this.offset = r.offset);
- var i = t.startPoint,
- o = t.endPoint,
- a = this.getControlPoints(t),
- s = [i];
- a && (s = s.concat(a)), s.push(o);
- var u = t.sourceNode,
- c = t.targetNode,
- l = r.radius,
- f = this.options.routeCfg,
- h = Object(g.mix)({}, f, t.routeCfg);
- h.offset = r.offset;
- var d = this.getPath(s, u, c, l, h, !Boolean(a));
- return (
- ((Object(g.isArray)(d) && d.length <= 1) ||
- (Object(g.isString)(d) && -1 === d.indexOf("L"))) &&
- (d = "M0 0, L0 0"),
- (isNaN(i.x) || isNaN(i.y) || isNaN(o.x) || isNaN(o.y)) &&
- (d = "M0 0, L0 0"),
- Object(g.mix)({}, xr.defaultEdge.style, r, {
- lineWidth: t.size,
- path: d,
- })
- );
- },
- updateShapeStyle: function (t, e) {
- var n = e.getContainer();
- if (e.isVisible()) {
- var r = { stroke: t.color },
- i =
- n.shapeMap["edge-shape"] ||
- n.find(function (t) {
- return "edge-shape" === t.get("className");
- }) ||
- e.getKeyShape(),
- o = t.size,
- a = (t = this.getPathPoints(t)).startPoint,
- s = t.endPoint,
- u = this.getControlPoints(t),
- c = [a];
- u && (c = c.concat(u)), c.push(s);
- var l = i.attr(),
- f = Object(g.mix)({}, r, l, t.style),
- h = t.sourceNode,
- d = t.targetNode,
- p = f.radius,
- v = this.options.routeCfg,
- y = Object(g.mix)({}, v, t.routeCfg);
- y.offset = f.offset;
- var m = this.getPath(c, h, d, p, y, !Boolean(u));
- ((Object(g.isArray)(m) && m.length <= 1) ||
- (Object(g.isString)(m) && -1 === m.indexOf("L"))) &&
- (m = "M0 0, L0 0"),
- (isNaN(a.x) || isNaN(a.y) || isNaN(s.x) || isNaN(s.y)) &&
- (m = "M0 0, L0 0"),
- l.endArrow &&
- !1 === f.endArrow &&
- (t.style.endArrow = { path: "" }),
- l.startArrow &&
- !1 === f.startArrow &&
- (t.style.startArrow = { path: "" });
- var b = Object(g.mix)(
- r,
- i.attr(),
- { lineWidth: o, path: m },
- t.style
- );
- i && i.attr(b);
- }
- },
- getPath: function (t, e, n, r, i, o) {
- var a = i.offset,
- s = i.obstacles,
- u = i.simple;
- if (!a || t.length > 2 || !1 === o) {
- if (r) return gu(t, r);
- var c = [];
- return (
- Object(g.each)(t, function (t, e) {
- 0 === e ? c.push(["M", t.x, t.y]) : c.push(["L", t.x, t.y]);
- }),
- c
- );
- }
- !1 === u || (null == s ? void 0 : s.length) || (u = !0);
- var l = u
- ? vu(t[t.length - 1], t[0], n, e, a)
- : Mu(t[0], t[t.length - 1], e, n, i);
- return l && l.length
- ? r
- ? gu(l, r)
- : ((l = (function (t) {
- if (!(null == t ? void 0 : t.length)) return t;
- for (
- var e = t[t.length - 1],
- n = { x: e.x, y: e.y },
- r = [e],
- i = [e],
- o = t.length - 2;
- o >= 0;
- o--
- ) {
- var a,
- s = t[o];
- if (
- (s.x === n.x ? r.push(s) : ((r = [s]), (n.x = s.x)),
- s.y === n.y ? i.push(s) : ((i = [s]), (n.y = s.y)),
- r.length > 2)
- )
- (a = t.indexOf(r[1])) > -1 && t.splice(a, 1);
- else if (i.length > 2)
- (a = t.indexOf(i[1])) > -1 && t.splice(a, 1);
- }
- return t;
- })(l)),
- dr.pointsToPolygon(l))
- : "M0 0, L0 0";
- },
- },
- "single-edge"
- );
- var ku = ci.cloneEvent,
- Au = ci.isNaN,
- ju = Math.abs,
- Cu = ["shift", "ctrl", "alt", "control"],
- Iu = {
- getDefaultCfg: function () {
- return {
- direction: "both",
- enableOptimize: !1,
- scalableRange: 0,
- allowDragOnItem: !1,
- };
- },
- getEvents: function () {
- return {
- mousedown: "onMouseDown",
- drag: "onDragMove",
- dragend: "onMouseUp",
- "canvas:click": "onMouseUp",
- keyup: "onKeyUp",
- focus: "onKeyUp",
- keydown: "onKeyDown",
- touchstart: "onTouchStart",
- touchmove: "onTouchMove",
- touchend: "onMouseUp",
- };
- },
- updateViewport: function (t) {
- var e = this.origin,
- n = +t.clientX,
- r = +t.clientY;
- if (!Au(n) && !Au(r)) {
- var i = n - e.x,
- o = r - e.y;
- "x" === this.get("direction")
- ? (o = 0)
- : "y" === this.get("direction") && (i = 0),
- (this.origin = { x: n, y: r });
- var a = this.graph.get("width"),
- s = this.graph.get("height"),
- u = this.graph.get("canvas").getCanvasBBox(),
- c = this.scalableRange,
- l = this.scalableRange;
- c < 1 && c > -1 && ((c *= a), (l *= s)),
- ((u.minX <= a + c && u.minX + i > a + c) ||
- (u.maxX + c >= 0 && u.maxX + c + i < 0)) &&
- (i = 0),
- ((u.minY <= s + l && u.minY + o > s + l) ||
- (u.maxY + l >= 0 && u.maxY + l + o < 0)) &&
- (o = 0),
- this.graph.translate(i, o);
- }
- },
- onTouchStart: function (t) {
- var e = t.originalEvent.touches,
- n = e[0],
- r = e[1];
- (n && r) ||
- (t.preventDefault(), (this.mousedown = !0), this.onDragStart(t));
- },
- onMouseDown: function (t) {
- this.mousedown = !0;
- },
- onDragMove: function (t) {
- this.mousedown &&
- (this.dragstart
- ? this.onDrag(t)
- : ((this.dragstart = !0), this.onDragStart(t)));
- },
- onDragStart: function (t) {
- var e = t.originalEvent;
- if (
- (!e || "touchstart" === t.name || 0 === e.button) &&
- ("touchstart" === t.name ||
- "undefined" == typeof window ||
- !window.event ||
- window.event.buttons ||
- window.event.button) &&
- this.shouldBegin(t, this) &&
- !this.keydown &&
- this.allowDrag(t)
- ) {
- if (
- ((this.origin = { x: t.clientX, y: t.clientY }),
- (this.dragging = !1),
- this.enableOptimize)
- ) {
- for (
- var n = this.graph, r = n.getEdges(), i = 0, o = r.length;
- i < o;
- i++
- ) {
- var a = r[i].get("group").get("children");
- a &&
- a.forEach(function (t) {
- t.set(
- "ori-visibility",
- t.get("ori-visibility") || t.get("visible")
- ),
- t.hide();
- });
- }
- for (var s = n.getNodes(), u = 0, c = s.length; u < c; u++)
- for (
- var l = 0, f = s[u].getContainer().get("children");
- l < f.length;
- l++
- ) {
- var h = f[l];
- h.get("isKeyShape") ||
- (h.set(
- "ori-visibility",
- h.get("ori-visibility") || h.get("visible")
- ),
- h.hide());
- }
- }
- if ("undefined" != typeof window) {
- var d = this;
- (this.handleDOMContextMenu = function (t) {
- return d.onMouseUp(t);
- }),
- document.body.addEventListener(
- "contextmenu",
- this.handleDOMContextMenu
- );
- }
- }
- },
- onTouchMove: function (t) {
- var e = t.originalEvent.touches,
- n = e[0],
- r = e[1];
- n && r ? this.onMouseUp(t) : (t.preventDefault(), this.onDrag(t));
- },
- onDrag: function (t) {
- if (this.mousedown) {
- var e = this.graph;
- if (
- !this.keydown &&
- this.allowDrag(t) &&
- ((t = ku(t)), this.origin)
- ) {
- if (this.dragging) (t.type = "drag"), e.emit("canvas:drag", t);
- else {
- if (
- ju(this.origin.x - t.clientX) +
- ju(this.origin.y - t.clientY) <
- 10
- )
- return;
- this.shouldBegin(t, this) &&
- ((t.type = "dragstart"),
- e.emit("canvas:dragstart", t),
- (this.originPosition = { x: t.clientX, y: t.clientY }),
- (this.dragging = !0));
- }
- this.shouldUpdate(t, this) && this.updateViewport(t);
- }
- }
- },
- onMouseUp: function (t) {
- var e, n;
- (this.mousedown = !1), (this.dragstart = !1);
- var r = this.graph;
- if (!this.keydown) {
- var i = r.getZoom(),
- o = r.get("modeController"),
- a =
- null ===
- (n =
- null === (e = null == o ? void 0 : o.modes[o.mode]) ||
- void 0 === e
- ? void 0
- : e.filter(function (t) {
- return "zoom-canvas" === t.type;
- })) || void 0 === n
- ? void 0
- : n[0],
- s = a ? a.optimizeZoom || 0.1 : 0;
- if (this.enableOptimize) {
- for (var u = r.getEdges(), c = 0, l = u.length; c < l; c++) {
- var f = u[c].get("group").get("children");
- f &&
- f.forEach(function (t) {
- var e = t.get("ori-visibility");
- t.set("ori-visibility", void 0), e && t.show();
- });
- }
- if (i > s)
- for (var h = r.getNodes(), d = 0, p = h.length; d < p; d++)
- for (
- var g = 0, v = h[d].getContainer().get("children");
- g < v.length;
- g++
- ) {
- var y = v[g];
- if (!y.get("isKeyShape")) {
- var m = y.get("ori-visibility");
- y.set("ori-visibility", void 0), m && y.show();
- }
- }
- }
- this.dragging
- ? ((t = ku(t)),
- this.shouldEnd(t, this) && this.updateViewport(t),
- (t.type = "dragend"),
- (t.dx = t.clientX - this.originPosition.x),
- (t.dy = t.clientY - this.originPosition.y),
- r.emit("canvas:dragend", t),
- this.endDrag(),
- "undefined" != typeof window &&
- document.body.removeEventListener(
- "contextmenu",
- this.handleDOMContextMenu
- ))
- : (this.origin = null);
- }
- },
- endDrag: function () {
- (this.origin = null),
- (this.dragging = !1),
- (this.dragbegin = !1),
- (this.mousedown = !1),
- (this.dragstart = !1);
- },
- onKeyDown: function (t) {
- var e = t.key;
- e &&
- (Cu.indexOf(e.toLowerCase()) > -1
- ? (this.keydown = !0)
- : (this.keydown = !1));
- },
- onKeyUp: function () {
- (this.keydown = !1),
- (this.origin = null),
- (this.dragging = !1),
- (this.dragbegin = !1);
- },
- allowDrag: function (t) {
- var e,
- n,
- r = t.target,
- i = r && r.isCanvas && r.isCanvas();
- if (
- Object(g.isBoolean)(this.allowDragOnItem) &&
- !this.allowDragOnItem &&
- !i
- )
- return !1;
- if (Object(g.isObject)(this.allowDragOnItem)) {
- var o = this.allowDragOnItem,
- a = o.node,
- s = o.edge,
- u = o.combo,
- c =
- null ===
- (n =
- null === (e = t.item) || void 0 === e
- ? void 0
- : e.getType) || void 0 === n
- ? void 0
- : n.call(e);
- if (!a && "node" === c) return !1;
- if (!s && "edge" === c) return !1;
- if (!u && "combo" === c) return !1;
- }
- return !0;
- },
- },
- Tu = {
- getDefaultCfg: function () {
- return {
- updateEdge: !0,
- delegateStyle: {},
- enableDelegate: !1,
- onlyChangeComboSize: !1,
- comboActiveState: "",
- selectedState: "selected",
- enableOptimize: !1,
- enableDebounce: !1,
- enableStack: !0,
- };
- },
- getEvents: function () {
- return {
- "node:mousedown": "onMouseDown",
- drag: "onDragMove",
- dragend: "onDragEnd",
- "combo:dragenter": "onDragEnter",
- "combo:dragleave": "onDragLeave",
- "combo:drop": "onDropCombo",
- "node:drop": "onDropNode",
- "canvas:drop": "onDropCanvas",
- touchstart: "onTouchStart",
- touchmove: "onTouchMove",
- touchend: "onDragEnd",
- afterchangedata: "onDragEnd",
- };
- },
- validationCombo: function (t) {
- return (
- !(!this.origin || !t || t.destroyed) && "combo" === t.getType()
- );
- },
- onTouchStart: function (t) {
- if (t.item) {
- try {
- var e = t.originalEvent.touches,
- n = e[0],
- r = e[1];
- if (n && r) return;
- t.preventDefault();
- } catch (t) {
- console.warn("Touch original event not exist!");
- }
- (this.mousedown = {
- item: t.item,
- target: t.target,
- origin: { x: t.x, y: t.y },
- }),
- (this.dragstart = !0),
- this.onDragStart(t);
- }
- },
- onTouchMove: function (t) {
- try {
- var e = t.originalEvent.touches,
- n = e[0],
- r = e[1];
- if (n && r) return void this.onDragEnd(t);
- t.preventDefault();
- } catch (t) {
- console.warn("Touch original event not exist!");
- }
- this.onDrag(t);
- },
- onMouseDown: function (t) {
- (this.mousedown = {
- item: t.item,
- target: t.target,
- origin: { x: t.x, y: t.y },
- }),
- "undefined" == typeof window ||
- this.windowEventBinded ||
- ((this.windowEventBinded = !0),
- document.body.addEventListener(
- "contextmenu",
- this.onDragEnd.bind(this)
- ),
- document.body.addEventListener(
- "mouseup",
- this.onDragEnd.bind(this)
- ));
- },
- onDragMove: function (t) {
- var e, n;
- "node" ===
- (null ===
- (n =
- null === (e = t.item) || void 0 === e ? void 0 : e.getType) ||
- void 0 === n
- ? void 0
- : n.call(e))
- ? this.mousedown &&
- (this.dragstart
- ? this.onDrag(
- Object(p.__assign)(
- Object(p.__assign)({}, t),
- this.mousedown
- )
- )
- : ((this.dragstart = !0), this.onDragStart(t)))
- : this.onDragEnd();
- },
- onDragStart: function (t) {
- var e = this;
- if (
- ((this.currentShouldEnd = !0),
- this.shouldBegin(
- Object(p.__assign)(Object(p.__assign)({}, t), this.mousedown),
- this
- ))
- ) {
- var n = this.mousedown,
- r = n.item,
- i = n.target;
- if (r && !r.destroyed && !r.hasLocked()) {
- if (
- (r.getContainer().set("capture", !1),
- this.cachedCaptureItems || (this.cachedCaptureItems = []),
- this.cachedCaptureItems.push(r),
- i)
- )
- if (i.get("isAnchorPoint")) return;
- var o = this.graph;
- (this.targets = []), (this.targetCombo = null);
- var a = o.findAllByState("node", this.selectedState),
- s = r.get("id");
- if (
- (0 ===
- a.filter(function (t) {
- var e = t.get("id");
- return s === e;
- }).length
- ? this.targets.push(r)
- : a.length > 1
- ? a.forEach(function (t) {
- t.hasLocked() || e.targets.push(t);
- })
- : this.targets.push(r),
- this.graph.get("enabledStack") && this.enableStack)
- ) {
- var u = [];
- this.targets.forEach(function (t) {
- var e = t.getModel(),
- n = e.x,
- r = e.y,
- i = e.id;
- u.push({ x: n, y: r, id: i });
- }),
- this.set("beforeDragNodes", u);
- }
- (this.hidenEdge = {}),
- this.get("updateEdge") &&
- this.enableOptimize &&
- !this.enableDelegate &&
- this.targets.forEach(function (t) {
- t.getEdges().forEach(function (t) {
- t.isVisible() &&
- ((e.hidenEdge[t.getID()] = !0), t.hide());
- });
- }),
- (this.origin = this.mousedown.origin),
- (this.point = {}),
- (this.originPoint = {});
- }
- }
- },
- onDrag: function (t) {
- var e = this;
- if (this.mousedown && this.origin && this.shouldUpdate(t, this))
- if (this.get("enableDelegate")) this.updateDelegate(t);
- else if (this.enableDebounce)
- this.debounceUpdate({
- targets: this.targets,
- graph: this.graph,
- point: this.point,
- origin: this.origin,
- evt: t,
- updateEdge: this.get("updateEdge"),
- onlyChangeComboSize: this.onlyChangeComboSize,
- updateParentCombos: this.updateParentCombos,
- });
- else {
- var n = {};
- this.targets.map(function (r) {
- e.update(r, t);
- var i = r.getModel().comboId;
- i && (n[i] = e.graph.findById(i));
- }),
- this.onlyChangeComboSize && this.updateParentCombos();
- }
- },
- onDragEnd: function (t) {
- var e,
- n = this;
- if (
- ((this.mousedown = !1),
- (this.dragstart = !1),
- "undefined" != typeof window &&
- this.windowEventBinded &&
- ((this.windowEventBinded = !1),
- document.body.removeEventListener(
- "contextmenu",
- this.onDragEnd.bind(this)
- ),
- document.body.removeEventListener(
- "mouseup",
- this.onDragEnd.bind(this)
- )),
- this.origin)
- ) {
- null === (e = this.cachedCaptureItems) ||
- void 0 === e ||
- e.forEach(function (t) {
- t.getContainer().set("capture", !0);
- }),
- (this.cachedCaptureItems = []),
- this.delegateRect &&
- (this.delegateRect.remove(), (this.delegateRect = null)),
- this.get("updateEdge") &&
- this.enableOptimize &&
- !this.enableDelegate &&
- this.targets.forEach(function (t) {
- t.getEdges().forEach(function (t) {
- n.hidenEdge[t.getID()] && t.show(), t.refresh();
- });
- }),
- (this.hidenEdge = {});
- var r = this.graph;
- if (r.get("enabledStack") && this.enableStack) {
- var i = {
- before: { nodes: [], edges: [], combos: [] },
- after: { nodes: [], edges: [], combos: [] },
- };
- this.get("beforeDragNodes").forEach(function (t) {
- i.before.nodes.push(t);
- }),
- this.targets.forEach(function (t) {
- var e = t.getModel(),
- n = e.x,
- r = e.y,
- o = e.id;
- i.after.nodes.push({ x: n, y: r, id: o });
- }),
- r.pushStack("update", Object(g.clone)(i));
- }
- r.emit("dragnodeend", { items: this.targets, targetItem: null }),
- (this.point = {}),
- (this.origin = null),
- (this.originPoint = {}),
- (this.targets.length = 0),
- (this.targetCombo = null);
- }
- },
- onDropCombo: function (t) {
- var e = t.item;
- if (
- ((this.currentShouldEnd = this.shouldEnd(t, e, this)),
- this.updatePositions(t, !this.currentShouldEnd),
- this.currentShouldEnd && this.validationCombo(e))
- ) {
- var n = this.graph;
- if (
- (this.comboActiveState &&
- n.setItemState(e, this.comboActiveState, !1),
- (this.targetCombo = e),
- this.onlyChangeComboSize)
- )
- n.updateCombos();
- else {
- var r = e.getModel();
- this.targets.map(function (t) {
- t.getModel().comboId !== r.id && n.updateComboTree(t, r.id);
- }),
- n.updateCombo(e);
- }
- n.emit("dragnodeend", {
- items: this.targets,
- targetItem: this.targetCombo,
- });
- }
- },
- onDropCanvas: function (t) {
- var e = this.graph;
- (this.currentShouldEnd = this.shouldEnd(t, void 0, this)),
- this.updatePositions(t, !this.currentShouldEnd),
- this.targets &&
- 0 !== this.targets.length &&
- this.currentShouldEnd &&
- (this.onlyChangeComboSize
- ? this.updateParentCombos()
- : this.targets.map(function (t) {
- t.getModel().comboId && e.updateComboTree(t);
- }));
- },
- onDropNode: function (t) {
- if (this.targets && 0 !== this.targets.length) {
- var e = t.item,
- n = this.graph,
- r = e.getModel().comboId,
- i = r ? n.findById(r) : void 0;
- if (
- ((this.currentShouldEnd = this.shouldEnd(t, i, this)),
- this.updatePositions(t, !this.currentShouldEnd),
- this.currentShouldEnd)
- ) {
- if (this.onlyChangeComboSize) this.updateParentCombos();
- else if (r) {
- var o = n.findById(r);
- this.comboActiveState &&
- n.setItemState(o, this.comboActiveState, !1),
- this.targets.map(function (t) {
- var e = t.getModel();
- r !== e.comboId && n.updateComboTree(t, r);
- }),
- n.updateCombo(o);
- } else
- this.targets.map(function (t) {
- t.getModel().comboId && n.updateComboTree(t);
- });
- n.emit("dragnodeend", { items: this.targets, targetItem: e });
- }
- }
- },
- onDragEnter: function (t) {
- var e = t.item;
- if (this.validationCombo(e)) {
- var n = this.graph;
- this.comboActiveState &&
- n.setItemState(e, this.comboActiveState, !0);
- }
- },
- onDragLeave: function (t) {
- var e = t.item;
- if (this.validationCombo(e)) {
- var n = this.graph;
- this.comboActiveState &&
- n.setItemState(e, this.comboActiveState, !1);
- }
- },
- updatePositions: function (t, e) {
- var n = this;
- this.targets &&
- 0 !== this.targets.length &&
- (this.get("enableDelegate")
- ? this.enableDebounce
- ? this.debounceUpdate({
- targets: this.targets,
- graph: this.graph,
- point: this.point,
- origin: this.origin,
- evt: t,
- updateEdge: this.get("updateEdge"),
- onlyChangeComboSize: this.onlyChangeComboSize,
- updateParentCombos: this.updateParentCombos,
- })
- : e ||
- this.targets.map(function (e) {
- return n.update(e, t);
- })
- : this.targets.map(function (r) {
- return n.update(r, t, e);
- }));
- },
- update: function (t, e, n) {
- var r = this.origin,
- i = t.get("model"),
- o = t.get("id");
- this.point[o] || (this.point[o] = { x: i.x || 0, y: i.y || 0 });
- var a = e.x - r.x + this.point[o].x,
- s = e.y - r.y + this.point[o].y;
- n && ((a += r.x - e.x), (s += r.y - e.y));
- var u = { x: a, y: s };
- this.get("updateEdge")
- ? this.graph.updateItem(t, u, !1)
- : t.updatePosition(u);
- },
- debounceUpdate: Object(g.debounce)(
- function (t) {
- var e = t.targets,
- n = t.graph,
- r = t.point,
- i = t.origin,
- o = t.evt,
- a = t.updateEdge,
- s = t.onlyChangeComboSize,
- u = t.updateParentCombos;
- e.map(function (t) {
- var e = t.get("model"),
- s = t.get("id");
- r[s] || (r[s] = { x: e.x || 0, y: e.y || 0 });
- var u = { x: o.x - i.x + r[s].x, y: o.y - i.y + r[s].y };
- a ? n.updateItem(t, u, !1) : t.updatePosition(u);
- }),
- s && u(n, e);
- },
- 50,
- !0
- ),
- updateDelegate: function (t) {
- var e = this.graph;
- if (this.delegateRect) {
- var n = t.x - this.origin.x + this.originPoint.minX,
- r = t.y - this.origin.y + this.originPoint.minY;
- this.delegateRect.attr({ x: n, y: r });
- } else {
- var i = e.get("group"),
- o = Object(g.deepMix)({}, Xr.delegateStyle, this.delegateStyle),
- a = this.calculationGroupPosition(t),
- s = a.x,
- u = a.y,
- c = a.width,
- l = a.height,
- f = a.minX,
- h = a.minY;
- (this.originPoint = {
- x: s,
- y: u,
- width: c,
- height: l,
- minX: f,
- minY: h,
- }),
- (this.delegateRect = i.addShape("rect", {
- attrs: Object(p.__assign)(
- { width: c, height: l, x: s, y: u },
- o
- ),
- name: "rect-delegate-shape",
- })),
- (this.delegate = this.delegateRect),
- this.delegateRect.set("capture", !1);
- }
- },
- calculationGroupPosition: function (t) {
- var e = this.targets;
- 0 === e.length && e.push(t.item);
- for (
- var n = 1 / 0, r = -1 / 0, i = 1 / 0, o = -1 / 0, a = 0;
- a < e.length;
- a++
- ) {
- var s = e[a].getBBox(),
- u = s.minX,
- c = s.minY,
- l = s.maxX,
- f = s.maxY;
- u < n && (n = u),
- c < i && (i = c),
- l > r && (r = l),
- f > o && (o = f);
- }
- return {
- x: Math.floor(n),
- y: Math.floor(i),
- width: Math.ceil(r) - Math.floor(n),
- height: Math.ceil(o) - Math.floor(i),
- minX: n,
- minY: i,
- };
- },
- updateParentCombos: function (t, e) {
- var n = t || this.graph,
- r = e || this.targets,
- i = {};
- null == r ||
- r.forEach(function (t) {
- var e = t.getModel().comboId;
- e && (i[e] = n.findById(e));
- }),
- Object.values(i).forEach(function (t) {
- t && n.updateCombo(t);
- });
- },
- },
- Nu = {
- getDefaultCfg: function () {
- return {
- trigger: "mouseenter",
- activeState: "active",
- inactiveState: "inactive",
- resetSelected: !1,
- shouldUpdate: function () {
- return !0;
- },
- };
- },
- getEvents: function () {
- return "mouseenter" === this.get("trigger")
- ? {
- "node:mouseenter": "setAllItemStates",
- "combo:mouseenter": "setAllItemStates",
- "node:mouseleave": "clearActiveState",
- "combo:mouseleave": "clearActiveState",
- }
- : {
- "node:click": "setAllItemStates",
- "combo:click": "setAllItemStates",
- "canvas:click": "clearActiveState",
- "node:touchstart": "setOnTouchStart",
- "combo:touchstart": "setOnTouchStart",
- "canvas:touchstart": "clearOnTouchStart",
- };
- },
- setOnTouchStart: function (t) {
- try {
- var e = t.originalEvent.touches,
- n = e[0],
- r = e[1];
- if (n && r) return;
- t.preventDefault();
- } catch (t) {
- console.warn("Touch original event not exist!");
- }
- this.setAllItemStates(t);
- },
- clearOnTouchStart: function (t) {
- try {
- var e = t.originalEvent.touches,
- n = e[0],
- r = e[1];
- if (n && r) return;
- t.preventDefault();
- } catch (t) {
- console.warn("Touch original event not exist!");
- }
- this.clearActiveState(t);
- },
- setAllItemStates: function (t) {
- clearTimeout(this.timer), this.throttleSetAllItemStates(t, this);
- },
- clearActiveState: function (t) {
- var e = this;
- this.timer = setTimeout(function () {
- e.throttleClearActiveState(t, e);
- }, 50);
- },
- throttleSetAllItemStates: Object(g.throttle)(
- function (t, e) {
- var n = t.item,
- r = e.graph;
- if (
- r &&
- !r.destroyed &&
- ((e.item = n),
- e.shouldUpdate(t.item, { event: t, action: "activate" }, e))
- ) {
- for (
- var i = e.activeState,
- o = e.inactiveState,
- a = r.getNodes(),
- s = r.getCombos(),
- u = r.getEdges(),
- c = r.get("vedges"),
- l = a.length,
- f = s.length,
- h = u.length,
- d = c.length,
- p = e.inactiveItems || {},
- g = e.activeItems || {},
- v = 0;
- v < l;
- v++
- ) {
- var y = a[v],
- m = y.getID(),
- b = y.hasState("selected");
- e.resetSelected && b && r.setItemState(y, "selected", !1),
- g[m] && (r.setItemState(y, i, !1), delete g[m]),
- o && !p[m] && (r.setItemState(y, o, !0), (p[m] = y));
- }
- for (v = 0; v < f; v++) {
- var x = s[v],
- w = x.getID();
- b = x.hasState("selected");
- e.resetSelected && b && r.setItemState(x, "selected", !1),
- g[w] && (r.setItemState(x, i, !1), delete g[w]),
- o && !p[w] && (r.setItemState(x, o, !0), (p[w] = x));
- }
- for (v = 0; v < h; v++) {
- g[(k = (M = u[v]).getID())] &&
- (r.setItemState(M, i, !1), delete g[k]),
- o && !p[k] && (r.setItemState(M, o, !0), (p[k] = M));
- }
- for (v = 0; v < d; v++) {
- var E = c[v],
- _ = E.getID();
- g[_] && (r.setItemState(E, i, !1), delete g[_]),
- o && !p[_] && (r.setItemState(E, o, !0), (p[_] = E));
- }
- if (n && !n.destroyed) {
- o && (r.setItemState(n, o, !1), delete p[n.getID()]),
- g[n.getID()] ||
- (r.setItemState(n, i, !0), (g[n.getID()] = n));
- var S = n.getEdges(),
- O = S.length;
- for (v = 0; v < O; v++) {
- var M,
- k = (M = S[v]).getID(),
- A = void 0,
- j = (A =
- M.getSource() === n
- ? M.getTarget()
- : M.getSource()).getID();
- o && p[j] && (r.setItemState(A, o, !1), delete p[j]),
- g[j] || (r.setItemState(A, i, !0), (g[j] = A)),
- p[k] && (r.setItemState(M, o, !1), delete p[k]),
- g[k] || (r.setItemState(M, i, !0), (g[k] = M)),
- M.toFront();
- }
- }
- (e.activeItems = g),
- (e.inactiveItems = p),
- r.emit("afteractivaterelations", {
- item: t.item,
- action: "activate",
- });
- }
- },
- 50,
- { trailing: !0, leading: !0 }
- ),
- throttleClearActiveState: Object(g.throttle)(
- function (t, e) {
- var n = e.get("graph");
- if (
- n &&
- !n.destroyed &&
- e.shouldUpdate(t.item, { event: t, action: "deactivate" }, e)
- ) {
- var r = e.activeState,
- i = e.inactiveState,
- o = e.activeItems || {},
- a = e.inactiveItems || {};
- Object.values(o)
- .filter(function (t) {
- return !t.destroyed;
- })
- .forEach(function (t) {
- n.clearItemStates(t, r);
- }),
- Object.values(a)
- .filter(function (t) {
- return !t.destroyed;
- })
- .forEach(function (t) {
- n.clearItemStates(t, i);
- }),
- (e.activeItems = {}),
- (e.inactiveItems = {}),
- n.emit("afteractivaterelations", {
- item: t.item || e.get("item"),
- action: "deactivate",
- });
- }
- },
- 50,
- { trailing: !0, leading: !0 }
- ),
- },
- Pu = Math.min,
- Du = Math.max,
- Lu = Math.abs,
- Ru = ["drag", "shift", "ctrl", "alt", "control"],
- Bu = {
- getDefaultCfg: function () {
- return {
- brushStyle: {
- fill: "#EEF6FF",
- fillOpacity: 0.4,
- stroke: "#DDEEFE",
- lineWidth: 1,
- },
- onSelect: function () {},
- onDeselect: function () {},
- selectedState: "selected",
- trigger: "shift",
- includeEdges: !0,
- includeCombos: !1,
- selectedEdges: [],
- selectedNodes: [],
- selectedCombos: [],
- };
- },
- getEvents: function () {
- return (
- Ru.indexOf(this.trigger.toLowerCase()) > -1 ||
- ((this.trigger = "shift"),
- console.warn(
- "Behavior brush-select 的 trigger 参数不合法,请输入 'drag'、'shift'、'ctrl' 或 'alt'"
- )),
- "drag" === this.trigger
- ? {
- dragstart: "onMouseDown",
- drag: "onMouseMove",
- dragend: "onMouseUp",
- "canvas:click": "clearStates",
- }
- : {
- dragstart: "onMouseDown",
- drag: "onMouseMove",
- dragend: "onMouseUp",
- "canvas:click": "clearStates",
- keyup: "onKeyUp",
- keydown: "onKeyDown",
- }
- );
- },
- onMouseDown: function (t) {
- var e = t.item,
- n = this.brush;
- e ||
- (("drag" === this.trigger || this.keydown) &&
- (this.selectedNodes &&
- 0 !== this.selectedNodes.length &&
- this.clearStates(),
- n || (n = this.createBrush()),
- (this.originPoint = { x: t.canvasX, y: t.canvasY }),
- n.attr({ width: 0, height: 0 }),
- n.show(),
- (this.dragging = !0)));
- },
- onMouseMove: function (t) {
- this.dragging &&
- ("drag" === this.trigger || this.keydown) &&
- this.updateBrush(t);
- },
- onMouseUp: function (t) {
- this.graph;
- (this.brush || this.dragging) &&
- ("drag" === this.trigger || this.keydown) &&
- (this.brush.remove(!0),
- (this.brush = null),
- this.getSelectedNodes(t),
- (this.dragging = !1));
- },
- clearStates: function () {
- var t = this.graph,
- e = this.selectedState,
- n = t.findAllByState("node", e),
- r = t.findAllByState("edge", e),
- i = t.findAllByState("combo", e);
- n.forEach(function (n) {
- return t.setItemState(n, e, !1);
- }),
- r.forEach(function (n) {
- return t.setItemState(n, e, !1);
- }),
- i.forEach(function (n) {
- return t.setItemState(n, e, !1);
- }),
- (this.selectedNodes = []),
- (this.selectedEdges = []),
- (this.selectedCombos = []),
- this.onDeselect &&
- this.onDeselect(
- this.selectedNodes,
- this.selectedEdges,
- this.selectedCombos
- ),
- t.emit("nodeselectchange", {
- selectedItems: { nodes: [], edges: [], combos: [] },
- select: !1,
- });
- },
- isBBoxCenterInRect: function (t, e, n, r, i) {
- var o = t.getBBox();
- return (
- o.centerX >= e &&
- o.centerX <= n &&
- o.centerY >= r &&
- o.centerY <= i
- );
- },
- getSelectedNodes: function (t) {
- var e = this,
- n = this.graph,
- r = this.originPoint,
- i = this.shouldUpdate,
- o = this.isBBoxCenterInRect,
- a = this.selectedState,
- s = { x: t.x, y: t.y },
- u = n.getPointByCanvas(r.x, r.y),
- c = Pu(s.x, u.x),
- l = Du(s.x, u.x),
- f = Pu(s.y, u.y),
- h = Du(s.y, u.y),
- d = [],
- p = [];
- n.getNodes().forEach(function (t) {
- if (t.isVisible() && o(t, c, l, f, h) && i(t, "select", e)) {
- d.push(t);
- var r = t.getModel();
- p.push(r.id), n.setItemState(t, a, !0);
- }
- });
- var g = [];
- this.includeEdges &&
- d.forEach(function (t) {
- t.getOutEdges().forEach(function (t) {
- if (t.isVisible()) {
- var r = t.getModel(),
- o = r.source,
- a = r.target;
- p.includes(o) &&
- p.includes(a) &&
- i(t, "select", e) &&
- (g.push(t), n.setItemState(t, e.selectedState, !0));
- }
- });
- });
- var v = [];
- this.includeCombos &&
- n.getCombos().forEach(function (t) {
- if (t.isVisible() && o(t, c, l, f, h) && i(t, "select", e)) {
- v.push(t);
- var r = t.getModel();
- p.push(r.id), n.setItemState(t, a, !0);
- }
- }),
- (this.selectedEdges = g),
- (this.selectedNodes = d),
- (this.selectedCombos = v),
- this.onSelect && this.onSelect(d, g, v),
- n.emit("nodeselectchange", {
- selectedItems: { nodes: d, edges: g, combos: v },
- select: !0,
- });
- },
- createBrush: function () {
- var t = this.graph
- .get("canvas")
- .addShape("rect", {
- attrs: this.brushStyle,
- capture: !1,
- name: "brush-shape",
- });
- return (this.brush = t), (this.delegate = t), t;
- },
- updateBrush: function (t) {
- var e = this.originPoint;
- this.brush.attr({
- width: Lu(t.canvasX - e.x),
- height: Lu(t.canvasY - e.y),
- x: Pu(t.canvasX, e.x),
- y: Pu(t.canvasY, e.y),
- });
- },
- onKeyDown: function (t) {
- var e = t.key;
- if (e) {
- var n = this.trigger.toLowerCase(),
- r = e.toLowerCase();
- this.keydown =
- r === n ||
- ("control" === r && "ctrl" === n) ||
- ("ctrl" === r && "control" === n);
- }
- },
- onKeyUp: function () {
- this.brush &&
- (this.brush.remove(!0),
- (this.brush = null),
- (this.dragging = !1)),
- (this.keydown = !1);
- },
- },
- Fu = ["shift", "ctrl", "alt", "control"],
- zu = {
- getDefaultCfg: function () {
- return {
- multiple: !0,
- trigger: "shift",
- selectedState: "selected",
- selectNode: !0,
- selectEdge: !1,
- selectCombo: !0,
- };
- },
- getEvents: function () {
- return (
- Fu.indexOf(this.trigger.toLowerCase()) > -1 ||
- ((this.trigger = "shift"),
- console.warn(
- "Behavior click-select 的 trigger 参数不合法,请输入 'drag'、'shift'、'ctrl' 或 'alt'"
- )),
- this.multiple
- ? {
- "node:click": "onClick",
- "combo:click": "onClick",
- "edge:click": "onClick",
- "canvas:click": "onCanvasClick",
- keyup: "onKeyUp",
- keydown: "onKeyDown",
- }
- : {
- "node:click": "onClick",
- "combo:click": "onClick",
- "edge:click": "onClick",
- "canvas:click": "onCanvasClick",
- }
- );
- },
- onClick: function (t) {
- var e = this,
- n = t.item;
- if (n && !n.destroyed) {
- var r = n.getType(),
- i = e.graph,
- o = e.keydown,
- a = e.multiple,
- s = e.shouldUpdate;
- if ((0, e.shouldBegin)(t, e)) {
- if (!o || !a) {
- var u = i
- .findAllByState("node", e.selectedState)
- .concat(i.findAllByState("edge", e.selectedState))
- .concat(i.findAllByState("combo", e.selectedState));
- Object(g.each)(u, function (t) {
- t !== n && i.setItemState(t, e.selectedState, !1);
- });
- }
- if (
- (function () {
- switch (r) {
- case "node":
- return e.selectNode;
- case "edge":
- return e.selectEdge;
- case "combo":
- return e.selectCombo;
- default:
- return !1;
- }
- })()
- )
- if (n.hasState(e.selectedState)) {
- s(t, e) && i.setItemState(n, e.selectedState, !1);
- (c = i.findAllByState("node", e.selectedState)),
- (l = i.findAllByState("edge", e.selectedState)),
- (f = i.findAllByState("combo", e.selectedState));
- i.emit("nodeselectchange", {
- target: n,
- selectedItems: { nodes: c, edges: l, combos: f },
- select: !1,
- });
- } else {
- s(t, e) && i.setItemState(n, e.selectedState, !0);
- (c = i.findAllByState("node", e.selectedState)),
- (l = i.findAllByState("edge", e.selectedState)),
- (f = i.findAllByState("combo", e.selectedState));
- i.emit("nodeselectchange", {
- target: n,
- selectedItems: { nodes: c, edges: l, combos: f },
- select: !0,
- });
- }
- else {
- var c = i.findAllByState("node", e.selectedState),
- l = i.findAllByState("edge", e.selectedState),
- f = i.findAllByState("combo", e.selectedState);
- i.emit("nodeselectchange", {
- selectedItems: { nodes: c, edges: l, combos: f },
- select: !1,
- });
- }
- }
- }
- },
- onCanvasClick: function (t) {
- var e = this,
- n = this.graph;
- if ((0, this.shouldBegin)(t, this)) {
- var r = n.findAllByState("node", this.selectedState);
- Object(g.each)(r, function (t) {
- n.setItemState(t, e.selectedState, !1);
- });
- var i = n.findAllByState("edge", this.selectedState);
- Object(g.each)(i, function (t) {
- n.setItemState(t, e.selectedState, !1);
- });
- var o = n.findAllByState("combo", this.selectedState);
- Object(g.each)(o, function (t) {
- n.setItemState(t, e.selectedState, !1);
- }),
- n.emit("nodeselectchange", {
- selectedItems: { nodes: [], edges: [], combos: [] },
- select: !1,
- });
- }
- },
- onKeyDown: function (t) {
- var e = t.key;
- e &&
- (e.toLowerCase() === this.trigger.toLowerCase() ||
- "control" === e.toLowerCase()
- ? (this.keydown = !0)
- : (this.keydown = !1));
- },
- onKeyUp: function () {
- this.keydown = !1;
- },
- },
- Gu = x.a.transform,
- Yu = {
- getDefaultCfg: function () {
- return {
- sensitivity: 2,
- minZoom: void 0,
- maxZoom: void 0,
- enableOptimize: !1,
- optimizeZoom: 0.1,
- fixSelectedItems: {
- fixAll: !1,
- fixLineWidth: !1,
- fixLabel: !1,
- fixState: "selected",
- },
- animate: !1,
- animateCfg: { duration: 500 },
- };
- },
- getEvents: function () {
- var t = this.fixSelectedItems;
- return (
- t.fixState || (t.fixState = "selected"),
- t.fixAll && ((t.fixLineWidth = !0), (t.fixLabel = !0)),
- {
- wheel: "onWheel",
- touchstart: "onTouchStart",
- touchmove: "onTouchMove",
- touchend: "onTouchEnd",
- }
- );
- },
- onTouchStart: function (t) {
- var e = t.originalEvent.touches,
- n = e[0],
- r = e[1];
- t.preventDefault(),
- r &&
- ((this.shouldBegin && !this.shouldBegin(t, this)) ||
- ((this.startPoint = { pageX: n.pageX, pageY: n.pageY }),
- (this.moveable = !0),
- r && (this.endPoint = { pageX: r.pageX, pageY: r.pageY }),
- (this.originScale =
- this.graph.getZoom() || this.currentScale || 1)));
- },
- onTouchMove: function (t) {
- if (this.moveable) {
- t.preventDefault();
- var e = t.originalEvent.touches,
- n = e[0],
- r = e[1];
- if (r) {
- this.endPoint ||
- (this.endPoint = { pageX: r.pageX, pageY: r.pageY });
- var i = function (t, e) {
- return Math.hypot(e.x - t.x, e.y - t.y);
- },
- o =
- i({ x: n.pageX, y: n.pageY }, { x: r.pageX, y: r.pageY }) /
- i(
- { x: this.startPoint.pageX, y: this.startPoint.pageY },
- { x: this.endPoint.pageX, y: this.endPoint.pageY }
- ),
- a = this.originScale * o;
- this.currentScale = a;
- var s = this.get("minZoom") || this.graph.get("minZoom");
- if (
- !(
- a > (this.get("maxZoom") || this.graph.get("maxZoom")) ||
- a < s
- )
- ) {
- var u = this.get("animate"),
- c = this.get("animateCfg"),
- l = this.graph
- .get("canvas")
- .getPointByClient(t.clientX, t.clientY);
- this.graph.zoomTo(a, { x: l.x, y: l.y }, u, c),
- this.graph.emit("wheelzoom", t);
- }
- }
- }
- },
- onTouchEnd: function () {
- (this.moveable = !1), (this.endPoint = null);
- },
- onWheel: function (t) {
- var e = this,
- n = this.graph,
- r = this.fixSelectedItems;
- if (
- (!this.shouldBegin || this.shouldBegin(t, this)) &&
- this.shouldUpdate(t, this)
- ) {
- t.preventDefault();
- var i = n.get("canvas").getPointByClient(t.clientX, t.clientY),
- o = this.get("sensitivity"),
- a = n.getZoom(),
- s = a;
- s = a * (t.wheelDelta < 0 ? 1 - 0.05 * o : 1 / (1 - 0.05 * o));
- var u = this.get("minZoom") || n.get("minZoom"),
- c = this.get("maxZoom") || n.get("maxZoom");
- if (
- (s > c ? (s = c) : s < u && (s = u), this.get("enableOptimize"))
- ) {
- var l = this.get("optimizeZoom"),
- f = this.get("optimized"),
- h = n.getNodes(),
- d = n.getEdges(),
- p = h.length,
- v = d.length;
- if (!f) {
- for (var y = 0; y < p; y++) {
- if (!(k = h[y]).destroyed)
- for (
- var m = (Z = k.get("group").get("children")).length,
- b = 0;
- b < m;
- b++
- ) {
- (R = Z[b]).destoryed ||
- R.get("isKeyShape") ||
- (R.set(
- "ori-visibility",
- R.get("ori-visibility") || R.get("visible")
- ),
- R.hide());
- }
- }
- for (var x = 0; x < v; x++)
- for (
- m = (Z = (q = d[x]).get("group").get("children")).length,
- b = 0;
- b < m;
- b++
- ) {
- (R = Z[b]).set(
- "ori-visibility",
- R.get("ori-visibility") || R.get("visible")
- ),
- R.hide();
- }
- this.set("optimized", !0);
- }
- clearTimeout(this.get("timeout"));
- var w = setTimeout(function () {
- var t = n.getZoom();
- if (e.get("optimized")) {
- e.set("optimized", !1);
- for (var r = 0; r < p; r++) {
- var i = h[r],
- o = (c = i.get("group").get("children")).length;
- if (t < l) {
- var a = (g = i.getKeyShape()).get("ori-visibility");
- g.set("ori-visibility", void 0), a && g.show();
- } else
- for (var s = 0; s < o; s++) {
- a = (y = c[s]).get("ori-visibility");
- y.set("ori-visibility", void 0),
- !y.get("visible") && a && a && y.show();
- }
- }
- for (var u = 0; u < v; u++) {
- var c,
- f = d[u];
- o = (c = f.get("group").get("children")).length;
- if (t < l) {
- var g;
- a = (g = f.getKeyShape()).get("ori-visibility");
- g.set("ori-visibility", void 0), a && g.show();
- } else
- for (s = 0; s < o; s++) {
- var y;
- if (!(y = c[s]).get("visible")) {
- a = y.get("ori-visibility");
- y.set("ori-visibility", void 0), a && y.show();
- }
- }
- }
- }
- }, 100);
- this.set("timeout", w);
- }
- if (a <= 1) {
- var E = void 0,
- _ = void 0;
- if (r.fixAll || r.fixLineWidth || r.fixLabel) {
- (E = n.findAllByState("node", r.fixState)),
- (_ = n.findAllByState("edge", r.fixState));
- for (var S = a / s, O = E.length, M = 0; M < O; M++) {
- var k,
- A = (k = E[M]).getContainer(),
- j = k.getModel(),
- C = k.getOriginStyle(),
- I = k.getStateStyle(r.fixState),
- T = k
- .get("shapeFactory")
- .getShape(j.type)
- .getStateStyle(r.fixState, k)[r.fixState];
- if (r.fixAll) {
- if (s <= 1) {
- var N = Object(g.clone)(A.getMatrix());
- N || (N = [1, 0, 0, 0, 1, 0, 0, 0, 1]);
- var P = k.getModel(),
- D = P.x,
- L = P.y;
- (N = Gu(N, [
- ["t", -D, -L],
- ["s", S, S],
- ["t", D, L],
- ])),
- A.setMatrix(N);
- }
- } else
- for (
- m = (Z = A.get("children")).length, b = 0;
- b < m;
- b++
- ) {
- var R = Z[b],
- B = void 0,
- F = void 0;
- if (r.fixLabel)
- if ("text" === R.get("type")) {
- B = R.attr("fontSize") || 12;
- var z = I[R.get("name")],
- G = T[R.get("name")],
- Y = z ? z.fontSize : 12,
- U = G ? G.fontSize : 12,
- X = Y || U || 12;
- if ((s <= 1 && R.attr("fontSize", X / s), F)) break;
- }
- if (r.fixLineWidth && R.get("isKeyShape")) {
- F = R.attr("lineWidth") || 0;
- var W =
- I.lineWidth || T.lineWidth || C.lineWidth || 0;
- if ((s <= 1 && R.attr("lineWidth", W / s), B)) break;
- }
- }
- }
- for (var V = _.length, H = 0; H < V; H++) {
- var q,
- Z = (A = (q = _[H]).getContainer()).get("children");
- for (
- j = q.getModel(),
- I = q.getStateStyle(r.fixState),
- T = q
- .get("shapeFactory")
- .getShape(j.type)
- .getStateStyle(r.fixState, q)[r.fixState],
- m = Z.length,
- b = 0;
- b < m;
- b++
- ) {
- (R = Z[b]), (B = void 0), (F = void 0);
- if (r.fixLabel || r.fixAll)
- if ("text" === R.get("type")) {
- B = R.attr("fontSize") || 12;
- (z = I[R.get("name")]),
- (G = T[R.get("name")]),
- (Y = z ? z.fontSize : 12),
- (U = G ? G.fontSize : 12),
- (X = Y || U || 12);
- if ((s <= 1 && R.attr("fontSize", X / s), F)) break;
- }
- if ((r.fixLineWidth || r.fixAll) && R.get("isKeyShape")) {
- F = R.attr("lineWidth") || 0;
- W = I.lineWidth || T.lineWidth || 1;
- if ((s <= 1 && R.attr("lineWidth", W / s), B)) break;
- }
- }
- }
- }
- }
- var K = this.get("animate"),
- Q = this.get("animateCfg");
- n.zoomTo(s, { x: i.x, y: i.y }, K, Q), n.emit("wheelzoom", t);
- }
- },
- },
- Uu = {
- onMouseEnter: function (t) {
- var e = t.item;
- (this.currentTarget = e),
- this.showTooltip(t),
- this.graph.emit("tooltipchange", {
- item: t.item,
- action: "show",
- });
- },
- onMouseMove: function (t) {
- this.shouldUpdate(t, this)
- ? this.currentTarget &&
- t.item === this.currentTarget &&
- this.updatePosition(t)
- : this.hideTooltip();
- },
- onMouseLeave: function (t) {
- this.shouldEnd(t, this) &&
- (this.hideTooltip(),
- this.graph.emit("tooltipchange", {
- item: this.currentTarget,
- action: "hide",
- }),
- (this.currentTarget = null));
- },
- showTooltip: function (t) {
- var e = this.container;
- if (t.item && !t.item.destroyed) {
- e ||
- ((e = this.createTooltip(this.graph.get("canvas"))),
- (this.container = e));
- var n = this.formatText(t.item.get("model"), t);
- (e.innerHTML = n),
- Hr(this.container, { visibility: "visible" }),
- this.updatePosition(t);
- }
- },
- hideTooltip: function () {
- Hr(this.container, { visibility: "hidden" });
- },
- updatePosition: function (t) {
- var e = this.get("shouldBegin"),
- n = this.width,
- r = this.height,
- i = this.container,
- o = this.graph;
- if (e(t, this)) {
- var a = o.getPointByClient(t.clientX, t.clientY),
- s = o.getCanvasByPoint(a.x, a.y),
- u = s.x,
- c = s.y,
- l = i.getBoundingClientRect();
- u > n / 2 ? (u -= l.width) : (u += this.offset),
- c > r / 2 ? (c -= l.height) : (c += this.offset);
- var f = "".concat(u, "px"),
- h = "".concat(c, "px");
- Hr(this.container, { left: f, top: h, visibility: "visible" });
- } else Hr(i, { visibility: "hidden" });
- },
- createTooltip: function (t) {
- var e = t.get("el");
- e.style.position = "relative";
- var n = Vr(
- '
')
- );
- return (
- e.parentNode.appendChild(n),
- Hr(n, { position: "absolute", visibility: "visible" }),
- (this.width = t.get("width")),
- (this.height = t.get("height")),
- (this.container = n),
- this.graph.get("tooltips").push(n),
- n
- );
- },
- },
- Xu = Object(p.__assign)(
- {
- getDefaultCfg: function () {
- return {
- item: "node",
- offset: 12,
- formatText: function (t) {
- return t.label;
- },
- };
- },
- getEvents: function () {
- return {
- "node:mouseenter": "onMouseEnter",
- "node:mouseleave": "onMouseLeave",
- "node:mousemove": "onMouseMove",
- afterremoveitem: "onMouseLeave",
- };
- },
- },
- Uu
- ),
- Wu = Object(p.__assign)(
- {
- getDefaultCfg: function () {
- return {
- item: "edge",
- offset: 12,
- formatText: function (t) {
- return "source: "
- .concat(t.source, " target: ")
- .concat(t.target);
- },
- };
- },
- getEvents: function () {
- return {
- "edge:mouseenter": "onMouseEnter",
- "edge:mouseleave": "onMouseLeave",
- "edge:mousemove": "onMouseMove",
- afterremoveitem: "onMouseLeave",
- };
- },
- },
- Uu
- ),
- Vu = ["click", "dblclick"],
- Hu = {
- getDefaultCfg: function () {
- return { trigger: "click", onChange: function () {} };
- },
- getEvents: function () {
- var t, e;
- return (
- Vu.includes(this.trigger)
- ? (e = this.trigger)
- : ((e = "click"),
- console.warn(
- "Behavior collapse-expand 的 trigger 参数不合法,请输入 'click' 或 'dblclick'"
- )),
- ((t = {})["node:".concat(e)] = "onNodeClick"),
- (t.touchstart = "onNodeClick"),
- t
- );
- },
- onNodeClick: function (t) {
- var e = this;
- if ("click" === this.trigger) {
- if (this.timer)
- return clearTimeout(this.timer), void (this.timer = 0);
- this.timer = setTimeout(function () {
- e.toggle(t), clearTimeout(e.timer), (e.timer = 0);
- }, 200);
- } else this.toggle(t);
- },
- toggle: function (t) {
- var e = t.item;
- if (e) {
- var n = this.graph.findDataById(e.get("id"));
- if (n) {
- var r = n.children;
- if (r && 0 !== r.length) {
- var i = !n.collapsed;
- this.shouldBegin(t, i, this) &&
- ((n.collapsed = i),
- (e.getModel().collapsed = i),
- this.graph.emit("itemcollapsed", {
- item: t.item,
- collapsed: i,
- }),
- this.shouldUpdate(t, i, this) &&
- (this.onChange(e, i, this), this.graph.layout()));
- }
- }
- }
- },
- },
- qu = ci.calculationItemsBBox,
- Zu = {
- getDefaultCfg: function () {
- return {
- enableDelegate: !1,
- delegateStyle: {},
- onlyChangeComboSize: !1,
- activeState: "",
- selectedState: "selected",
- enableStack: !0,
- };
- },
- getEvents: function () {
- return {
- "combo:mousedown": "onMouseDown",
- "combo:dragstart": "onDragStart",
- "combo:drag": "onDrag",
- "combo:dragend": "onDragEnd",
- "combo:drop": "onDrop",
- "node:drop": "onNodeDrop",
- "combo:dragenter": "onDragEnter",
- "combo:dragleave": "onDragLeave",
- };
- },
- validationCombo: function (t) {
- var e = t.item;
- return (
- !(!e || e.destroyed) &&
- !!this.shouldUpdate(t, this) &&
- "combo" === e.getType()
- );
- },
- onMouseDown: function (t) {
- this.origin = { x: t.x, y: t.y };
- },
- onDragStart: function (t) {
- var e = this,
- n = this.graph,
- r = t.item;
- if (((this.currentShouldEnd = !0), this.validationCombo(t))) {
- this.targets = [];
- var i = n.findAllByState("combo", this.selectedState),
- o = r.get("id");
- 0 ===
- i.filter(function (t) {
- var e = t.get("id");
- return o === e;
- }).length
- ? this.targets.push(r)
- : (this.targets = i);
- var a = [];
- this.targets.forEach(function (t) {
- var e = t.getModel(),
- n = e.x,
- r = e.y,
- i = e.id;
- a.push({ x: n, y: r, id: i });
- }),
- this.set("beforeDragItems", a),
- this.activeState &&
- this.targets.map(function (t) {
- var r = t.getModel();
- if (r.parentId) {
- var i = n.findById(r.parentId);
- i && n.setItemState(i, e.activeState, !0);
- }
- }),
- (this.point = {}),
- (this.originPoint = {}),
- (this.currentItemChildCombos = []),
- (function t(e, n) {
- if (!1 !== n(e) && e) {
- var r = e.get("combos");
- if (0 === r.length) return !1;
- Object(g.each)(r, function (e) {
- t(e, n);
- });
- }
- })(r, function (t) {
- if (t.destroyed) return !1;
- var n = t.getModel();
- return e.currentItemChildCombos.push(n.id), !0;
- });
- }
- },
- onDrag: function (t) {
- var e = this;
- if (this.origin && this.validationCombo(t))
- if (this.enableDelegate) this.updateDelegate(t);
- else {
- if (this.activeState) {
- var n = this.graph,
- r = t.item,
- i = r.getModel(),
- o = n.getCombos(),
- a = r.getBBox(),
- s = a.centerX,
- u = a.centerY,
- c = a.width;
- o.filter(function (t) {
- var n = t.getModel();
- return (
- i.parentId,
- n.id !== i.id && !e.currentItemChildCombos.includes(n.id)
- );
- }).map(function (t) {
- var r = t.getBBox(),
- i = r.centerX,
- o = r.centerY,
- a = r.width,
- l = s - i,
- f = u - o,
- h = 2 * Math.sqrt(l * l + f * f);
- c + a - h > 0.8 * c
- ? n.setItemState(t, e.activeState, !0)
- : n.setItemState(t, e.activeState, !1);
- });
- }
- Object(g.each)(this.targets, function (n) {
- e.updateCombo(n, t);
- }),
- this.onlyChangeComboSize && this.updateParentCombos();
- }
- },
- updatePositions: function (t, e) {
- var n = this;
- (this.enableDelegate || e) &&
- Object(g.each)(this.targets, function (r) {
- n.updateCombo(r, t, e);
- });
- },
- onDrop: function (t) {
- var e = this,
- n = t.item;
- if (
- ((this.currentShouldEnd = this.shouldEnd(t, n, this)),
- this.updatePositions(t, !this.currentShouldEnd),
- this.currentShouldEnd && n && this.targets && !n.destroyed)
- ) {
- var r = this.graph,
- i = n.getModel();
- this.targets.map(function (t) {
- t.getModel().parentId !== i.id
- ? (e.activeState && r.setItemState(n, e.activeState, !1),
- e.onlyChangeComboSize
- ? r.updateCombo(t)
- : r.updateComboTree(t, i.id, !1))
- : r.updateCombo(n);
- }),
- this.end(n, t),
- (this.endComparison = !0);
- }
- },
- onNodeDrop: function (t) {
- var e = this;
- if (this.targets && 0 !== this.targets.length) {
- var n = this.graph,
- r = t.item.getModel().comboId,
- i = r ? n.findById(r) : void 0;
- if (
- ((this.currentShouldEnd = this.shouldEnd(t, i, this)),
- this.updatePositions(t, !this.currentShouldEnd),
- this.currentShouldEnd)
- ) {
- var o;
- if (r) {
- if (this.activeState) {
- var a = n.findById(r);
- n.setItemState(a, this.activeState, !1);
- }
- this.targets.map(function (t) {
- e.onlyChangeComboSize
- ? n.updateCombo(t)
- : r !== t.getID() &&
- ((o = n.findById(r)),
- r !== t.getModel().parentId &&
- n.updateComboTree(t, r, !1));
- });
- } else
- this.targets.map(function (t) {
- e.onlyChangeComboSize
- ? n.updateCombo(t)
- : t.getModel().comboId &&
- n.updateComboTree(t, void 0, !1);
- });
- (this.endComparison = !0), this.end(o, t);
- }
- }
- },
- onDragEnter: function (t) {
- if (this.origin && this.validationCombo(t)) {
- var e = t.item,
- n = this.graph;
- this.activeState && n.setItemState(e, this.activeState, !0);
- }
- },
- onDragLeave: function (t) {
- if (this.origin && this.validationCombo(t)) {
- var e = t.item,
- n = this.graph;
- this.activeState && n.setItemState(e, this.activeState, !1);
- }
- },
- onDragEnd: function (t) {
- if (this.targets && 0 !== this.targets.length) {
- var e = t.item;
- this.currentShouldEnd && this.updatePositions(t);
- var n = this.getParentCombo(e.getModel().parentId),
- r = this.graph;
- n && this.activeState && r.setItemState(n, this.activeState, !1),
- this.end(void 0, t);
- }
- },
- end: function (t, e) {
- var n = this;
- if (this.origin) {
- var r = this.graph;
- if (this.delegateShape)
- r.get("delegateGroup").clear(), (this.delegateShape = null);
- if (
- (t &&
- this.activeState &&
- r.setItemState(t, this.activeState, !1),
- !t)
- ) {
- var i = r.get("enabledStack") && this.enableStack,
- o = {
- before: {
- nodes: [],
- edges: [],
- combos: [].concat(this.get("beforeDragItems")),
- },
- after: { nodes: [], edges: [], combos: [] },
- };
- this.targets.map(function (t) {
- if (n.onlyChangeComboSize) {
- r.updateCombo(t);
- var e = t.getModel(),
- a = e.x,
- s = e.y,
- u = e.id;
- o.after.combos.push({ x: a, y: s, id: u }),
- r.pushStack("update", o);
- } else r.updateComboTree(t, void 0, i);
- });
- }
- (this.point = []),
- (this.origin = null),
- (this.originPoint = null),
- (this.targets.length = 0);
- }
- },
- traverse: function (t, e, n) {
- var r = this;
- if ((void 0 === n && (n = {}), !1 !== e(t, n) && t)) {
- var i = t.get("combos");
- Object(g.each)(i, function (t) {
- r.traverse(t, e, n);
- });
- var o = t.get("nodes");
- Object(g.each)(o, function (t) {
- r.traverse(t, e, n);
- });
- }
- },
- updateCombo: function (t, e, n) {
- this.updateSingleItem(t, e, n);
- var r = {};
- this.traverse(
- t,
- function (t, e) {
- return (
- !t.destroyed &&
- (t.getEdges().forEach(function (t) {
- return (e[t.getID()] = t);
- }),
- !0)
- );
- },
- r
- ),
- Object.values(r).forEach(function (t) {
- return t.refresh();
- });
- },
- updateSingleItem: function (t, e, n) {
- var r = this.origin,
- i = this.graph,
- o = t.getModel(),
- a = t.get("id");
- this.point[a] || (this.point[a] = { x: o.x, y: o.y });
- var s = e.x - r.x + this.point[a].x,
- u = e.y - r.y + this.point[a].y;
- n && ((s += r.x - e.x), (u += r.y - e.y)),
- i.updateItem(t, { x: s, y: u }, !1);
- },
- getParentCombo: function (t) {
- var e = this.graph;
- if (t) {
- var n = e.findById(t);
- if (n) return n;
- }
- },
- updateDelegate: function (t) {
- var e = this.graph;
- if (this.delegateShape) {
- var n = t.x - this.origin.x + this.originPoint.minX,
- r = t.y - this.origin.y + this.originPoint.minY;
- this.delegateShape.attr({ x: n, y: r });
- } else {
- var i = e.get("delegateGroup"),
- o = null,
- a = (o =
- this.targets.length > 1
- ? qu(this.targets)
- : this.targets[0].getBBox()).x,
- s = o.y,
- u = o.width,
- c = o.height,
- l = o.minX,
- f = o.minY;
- this.originPoint = {
- x: a,
- y: s,
- width: u,
- height: c,
- minX: l,
- minY: f,
- };
- var h = Object(p.__assign)(
- Object(p.__assign)({}, Xr.delegateStyle),
- this.delegateStyle
- );
- (this.delegateShape = i.addShape("rect", {
- attrs: Object(p.__assign)(
- { width: o.width, height: o.height, x: o.x, y: o.y },
- h
- ),
- name: "combo-delegate-shape",
- })),
- this.delegateShape.set("capture", !1),
- (this.delegate = this.delegateShape);
- }
- },
- updateParentCombos: function () {
- var t = this.graph,
- e = this.targets,
- n = {};
- null == e ||
- e.forEach(function (e) {
- var r = e.getModel().parentId;
- r && (n[r] = t.findById(r));
- }),
- Object.values(n).forEach(function (e) {
- e && t.updateCombo(e);
- });
- },
- },
- Ku = ["click", "dblclick"],
- Qu = {
- getDefaultCfg: function () {
- return { trigger: "dblclick", relayout: !0 };
- },
- getEvents: function () {
- var t, e;
- return (
- Ku.includes(this.trigger)
- ? (e = this.trigger)
- : ((e = "dblclick"),
- console.warn(
- "Behavior collapse-expand-group 的 trigger 参数不合法,请输入 'click' 或 'dblclick'"
- )),
- ((t = {})["combo:".concat(e)] = "onComboClick"),
- t
- );
- },
- onComboClick: function (t) {
- var e = t.item,
- n = this.graph,
- r = this.relayout;
- if (e && !e.destroyed && "combo" === e.getType()) {
- var i = e.getModel().id;
- i &&
- (n.collapseExpandCombo(i),
- r && n.get("layout") ? n.layout() : n.refreshPositions());
- }
- },
- },
- $u = ci.isPolygonsIntersect,
- Ju = ci.pathToPoints,
- tc = ["drag", "shift", "ctrl", "alt", "control"],
- ec = ["click", "drag"],
- nc = ["shift", "ctrl", "control", "alt", "meta", void 0],
- rc = ["shift", "ctrl", "alt", "control"],
- ic = ["shift", "ctrl", "alt", "control", "meta"],
- oc = {
- "drag-canvas": Iu,
- "zoom-canvas": Yu,
- "drag-node": Tu,
- "activate-relations": Nu,
- "brush-select": Bu,
- "click-select": zu,
- "lasso-select": {
- getDefaultCfg: function () {
- return {
- delegateStyle: {
- fill: "#EEF6FF",
- fillOpacity: 0.4,
- stroke: "#DDEEFE",
- lineWidth: 1,
- },
- onSelect: function () {},
- onDeselect: function () {},
- shouldDeselect: void 0,
- selectedState: "selected",
- trigger: "shift",
- includeEdges: !0,
- selectedEdges: [],
- selectedNodes: [],
- };
- },
- getEvents: function () {
- return (
- tc.indexOf(this.trigger.toLowerCase()) > -1 ||
- ((this.trigger = "shift"),
- console.warn(
- "Behavior lasso-select 的 trigger 参数不合法,请输入 'drag'、'shift'、'ctrl' 或 'alt'"
- )),
- "drag" === this.trigger
- ? {
- dragstart: "onDragStart",
- drag: "onDragMove",
- dragend: "onDragEnd",
- "canvas:click": "clearStates",
- }
- : {
- dragstart: "onDragStart",
- drag: "onDragMove",
- dragend: "onDragEnd",
- keyup: "onKeyUp",
- keydown: "onKeyDown",
- "canvas:click": "clearStates",
- }
- );
- },
- onDragStart: function (t) {
- var e = this.lasso;
- t.item ||
- (("drag" === this.trigger || this.keydown) &&
- (this.selectedNodes &&
- 0 !== this.selectedNodes.length &&
- this.clearStates("dragstart"),
- e || (e = this.createLasso()),
- (this.dragging = !0),
- (this.originPoint = { x: t.x, y: t.y }),
- this.points.push(this.originPoint),
- e.show()));
- },
- onDragMove: function (t) {
- this.dragging &&
- ("drag" === this.trigger || this.keydown) &&
- (this.points.push({ x: t.x, y: t.y }), this.updateLasso(t));
- },
- onDragEnd: function (t) {
- (this.lasso || this.dragging) &&
- ("drag" === this.trigger || this.keydown) &&
- (this.points.push(this.originPoint),
- this.getSelectedItems(),
- this.lasso.remove(!0),
- (this.lasso = null),
- (this.points = []),
- (this.dragging = !1));
- },
- getLassoPath: function () {
- var t = this.points,
- e = [];
- return (
- t.length &&
- (t.forEach(function (t, n) {
- 0 === n ? e.push(["M", t.x, t.y]) : e.push(["L", t.x, t.y]);
- }),
- e.push(["L", t[0].x, t[0].y])),
- e
- );
- },
- clearStates: function (t) {
- void 0 === t && (t = "canvas:click");
- var e = this.graph,
- n = this.selectedState,
- r = this.shouldDeselect,
- i = e.findAllByState("node", n),
- o = e.findAllByState("edge", n);
- (r && !r({ action: t, nodes: i, edges: o })) ||
- (i.forEach(function (t) {
- return e.setItemState(t, n, !1);
- }),
- o.forEach(function (t) {
- return e.setItemState(t, n, !1);
- })),
- this.onDeselect &&
- this.onDeselect(this.selectedNodes, this.selectedEdges),
- (this.selectedNodes = []),
- (this.selectedEdges = []),
- e.emit("nodeselectchange", {
- selectedItems: { nodes: [], edges: [] },
- select: !1,
- });
- },
- getSelectedItems: function () {
- var t = this,
- e = this.graph,
- n = this.shouldUpdate,
- r = this.points.map(function (t) {
- return [
- e.getCanvasByPoint(t.x, t.y).x,
- e.getCanvasByPoint(t.x, t.y).y,
- ];
- }),
- i = this.selectedState,
- o = [],
- a = [];
- e.getNodes().forEach(function (s) {
- if (
- s.isVisible() &&
- (function (t, e) {
- var n,
- r = t.getKeyShape();
- if ("path" === t.get("type")) n = Ju(r.attr("path"));
- else {
- var i = r.getCanvasBBox();
- n = [
- [i.minX, i.minY],
- [i.maxX, i.minY],
- [i.maxX, i.maxY],
- [i.minX, i.maxY],
- ];
- }
- return $u(e, n);
- })(s, r) &&
- n(s, "select", t)
- ) {
- o.push(s);
- var u = s.getModel();
- a.push(u.id), e.setItemState(s, i, !0);
- }
- });
- var s = [];
- this.includeEdges &&
- o.forEach(function (r) {
- r.getOutEdges().forEach(function (r) {
- if (r.isVisible()) {
- var i = r.getModel(),
- o = i.source,
- u = i.target;
- a.includes(o) &&
- a.includes(u) &&
- n(r, "select", t) &&
- (s.push(r), e.setItemState(r, t.selectedState, !0));
- }
- });
- }),
- (this.selectedEdges = s),
- (this.selectedNodes = o),
- this.onSelect && this.onSelect(o, s),
- e.emit("nodeselectchange", {
- selectedItems: { nodes: o, edges: s },
- select: !0,
- });
- },
- createLasso: function () {
- var t = this.graph
- .get("delegateGroup")
- .addShape("path", {
- attrs: Object(p.__assign)({ path: [] }, this.delegateStyle),
- capture: !1,
- name: "lasso-shape",
- });
- return (
- (this.lasso = t), (this.delegate = t), (this.points = []), t
- );
- },
- updateLasso: function (t) {
- this.lasso.attr({ path: this.getLassoPath() });
- },
- onKeyDown: function (t) {
- var e = t.key;
- e &&
- (e.toLowerCase() === this.trigger.toLowerCase()
- ? (this.keydown = !0)
- : (this.keydown = !1));
- },
- onKeyUp: function () {
- this.lasso &&
- (this.lasso.remove(!0),
- (this.lasso = null),
- (this.points = []),
- (this.dragging = !1)),
- (this.keydown = !1);
- },
- },
- tooltip: Xu,
- "edge-tooltip": Wu,
- "collapse-expand": Hu,
- "drag-combo": Zu,
- "collapse-expand-combo": Qu,
- "create-edge": {
- getDefaultCfg: function () {
- return {
- trigger: "click",
- key: void 0,
- edgeConfig: {},
- getEdgeConfig: void 0,
- };
- },
- getEvents: function () {
- var t;
- return (
- ec.indexOf(this.trigger.toLowerCase()) > -1 ||
- ((this.trigger = "click"),
- console.warn(
- "Behavior create-edge 的 trigger 参数不合法,请输入 'click','drag'"
- )),
- this.key &&
- -1 === nc.indexOf(this.key.toLowerCase()) &&
- ((this.trigger = void 0),
- console.warn(
- "Behavior create-edge 的 key 参数不合法,请输入 'shift','ctrl','alt','control',或 undefined"
- )),
- "drag" === this.trigger
- ? (t = {
- "node:dragstart": "onClick",
- "combo:dragstart": "onClick",
- drag: "updateEndPoint",
- "node:drop": "onClick",
- "combo:drop": "onClick",
- dragend: "onDragEnd",
- })
- : "click" === this.trigger &&
- (t = {
- "node:click": "onClick",
- mousemove: "updateEndPoint",
- "edge:click": "cancelCreating",
- "canvas:click": "cancelCreating",
- "combo:click": "onClick",
- }),
- this.key && ((t.keydown = "onKeyDown"), (t.keyup = "onKeyUp")),
- t
- );
- },
- onDragEnd: function (t) {
- if (!this.key || this.keydown) {
- var e = t.item;
- (e && e.getID() !== this.source && "node" === e.getType()) ||
- this.cancelCreating({ item: this.edge, x: t.x, y: t.y });
- }
- },
- onClick: function (t) {
- if (!this.key || this.keydown) {
- var e = t.item,
- n = this.graph,
- r = e.getModel(),
- i = this.getEdgeConfig;
- if (this.addingEdge && this.edge) {
- if (!this.shouldEnd(t, this)) return;
- var o = void 0;
- o =
- i && Object(g.isFunction)(i)
- ? i({ source: this.source, target: r.id }, this)
- : this.edgeConfig;
- var a = Object(p.__assign)({ target: r.id }, o);
- if (
- (this.source === r.id && (a.type = "loop"),
- n.emit("beforecreateedge", {}),
- n.updateItem(this.edge, a, !1),
- n.get("enabledStack"))
- ) {
- var s = Object(p.__assign)(
- Object(p.__assign)({}, this.edge.getModel()),
- { itemType: "edge" }
- ),
- u = {};
- (u.edges = [s]),
- n.pushStack("add", { before: {}, after: u });
- }
- n.emit("aftercreateedge", { edge: this.edge }),
- this.edge.getKeyShape().set("capture", !0),
- (this.edge = null),
- (this.addingEdge = !1);
- } else {
- if (!this.shouldBegin(t, this)) return;
- o = void 0;
- (o =
- i && Object(g.isFunction)(i)
- ? i({ source: r.id, target: r.id }, this)
- : this.edgeConfig),
- (this.edge = n.addItem(
- "edge",
- Object(p.__assign)({ source: r.id, target: r.id }, o),
- !1
- )),
- (this.source = r.id),
- (this.addingEdge = !0),
- this.edge.getKeyShape().set("capture", !1);
- }
- }
- },
- updateEndPoint: function (t) {
- if (!this.key || this.keydown) {
- this.edge &&
- this.edge.destroyed &&
- this.cancelCreating({ item: this.edge });
- var e = { x: t.x, y: t.y };
- this.graph.findById(this.source)
- ? this.addingEdge &&
- this.edge &&
- this.graph.updateItem(this.edge, { target: e }, !1)
- : (this.addingEdge = !1);
- }
- },
- cancelCreating: function (t) {
- var e, n;
- if (!this.key || this.keydown) {
- var r = this.graph,
- i = t.item;
- return this.addingEdge &&
- (this.edge === i ||
- (null ===
- (n =
- null === (e = t.target) || void 0 === e
- ? void 0
- : e.isCanvas) || void 0 === n
- ? void 0
- : n.call(e)))
- ? (this.edge &&
- !this.edge.destroyed &&
- r.removeItem(this.edge, !1),
- (this.edge = null),
- void (this.addingEdge = !1))
- : void 0;
- }
- },
- onKeyDown: function (t) {
- var e = t.key;
- e &&
- (e.toLowerCase() === this.key.toLowerCase()
- ? (this.keydown = !0)
- : (this.keydown = !1));
- },
- onKeyUp: function () {
- this.addingEdge &&
- this.edge &&
- (this.graph.removeItem(this.edge, !1),
- (this.addingEdge = !1),
- (this.edge = null)),
- (this.keydown = !1);
- },
- },
- "shortcuts-call": {
- getDefaultCfg: function () {
- return {
- trigger: "ctrl",
- combinedKey: "1",
- functionName: "fitView",
- functionParams: [],
- };
- },
- getEvents: function () {
- return (
- rc.indexOf(this.trigger.toLowerCase()) > -1 ||
- ((this.trigger = "ctrl"),
- console.warn(
- "Behavior shortcuts-fit-view 的 trigger 参数 '".concat(
- this.trigger,
- "' 不合法,请输入 'drag'、'shift'、'ctrl' 或 'alt'"
- )
- )),
- this.combinedKey === this.trigger &&
- (this.combinedKey = void 0),
- { keyup: "onKeyUp", keydown: "onKeyDown" }
- );
- },
- onKeyDown: function (t) {
- var e = t.key;
- if (e) {
- var n = this.trigger.toLowerCase(),
- r = e.toLowerCase();
- this.triggerKeydown ||
- (this.triggerKeydown =
- r === n ||
- ("control" === r && "ctrl" === n) ||
- ("ctrl" === r && "control" === n));
- var i = this.graph;
- if (!i[this.functionName])
- return (
- console.warn(
- "Behavior shortcuts-fit-view 的 functionName 参数 '".concat(
- this.functionName,
- "' 不合法,它不是 Graph 的一个函数名"
- )
- ),
- {}
- );
- if (!this.triggerKeydown || this.combinedKey) {
- var o = this.combinedKey.toLowerCase();
- this.triggerKeydown &&
- (r === o ||
- ("control" === r && "ctrl" === o) ||
- ("ctrl" === r && "control" === o)) &&
- (this.functionParams && this.functionParams.length
- ? i[this.functionName].apply(i, this.functionParams)
- : i[this.functionName]());
- } else
- this.functionParams && this.functionParams.length
- ? i[this.functionName].apply(i, this.functionParams)
- : i[this.functionName]();
- }
- },
- onKeyUp: function () {
- this.brush &&
- (this.brush.remove(!0),
- (this.brush = null),
- (this.dragging = !1)),
- (this.triggerKeydown = !1);
- },
- },
- "scroll-canvas": {
- getDefaultCfg: function () {
- return {
- direction: "both",
- enableOptimize: !1,
- zoomKey: "ctrl",
- scalableRange: 0,
- allowDragOnItem: !0,
- };
- },
- getEvents: function () {
- return (
- (this.zoomKey && -1 !== ic.indexOf(this.zoomKey)) ||
- (this.zoomKey = "ctrl"),
- { wheel: "onWheel" }
- );
- },
- onWheel: function (t) {
- var e = this;
- if (this.allowDrag(t)) {
- var n = this.graph,
- r = Array.isArray(this.zoomKey)
- ? [].concat(this.zoomKey)
- : [this.zoomKey];
- if (
- (r.includes("control") && r.push("ctrl"),
- r.some(function (e) {
- return t["".concat(e, "Key")];
- }))
- ) {
- var i = n
- .get("canvas")
- .getPointByClient(t.clientX, t.clientY),
- o = n.getZoom();
- t.wheelDelta > 0 ? (o += 0.05 * o) : (o -= 0.05 * o),
- n.zoomTo(o, { x: i.x, y: i.y });
- } else {
- var a = t.deltaX || t.movementX,
- s = t.deltaY || t.movementY;
- !s &&
- navigator.userAgent.indexOf("Firefox") > -1 &&
- (s = (125 * -t.wheelDelta) / 3);
- var u = this.graph.get("width"),
- c = this.graph.get("height"),
- l = this.graph.get("canvas").getCanvasBBox(),
- f = this.scalableRange,
- h = this.scalableRange;
- f < 1 && f > -1 && ((f *= u), (h *= c));
- var d = l.minX,
- p = l.maxX,
- g = l.minY,
- v = l.maxY;
- a > 0
- ? p < -f
- ? (a = 0)
- : p - a < -f && (a = p + f)
- : a < 0 &&
- (d > u + f
- ? (a = 0)
- : d - a > u + f && (a = d - (u + f))),
- s > 0
- ? v < -h
- ? (s = 0)
- : v - s < -h && (s = v + h)
- : s < 0 &&
- (g > c + h
- ? (s = 0)
- : g - s > c + h && (s = g - (c + h))),
- "x" === this.get("direction")
- ? (s = 0)
- : "y" === this.get("direction") && (a = 0),
- n.translate(-a, -s);
- }
- if ((t.preventDefault(), this.get("enableOptimize"))) {
- var y = this.get("optimizeZoom"),
- m = this.get("optimized"),
- b = n.getNodes(),
- x = n.getEdges(),
- w = b.length,
- E = x.length;
- if (!m) {
- for (var _ = 0; _ < w; _++) {
- var S = b[_];
- if (!S.destroyed)
- for (
- var O = (A = S.get("group").get("children")).length,
- M = 0;
- M < O;
- M++
- ) {
- (j = A[M]).destoryed ||
- j.get("isKeyShape") ||
- (j.set(
- "ori-visibility",
- j.get("ori-visibility") || j.get("visible")
- ),
- j.hide());
- }
- }
- for (var k = 0; k < E; k++) {
- var A;
- for (
- O = (A = x[k].get("group").get("children")).length,
- M = 0;
- M < O;
- M++
- ) {
- var j;
- (j = A[M]).set(
- "ori-visibility",
- j.get("ori-visibility") || j.get("visible")
- ),
- j.hide();
- }
- }
- this.set("optimized", !0);
- }
- clearTimeout(this.get("timeout"));
- var C = setTimeout(function () {
- var t = n.getZoom();
- if (e.get("optimized")) {
- e.set("optimized", !1);
- for (var r = 0; r < w; r++) {
- var i = b[r],
- o = (c = i.get("group").get("children")).length;
- if (t < y)
- (s = (l = i.getKeyShape()).get("ori-visibility")) &&
- l.show();
- else
- for (var a = 0; a < o; a++) {
- var s = (h = c[a]).get("ori-visibility");
- !h.get("visible") && s && s && h.show();
- }
- }
- for (var u = 0; u < E; u++) {
- var c,
- l,
- f = x[u];
- o = (c = f.get("group").get("children")).length;
- if (t < y)
- (s = (l = f.getKeyShape()).get("ori-visibility")) &&
- l.show();
- else
- for (a = 0; a < o; a++) {
- var h;
- if (!(h = c[a]).get("visible"))
- (s = h.get("ori-visibility")) && h.show();
- }
- }
- }
- }, 100);
- this.set("timeout", C);
- }
- }
- },
- allowDrag: function (t) {
- var e,
- n,
- r = t.target,
- i = r && r.isCanvas && r.isCanvas();
- if (
- Object(g.isBoolean)(this.allowDragOnItem) &&
- !this.allowDragOnItem &&
- !i
- )
- return !1;
- if (Object(g.isObject)(this.allowDragOnItem)) {
- var o = this.allowDragOnItem,
- a = o.node,
- s = o.edge,
- u = o.combo,
- c =
- null ===
- (n =
- null === (e = t.item) || void 0 === e
- ? void 0
- : e.getType) || void 0 === n
- ? void 0
- : n.call(e);
- if (!a && "node" === c) return !1;
- if (!s && "edge" === c) return !1;
- if (!u && "combo" === c) return !1;
- }
- return !0;
- },
- },
- };
- Object(g.each)(oc, function (t, e) {
- br(e, t);
- });
- var ac = Object(p.__assign)(Object(p.__assign)({}, r), wr),
- sc = qs.Grid,
- uc = qs.Minimap,
- cc = qs.Bundling,
- lc = qs.Menu,
- fc = qs.Fisheye,
- hc = qs.ToolBar,
- dc = qs.Tooltip,
- pc = qs.TimeBar,
- gc = qs.ImageMinimap,
- vc = qs.EdgeFilterLens,
- yc = qs.SnapLine,
- mc = qs.Legend,
- bc = qs.Annotation,
- xc = {
- version: Xr.version,
- Graph: Di,
- TreeGraph: Bi,
- Util: ci,
- Layout: Qr.Layouts,
- TreeLayout: fi,
- registerLayout: hi,
- Global: Xr,
- registerBehavior: br,
- registerCombo: mr,
- registerEdge: yr,
- registerNode: vr,
- Minimap: qs.Minimap,
- Grid: qs.Grid,
- Bundling: qs.Bundling,
- Menu: qs.Menu,
- ToolBar: qs.ToolBar,
- Tooltip: qs.Tooltip,
- Legend: qs.Legend,
- TimeBar: pc,
- SnapLine: yc,
- Fisheye: fc,
- ImageMinimap: gc,
- EdgeFilterLens: vc,
- Annotation: bc,
- Algorithm: ac,
- Arrow: sr,
- Marker: ur,
- Shape: cr,
- };
- xc.version = "4.8.8";
- e.default = xc;
- var wc = "4.8.8";
- },
- ]).default;
-});
-//# sourceMappingURL=g6.min.js.map
diff --git a/lineage_panel/index.html b/lineage_panel/index.html
deleted file mode 100644
index 10603216e..000000000
--- a/lineage_panel/index.html
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
Lineage Graph
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/lineage_panel/main.js b/lineage_panel/main.js
deleted file mode 100644
index c69059f15..000000000
--- a/lineage_panel/main.js
+++ /dev/null
@@ -1,128 +0,0 @@
-const themeStyles = {
- dark: { style: { stroke: "#C5C5C5" } },
- light: { style: { stroke: "#232b2b" } },
-};
-
-const vscode = acquireVsCodeApi();
-const width = document.getElementById("container").scrollWidth;
-const height = document.getElementById("container").scrollHeight || 500;
-const container = document.getElementById("container");
-const legendData = {
- nodes: [
- { id: "current", label: "current node", style: { fill: "#88447D" } },
- { id: "parents", label: "parents", style: { fill: "#8DAAE8" } },
- { id: "children", label: "children", style: { fill: "#EFB27B" } },
- { id: "tests", label: "tests", style: { fill: "#8DE88E" } },
- ],
-};
-const legend = new G6.Legend({
- data: legendData,
- align: "center",
- layout: "vertical",
- position: "top-left",
- vertiSep: 12,
- horiSep: 24,
- padding: [8],
- containerStyle: {
- fill: "white",
- lineWidth: 1,
- radius: 5,
- },
-});
-
-const graph = new G6.Graph({
- container: "container",
- width,
- height,
- fitView: true,
- pixelRatio: 2.0,
- fitViewPadding: [20, 20, 20, 140],
- modes: {
- default: ["zoom-canvas", "click-select", "drag-canvas"],
- },
- layout: {
- type: "dagre",
- rankdir: "LR",
- align: "UL",
- controlPoints: true,
- nodesepFunc: () => 1,
- ranksepFunc: () => 1,
- },
- defaultNode: {
- size: [280, 40],
- type: "rect",
- labelCfg: { style: { fill: "#232b2b" } },
- style: {
- fontSize: 16,
- lineWidth: 3,
- },
- stateIcon: {
- show: false,
- },
- },
- nodeStateStyles: {
- hover: {
- opacity: 0.75,
- cursor: "pointer",
- },
- },
- defaultEdge: {
- type: "polyline",
- size: 1,
- color: "#232b2b",
- style: {
- lineWidth: 2,
- endArrow: true,
- },
- },
- plugins: [legend],
-});
-
-graph.on("nodeselectchange", (e) => {
- if (!e.target) {
- return;
- }
- const nodeUrl = e.target._cfg.model.url;
- vscode.postMessage({
- command: "openFile",
- args: { url: nodeUrl },
- });
-});
-
-graph.on("node:mouseenter", (e) => {
- const nodeItem = e.item; // Get the target item
- graph.setItemState(nodeItem, "hover", true);
-});
-
-graph.on("node:mouseleave", (e) => {
- const nodeItem = e.item;
- graph.setItemState(nodeItem, "hover", false);
-});
-
-const updateStyles = (theme) => {
- graph.getEdges().forEach((edge) => {
- graph.updateItem(edge, {
- ...themeStyles[theme],
- });
- });
-};
-
-window.addEventListener("message", (event) => {
- console.log("graph:message -> ", event?.data);
- const { command } = event?.data;
- if (command === "renderGraph") {
- graph.data(event.data.graph);
- graph.render();
- } else if (command === "setStylesByTheme") {
- updateStyles(event.data.theme);
- }
-});
-
-document.getElementById("new-panel-button")?.addEventListener("click", () => {
- vscode.postMessage({ command: "setNewLineageView" });
-});
-
-window.onload = () => {
- console.log("graph:onload -> ");
- vscode.postMessage({ command: "init", args: {} });
-};
diff --git a/lineage_panel/style.css b/lineage_panel/style.css
deleted file mode 100644
index c8cd886e4..000000000
--- a/lineage_panel/style.css
+++ /dev/null
@@ -1,32 +0,0 @@
-.top-right-container {
- position: absolute;
- top: 16px;
- right: 16px;
- display: flex;
- gap: 8px;
-}
-
-.btn {
- display: inline-block;
- padding: 0.375rem 0.75rem;
- color: #ffffff;
- text-align: center;
- text-decoration: none;
- vertical-align: middle;
- cursor: pointer;
- user-select: none;
- border: 1px solid #0d6efd;
- border-radius: 0.375rem;
- background-color: #0d6efd;
- font-size: 1rem;
- transition:
- color 0.15s ease-in-out,
- background-color 0.15s ease-in-out,
- border-color 0.15s ease-in-out,
- box-shadow 0.15s ease-in-out;
-}
-
-.btn:hover {
- background-color: #0b5ed7;
- border-color: #0a58ca;
-}
diff --git a/package.json b/package.json
index 3c0bb37f1..7a9d7038b 100644
--- a/package.json
+++ b/package.json
@@ -119,10 +119,6 @@
"displayName": "MCP Server SSL Certificate Path",
"default": ""
},
- "dbt.enableNewLineagePanel": {
- "type": "boolean",
- "description": "Enable the new lineage panel in dbt."
- },
"dbt.enableCollaboration": {
"type": "boolean",
"description": "Enable dbt docs collaboration.",
diff --git a/src/webview_provider/lineagePanel.ts b/src/webview_provider/lineagePanel.ts
index cc372c809..5653e1e9e 100644
--- a/src/webview_provider/lineagePanel.ts
+++ b/src/webview_provider/lineagePanel.ts
@@ -2,14 +2,12 @@ import {
CancellationToken,
commands,
Disposable,
- env,
TextEditor,
Uri,
WebviewView,
WebviewViewProvider,
WebviewViewResolveContext,
window,
- workspace,
} from "vscode";
import { provideSingleton } from "../utils";
import { TelemetryService } from "../telemetry";
@@ -18,7 +16,6 @@ import {
ManifestCacheChangedEvent,
ManifestCacheProjectAddedEvent,
} from "../manifest/event/manifestCacheChangedEvent";
-import { ModelGraphViewPanel } from "./modelGraphViewPanel";
import { NewLineagePanel } from "./newLineagePanel";
import { DBTTerminal } from "../dbt_client/dbtTerminal";
@@ -42,8 +39,7 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
public constructor(
private lineagePanel: NewLineagePanel,
- private legacyLineagePanel: ModelGraphViewPanel,
- dbtProjectContainer: DBTProjectContainer,
+ private dbtProjectContainer: DBTProjectContainer,
private telemetry: TelemetryService,
private dbtTerminal: DBTTerminal,
) {
@@ -65,12 +61,7 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
}
private getPanel() {
- const isEnableNewLineagePanel = workspace
- .getConfiguration("dbt")
- .get
("enableNewLineagePanel", false);
- return isEnableNewLineagePanel
- ? this.lineagePanel
- : this.legacyLineagePanel;
+ return this.lineagePanel;
}
private onManifestCacheChanged(event: ManifestCacheChangedEvent): void {
@@ -109,18 +100,12 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
this.panel = panel;
this.context = context;
this.token = token;
- const panelType = workspace
- .getConfiguration("dbt")
- .get("enableNewLineagePanel", false);
this.init();
panel.webview.onDidReceiveMessage(this.handleWebviewMessage, null, []);
const sendLineageViewEvent = () => {
if (this.panel!.visible) {
- // keeping the legacy event name same for analysis
- this.telemetry.sendTelemetryEvent(
- panelType ? "NewLineagePanelActive" : "LineagePanelActive",
- );
+ this.telemetry.sendTelemetryEvent("NewLineagePanelActive");
}
};
sendLineageViewEvent();
@@ -150,24 +135,6 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
return;
}
- if (command === "setNewLineageView") {
- await workspace
- .getConfiguration("dbt")
- .update("enableNewLineagePanel", true);
- this.init();
- this.telemetry.sendTelemetryEvent("NewLineagePanelSelected");
- return;
- }
-
- if (command === "setLegacyLineageView") {
- await workspace
- .getConfiguration("dbt")
- .update("enableNewLineagePanel", false);
- this.init();
- this.telemetry.sendTelemetryEvent("LegacyLineagePanelSelected");
- return;
- }
-
if (command === "init") {
this.getPanel()?.init();
return;
diff --git a/webview_panels/src/modules/lineage/ActionWidget.tsx b/webview_panels/src/modules/lineage/ActionWidget.tsx
index fa48d6c6c..26d4770d4 100644
--- a/webview_panels/src/modules/lineage/ActionWidget.tsx
+++ b/webview_panels/src/modules/lineage/ActionWidget.tsx
@@ -2,9 +2,6 @@ import MissingLineageMessageComponent from "./MissingLineageMessage";
import { MissingLineageMessage } from "./types";
import FeedbackButton from "@modules/commonActionButtons/FeedbackButton";
import HelpButton from "./components/help/HelpButton";
-import { Button } from "@uicore";
-import { executeRequestInAsync } from "@modules/app/requestExecutor";
-import { CLL } from "@lib";
import styles from "./lineage.module.scss";
const ActionWidget = ({
@@ -32,15 +29,6 @@ const ActionWidget = ({
-