UNPKG

igniteui-angular-charts

Version:

Ignite UI Angular charting components for building rich data visualizations for modern web apps.

131 lines (130 loc) 4.6 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 { Snapper } from "./Snapper"; import { markType } from "igniteui-angular-core"; import { truncate, isInfinity, isNaN_, log10 } from "igniteui-angular-core"; /** * @hidden */ var LinearNumericSnapper = /** @class */ /*@__PURE__*/ (function (_super) { __extends(LinearNumericSnapper, _super); function LinearNumericSnapper(a) { var _rest = []; for (var _i = 1; _i < arguments.length; _i++) { _rest[_i - 1] = arguments[_i]; } var _this = _super.call(this) || this; _this.i = 0; _this.g = 0; _this.k = 0; _this.j = 0; a = (a == void 0) ? 0 : a; switch (a) { case 0: { var c = _rest[0]; var d = _rest[1]; var e = _rest[2]; var f = _rest[3]; var g = _rest[4]; _this.i = g; if (f > 0) { _this.f = f; _this.b = true; } _this.l(c, d, e, 10); } break; case 1: { var c = _rest[0]; var d = _rest[1]; var e = _rest[2]; var f = _rest[3]; var g = _rest[4]; var h = _rest[5]; _this.i = h; if (g > 0) { _this.f = g; _this.b = true; } _this.l(c, d, e, f); } break; } return _this; } LinearNumericSnapper.prototype.l = function (a, b, c, d) { this.g = NaN; this.k = 0; this.j = 0; var e = 0; if (c < 100 && !this.b) { e = 4; } else { e = Math.min(d, truncate((c / this.f))); if (this.b && !isInfinity(this.f) && !isNaN_(this.f)) { e = Math.min(d + 1, truncate(((c + this.f) / this.f))); if (e == 0) { e = 1; } } } if (e > 0) { var f = this.h(a, b, e, true); if (this.b && (f + 1) > e) { this.g = NaN; f = this.h(a, b, e - 1, true); if (this.b && (f + 1) > e) { this.g = NaN; f = this.h(a, b, e - 1, false); } } e = f; if (c / e > this.f * 10) { this.j = 10; } else { if (c / e > this.f * 5) { this.j = 5; } else { if (c / e > this.f * 2) { this.j = 2; } } } this.k = Math.max(-truncate(Math.floor(log10(this.g))), 0); } }; LinearNumericSnapper.prototype.h = function (a, b, c, d) { var e = Snapper.e(b - a, false); var f = Math.max(1, c - 1); this.g = Snapper.e(e / f, d); if (this.i >= 0) { var g = Math.max(-truncate(Math.floor(log10(this.g))), 0); if (g > this.i) { var h = Math.pow(10, this.i); var i = this.g * h; i = Math.round(i); this.g = i / h; if (this.i == 0 && this.g == 0) { this.g = 1; } } } var j = Math.floor(a / this.g) * this.g; var k = Math.ceil(b / this.g) * this.g; var l = truncate(Math.round((k - j) / this.g)); return l; }; LinearNumericSnapper.$t = markType(LinearNumericSnapper, 'LinearNumericSnapper', Snapper.$); return LinearNumericSnapper; }(Snapper)); export { LinearNumericSnapper };