igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
707 lines (706 loc) • 25 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 { __extends, __values } from "tslib";
import { AnchoredRadialSeries } from "./AnchoredRadialSeries";
import { DependencyProperty } from "igniteui-react-core";
import { enumGetBox, Point_$type, runOn, typeCast, markType, markDep, fromEnum } from "igniteui-react-core";
import { LegendEmptyValuesMode_$type } from "igniteui-react-core";
import { Defaults } from "./Defaults";
import { Pool$1 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { RadialBaseView } from "./RadialBaseView";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-react-core";
import { ViewportUtils } from "./ViewportUtils";
import { SliceCoords } from "./SliceCoords";
import { PathFigure } from "igniteui-react-core";
import { LineSegment } from "igniteui-react-core";
import { ArcSegment } from "igniteui-react-core";
import { PieSliceCollisionGeometry } from "igniteui-react-core";
import { Size } from "igniteui-react-core";
import { GeometryUtil } from "igniteui-react-core";
import { MathUtil } from "igniteui-react-core";
import { ProportionalCategoryAngleAxis } from "./ProportionalCategoryAngleAxis";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { DataContext } from "igniteui-react-core";
import { ChartSelection } from "./ChartSelection";
import { CollisionRect } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { intDivide, isNaN_ } from "igniteui-react-core";
import { AnchoredRadialSeriesView } from "./AnchoredRadialSeriesView";
/**
* @hidden
*/
var RadialPieSeries = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(RadialPieSeries, _super);
function RadialPieSeries() {
var _this = _super.call(this) || this;
_this.adv = null;
_this.ad0 = null;
_this.ads = 0;
_this.ab = RadialPieSeries.$;
return _this;
}
RadialPieSeries.prototype.bk = function () {
return new RadialPieSeries();
};
RadialPieSeries.prototype.get_fo = function () {
return true;
};
RadialPieSeries.prototype.get_fm = function () {
return true;
};
RadialPieSeries.prototype.jl = function () {
if (!isNaN_(this.jk)) {
return _super.prototype.jl.call(this);
}
return Defaults.h;
};
RadialPieSeries.prototype.ct = function () {
return new RadialPieSeriesView(this);
};
RadialPieSeries.prototype.q3 = function (a) {
_super.prototype.q3.call(this, a);
this.adu = a;
};
Object.defineProperty(RadialPieSeries.prototype, "adw", {
get: function () {
return this.adv;
},
set: function (a) {
if (this.adv != a) {
var b = this.adw;
this.adv = a;
this.raisePropertyChanged("LegendLabelColumn", b, this.adw);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(RadialPieSeries.prototype, "ad3", {
get: function () {
return this.ad0;
},
set: function (a) {
if (this.ad0 != a) {
var b = this.ad0;
this.ad0 = a;
this.raisePropertyChanged("LegendLabelMemberPath", b, this.ad0);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(RadialPieSeries.prototype, "adt", {
get: function () {
return this.ads;
},
set: function (a) {
if (this.ads != a) {
var b = this.ads;
this.ads = a;
this.raisePropertyChanged("LegendEmptyValuesMode", enumGetBox(LegendEmptyValuesMode_$type, b), enumGetBox(LegendEmptyValuesMode_$type, this.ads));
}
},
enumerable: false,
configurable: true
});
RadialPieSeries.prototype.preferredCategoryMode = function (a) {
return a != null && a == this.y4 ? 2 : 0;
};
RadialPieSeries.prototype.o7 = function (a, b) {
_super.prototype.o7.call(this, a, b);
var c = b;
if (a && c.dj != null) {
c.dj.count = 0;
}
};
RadialPieSeries.prototype.ix = function () {
return this.y4.k8(this.cw.ca, this.cw.b9, this.getEffectiveViewport1(this.cw));
};
RadialPieSeries.prototype.ar = function (a, b) {
var c = new List$1(Rect.$, 0);
var d = this.cw.ca;
var e = this.cw.b9;
var f = this.getEffectiveViewport1(this.cw);
var g = this.wo(this.cw);
var h = this.za.k5(e, d, f, g);
var i = { $type: Point_$type, x: 0.5, y: 0.5 };
var j = this.za;
var k = Math.max(0, 0.5 * j.n6);
var l = k;
l = Math.max(l, h.minLength);
var m = this.y4.k8(d, e, f);
var n = this.y4 != null && this.y4.cl;
var o = this.zd;
if (this.d4()) {
o = this.zg;
}
{
if (n) {
m = this.z3(a, d, e, f);
}
if (b < 0 || b > o.h.count - 1) {
return null;
}
var p = o.h._inner[b][0];
var q = Math.min(o.h._inner[b][2], h.maxLength);
return this.adx(d, e, f, p - (m * 0.5), p + (m * 0.5), l, q, i);
}
};
RadialPieSeries.prototype.get_ef = function () {
return true;
};
RadialPieSeries.prototype.get_acj = function () {
return true;
};
RadialPieSeries.prototype.get_acd = function () {
return true;
};
RadialPieSeries.prototype.abf = function (a, b) {
_super.prototype.abf.call(this, a, b);
var c = b;
var d = b.ca;
var e = b.b9;
var f = this.getEffectiveViewport1(b);
var g = this.wo(b);
var h = this.za.k5(e, d, f, g);
var i = a.h;
var j = this.za;
var k = Math.max(0, 0.5 * j.n6);
var l = k;
l = Math.max(l, h.minLength);
var m = this.y4.k8(d, e, f);
var n = this.y4.cl;
var o = { $type: Point_$type, x: 0.5, y: 0.5 };
var p = this.ady;
var q = this.adz;
var r = (p > 0 && q > 0);
var s = this.acb.count;
this.zj.a2(this, this.z0(), runOn(this, this.ys), this.z9(b), this.aaa(b));
this.zj.r = this.ady;
this.zj.s = this.adz;
this.zj.k = this.ady;
this.zj.l = this.adz;
var t = false;
var u = this.zj.b;
if (u != null) {
t = true;
}
var v = this.y4;
var w = new ScalerParams(1, b.ca, b.b9, v.ch);
w.c = this.getEffectiveViewport();
var x = 0;
var y = 0;
for (var z = 0; z < i.count; ++z) {
var aa = i._inner[z][0];
var ab = Math.min(i._inner[z][2], h.maxLength);
var ac = i._inner[z][1];
var ad = i._inner[z][2];
var ae = i._inner[z][3];
if (t) {
this.ac8(i, z, s, v, w, b.t);
}
if (n) {
if (isNaN_(aa) || isNaN_(ac) || isNaN_(ad)) {
continue;
}
var af = (b.da.c + z) * b.da.b;
if ((b.da.c + z) * b.da.b > this.y4.lk - 1) {
if ((af) * b.da.b >= this.y4.lj) {
af = (af) - (intDivide((this.y4.lj), b.da.b));
}
}
m = ae;
if (isNaN_(m)) {
continue;
}
}
var ag = c.dj.item(x);
x++;
var ah = this.zj.k;
var ai = this.zj.l;
r = (ah > 0 && ai > 0);
var aj = null;
if (r) {
aj = this.ad9(d, e, f, aa - (m * 0.5), aa + (m * 0.5), l, ab, o, ah, ai);
}
else {
aj = this.aea(d, e, f, aa - (m * 0.5), aa + (m * 0.5), l, ab, o);
}
ag.an = aj;
this.zj.ad(ag, false, false, false, false);
var ak = i._inner[z][2];
if (ak > y) {
y = ak;
}
}
c.dc = ViewportUtils.f(y, d, e);
c.dd = { $type: Point_$type, x: ViewportUtils.e(o.x, d, e, f), y: ViewportUtils.i(o.y, d, e, f) };
c.dj.count = x;
c.dp();
};
RadialPieSeries.prototype.aea = function (a, b, c, d, e, f, g, h) {
var i = SliceCoords.b(a, b, c, d, e, f, g, h);
var j = new PathFigure();
j._startPoint = i.d;
j._isClosed = true;
j._segments.add(((function () {
var $ret = new LineSegment(1);
$ret.c = i.f;
return $ret;
})()));
j._segments.add(((function () {
var $ret = new ArcSegment();
$ret.e = i.h;
$ret.f = i.n;
$ret.d = 1;
$ret.b = i.c;
return $ret;
})()));
j._segments.add(((function () {
var $ret = new LineSegment(1);
$ret.c = i.j;
return $ret;
})()));
j._segments.add(((function () {
var $ret = new ArcSegment();
$ret.e = i.d;
$ret.f = i.m;
$ret.d = 0;
$ret.b = i.c;
return $ret;
})()));
var k = new PathGeometry();
k.c.add(j);
return k;
};
RadialPieSeries.prototype.adx = function (a, b, c, d, e, f, g, h) {
var i = SliceCoords.b(a, b, c, d, e, f, g, h);
if (isNaN_(i.n.width) || isNaN_(d) || isNaN_(e)) {
return null;
}
var j = ViewportUtils.e(0.5, a, b, c);
var k = ViewportUtils.i(0.5, a, b, c);
return new PieSliceCollisionGeometry(j, k, i.n.width, i.m.width, d, e);
};
RadialPieSeries.prototype.ad9 = function (a, b, c, d, e, f, g, h, i, j) {
var k = SliceCoords.a(a, b, c, d, e, f, g, h, i, j);
if (k == null) {
return this.aea(a, b, c, d, e, f, g, h);
}
var l = new PathFigure();
l._startPoint = k.d;
l._isClosed = true;
var m = ((d + ((e - d) * 0.5)) * 180 / Math.PI) + 90;
var n = new Size(1, k.l.width * (f / g), k.l.height * (f / g));
l._segments.add(((function () {
var $ret = new ArcSegment();
$ret.e = k.e;
$ret.f = n;
$ret.c = m;
$ret.d = 1;
$ret.b = false;
return $ret;
})()));
l._segments.add(((function () {
var $ret = new LineSegment(1);
$ret.c = k.f;
return $ret;
})()));
l._segments.add(((function () {
var $ret = new ArcSegment();
$ret.e = k.g;
$ret.f = k.l;
$ret.c = m;
$ret.d = 1;
$ret.b = false;
return $ret;
})()));
l._segments.add(((function () {
var $ret = new ArcSegment();
$ret.e = k.h;
$ret.f = k.n;
$ret.d = 1;
$ret.b = k.c;
return $ret;
})()));
l._segments.add(((function () {
var $ret = new ArcSegment();
$ret.e = k.i;
$ret.f = k.l;
$ret.c = m;
$ret.d = 1;
$ret.b = false;
return $ret;
})()));
l._segments.add(((function () {
var $ret = new LineSegment(1);
$ret.c = k.j;
return $ret;
})()));
l._segments.add(((function () {
var $ret = new ArcSegment();
$ret.e = k.k;
$ret.f = n;
$ret.c = m;
$ret.d = 1;
$ret.b = false;
return $ret;
})()));
l._segments.add(((function () {
var $ret = new ArcSegment();
$ret.e = k.d;
$ret.f = k.m;
$ret.d = 0;
$ret.b = k.c;
return $ret;
})()));
var o = new PathGeometry();
o.c.add(l);
return o;
};
RadialPieSeries.prototype.rc = function (a, b, c, d) {
_super.prototype.rc.call(this, a, b, c, d);
switch (b) {
case RadialPieSeries.$$p[0]:
case RadialPieSeries.$$p[1]:
this.q5();
break;
case "FastItemsSource":
if (c != null) {
if (this.adw != null) {
c.deregisterColumn(this.adw);
}
}
if (d != null) {
if (this.ad3 != null) {
this.adw = this.dn(this.ad3);
}
}
break;
case "LegendLabelMemberPath":
if (this.dp != null) {
this.dp.deregisterColumn(this.adw);
this.adw = this.dn(this.ad3);
this.pg();
this.pv();
}
break;
}
};
RadialPieSeries.prototype.ws = function (a) {
var b = this.adu.ca;
var c = this.adu.b9;
var d = this.getEffectiveViewport1(this.adu);
var e = this.wo(this.adu);
var f = this.za.k5(c, b, d, e);
var g = { $type: Point_$type, x: 0.5, y: 0.5 };
var h = GeometryUtil.j(g, a);
var i = this.zd.h;
var j = 0;
for (var k = 0; k < i.count; k++) {
var l = i._inner[k][0];
var m = Math.min(i._inner[k][2], f.maxLength);
var n = i._inner[k][3];
if (isNaN_(n)) {
continue;
}
l = l % 6.28318531;
if (l < 0) {
l += 6.28318531;
}
if (h >= l - (n * 0.5) && h <= l + (n * 0.5)) {
var o = Math.max(0, 0.5 * this.za.n6);
var p = o;
p = Math.max(p, f.minLength);
var q = SliceCoords.b(b, c, d, l - (n * 0.5), l + (n * 0.5), p, m, g);
var r = GeometryUtil.u({ $type: Point_$type, x: ViewportUtils.e(g.x, b, c, d), y: ViewportUtils.i(g.y, b, c, d) }, MathUtil.f(l), q.n.width);
var s = 1.7976931348623157E+308;
var t = 1.7976931348623157E+308;
var u = -1.7976931348623157E+308;
var v = -1.7976931348623157E+308;
s = Math.min(s, q.d.x);
s = Math.min(s, q.f.x);
s = Math.min(s, q.h.x);
s = Math.min(s, q.j.x);
s = Math.min(s, r.x);
t = Math.min(t, q.d.y);
t = Math.min(t, q.f.y);
t = Math.min(t, q.h.y);
t = Math.min(t, q.j.y);
t = Math.min(t, r.y);
u = Math.max(u, q.d.x);
u = Math.max(u, q.f.x);
u = Math.max(u, q.h.x);
u = Math.max(u, q.j.x);
u = Math.max(u, r.x);
v = Math.max(v, q.d.y);
v = Math.max(v, q.f.y);
v = Math.max(v, q.h.y);
v = Math.max(v, q.j.y);
v = Math.max(v, r.y);
return new Rect(0, s, t, u - s, v - t);
}
j++;
}
return new Rect(0, 0, 0, 0, 0);
};
RadialPieSeries.prototype.kv = function (a) {
if (this.y4 != null && this.y4.cl && a == this.y4.othersIndex) {
return null;
}
if (this.adw != null) {
return this.adw.item(a);
}
return null;
};
RadialPieSeries.prototype.ed = function (a, b, c, d, e) {
var _this = this;
if (_super.prototype.ed.call(this, a, b, c, d, e)) {
var f = typeCast(ProportionalCategoryAngleAxis.$, this.y4) !== null && this.y4.hasOthersCategory;
if (e && (this.adt == 1 || (this.adt == 2 && !f))) {
var g = this.y4;
var h = new ScalerParams(1, this.dc.wt, this.wx, g.ch);
h.c = this.getEffectiveViewport1(this.cw);
var i = this.za;
var j = new ScalerParams(1, this.dc.wt, this.wx, i.ch);
j.c = this.getEffectiveViewport1(this.cw);
var k = this.z8;
var _loop_1 = function (l) {
var m = this_1.dp.item(l);
var n = NaN;
if (m != null) {
n = this_1.jd(m);
}
if (n == 0) {
var o = new SeriesPointOfInterest();
o.f = this_1.aa8(n, m, l, d, k, c, b, false);
o.b = ((function () {
var $ret = new DataContext();
$ret.item = m;
$ret.series = _this;
return $ret;
})());
o.g = this_1.vl;
o.c = l;
if (this_1.ha) {
o.g = this_1.vs(l);
}
var p = false;
for (var q = 0; q < a.count; q++) {
if (o.c < a._inner[q].c) {
a.insert(q, o);
p = true;
break;
}
}
if (!p) {
a.add(o);
}
}
};
var this_1 = this;
for (var l = 0; l < this.dp.count; l++) {
_loop_1(l);
}
}
return true;
}
return false;
};
RadialPieSeries.prototype.ak = function (a, b) {
var c = new List$1(ChartSelection.$, 0);
this.p6(a, c, b);
return c.toArray();
};
RadialPieSeries.prototype.p6 = function (a, b, c) {
var _this = this;
if (this.y5 == 0) {
_super.prototype.p6.call(this, a, b, c);
return;
}
var d = this.cw.ca;
var e = this.cw.b9;
var f = this.getEffectiveViewport1(this.cw);
var g = this.dc.w1(this.wx, this.getEffectiveViewport(), d);
var h = this.za.k5(e, d, f, g);
var i = { $type: Point_$type, x: 0.5, y: 0.5 };
var j = this.za;
var k = Math.max(0, 0.5 * j.n6);
var l = k;
l = Math.max(l, h.minLength);
var m = this.y4.k8(d, e, f);
var n = this.y4 != null && this.y4.cl;
var o = new CollisionRect(0, this.dc.wy(a));
var _loop_2 = function (p) {
var q = typeCast(RadialBaseView.$, this_2.cw);
var r = q.da.getBucket(p);
var s = this_2.acm(this_2.y4, d, e, f);
if (n) {
m = this_2.z3(p, d, e, f);
s = this_2.acl(p, this_2.y4, d, e, f);
if (isNaN_(s)) {
s = 0;
}
}
r[0] = this_2.y4.getScaledAngle(r[0]) + s;
var t = r[0];
var u = Math.min(this_2.zb.b.od(r[2]), h.maxLength);
var v = this_2.adx(d, e, f, t - (m * 0.5), t + (m * 0.5), l, u, i);
if (v.collidesWithHeavy(o)) {
if (c == 7 || c == 6) {
b.add(((function () {
var $ret = new ChartSelection();
$ret.series = _this;
return $ret;
})()));
return { value: void 0 };
}
if (c == 2 || c == 1) {
b.add(((function () {
var $ret = new ChartSelection();
$ret.item = _this.dp.item(p);
return $ret;
})()));
}
else {
b.add(((function () {
var $ret = new ChartSelection();
$ret.item = _this.dp.item(p);
$ret.series = _this;
return $ret;
})()));
}
}
};
var this_2 = this;
for (var p = 0; p < this.y4.lk; p++) {
var state_1 = _loop_2(p);
if (typeof state_1 === "object")
return state_1.value;
}
};
RadialPieSeries.$t = markType(RadialPieSeries, 'RadialPieSeries', AnchoredRadialSeries.$);
RadialPieSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RadialPieSeries, 'raisePropertyChanged', ['RadiusX:ady:ad7', [1, 2], 'RadiusY:adz:ad8', [1, 2]]);
return RadialPieSeries;
}(AnchoredRadialSeries));
export { RadialPieSeries };
/**
* @hidden
*/
var RadialPieSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(RadialPieSeriesView, _super);
function RadialPieSeriesView(a) {
var _this = _super.call(this, a) || this;
_this.di = null;
_this.dj = null;
_this.dk = null;
_this.dq = new Path();
_this.di = a;
_this.dj = ((function () {
var $ret = new Pool$1(Path.$);
$ret.create = runOn(_this, _this.dr);
$ret.activate = runOn(_this, _this.dl);
$ret.disactivate = runOn(_this, _this.dn);
$ret.destroy = runOn(_this, _this.dm);
return $ret;
})());
return _this;
}
RadialPieSeriesView.prototype.a4 = function () {
_super.prototype.a4.call(this);
this.dk = new List$1(Path.$, 0);
if (!this.t) {
this.c9.xf = Defaults.c;
this.c9.jq = Defaults.i;
}
};
RadialPieSeriesView.prototype.dr = function () {
var _this = this;
var a = ((function () {
var $ret = new Path();
$ret.dataContext = ((function () {
var $ret = new DataContext();
$ret.series = _this.f;
return $ret;
})());
return $ret;
})());
this.dk.add(a);
a._visibility = 1;
return a;
};
RadialPieSeriesView.prototype.dl = function (a) {
a._visibility = 0;
};
RadialPieSeriesView.prototype.dn = function (a) {
a._visibility = 1;
};
RadialPieSeriesView.prototype.dm = function (a) {
this.dk.remove(a);
};
RadialPieSeriesView.prototype.bs = function (a, b) {
_super.prototype.bs.call(this, a, b);
var c = a;
};
RadialPieSeriesView.prototype.ak = function (a) {
return this.dk._inner[a];
};
RadialPieSeriesView.prototype.aj = function (a) {
var b = this.dk._inner[a];
this.dq._visibility = b._visibility;
this.dq.an = b.an;
var c = this.b4(a);
this.dq._fill = c;
this.dq._stroke = c;
this.dq.ad = this.f.ig;
return this.dq;
};
RadialPieSeriesView.prototype.bj = function (a, b) {
_super.prototype.bj.call(this, a, b);
if (a.d) {
for (var c = 0; c < this.dk.count; c++) {
var d = this.ai(c, b);
a.t(d);
}
}
};
RadialPieSeriesView.prototype.dp = function () {
this.a2();
};
RadialPieSeriesView.prototype.ax = function (a) {
var e_1, _a;
_super.prototype.ax.call(this, a);
var b = 0;
try {
for (var _b = __values(fromEnum(this.dj.a)), _c = _b.next(); !_c.done; _c = _b.next()) {
var c = _c.value;
this.f.bc.exportPathData(a, c, "slice" + b, ["Main", "Fill"]);
b++;
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_1)
throw e_1.error;
}
}
};
RadialPieSeriesView.$t = markType(RadialPieSeriesView, 'RadialPieSeriesView', AnchoredRadialSeriesView.$);
return RadialPieSeriesView;
}(AnchoredRadialSeriesView));
export { RadialPieSeriesView };