UNPKG

igniteui-react-charts

Version:

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

602 lines (601 loc) 20.4 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 { Base, typeCast, Point_$type, markType, PointUtil } from "igniteui-react-core"; import { Extensions } from "igniteui-react-core"; import { Brush } from "igniteui-react-core"; import { Color } from "igniteui-react-core"; import { BrushUtil } from "igniteui-react-core"; import { Defaults } from "./Defaults"; import { MathUtil } from "igniteui-react-core"; import { Size } from "igniteui-react-core"; import { RotateTransform } from "igniteui-react-core"; import { TransformGroup } from "igniteui-react-core"; import { BrushUtilCore } from "igniteui-react-core"; import { CoreGeometryUtil } from "igniteui-react-core"; import { FontInfo } from "igniteui-react-core"; import { Rect } from "igniteui-react-core"; import { RectUtil } from "igniteui-react-core"; import { stringIsNullOrEmpty } from "igniteui-react-core"; import { isNaN_ } from "igniteui-react-core"; /** * @hidden */ export let OverlayTextUtil = /*@__PURE__*/ (() => { class OverlayTextUtil extends Base { static ac(a) { let b = stringIsNullOrEmpty(a.textContent); let c = OverlayTextUtil.o(a.f, a.textVisible); let d = a.textLocation; if (d == 18) { c = false; } if (!c || b) { return; } if (!OverlayTextUtil.n(a.ad)) { return; } a.aa = OverlayTextUtil.ak(a.textLocation, a.ad, a.textAngle, a.horizontalMargin, a.verticalMargin, a.horizontalPadding, a.verticalPadding, a.ab, !a.g); if (!Extensions.a(a.aa)) { return; } OverlayTextUtil.y(a.ac, a.background, a.borderStroke, a.borderThickness, a.borderRadius); OverlayTextUtil.z(a.u, a.textColor); OverlayTextUtil.x(a); OverlayTextUtil.w(a); } static ae(a) { let b = typeCast(Brush.$, a); if (b != null) { let c = b.color.l < 100; if (c) { return ((() => { let $ret = new Brush(); $ret.color = OverlayTextUtil.aj; return $ret; })()); } } return BrushUtil.k(a, OverlayTextUtil.ai, OverlayTextUtil.aj); } static af(a, b, c, d) { if (b == null) { return OverlayTextUtil.ae(a); } else { return OverlayTextUtil.ah(b, c, d); } } static ad(a) { if (isNaN_(a.verticalPadding)) { a.verticalPadding = Defaults.dataAnnotationOverlayHorizontalPadding; } if (isNaN_(a.horizontalPadding)) { a.horizontalPadding = Defaults.dataAnnotationOverlayVerticalPadding; } if (a.borderRadius < 0) { a.borderRadius = 0; } if (a.verticalPadding < 0) { a.verticalPadding = 0; } if (a.horizontalPadding < 0) { a.horizontalPadding = 0; } a.background = OverlayTextUtil.ag(a.background, Defaults.dataAnnotationOverlayBackground); a.background = OverlayTextUtil.ah(a.background, a.backgroundShift, a.backgroundMode); a.borderStroke = OverlayTextUtil.ag(a.borderStroke, Defaults.dataAnnotationOverlayBorderStroke); a.borderStroke = OverlayTextUtil.ah(a.borderStroke, a.borderShift, a.borderMode); a.textColor = OverlayTextUtil.af(a.background, a.textColor, a.textColorShift, a.textColorMode); a.textEmpty = stringIsNullOrEmpty(a.textContent); a.textAngle = OverlayTextUtil.r(a.textAngle, !a.f); a.borderRadius = OverlayTextUtil.t(a.borderRadius, Defaults.dataAnnotationOverlayBorderCorner); a.borderThickness = OverlayTextUtil.t(a.borderThickness, Defaults.dataAnnotationOverlayBorderThickness); } static ah(a, b, c) { if (a != null && !isNaN_(b) && b != 0) { if (c == 0 || c == 1) { b = MathUtil.d(b, -1, 1); if (b < 0) { b *= -1; } return BrushUtil.o(a, b); } else if (c == 2) { return BrushUtil.q(a, b); } else if (c == 4 || c == 3) { b = MathUtil.d(b, -1, 1); if (b < 0) { b *= -1; } return BrushUtil.s(a, b); } } return a; } static w(a) { if (!OverlayTextUtil.n(a.ad)) { return; } if (!Extensions.a(a.aa)) { return; } let b = new Size(1, a.ad.width, a.ad.height); b.width += a.horizontalPadding * 2; b.height += a.verticalPadding * 2; b.width += a.borderThickness * 2; b.height += a.borderThickness * 2; let c = PointUtil.create(); c.x = a.aa.x - a.horizontalPadding; c.y = a.aa.y - a.verticalPadding; c.x -= a.borderThickness; c.y -= a.borderThickness; a.ac.width = b.width; a.ac.height = b.height; OverlayTextUtil.aa(a.ac, c); OverlayTextUtil.ab(a.ac, a.textAngle, b); } static x(a) { if (a == null) { return; } if (!OverlayTextUtil.n(a.ad)) { return; } if (!Extensions.a(a.aa)) { return; } OverlayTextUtil.aa(a.u, a.aa); OverlayTextUtil.ab(a.u, a.textAngle, a.ad); a.u.al = a.textContent; } static aa(a, b) { if (Extensions.a(b)) { a.n = b.x; a.o = b.y; } } static ab(a, b, c) { let d = Math.abs(b - 0) > 1E-06; if (isNaN_(b) || b == 0 || b == 360) { a.j = null; } else { let e = ((() => { let $ret = new RotateTransform(); $ret.j = b; $ret.k = 0.5 * c.width; $ret.l = 0.5 * c.height; return $ret; })()); let f = new TransformGroup(); f.j.add(e); a.j = f; } } static y(a, b, c, d, e) { let f = OverlayTextUtil.p(b); let g = OverlayTextUtil.p(c) && d > 0; if (g || f) { a._fill = b; a._stroke = c; a.ad = d; a.ap = e; a.aq = e; a._visibility = 0; } else { a._visibility = 1; } } static z(a, b) { a.ao = b; } static p(a) { if (a == null) { return false; } if (a != null) { return !BrushUtilCore.a(a); } return false; } static ag(a, b) { return a != null ? a : b; } static t(a, b) { return !isNaN_(a) ? a : b; } static r(a, b) { let c = !isNaN_(a) ? a : b ? 90 : 0; c = CoreGeometryUtil.a(a); return c; } static s(a) { return !isNaN_(a) ? a : 1; } static k(a) { return isNaN_(a.f) && stringIsNullOrEmpty(a.q) && !stringIsNullOrEmpty(a.fontString) && a.fontString != "NaNpx/normal"; } static o(a, b) { if (!b) { return false; } if (a != null) { return a.f > 0; } return false; } static n(a) { if (isNaN_(a.width) || a.width <= 0) { return false; } if (isNaN_(a.height) || a.height <= 0) { return false; } return true; } static m(a) { if (isNaN_(a.x)) { return false; } if (isNaN_(a.y)) { return false; } return true; } static q(a) { if (a == null) { return true; } if (a.q == null) { return isNaN_(a.f); } return false; } static ak(a, b, c, d, e, f, g, h, i) { let j = { $type: Point_$type, x: NaN, y: NaN }; if (!OverlayTextUtil.m(h)) { return j; } if (!OverlayTextUtil.n(b)) { return j; } a = OverlayTextUtil.a(a, h, i); if (a == 18) { return j; } let k = h.x + h.width; let l = h.y + h.height; let m = h.x; let n = h.y; let o = h.width; let p = h.height; if (isNaN_(e)) { e = OverlayTextUtil.g(a) ? 0 : Defaults.dataAnnotationOverlayVerticalMargin; } if (isNaN_(d)) { d = OverlayTextUtil.e(a) ? 0 : Defaults.dataAnnotationOverlayHorizontalMargin; } if (isNaN_(g)) { g = Defaults.dataAnnotationOverlayVerticalPadding; } if (isNaN_(f)) { f = Defaults.dataAnnotationOverlayHorizontalPadding; } let q = new Rect(0, 0, 0, b.width, b.height); q.width += (f * 2); q.height += (g * 2); q.x -= f; q.y -= g; if (a == 1) { j.y = n + (p / 2) - (b.height / 2); j.x = m + (o / 2) - (b.width / 2); } else if (a == 2) { j.y = n + (p / 2) - (b.height / 2); j.x = m; } else if (a == 3) { j.y = n + (p / 2) - (b.height / 2); j.x = k - b.width; } else if (a == 5) { j.y = n; j.x = m + (o / 2) - (b.width / 2); } else if (a == 4) { j.y = n; j.x = m; } else if (a == 6) { j.y = n; j.x = k - b.width; } else if (a == 8) { j.y = l - b.height; j.x = m + (o / 2) - (b.width / 2); } else if (a == 7) { j.y = l - b.height; j.x = m; } else if (a == 9) { j.y = l - b.height; j.x = k - b.width; } else if (a == 11) { j.y = n - b.height; j.x = m + (o / 2) - (b.width / 2); } else if (a == 10) { j.y = i ? n : n - b.height; j.x = i ? m - b.width : m; } else if (a == 12) { j.y = i ? n : n - b.height; j.x = i ? k : k - b.width; } else if (a == 16) { j.y = l; j.x = m + (o / 2) - (b.width / 2); } else if (a == 15) { j.y = i ? l - b.height : l; j.x = i ? m - b.width : m; } else if (a == 17) { j.y = i ? l - b.height : l; j.x = i ? k : k - b.width; } else if (a == 13) { j.y = n + (p / 2) - (b.height / 2); j.x = m - b.width; } else if (a == 14) { j.y = n + (p / 2) - (b.height / 2); j.x = k; } if (!isNaN_(c) && c != 0) { let r = RectUtil.w(q, c); if (a == 4 || a == 2 || a == 7) { j.x -= r.left; } else if (a == 6 || a == 3 || a == 9) { j.x += r.left; } if (a == 4 || a == 5 || a == 6) { j.y -= r.top; } else if (a == 7 || a == 8 || a == 9) { j.y += r.top; } if (i) { if (a == 12 || a == 14 || a == 17) { j.x -= r.left; } else if (a == 10 || a == 13 || a == 15) { j.x += r.left; } if (a == 16 || a == 10 || a == 12) { j.y -= r.top; } else if (a == 11 || a == 15 || a == 17) { j.y += r.top; } } else { if (a == 14 || a == 10 || a == 15) { j.x -= r.left; } else if (a == 13 || a == 12 || a == 17) { j.x += r.left; } if (a == 15 || a == 16 || a == 17) { j.y -= r.top; } else if (a == 10 || a == 11 || a == 12) { j.y += r.top; } } } if (OverlayTextUtil.j(a)) { if (OverlayTextUtil.d(a)) { j.y -= e; } else { j.y += e; } if (OverlayTextUtil.h(a)) { j.x -= d; } else { j.x += d; } } else { if (i) { if (OverlayTextUtil.h(a)) { j.x -= d; } else { j.x += d; } if (a == 15 || a == 17 || a == 11) { j.y -= e; } else if (a == 10 || a == 12 || a == 13 || a == 14 || a == 16) { j.y += e; } } else { if (OverlayTextUtil.h(a)) { j.x += d; } else { j.x -= d; } if (a == 10 || a == 12 || a == 11 || a == 13 || a == 14) { j.y -= e; } else if (a == 15 || a == 17 || a == 16) { j.y += e; } } } return j; } static a(a, b, c) { if (a == 18) { return a; } if (b.width > 1 && b.height > 1) { if (a == 0) { return 1; } else { return a; } } else { if (c) { if (a == 0) { return 14; } else if (a == 9) { return 7; } else if (a == 7) { return 9; } else if (a == 6) { return 4; } else if (a == 4) { return 6; } else if (a == 3) { return 14; } else if (a == 2) { return 13; } else if (a == 12) { return 4; } else if (a == 10) { return 6; } else if (a == 17) { return 7; } else if (a == 15) { return 9; } else { return a; } } else { if (a == 0) { return 16; } else if (a == 7) { return 4; } else if (a == 4) { return 7; } else if (a == 9) { return 6; } else if (a == 6) { return 9; } else if (a == 12) { return 9; } else if (a == 10) { return 7; } else if (a == 17) { return 6; } else if (a == 15) { return 4; } else if (a == 5) { return 8; } else if (a == 8) { return 5; } else { return a; } } } } static f(a) { return a == 4 || a == 2 || a == 7 || a == 12 || a == 14 || a == 17; } static h(a) { return a == 10 || a == 13 || a == 15 || a == 6 || a == 3 || a == 9; } static i(a) { return a == 4 || a == 5 || a == 6 || a == 15 || a == 16 || a == 17; } static d(a) { return a == 10 || a == 11 || a == 12 || a == 7 || a == 8 || a == 9; } static g(a) { return a == 13 || a == 14 || a == 2 || a == 1 || a == 3; } static e(a) { return a == 11 || a == 16 || a == 5 || a == 1 || a == 8; } static j(a) { return a == 4 || a == 5 || a == 6 || a == 2 || a == 1 || a == 3 || a == 7 || a == 8 || a == 9; } static l(a) { return a == 10 || a == 11 || a == 12 || a == 13 || a == 14 || a == 15 || a == 16 || a == 17; } static c() { if (OverlayTextUtil.b == null) { OverlayTextUtil.b = ((() => { let $ret = new FontInfo(); $ret.q = Defaults.dataAnnotationOverlayFontFamily; $ret.f = Defaults.dataAnnotationOverlayFontSize; $ret.t = Defaults.dataAnnotationOverlayFontStyle; $ret.v = Defaults.dataAnnotationOverlayFontWeight; $ret.r = Defaults.dataAnnotationOverlayFontStretch; $ret.u = Defaults.dataAnnotationOverlayFontVariant; return $ret; })()); } return OverlayTextUtil.b; } static u(a) { for (let b = 0; b < a.count; b++) { a.item(b).al = null; } a.clear(); } static v(a) { for (let b = 0; b < a.count; b++) { a._inner[b].al = null; } a.clear(); } } OverlayTextUtil.$t = /*@__PURE__*/ markType(OverlayTextUtil, 'OverlayTextUtil'); OverlayTextUtil.aj = /*@__PURE__*/ Color.u(255, 0, 0, 0); OverlayTextUtil.ai = /*@__PURE__*/ Color.u(255, 255, 255, 255); OverlayTextUtil.b = null; return OverlayTextUtil; })();