igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
540 lines (539 loc) • 18.5 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-react-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-react-core";
import { ScalerParams } from "./ScalerParams";
import { NumericScaler } from "./NumericScaler";
import { EventArgs, runOn, delegateCombine, typeCast, enumGetBox, Date_$type, markType } from "igniteui-react-core";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { TimeAxisBase } from "./TimeAxisBase";
import { TimeXAxis } from "./TimeXAxis";
import { AxisRangeChangedEventArgs } from "./AxisRangeChangedEventArgs";
import { truncate } from "igniteui-react-core";
import { dateMaxValue, dateMinValue, dateAdd, dateSubtract } from "igniteui-react-core";
import { timeSpanFromMilliseconds, timeSpanTotalMilliseconds } from "igniteui-react-core";
/**
* @hidden
*/
export let OrdinalTimeXAxis = /*@__PURE__*/ (() => {
class OrdinalTimeXAxis extends CategoryXAxis {
f8(a, b, c) {
return this.f6(a, new ScalerParams(0, b, c, this.dn, this.o1()));
}
f7(a, b, c) {
return this.f6(a, b);
}
f6(a, b) {
if (!b.c.isEmpty) {
let c = this.s4(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.s4(a, b.e, b.d);
}
s4(a, b, c) {
let d = this.rt;
let e = this.ru;
let f = this.rt - this.ru;
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;
}
k0(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.rt;
let u = this.ru;
let v = this.rt - this.ru;
let w = this.rc(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;
}
}
}
}
k1(a, b, c, d) {
for (let e = b; e < c; e++) {
a.item(e, this.f6(a.item(e), d));
}
}
gb(a, b, c) {
return this.f9(a, new ScalerParams(0, b, this.o6, this.dn, this.o1()));
}
getUnscaledValue3(a, b, c, d) {
return this.f9(a, new ScalerParams(0, b, this.o6, this.dn, this.o1()));
}
f9(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.s5(c, NumericScaler.ac, b.c);
return c;
}
return this.s5(a, b.e, b.d);
}
s5(a, b, c) {
let d = b.left + (a - c.left) * b.width / c.width;
if (this.dp) {
d = 1 - d;
}
return this.ru + d * (this.rt - this.ru);
}
ga(a, b, c) {
return this.f9(a, b);
}
k2(a, b, c, d) {
for (let e = b; e < c; e++) {
a.item(e, this.f9(a.item(e), d));
}
}
constructor() {
super();
this.sr = dateMaxValue();
this.sq = dateMinValue();
this.sx = dateMaxValue();
this.sw = dateMinValue();
this.st = dateMaxValue();
this.ss = dateMinValue();
this.s7 = null;
this.s6 = null;
this.sm = 0;
this.so = null;
this.sk = null;
this.tg = 0;
this.sv = dateMinValue();
this.su = dateMaxValue();
this.visibleRangeChanged = null;
FastItemDateTimeColumn.o();
this.sk = new TimeAxisLabelFormatCollection();
let a = this.sl;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.ti));
this.ru = 0;
}
al() {
return new OrdinalTimeXAxis();
}
la(a, b, c, d) {
super.la(a, b, c, d);
switch (b) {
case "FastItemsSource":
let e = typeCast(IFastItemsSource_$type, c);
if (e != null) {
e.deregisterColumn(this.sp);
this.sp = null;
}
if (this.pm != null) {
this.sp = TimeAxisBase.rf(this.dateTimeMemberPath, this);
}
break;
case "DateTimeMemberPath":
if (this.pm != null) {
this.pm.deregisterColumn(this.sp);
this.sp = TimeAxisBase.rf(this.dateTimeMemberPath, this);
}
break;
case "DateTimeColumn":
this.ed();
this.tg = this.tf();
break;
case "MinimumValue":
case "MaximumValue":
this.ed();
this.lx();
break;
case "LabellingMode":
this.lx();
break;
}
}
get actualMinimumValue() {
return this.sr;
}
set actualMinimumValue(a) {
this.sr = a;
}
get actualMaximumValue() {
return this.sq;
}
set actualMaximumValue(a) {
this.sq = a;
}
get visibleMinimum() {
return this.sx;
}
set visibleMinimum(a) {
this.sx = a;
}
get visibleMaximum() {
return this.sw;
}
set visibleMaximum(a) {
this.sw = a;
}
get s1() {
return this.st;
}
set s1(a) {
this.st = a;
}
get s0() {
return this.ss;
}
set s0(a) {
this.ss = a;
}
tj() {
if (this.sp == null || this.sp.count == 0 || this.sp.count < this.ru - 1) {
this.actualMinimumValue = dateMinValue();
this.actualMaximumValue = dateMaxValue();
return;
}
let a = Math.max(0, Math.min(this.ru, this.sp.count - 1));
let b = Math.max(0, Math.min(this.rt, this.sp.count - 1));
let c = +(this.actualMinimumValue) != +(this.sp.item(a)) || +(this.actualMaximumValue) != +(this.sp.item(b));
if (c) {
let d = this.actualMinimumValue;
let e = this.actualMaximumValue;
this.actualMinimumValue = this.sp.item(a);
this.actualMaximumValue = this.sp.item(b);
this.tk();
}
}
tk() {
if (this.sp == null || this.sp.count == 0 || this.b7 == null) {
let a = +(this.visibleMinimum) != +(this.actualMinimumValue) || +(this.visibleMaximum) != +(this.actualMaximumValue);
this.visibleMinimum = this.actualMinimumValue;
this.visibleMaximum = this.actualMaximumValue;
this.s1 = this.visibleMinimum;
this.s0 = this.visibleMaximum;
if (a && this.visibleRangeChanged != null) {
this.visibleRangeChanged(this, EventArgs.empty);
}
return;
}
let b = this.o0();
let c = new ScalerParams(1, this.b7.za, this.b7.y9, this.dn);
c.c = this.o1();
let d = this.f9(b.left, c);
let e = this.f9(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.sp.count ? this.sp.item(f) : h;
let k = g >= 0 && g < this.sp.count ? this.sp.item(g) : i;
let l = j;
let m = k;
if (d > f) {
let n = f + 1;
let o = n >= 0 && n < this.sp.count ? this.sp.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.sp.count ? this.sp.item(q) : j;
let s = dateSubtract(+k, +(timeSpanFromMilliseconds(timeSpanTotalMilliseconds((+k - +r)) * (g - e))));
m = s;
}
this.s1 = l;
this.s0 = 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);
}
}
lz(a) {
let b = TimeXAxis.tl(this.actualMinimumValue, false, this.actualMinimumValue, this.sn, this.te, this.sl, this.g9);
if (b != this.s7 && this.eg) {
this.l3();
}
this.s7 = b;
super.lz(a);
}
get dateTimeMemberPath() {
return this.s6;
}
set dateTimeMemberPath(a) {
let b = this.dateTimeMemberPath;
if (a != b) {
this.s6 = a;
this.ls("DateTimeMemberPath", b, this.dateTimeMemberPath);
}
}
get sn() {
return this.sm;
}
set sn(a) {
let b = this.sn;
if (a != b) {
this.sm = a;
this.ls("LabellingMode", enumGetBox(TimeAxisLabellingMode_$type, b), enumGetBox(TimeAxisLabellingMode_$type, this.sn));
}
}
get_dr() {
return true;
}
get sp() {
return this.so;
}
set sp(a) {
if (this.so != a) {
let b = this.so;
this.so = a;
this.ls("DateTimeColumn", b, this.so);
}
}
me(a, b) {
super.me(a, b);
this.tk();
}
getWindowRectForSelection(a, b) {
if (this.sp == null) {
return Rect.empty;
}
let c = a > b;
let d = c ? b : a;
let e = c ? a : b;
let f = -1;
while (++f < this.sp.count && this.sp.item(f) < d) {
}
let g = this.sp.count;
while (--g >= 0 && this.sp.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.b7.yv);
let i = this.f6(f, h);
let j = this.f6(g + 1, h);
return new Rect(0, i, NaN, Math.max(0, j - i), NaN);
}
get sl() {
return this.sk;
}
ti(a, b) {
this.ly(false);
}
lc(a) {
super.lc(a);
this.dateTimeMemberPath = a;
}
hw(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.hw(a);
}
let b = dateMinValue();
let c = false;
if (this.rv != null) {
if (typeCast(Date_$type, this.rv) !== null) {
b = this.rv;
c = true;
}
}
let d = TimeXAxis.tg(a, c, b, this.sn, this.te, this.sl, this.g9);
return d == null ? super.hw(a) : d;
}
i8(a) {
let b = 0;
if (this.categoryMode == 0) {
b = truncate(Math.round(a));
}
else {
b = truncate(Math.floor(a));
}
if (b < 0 || b > this.qb - 1) {
return super.i8(a);
}
let c = this.sp.item(b);
let d = this.hw(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.qb - 1) {
b = this.qb - 1;
}
if (this.sp == null) {
return dateMinValue();
}
let c = this.sp.item(b);
return c;
}
get th() {
return +(this.visibleMaximum) - +(this.visibleMinimum);
}
get te() {
return +(this.s0) - +(this.s1);
}
re() {
return this.sp;
}
md(a, b) {
super.md(a, b);
this.tk();
}
rn(a, b) {
let c = this.categoryMode == 0 ? 0 : 0.5;
return super.rn(a + c, b);
}
rm(a, b, c, d) {
return b;
}
tf() {
if (this.sp == null || this.sp.count < 2) {
return (0);
}
return TimeXAxis.tr((a) => this.sp.item(a), this.sp.count);
}
itemLabelFormat() {
return TimeXAxis.tn(this.tg);
}
get minimumValue() {
return this.sv;
}
set minimumValue(a) {
let b = this.minimumValue;
if (+a != +b) {
this.sv = a;
this.la(this, "MinimumValue", b, this.minimumValue);
}
}
get maximumValue() {
return this.su;
}
set maximumValue(a) {
let b = this.maximumValue;
if (+a != +b) {
this.su = a;
this.la(this, "MaximumValue", b, this.maximumValue);
}
}
ef() {
if (+(this.minimumValue) == +(dateMaxValue()) || +(this.maximumValue) == +(dateMinValue())) {
return super.ef();
}
if (this.d0 && this.eg) {
this.b1 = this.b0();
}
if (this.pm == null || this.sp == null) {
return false;
}
let a = this.ru;
if (+(this.minimumValue) != +(dateMinValue())) {
let b = -1;
while (b++ <= this.sp.count) {
if (this.sp.item(b) >= this.minimumValue) {
break;
}
}
a = b;
}
let c = this.categoryMode == 0 ? this.pm.count - 1 : this.pm.count;
if (+(this.maximumValue) != +(dateMaxValue())) {
let d = this.pm.count;
while (d-- > 0) {
if (this.sp.item(d) <= this.maximumValue) {
break;
}
}
c = d;
}
if (a != this.ru || c != this.rt) {
let e = new AxisRangeChangedEventArgs(0, this.ru, a, this.rt, c);
this.ru = a;
this.rt = c;
this.lt(e);
this.tj();
this.qp();
return true;
}
return false;
}
qy(a) {
super.qy(a);
this.ee(true);
}
get isVertical() {
return this.dy;
}
j$d(a, b) {
return this.f9.apply(this, arguments);
}
j$c(a, b) {
return this.f6.apply(this, arguments);
}
j$e(a, b, c, d, e) {
this.k0.apply(this, arguments);
}
j$f(a, b, c, d) {
this.k1.apply(this, arguments);
}
j$g(a, b, c, d) {
this.k2.apply(this, arguments);
}
get j$b() {
return this.dn;
}
j$a() {
return this.ag.apply(this, arguments);
}
}
OrdinalTimeXAxis.$t = /*@__PURE__*/ markType(OrdinalTimeXAxis, 'OrdinalTimeXAxis', CategoryXAxis.$, [ITimeRangeSelectorAxis_$type, IOrdinalAxis_$type]);
return OrdinalTimeXAxis;
})();