igniteui-angular-charts
Version:
Ignite UI Angular charting components for building rich data visualizations for modern web apps.
540 lines (539 loc) • 19 kB
JavaScript
/*
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 { FastItemDateTimeColumn } from "igniteui-angular-core";
import { CategoryXAxis } from "./CategoryXAxis";
import { ITimeRangeSelectorAxis_$type } from "./ITimeRangeSelectorAxis";
import { IOrdinalAxis_$type } from "./IOrdinalAxis";
import { TimeAxisLabellingMode_$type } from "./TimeAxisLabellingMode";
import { TimeAxisLabelFormatCollection } from "./TimeAxisLabelFormatCollection";
import { Rect } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { NumericScaler } from "./NumericScaler";
import { EventArgs, runOn, delegateCombine, typeCast, enumGetBox, Date_$type, markType } from "igniteui-angular-core";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { TimeAxisBase } from "./TimeAxisBase";
import { TimeXAxis } from "./TimeXAxis";
import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs";
import { truncate } from "igniteui-angular-core";
import { dateMaxValue, dateMinValue, dateAdd, dateSubtract } from "igniteui-angular-core";
import { timeSpanFromMilliseconds, timeSpanTotalMilliseconds } from "igniteui-angular-core";
/**
* @hidden
*/
export let OrdinalTimeXAxis = /*@__PURE__*/ (() => {
class OrdinalTimeXAxis extends CategoryXAxis {
constructor() {
super();
this.so = dateMaxValue();
this.sn = dateMinValue();
this.su = dateMaxValue();
this.st = dateMinValue();
this.sq = dateMaxValue();
this.sp = dateMinValue();
this.s4 = null;
this.s3 = null;
this.sj = 0;
this.sl = null;
this.sh = null;
this.td = 0;
this.ss = dateMinValue();
this.sr = dateMaxValue();
this.visibleRangeChanged = null;
FastItemDateTimeColumn.o();
this.sh = new TimeAxisLabelFormatCollection();
let a = this.si;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.tf));
this.rr = 0;
}
f7(a, b, c) {
return this.f5(a, new ScalerParams(0, b, c, this.dn, this.oy()));
}
f6(a, b, c) {
return this.f5(a, b);
}
f5(a, b) {
if (!b.c.isEmpty) {
let c = this.s1(a, NumericScaler.ac, b.c);
c = (c - b.d.left) / b.d.width;
c = b.d.left + b.d.width * (c - b.e.left) / b.e.width;
return c;
}
return this.s1(a, b.e, b.d);
}
s1(a, b, c) {
let d = this.rq;
let e = this.rr;
let f = this.rq - this.rr;
let g = f >= 1 ? (a - e) / (d - e) : f == 0 ? 0.5 : NaN;
if (this.dp) {
g = 1 - g;
}
return c.left + c.width * (g - b.left) / b.width;
}
kx(a, b, c, d, e) {
let f;
let g = e.e;
let h = e.d;
let i = e.c;
let j = e.a;
let k = !i.isEmpty;
let l = i.left;
let m = i.width;
let n = g.left;
let o = g.width;
let p = h.left;
let q = h.width;
let r = 0;
let s = 1;
let t = this.rq;
let u = this.rr;
let v = this.rq - this.rr;
let w = this.q9(a);
let x = w != null;
for (let y = 0; y < b.count; y++) {
let z = b.item(y);
for (let aa = c; aa < d; aa++) {
f = x ? w[aa] : a.item(aa);
if (k) {
let ab = v >= 1 ? (f[z] - u) / (t - u) : v == 0 ? 0.5 : NaN;
if (j) {
ab = 1 - ab;
}
ab = l + m * (ab - r) / s;
let ac = (ab - p) / q;
ac = p + q * (ac - n) / o;
f[z] = ac;
}
else {
let ad = v >= 1 ? (f[z] - u) / (t - u) : v == 0 ? 0.5 : NaN;
if (j) {
ad = 1 - ad;
}
ad = p + q * (ad - n) / o;
f[z] = ad;
}
}
}
}
ky(a, b, c, d) {
for (let e = b; e < c; e++) {
a.item(e, this.f5(a.item(e), d));
}
}
ga(a, b, c) {
return this.f8(a, new ScalerParams(0, b, this.o3, this.dn, this.oy()));
}
getUnscaledValue3(a, b, c, d) {
return this.f8(a, new ScalerParams(0, b, this.o3, this.dn, this.oy()));
}
f8(a, b) {
if (!b.c.isEmpty) {
let c = b.e.left + b.e.width * (a - b.d.left) / b.d.width;
c = (c * b.d.width) + b.d.left;
c = this.s2(c, NumericScaler.ac, b.c);
return c;
}
return this.s2(a, b.e, b.d);
}
s2(a, b, c) {
let d = b.left + (a - c.left) * b.width / c.width;
if (this.dp) {
d = 1 - d;
}
return this.rr + d * (this.rq - this.rr);
}
f9(a, b, c) {
return this.f8(a, b);
}
kz(a, b, c, d) {
for (let e = b; e < c; e++) {
a.item(e, this.f8(a.item(e), d));
}
}
al() {
return new OrdinalTimeXAxis();
}
k7(a, b, c, d) {
super.k7(a, b, c, d);
switch (b) {
case "FastItemsSource":
let e = typeCast(IFastItemsSource_$type, c);
if (e != null) {
e.deregisterColumn(this.sm);
this.sm = null;
}
if (this.pj != null) {
this.sm = TimeAxisBase.rc(this.dateTimeMemberPath, this);
}
break;
case "DateTimeMemberPath":
if (this.pj != null) {
this.pj.deregisterColumn(this.sm);
this.sm = TimeAxisBase.rc(this.dateTimeMemberPath, this);
}
break;
case "DateTimeColumn":
this.ec();
this.td = this.tc();
break;
case "MinimumValue":
case "MaximumValue":
this.ec();
this.lu();
break;
case "LabellingMode":
this.lu();
break;
}
}
get actualMinimumValue() {
return this.so;
}
set actualMinimumValue(a) {
this.so = a;
}
get actualMaximumValue() {
return this.sn;
}
set actualMaximumValue(a) {
this.sn = a;
}
get visibleMinimum() {
return this.su;
}
set visibleMinimum(a) {
this.su = a;
}
get visibleMaximum() {
return this.st;
}
set visibleMaximum(a) {
this.st = a;
}
get sy() {
return this.sq;
}
set sy(a) {
this.sq = a;
}
get sx() {
return this.sp;
}
set sx(a) {
this.sp = a;
}
tg() {
if (this.sm == null || this.sm.count == 0 || this.sm.count < this.rr - 1) {
this.actualMinimumValue = dateMinValue();
this.actualMaximumValue = dateMaxValue();
return;
}
let a = Math.max(0, Math.min(this.rr, this.sm.count - 1));
let b = Math.max(0, Math.min(this.rq, this.sm.count - 1));
let c = +(this.actualMinimumValue) != +(this.sm.item(a)) || +(this.actualMaximumValue) != +(this.sm.item(b));
if (c) {
let d = this.actualMinimumValue;
let e = this.actualMaximumValue;
this.actualMinimumValue = this.sm.item(a);
this.actualMaximumValue = this.sm.item(b);
this.th();
}
}
th() {
if (this.sm == null || this.sm.count == 0 || this.b2 == null) {
let a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue);
this.visibleMinimum = this.actualMinimumValue;
this.visibleMaximum = this.actualMaximumValue;
this.sy = this.visibleMinimum;
this.sx = this.visibleMaximum;
if (a && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
return;
}
let b = this.ox();
let c = new ScalerParams(1, this.b2.za, this.b2.y9, this.dn);
c.c = this.oy();
let d = this.f8(b.left, c);
let e = this.f8(b.right, c);
let f = truncate(Math.floor(d));
let g = truncate(Math.ceil(e));
let h = this.dn ? this.actualMaximumValue : this.actualMinimumValue;
let i = this.dn ? this.actualMinimumValue : this.actualMaximumValue;
let j = f >= 0 && f < this.sm.count ? this.sm.item(f) : h;
let k = g >= 0 && g < this.sm.count ? this.sm.item(g) : i;
let l = j;
let m = k;
if (d > f) {
let n = f + 1;
let o = n >= 0 && n < this.sm.count ? this.sm.item(n) : k;
let p = dateAdd(+j, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+o - +j)) * (d - f))));
l = p;
}
if (e < g) {
let q = g - 1;
let r = q >= 0 && q < this.sm.count ? this.sm.item(q) : j;
let s = dateSubtract(+k, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+k - +r)) * (g - e))));
m = s;
}
this.sy = l;
this.sx = m;
let t = +(this.visibleMinimum) != +j || +(this.visibleMaximum) != +k;
this.visibleMinimum = j;
this.visibleMaximum = k;
if (t && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
}
lw(a) {
let b = TimeXAxis.th(this.actualMinimumValue, false, this.actualMinimumValue, this.sk, this.tb, this.si, this.g8);
if (b != this.s4 && this.ef) {
this.l0();
}
this.s4 = b;
super.lw(a);
}
get dateTimeMemberPath() {
return this.s3;
}
set dateTimeMemberPath(a) {
let b = this.dateTimeMemberPath;
if (a != b) {
this.s3 = a;
this.lp("DateTimeMemberPath", b, this.dateTimeMemberPath);
}
}
get sk() {
return this.sj;
}
set sk(a) {
let b = this.sk;
if (a != b) {
this.sj = a;
this.lp("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.sk));
}
}
get_dr() {
return true;
}
get sm() {
return this.sl;
}
set sm(a) {
if (this.sl != a) {
let b = this.sl;
this.sl = a;
this.lp("DateTimeColumn", b, this.sl);
}
}
mb(a, b) {
super.mb(a, b);
this.th();
}
getWindowRectForSelection(a, b) {
if (this.sm == null) {
return Rect.empty;
}
let c = a > b;
let d = c ? b : a;
let e = c ? a : b;
let f = -1;
while (++f < this.sm.count && this.sm.item(f) < d) {
}
let g = this.sm.count;
while (--g >= 0 && this.sm.item(g) > e) {
}
let h = new ScalerParams(0, new Rect(0, 0, 0, 1, 1), new Rect(0, 0, 0, 1, 1), this.dn, this.b2.yv);
let i = this.f5(f, h);
let j = this.f5(g + 1, h);
return new Rect(0, i, NaN, Math.max(0, j - i), NaN);
}
get si() {
return this.sh;
}
tf(a, b) {
this.lv(false);
}
k9(a) {
super.k9(a);
this.dateTimeMemberPath = a;
}
hv(a) {
if (this.az != null) {
return this.az(a);
}
if (this.ai != null) {
return this.ai.i(a);
}
if (!(typeCast(Date_$type, a) !== null)) {
return super.hv(a);
}
let b = dateMinValue();
let c = false;
if (this.rs != null) {
if (typeCast(Date_$type, this.rs) !== null) {
b = this.rs;
c = true;
}
}
let d = TimeXAxis.tc(a, c, b, this.sk, this.tb, this.si, this.g8);
return d == null ? super.hv(a) : d;
}
i6(a) {
let b = 0;
if (this.categoryMode == 0) {
b = truncate(Math.round(a));
}
else {
b = truncate(Math.floor(a));
}
if (b < 0 || b > this.p8 - 1) {
return super.i6(a);
}
let c = this.sm.item(b);
let d = this.hv(c);
if (d == null) {
return null;
}
return d.toString();
}
getDateTime(a) {
let b = truncate(Math.round(a));
if (b < 0) {
b = 0;
}
if (b > this.p8 - 1) {
b = this.p8 - 1;
}
if (this.sm == null) {
return dateMinValue();
}
let c = this.sm.item(b);
return c;
}
get te() {
return +(this.visibleMaximum) - +(this.visibleMinimum);
}
get tb() {
return +(this.sx) - +(this.sy);
}
rb() {
return this.sm;
}
ma(a, b) {
super.ma(a, b);
this.th();
}
rk(a, b) {
let c = this.categoryMode == 0 ? 0 : 0.5;
return super.rk(a + c, b);
}
rj(a, b, c, d) {
return b;
}
tc() {
if (this.sm == null || this.sm.count < 2) {
return (0);
}
return TimeXAxis.tn((a) => this.sm.item(a), this.sm.count);
}
itemLabelFormat() {
return TimeXAxis.tj(this.td);
}
get minimumValue() {
return this.ss;
}
set minimumValue(a) {
let b = this.minimumValue;
if (+a != +b) {
this.ss = a;
this.k7(this, "MinimumValue", b, this.minimumValue);
}
}
get maximumValue() {
return this.sr;
}
set maximumValue(a) {
let b = this.maximumValue;
if (+a != +b) {
this.sr = a;
this.k7(this, "MaximumValue", b, this.maximumValue);
}
}
ee() {
if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) {
return super.ee();
}
if (this.d0 && this.ef) {
this.bw = this.bv();
}
if (this.pj == null || this.sm == null) {
return false;
}
let a = this.rr;
if (+(this.minimumValue) != +(dateMinValue())) {
let b = -1;
while (b++ <= this.sm.count) {
if (this.sm.item(b) >= this.minimumValue) {
break;
}
}
a = b;
}
let c = this.categoryMode == 0 ? this.pj.count - 1 : this.pj.count;
if (+(this.maximumValue) != +(dateMaxValue())) {
let d = this.pj.count;
while (d-- > 0) {
if (this.sm.item(d) <= this.maximumValue) {
break;
}
}
c = d;
}
if (a != this.rr || c != this.rq) {
let e = new AxisRangeChangedEventArgs(0, this.rr, a, this.rq, c);
this.rr = a;
this.rq = c;
this.lq(e);
this.tg();
this.qm();
return true;
}
return false;
}
qv(a) {
super.qv(a);
this.ed(true);
}
get isVertical() {
return this.dy;
}
j$d(a, b) {
return this.f8.apply(this, arguments);
}
j$c(a, b) {
return this.f5.apply(this, arguments);
}
j$e(a, b, c, d, e) {
this.kx.apply(this, arguments);
}
j$f(a, b, c, d) {
this.ky.apply(this, arguments);
}
j$g(a, b, c, d) {
this.kz.apply(this, arguments);
}
get j$b() {
return this.dn;
}
j$a() {
return this.ag.apply(this, arguments);
}
}
OrdinalTimeXAxis.$t = markType(OrdinalTimeXAxis, 'OrdinalTimeXAxis', CategoryXAxis.$, [ITimeRangeSelectorAxis_$type, IOrdinalAxis_$type]);
return OrdinalTimeXAxis;
})();