igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
265 lines (264 loc) • 8.23 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 { LegendBase } from "./LegendBase";
import { IChartScaleLegend_$type } from "igniteui-react-core";
import { TextBlock } from "igniteui-react-core";
import { LegendBaseView } from "./LegendBaseView";
import { typeCast, markType, runOn, Point_$type } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { ColorUtil } from "igniteui-react-core";
import { Shape } from "igniteui-react-core";
import { GradientData } from "./GradientData";
import { Size } from "igniteui-react-core";
import { Polygon } from "igniteui-react-core";
import { GradientStopData } from "./GradientStopData";
import { IInternalLegendOwner_$type } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
/**
* @hidden
*/
export let ScaleLegend = /*@__PURE__*/ (() => {
class ScaleLegend extends LegendBase {
aj() {
return new ScaleLegendView(this);
}
bd(a) {
super.bd(a);
this.bi = a;
}
get legendScaleElement() {
return this.bi.bb;
}
get minText() {
return this.bi.a7;
}
get maxText() {
return this.bi.a6;
}
constructor() {
super();
this.bi = null;
this.bk = 0;
this.bj = 0;
this.bg = null;
this.ab = ScaleLegend.$;
}
get bh() {
return this.bg;
}
set bh(a) {
this.bg = a;
}
bn() {
this.bi.a3();
}
restoreOriginalState() {
this.bn();
}
bq(a) {
if (a == null) {
return this.bi.ba();
}
return ColorUtil.w(a);
}
bl(a) {
this.bh = a;
this.bm();
}
initializeLegend(a) {
this.bl(a);
}
get_isScale() {
return true;
}
bm() {
if (this.legendScaleElement == null || this.bh == null || !this.bh.legendReady) {
return;
}
if (this.bh == null || !this.bh.isAttachedTo(this)) {
return;
}
let a = false;
let b = typeCast(Shape.$, this.legendScaleElement);
if (b != null) {
let c = this.bi.ax();
if (!this.bh.forScaleColors((d, e) => this.bi.az(c, this.bq(d), e))) {
a = true;
}
this.bi.a4(b, a, c);
}
if (this.minText != null) {
this.minText.al = this.bh.minScaleText;
}
if (this.maxText != null) {
this.maxText.al = this.bh.maxScaleText;
}
}
}
ScaleLegend.$t = /*@__PURE__*/ markType(ScaleLegend, 'ScaleLegend', LegendBase.$, [IChartScaleLegend_$type]);
return ScaleLegend;
})();
/**
* @hidden
*/
export let ScaleLegendView = /*@__PURE__*/ (() => {
class ScaleLegendView extends LegendBaseView {
constructor(a) {
super(a);
this.aq = null;
this.bb = null;
this.a7 = null;
this.a6 = null;
this.ap = null;
this.ar = null;
this.bc = new Size();
this.as = false;
this.at = 0;
this.a9 = null;
this.a8 = null;
this.aq = a;
this.a7 = new TextBlock();
this.a6 = new TextBlock();
this.bb = new Polygon();
}
a3() {
}
aa() {
}
ba() {
return Color.u(0, 0, 0, 0);
}
ax() {
return new GradientData();
}
az(a, b, c) {
let d = a;
d.a.add(((() => {
let $ret = new GradientStopData();
$ret.b = ((() => {
let $ret = new Brush();
$ret.color = b;
return $ret;
})());
$ret.a = c;
return $ret;
})()));
}
a4(a, b, c) {
if (b) {
this.a8 = this.aq.bh.actualMarkerBrush;
this.ap = null;
}
else {
this.a8 = null;
this.ap = c;
this.ap.b();
}
this.a0();
}
aj(a) {
super.aj(a);
this.ar = this.d.b(a);
this.bc = this.d.ab();
this.a0();
}
a0() {
if (!this.as) {
this.as = true;
if (this.d.g != null) {
this.d.g.setTimeout(runOn(this, this.a5), 0);
}
else {
window.setTimeout(runOn(this, this.a5), 0);
}
}
}
a5() {
if (this.as) {
this.as = false;
this.a2();
}
}
a2() {
if (this.ar == null) {
return;
}
this.a1();
}
av(a) {
let b = typeCast(TextBlock.$, a);
if (b != null && b.al != null) {
return this.ar.f(b) + 0;
}
return 0;
}
au(a) {
return this.at + 0;
}
a1() {
if (this.aq.bh == null || this.aq.bh.container == null || (this.ap == null && this.a8 == null)) {
return;
}
if (this.ar.d) {
let a = typeCast(IInternalLegendOwner_$type, this.aq.bh.container);
this.ar.ae(a.getFontInfo());
this.at = a.getFontHeight();
this.a9 = a.getFontBrush();
let b = this.av(this.a7);
let c = this.av(this.a6);
let d = Math.max(b, c) + 4;
if (d >= this.bc.width) {
d = 0;
}
let e = this.bc.width - d;
let f = 2;
let g = 2;
e = e - 4;
let h = this.bc.height - 4;
let i = f + e + 4;
let j = g;
let k = h;
let l = { $type: Point_$type, x: f + (3 / 5) * e, y: g };
let m = { $type: Point_$type, x: f + (5 / 5) * e, y: g };
let n = { $type: Point_$type, x: f + (5 / 5) * e, y: h };
let o = { $type: Point_$type, x: f, y: h };
let p = this.bb;
p.an.clear();
p.an.add(l);
p.an.add(m);
p.an.add(n);
p.an.add(o);
this.a7.n = i;
this.a7.o = j;
this.a7.ao = this.a9;
this.a6.n = i;
this.a6.o = j + k - (this.au(this.a7));
this.a6.ao = this.a9;
if (!this.ar.e) {
this.ar.l(0, 0, this.bc.width, this.bc.height);
}
if (this.ap == null && this.a8 != null) {
p._fill = this.a8;
this.ar.u(p);
}
else {
this.d.y(this.ar, p, this.ap, new Rect(0, g, f, e, h));
}
if (d > 0) {
this.ar.x(this.a7);
this.ar.x(this.a6);
}
}
}
am() {
super.am();
}
}
ScaleLegendView.$t = /*@__PURE__*/ markType(ScaleLegendView, 'ScaleLegendView', LegendBaseView.$);
return ScaleLegendView;
})();