igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
285 lines (284 loc) • 9.14 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 } from "tslib";
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
*/
var ScaleLegend = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ScaleLegend, _super);
function ScaleLegend() {
var _this = _super.call(this) || this;
_this.bl = null;
_this.bn = 0;
_this.bm = 0;
_this.bj = null;
_this.ab = ScaleLegend.$;
return _this;
}
ScaleLegend.prototype.aj = function () {
return new ScaleLegendView(this);
};
ScaleLegend.prototype.bd = function (a) {
_super.prototype.bd.call(this, a);
this.bl = a;
};
Object.defineProperty(ScaleLegend.prototype, "legendScaleElement", {
get: function () {
return this.bl.be;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ScaleLegend.prototype, "minText", {
get: function () {
return this.bl.ba;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ScaleLegend.prototype, "maxText", {
get: function () {
return this.bl.a9;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ScaleLegend.prototype, "bk", {
get: function () {
return this.bj;
},
set: function (a) {
this.bj = a;
},
enumerable: false,
configurable: true
});
ScaleLegend.prototype.bq = function () {
this.bl.a6();
};
ScaleLegend.prototype.restoreOriginalState = function () {
this.bq();
};
ScaleLegend.prototype.bt = function (a) {
if (a == null) {
return this.bl.bd();
}
return ColorUtil.w(a);
};
ScaleLegend.prototype.bo = function (a) {
this.bk = a;
this.bp();
};
ScaleLegend.prototype.initializeLegend = function (a) {
this.bo(a);
};
ScaleLegend.prototype.get_isScale = function () {
return true;
};
ScaleLegend.prototype.bp = function () {
var _this = this;
if (this.legendScaleElement == null || this.bk == null || !this.bk.legendReady) {
return;
}
if (this.bk == null || !this.bk.isAttachedTo(this)) {
return;
}
var a = false;
var b = typeCast(Shape.$, this.legendScaleElement);
if (b != null) {
var c_1 = this.bl.a0();
if (!this.bk.forScaleColors(function (d, e) { return _this.bl.a2(c_1, _this.bt(d), e); })) {
a = true;
}
this.bl.a7(b, a, c_1);
}
if (this.minText != null) {
this.minText.al = this.bk.minScaleText;
}
if (this.maxText != null) {
this.maxText.al = this.bk.maxScaleText;
}
};
ScaleLegend.$t = markType(ScaleLegend, 'ScaleLegend', LegendBase.$, [IChartScaleLegend_$type]);
return ScaleLegend;
}(LegendBase));
export { ScaleLegend };
/**
* @hidden
*/
var ScaleLegendView = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(ScaleLegendView, _super);
function ScaleLegendView(a) {
var _this = _super.call(this, a) || this;
_this.at = null;
_this.be = null;
_this.ba = null;
_this.a9 = null;
_this.as = null;
_this.au = null;
_this.bf = new Size();
_this.av = false;
_this.aw = 0;
_this.bc = null;
_this.bb = null;
_this.at = a;
_this.ba = new TextBlock();
_this.a9 = new TextBlock();
_this.be = new Polygon();
return _this;
}
ScaleLegendView.prototype.a6 = function () {
};
ScaleLegendView.prototype.aa = function () {
};
ScaleLegendView.prototype.bd = function () {
return Color.u(0, 0, 0, 0);
};
ScaleLegendView.prototype.a0 = function () {
return new GradientData();
};
ScaleLegendView.prototype.a2 = function (a, b, c) {
var d = a;
d.a.add(((function () {
var $ret = new GradientStopData();
$ret.b = ((function () {
var $ret = new Brush();
$ret.color = b;
return $ret;
})());
$ret.a = c;
return $ret;
})()));
};
ScaleLegendView.prototype.a7 = function (a, b, c) {
if (b) {
this.bb = this.at.bk.actualMarkerBrush;
this.as = null;
}
else {
this.bb = null;
this.as = c;
this.as.b();
}
this.a3();
};
ScaleLegendView.prototype.aj = function (a) {
_super.prototype.aj.call(this, a);
this.au = this.d.b(a);
this.bf = this.d.aj();
this.a3();
};
ScaleLegendView.prototype.a3 = function () {
if (!this.av) {
this.av = true;
if (this.d.i != null) {
this.d.i.setTimeout(runOn(this, this.a8), 0);
}
else {
window.setTimeout(runOn(this, this.a8), 0);
}
}
};
ScaleLegendView.prototype.a8 = function () {
if (this.av) {
this.av = false;
this.a5();
}
};
ScaleLegendView.prototype.a5 = function () {
if (this.au == null) {
return;
}
this.a4();
};
ScaleLegendView.prototype.ay = function (a) {
var b = typeCast(TextBlock.$, a);
if (b != null && b.al != null) {
return this.au.f(b) + 0;
}
return 0;
};
ScaleLegendView.prototype.ax = function (a) {
return this.aw + 0;
};
ScaleLegendView.prototype.a4 = function () {
if (this.at.bk == null || this.at.bk.container == null || (this.as == null && this.bb == null)) {
return;
}
if (this.au.d) {
var a = typeCast(IInternalLegendOwner_$type, this.at.bk.container);
this.au.af(a.getFontInfo());
this.aw = a.getFontHeight();
this.bc = a.getFontBrush();
var b = this.ay(this.ba);
var c = this.ay(this.a9);
var d = Math.max(b, c) + 4;
if (d >= this.bf.width) {
d = 0;
}
var e = this.bf.width - d;
var f = 2;
var g = 2;
e = e - 4;
var h = this.bf.height - 4;
var i = f + e + 4;
var j = g;
var k = h;
var l = { $type: Point_$type, x: f + (3 / 5) * e, y: g };
var m = { $type: Point_$type, x: f + (5 / 5) * e, y: g };
var n = { $type: Point_$type, x: f + (5 / 5) * e, y: h };
var o = { $type: Point_$type, x: f, y: h };
var p = this.be;
p.an.clear();
p.an.add(l);
p.an.add(m);
p.an.add(n);
p.an.add(o);
this.ba.n = i;
this.ba.o = j;
this.ba.ao = this.bc;
this.a9.n = i;
this.a9.o = j + k - (this.ax(this.ba));
this.a9.ao = this.bc;
if (!this.au.e) {
this.au.l(0, 0, this.bf.width, this.bf.height);
}
if (this.as == null && this.bb != null) {
p._fill = this.bb;
this.au.u(p);
}
else {
this.d.ac(this.au, p, this.as, new Rect(0, g, f, e, h));
}
if (d > 0) {
this.au.x(this.ba);
this.au.x(this.a9);
}
}
};
ScaleLegendView.prototype.am = function () {
_super.prototype.am.call(this);
};
ScaleLegendView.$t = markType(ScaleLegendView, 'ScaleLegendView', LegendBaseView.$);
return ScaleLegendView;
}(LegendBaseView));
export { ScaleLegendView };