UNPKG

igniteui-react-charts

Version:

Ignite UI React charting components for building rich data visualizations using TypeScript APIs.

422 lines (421 loc) 16.3 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { __extends } from "tslib"; import { Base, Point_$type, typeCast, markType } from "igniteui-react-core"; import { PathFigure } from "igniteui-react-core"; import { ViewportUtils } from "./ViewportUtils"; import { ArcSegment } from "igniteui-react-core"; import { Size } from "igniteui-react-core"; import { PathGeometry } from "igniteui-react-core"; import { LineSegment } from "igniteui-react-core"; import { LineGeometry } from "igniteui-react-core"; import { PolarAxisRenderingParameters } from "./PolarAxisRenderingParameters"; import { RadialAxisRenderingParameters } from "./RadialAxisRenderingParameters"; import { RangeInfo } from "./RangeInfo"; /** * @hidden */ var PolarAxisRenderingManager = /** @class */ /*@__PURE__*/ (function (_super) { __extends(PolarAxisRenderingManager, _super); function PolarAxisRenderingManager() { return _super !== null && _super.apply(this, arguments) || this; } PolarAxisRenderingManager.prototype.r = function (a, b, c, d, e, f, g) { var h = ViewportUtils.d(a, e, f, g); var i = ViewportUtils.h(a, e, f, g); var j = ViewportUtils.e(b.x, e, f, g); var k = ViewportUtils.i(b.y, e, f, g); if (d - c < Math.PI && d - c > 0) { var l = { $type: Point_$type, x: ViewportUtils.e(b.x + a * Math.cos(c), e, f, g), y: ViewportUtils.i(b.y + a * Math.sin(c), e, f, g) }; var m_1 = { $type: Point_$type, x: ViewportUtils.e(b.x + a * Math.cos(d), e, f, g), y: ViewportUtils.i(b.y + a * Math.sin(d), e, f, g) }; var n = new PathFigure(); n._startPoint = l; n._isClosed = false; n._segments.add(((function () { var $ret = new ArcSegment(); $ret.b = false; $ret.e = m_1; $ret.f = new Size(1, h, i); $ret.d = 1; return $ret; })())); return n; } else { var o = new PathFigure(); o._startPoint = { $type: Point_$type, x: j, y: k - i }; o._isClosed = true; o._segments.add(((function () { var $ret = new ArcSegment(); $ret.b = false; $ret.e = { $type: Point_$type, x: j, y: k + i }; $ret.f = new Size(1, h, i); $ret.d = 1; return $ret; })())); o._segments.add(((function () { var $ret = new ArcSegment(); $ret.b = false; $ret.e = { $type: Point_$type, x: j, y: k - i }; $ret.f = new Size(1, h, i); $ret.d = 1; return $ret; })())); return o; } }; PolarAxisRenderingManager.prototype.l = function (a, b, c, d, e, f, g, h, i) { var j = Math.min(b, c); var k = Math.max(b, c); var l = new PathGeometry(); var m = null; var n = null; var o = null; var p = null; if (j > 0) { m = this.r(j, g, h, i, f, d, e); if (i - h < Math.PI && i - h > 0) { var q = typeCast(ArcSegment.$, m._segments._inner[0]); if (q != null) { var r_1 = { $type: Point_$type, x: ViewportUtils.e(g.x + k * Math.cos(i), f, d, e), y: ViewportUtils.i(g.y + k * Math.sin(i), f, d, e) }; n = ((function () { var $ret = new LineSegment(1); $ret.c = r_1; return $ret; })()); } } } if (k > 0) { o = this.r(k, g, h, i, f, d, e); } if (j > 0) { if (i - h < Math.PI && i - h > 0) { var s = o._startPoint; var t = typeCast(ArcSegment.$, o._segments._inner[0]); if (t != null) { o._startPoint = t.e; t.e = s; t.d = 0; var u_1 = { $type: Point_$type, x: ViewportUtils.e(g.x + j * Math.cos(h), f, d, e), y: ViewportUtils.i(g.y + j * Math.sin(h), f, d, e) }; p = ((function () { var $ret = new LineSegment(1); $ret.c = u_1; return $ret; })()); } } } if (n != null && p != null) { m._segments.add(n); var v = o._segments._inner[0]; o._segments.remove(v); m._segments.add(v); m._segments.add(p); m._isClosed = true; l.c.add(m); } else { if (m != null) { l.c.add(m); this.q(o); } if (o != null) { l.c.add(o); } } a.add(l); }; PolarAxisRenderingManager.prototype.q = function (a) { if (a._segments.count > 1) { var b = typeCast(ArcSegment.$, a._segments._inner[0]); var c = typeCast(ArcSegment.$, a._segments._inner[1]); a._segments._inner[0] = c; a._segments._inner[1] = b; var d = c.e; var e = a._startPoint; var f = b.e; a._startPoint = d; c.e = f; b.e = e; b.d = 0; c.d = 0; } else { var g = a._startPoint; var h = typeCast(ArcSegment.$, a._segments._inner[0]); if (h != null) { a._startPoint = h.e; h.e = g; h.d = 0; } } }; PolarAxisRenderingManager.prototype.k = function (a, b, c, d, e, f, g, h) { if (b > 0) { var i = new PathGeometry(); i.c.add(this.r(b, f, g, h, e, c, d)); a.add(i); } }; PolarAxisRenderingManager.prototype.p = function (a, b, c, d, e, f, g, h, i) { var j = Math.min(b, c); var k = Math.max(b, c); var l = false; if (k - j > Math.PI) { l = true; } var m = Math.cos(j); var n = Math.sin(j); var o = i.x + m * g; var p = i.y + n * g; var q = i.x + m * h; var r = i.y + n * h; var s = Math.cos(k); var t = Math.sin(k); var u = i.x + s * g; var v = i.y + t * g; var w = i.x + s * h; var x = i.y + t * h; o = ViewportUtils.e(o, f, d, e); p = ViewportUtils.i(p, f, d, e); q = ViewportUtils.e(q, f, d, e); r = ViewportUtils.i(r, f, d, e); u = ViewportUtils.e(u, f, d, e); v = ViewportUtils.i(v, f, d, e); w = ViewportUtils.e(w, f, d, e); x = ViewportUtils.i(x, f, d, e); var y = new PathFigure(); y._startPoint = { $type: Point_$type, x: o, y: p }; y._isClosed = true; y._segments.add(((function () { var $ret = new LineSegment(1); $ret.c = { $type: Point_$type, x: q, y: r }; return $ret; })())); y._segments.add(((function () { var $ret = new ArcSegment(); $ret.e = { $type: Point_$type, x: w, y: x }; $ret.f = new Size(1, ViewportUtils.d(h, f, d, e), ViewportUtils.h(h, f, d, e)); $ret.d = 1; $ret.b = l; return $ret; })())); y._segments.add(((function () { var $ret = new LineSegment(1); $ret.c = { $type: Point_$type, x: u, y: v }; return $ret; })())); y._segments.add(((function () { var $ret = new ArcSegment(); $ret.e = { $type: Point_$type, x: o, y: p }; $ret.f = new Size(1, ViewportUtils.d(g, f, d, e), ViewportUtils.h(g, f, d, e)); $ret.d = 0; $ret.b = l; return $ret; })())); var z = new PathGeometry(); z.c.add(y); a.add(z); }; PolarAxisRenderingManager.prototype.o = function (a, b, c, d, e, f, g, h) { var i = new LineGeometry(); var j = Math.cos(b); var k = Math.sin(b); var l = h.x + j * f; var m = h.y + k * f; var n = h.x + j * g; var o = h.y + k * g; l = ViewportUtils.e(l, e, c, d); m = ViewportUtils.i(m, e, c, d); n = ViewportUtils.e(n, e, c, d); o = ViewportUtils.i(o, e, c, d); i.d = { $type: Point_$type, x: l, y: m }; i.c = { $type: Point_$type, x: n, y: o }; a.add(i); }; PolarAxisRenderingManager.prototype.a = function (a, b, c, d) { var e = { $type: Point_$type, x: ViewportUtils.e(a.x, b, c, d), y: ViewportUtils.i(a.y, b, c, d) }; return (e.x >= c.left && e.x <= c.right); }; PolarAxisRenderingManager.prototype.b = function (a, b, c, d) { var e = { $type: Point_$type, x: ViewportUtils.e(a.x, b, c, d), y: ViewportUtils.i(a.y, b, c, d) }; return (e.y >= c.top && e.y <= c.bottom); }; PolarAxisRenderingManager.prototype.c = function (a, b, c, d) { var e = this.d(a, { $type: Point_$type, x: c.left, y: c.top }, b, c, d); var f = this.d(a, { $type: Point_$type, x: c.right, y: c.top }, b, c, d); var g = this.d(a, { $type: Point_$type, x: c.right, y: c.bottom }, b, c, d); var h = this.d(a, { $type: Point_$type, x: c.left, y: c.bottom }, b, c, d); return Math.min(e, Math.min(f, Math.min(g, h))); }; PolarAxisRenderingManager.prototype.f = function (a, b, c, d) { var e = this.d(a, { $type: Point_$type, x: c.left, y: c.top }, b, c, d); var f = this.d(a, { $type: Point_$type, x: c.right, y: c.top }, b, c, d); var g = this.d(a, { $type: Point_$type, x: c.right, y: c.bottom }, b, c, d); var h = this.d(a, { $type: Point_$type, x: c.left, y: c.bottom }, b, c, d); return Math.max(e, Math.max(f, Math.max(g, h))); }; PolarAxisRenderingManager.prototype.d = function (a, b, c, d, e) { var f = { $type: Point_$type, x: ViewportUtils.e(a.x, c, d, e), y: ViewportUtils.i(a.y, c, d, e) }; var g = b; var h = Math.sqrt((f.x - g.x) * (f.x - g.x) + (f.y - g.y) * (f.y - g.y)); var i = ViewportUtils.a(h, c, d, e); return i; }; PolarAxisRenderingManager.prototype.e = function (a, b, c, d, e) { var f = { $type: Point_$type, x: ViewportUtils.e(a.x, c, d, e), y: ViewportUtils.i(a.y, c, d, e) }; var g = { $type: Point_$type, x: ViewportUtils.e(b.x, c, d, e), y: ViewportUtils.i(b.y, c, d, e) }; var h = Math.sqrt((f.x - g.x) * (f.x - g.x) + (f.y - g.y) * (f.y - g.y)); var i = ViewportUtils.a(h, c, d, e); return i; }; PolarAxisRenderingManager.prototype.h = function (a, b, c) { var d = { $type: Point_$type, x: 0.5, y: 0.5 }; if (this.a(d, a, b, c) && this.b(d, a, b, c)) { return 0; } if (this.a(d, a, b, c)) { if (d.y < a.top) { return this.e(d, { $type: Point_$type, x: d.x, y: a.top }, a, b, c); } else { return this.e(d, { $type: Point_$type, x: d.x, y: a.bottom }, a, b, c); } } if (this.b(d, a, b, c)) { if (d.x < a.left) { return this.e(d, { $type: Point_$type, x: a.left, y: d.y }, a, b, c); } else { return this.e(d, { $type: Point_$type, x: a.right, y: d.y }, a, b, c); } } return this.c(d, a, b, c); }; PolarAxisRenderingManager.prototype.i = function (a, b, c) { var d = { $type: Point_$type, x: 0.5, y: 0.5 }; return this.f(d, a, b, c); }; PolarAxisRenderingManager.prototype.g = function (a, b) { var c = Math.sqrt(Math.pow(b.x - a.x, 2) + Math.pow(b.y - a.y, 2)); var d = Math.acos((b.x - a.x) / c); if ((b.y - a.y) < 0) { d = (2 * Math.PI) - d; } return d; }; PolarAxisRenderingManager.prototype.j = function (a, b) { return ((a.y - 0.5) * b.x) + ((0.5 - a.x) * b.y) + ((a.x * 0.5) - (0.5 * a.y)); }; PolarAxisRenderingManager.prototype.n = function (a, b, c, d, e) { var f = { $type: Point_$type, x: 0.5, y: 0.5 }; if (this.a(f, a, b, c) && this.b(f, a, b, c)) { d = 0; e = Math.PI * 2; return { p3: d, p4: e }; } var g = { $type: Point_$type, x: ViewportUtils.e(f.x, a, b, c), y: ViewportUtils.i(f.y, a, b, c) }; var h = this.g(g, { $type: Point_$type, x: b.left, y: b.top }); var i = this.g(g, { $type: Point_$type, x: b.right, y: b.top }); var j = this.g(g, { $type: Point_$type, x: b.right, y: b.bottom }); var k = this.g(g, { $type: Point_$type, x: b.left, y: b.bottom }); if (this.b(f, a, b, c) && b.left > g.x) { d = h; e = 2 * Math.PI + k; return { p3: d, p4: e }; } d = Math.min(h, Math.min(i, Math.min(j, k))); e = Math.max(h, Math.max(i, Math.max(j, k))); return { p3: d, p4: e }; }; PolarAxisRenderingManager.prototype.m = function (a, b, c, d, e, f, g, h, i) { var j; var k; var l = this.n(a, b, c, j, k); j = l.p3; k = l.p4; var m = Math.min(j, k); var n = Math.max(j, k); if (typeCast(PolarAxisRenderingParameters.$, d) !== null) { d.minAngle = m; d.maxAngle = n; } else if (typeCast(RadialAxisRenderingParameters.$, d) !== null) { d.minAngle = m; d.maxAngle = n; } if (j == 0 && k == Math.PI * 2) { var o = e; var p = f; var q_1 = Math.min(o, p); var r_2 = Math.max(o, p); d.k.add(((function () { var $ret = new RangeInfo(); $ret.d = q_1; $ret.c = r_2; $ret.b = i; return $ret; })())); return; } else { if (k > Math.PI * 2) { k = k - Math.PI * 2; } var s = h(j); var t = h(k); if (s < e || s > f) { s = h(j + Math.PI * 2); } if (t < e || t > f) { t = h(k + Math.PI * 2); } var u_2 = Math.min(s, t); var v_1 = Math.max(s, t); if ((!g && s > t) || (g && s < t)) { var w_1 = (f - v_1); var x_1 = (u_2 - e); d.k.add(((function () { var $ret = new RangeInfo(); $ret.d = v_1; $ret.c = f; $ret.b = (w_1 / (w_1 + x_1)) * i; return $ret; })())); d.k.add(((function () { var $ret = new RangeInfo(); $ret.d = e; $ret.c = u_2; $ret.b = (x_1 / (w_1 + x_1)) * i; return $ret; })())); } else { d.k.add(((function () { var $ret = new RangeInfo(); $ret.d = u_2; $ret.c = v_1; $ret.b = i; return $ret; })())); } } }; PolarAxisRenderingManager.$t = markType(PolarAxisRenderingManager, 'PolarAxisRenderingManager'); return PolarAxisRenderingManager; }(Base)); export { PolarAxisRenderingManager };