igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
114 lines (113 loc) • 4.81 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 { ColorScale } from "./ColorScale";
import { DependencyProperty } from "igniteui-react-core";
import { ObservableColorCollection } from "igniteui-react-core";
import { runOn, delegateCombine, delegateRemove, enumGetBox, markType, markDep } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { ColorScaleInterpolationMode_$type } from "./ColorScaleInterpolationMode";
import { ColorUtil } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_ } from "igniteui-react-core";
/**
* @hidden
*/
export let CustomPaletteColorScale = /*@__PURE__*/ (() => {
class CustomPaletteColorScale extends ColorScale {
constructor() {
super();
this.p = null;
this.ag = new Color();
this.u = NaN;
this.t = NaN;
this.s = true;
this.r = true;
this.n = 0;
this.ag = Color.u(0, 0, 0, 0);
this.p = new ObservableColorCollection();
let a = this.p;
a.collectionChanged = delegateCombine(a.collectionChanged, runOn(this, this.ab));
this.propertyUpdated = delegateCombine(this.propertyUpdated, (b, c) => this.k(b, c.propertyName, c.oldValue, c.newValue));
}
get palette() {
return this.p;
}
set palette(a) {
let b = this.p;
if (this.p != null) {
let c = this.p;
c.collectionChanged = delegateRemove(c.collectionChanged, runOn(this, this.ab));
}
this.p = a;
if (this.p != null) {
let d = this.p;
d.collectionChanged = delegateCombine(d.collectionChanged, runOn(this, this.ab));
}
this.l("Palette", b, this.palette);
}
ab(a, b) {
this.l("Palette", this.palette, this.palette);
}
k(a, b, c, d) {
super.k(a, b, c, d);
switch (b) {
case CustomPaletteColorScale.$$p[2]:
this.u = this.minimumValue;
this.s = isNaN_(this.u);
break;
case CustomPaletteColorScale.$$p[1]:
this.t = this.maximumValue;
this.r = isNaN_(this.t);
break;
case CustomPaletteColorScale.$$p[0]:
this.n = this.interpolationMode;
break;
}
}
getColor(a, b, c, d) {
if (((this.p == null) || (this.p.count == 0)) || d == null) {
return this.ag;
}
let e = this.s ? b : this.u;
let f = this.r ? c : this.t;
let g = (a - e) / (f - e);
if (isNaN_(g) || g < 0 || g > 1) {
return this.ag;
}
let h = g * (this.p.count - 1);
if (this.n == 2 || this.n == 1) {
let i = Math.floor(h);
let j = Math.ceil(h);
let k = this.p._inner[truncate(i)];
let l = this.p._inner[truncate(j)];
let m = h - i;
let n = this.n == 2 ? 1 : 0;
return ColorUtil.x(k, m, l, n);
}
else {
let o = truncate(Math.round(h));
return this.p._inner[o];
}
}
providePalette(a) {
let b = new ObservableColorCollection();
for (let d = 0; d < a.length; d++) {
let c = a[d];
let e = ((() => {
let $ret = new Color();
$ret.colorString = c;
return $ret;
})());
b.add(e);
}
this.palette = b;
}
}
CustomPaletteColorScale.$t = /*@__PURE__*/ markType(CustomPaletteColorScale, 'CustomPaletteColorScale', ColorScale.$);
CustomPaletteColorScale.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CustomPaletteColorScale, 'l', ['InterpolationMode', [ColorScaleInterpolationMode_$type, /*@__PURE__*/ enumGetBox(ColorScaleInterpolationMode_$type, 0)], 'MaximumValue', [1, NaN], 'MinimumValue', [1, NaN]]);
return CustomPaletteColorScale;
})();