igniteui-react-charts
Version:
Ignite UI React charting components for building rich data visualizations using TypeScript APIs.
664 lines (663 loc) • 24.2 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 { Base, typeCast, String_$type, runOn, markType } from "igniteui-react-core";
import { IDomainChartToolbarProvider_$type } from "./IDomainChartToolbarProvider";
import { ToolCommandStateChanged } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { Defaults } from "./Defaults";
import { LegendTemplates } from "./LegendTemplates";
import { ToolActionGroupHeaderInfo } from "igniteui-react-core";
import { IDataSource_$type } from "igniteui-react-core";
import { ToolActionFieldSelectorInfo } from "igniteui-react-core";
import { ToolActionIconMenuInfo } from "igniteui-react-core";
import { NativeUIComponent } from "igniteui-react-core";
import { IDataLegendTarget_$type } from "igniteui-react-core";
import { XYChart } from "./XYChart";
import { BrushUtilCore } from "igniteui-react-core";
import { ToolCommandArgument } from "igniteui-react-core";
import { AxisStrokeSettings } from "./AxisStrokeSettings";
import { DeviceUtils } from "igniteui-react-core";
import { FastIterationDictionary$2 } from "igniteui-react-core";
import { AxisDefaults } from "./AxisDefaults";
import { TrendLineTypeCollection } from "./TrendLineTypeCollection";
import { ValueModeCollection } from "./ValueModeCollection";
import { BrushCollection } from "igniteui-react-core";
import { DataSeriesAdapterPropertyInfo } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
/**
* @hidden
*/
export let DomainChartToolbarProvider = /*@__PURE__*/ (() => {
class DomainChartToolbarProvider extends Base {
constructor() {
super(...arguments);
this.e = null;
this.g = false;
this._container = null;
this.b = new DataSeriesAdapterPropertyInfo();
this.c = new DataSeriesAdapterPropertyInfo();
this._commandChanged = null;
this.f = new FastIterationDictionary$2(String_$type, AxisStrokeSettings.$, 0);
this.d = null;
}
get container() {
return this._container;
}
set container(a) {
this._container = a;
}
get commandChanged() {
return this._commandChanged;
}
set commandChanged(a) {
this._commandChanged = a;
}
static ag(a) {
let b = a.data;
let c = BrushUtil.h(255, 0, 0, 0);
LegendTemplates.u(a, 2, c, null, 0, 0, Defaults.w, Defaults.u);
}
getDesiredToolbarActions(a, b, c) {
let d;
if (a.itemsSource != null && typeCast(IDataSource_$type, a.itemsSource) !== null && NativeUIComponent.v(16, 0)) {
let e = new ToolActionGroupHeaderInfo();
e.name = "AxisFieldLabelHeader";
e.title = "Label Fields";
let f = typeCast(IDataSource_$type, a.itemsSource);
let g = new ToolActionFieldSelectorInfo();
g.name = "LabelFieldSelector";
g.fieldType = 0;
g.dataSource = f;
g.updateDataSource = true;
g.singleSelection = true;
g.ah = typeCast(IDataLegendTarget_$type, a);
let h = new ToolActionGroupHeaderInfo();
h.name = "AxisFieldValueHeader";
h.title = "Value Fields";
let i = new ToolActionFieldSelectorInfo();
i.name = "ValueFieldSelector";
i.fieldType = 1;
i.dataSource = f;
i.updateDataSource = true;
i.ah = typeCast(IDataLegendTarget_$type, a);
let j = new ToolActionIconMenuInfo();
j.name = "AxisFieldMenu";
j.iconName = "analyze-valuelabels-showlast";
j.iconCollectionName = "ChartToolbarIcons";
j.iconWidth = 24;
j.iconHeight = 25;
j.actions = [e, g, h, i];
d = new Array(b.length + 1);
for (let k = 0; k < b.length; k++) {
d[k] = b[k];
}
d[b.length] = j;
}
else {
d = b;
}
for (let l = 0; l < d.length; l++) {
this.i(a, d[l]);
}
return d;
}
i(a, b) {
if (b.actions != null && b.actions.length > 0) {
for (let c = 0; c < b.actions.length; c++) {
this.i(a, b.actions[c]);
}
}
switch (b.name) {
case "ShowCrosshairs":
{
let d = b;
d.isChecked = a.crosshairsDisplayMode != 1;
}
break;
case "ShowGridlines":
{
let e = b;
if (typeCast(XYChart.$, a) !== null) {
let f = a;
e.isChecked = f.ago != null && !BrushUtilCore.a(f.ago) && f.ab2 > 0 && f.agv != null && !BrushUtilCore.a(f.agv) && f.acj > 0;
}
}
break;
case "ShowValueLabels":
{
let g = b;
g.isChecked = a.autoCalloutsVisible;
}
break;
case "ShowLastValueLabel":
{
let h = b;
h.isChecked = a.finalValueAnnotationsVisible;
}
break;
case "MinValue":
{
if (a.valueLines != null) {
let i = b;
for (let j = 0; j < a.valueLines.count; j++) {
if (a.valueLines._inner[j] == 4) {
i.isChecked = true;
break;
}
}
}
}
break;
case "MaxValue":
{
if (a.valueLines != null) {
let k = b;
for (let l = 0; l < a.valueLines.count; l++) {
if (a.valueLines._inner[l] == 5) {
k.isChecked = true;
break;
}
}
}
}
break;
case "Average":
{
if (a.valueLines != null) {
let m = b;
for (let n = 0; n < a.valueLines.count; n++) {
if (a.valueLines._inner[n] == 6) {
m.isChecked = true;
break;
}
}
}
}
break;
case "SeriesAvg":
{
if (a.valueLines != null) {
let o = b;
for (let p = 0; p < a.valueLines.count; p++) {
if (a.valueLines._inner[p] == 3) {
o.isChecked = true;
break;
}
}
}
}
break;
case "AxisFieldLabel":
{
}
break;
case "AxisFieldValue":
{
}
break;
}
this.j(a, b);
}
j(a, b) {
}
onToolCommandExecuting(a, b) {
this.g = true;
let c = 0;
switch (b.commandId) {
case "ZoomReset":
this.af(a, b);
break;
case "ZoomIn":
this.ad(a, b);
break;
case "ZoomOut":
this.ae(a, b);
break;
case "ShowCrosshairs":
this.q(a, b);
break;
case "ShowGridlines":
this.s(a, b);
break;
case "MaxValue":
this.w(a, b);
break;
case "MinValue":
this.x(a, b);
break;
case "Average":
this.l(a, b);
break;
case "Exponential":
this.r(a, b);
break;
case "Linear":
this.u(a, b);
break;
case "Logarithmic":
this.v(a, b);
break;
case "NoTrends":
this.y(a, b);
break;
case "SeriesAvg":
this.z(a, b);
break;
case "ShowValueLabels":
this.ab(a, b);
break;
case "ShowLastValueLabel":
this.aa(a, b);
break;
case "CopyAsImage":
this.p(a, b);
c = 2;
break;
case "AxisFieldLabel":
this.n(a, b);
break;
case "AxisFieldValue":
this.o(a, b);
break;
}
this.g = false;
return c;
}
onTargetPropertyChanged(a, b, c, d) {
if (this.g) {
return;
}
switch (b) {
case "CrosshairsDisplayMode":
if (a.crosshairsDisplayMode == 1) {
this.k("ShowCrosshairs", 2, false);
}
else {
this.k("ShowCrosshairs", 2, true);
}
break;
case "AutoCalloutsVisible":
this.k("ShowValueLabels", 2, a.autoCalloutsVisible);
break;
case "FinalValueAnnotationsVisible":
this.k("ShowLastValueLabel", 2, a.finalValueAnnotationsVisible);
break;
}
this.ac(a, b, c, d);
}
ac(a, b, c, d) {
}
k(a, b, c) {
if (this.commandChanged != null) {
this.commandChanged(((() => {
let $ret = new ToolCommandStateChanged();
$ret.c = a;
$ret.a = b;
$ret.b = c;
return $ret;
})()));
}
}
h(a, b) {
if (a.commandId == b) {
let e = a.argumentsList;
for (let d = 0; d < e.length; d++) {
let c = e[d];
if (c.argumentName == "IsChecked") {
return c.value;
}
}
}
return false;
}
q(a, b) {
if (this.h(b, "ShowCrosshairs")) {
a.crosshairsDisplayMode = 0;
a.crosshairsAnnotationEnabled = true;
}
else {
a.crosshairsDisplayMode = 1;
}
}
a(a, b, c) {
let d = new AxisStrokeSettings();
if (b == "xaxis") {
d.b = a.ago == null || BrushUtilCore.a(a.ago) ? c : a.ago;
d.a = isNaN_(a.ab2) || a.ab2 == 0 ? DeviceUtils.g(1) : a.ab2;
this.f.item("xaxis", d);
}
else {
d.b = a.agv == null || BrushUtilCore.a(a.agv) ? c : a.agv;
d.a = isNaN_(a.acj) || a.acj == 0 ? DeviceUtils.g(1) : a.acj;
this.f.item("yaxis", d);
}
return d;
}
s(a, b) {
if (this.h(b, "ShowGridlines")) {
if (typeCast(XYChart.$, a) !== null) {
let c = a;
let d = true;
if (this.f.d("xaxis")) {
if (this.f.item("xaxis").b != c.ago || c.ab2 != 0) {
d = true;
}
else {
c.ago = this.f.item("xaxis").b;
c.ab2 = this.f.item("xaxis").a;
d = false;
}
}
if (d) {
let e = this.a(c, "xaxis", AxisDefaults.h);
c.ago = e.b;
c.ab2 = e.a;
}
d = true;
if (this.f.d("yaxis")) {
if (this.f.item("yaxis").b != c.agv || c.acj != 0) {
d = true;
}
else {
c.agv = this.f.item("yaxis").b;
c.acj = this.f.item("yaxis").a;
d = false;
}
}
if (d) {
let f = this.a(c, "yaxis", AxisDefaults.h);
c.agv = f.b;
c.acj = f.a;
}
}
}
else {
if (typeCast(XYChart.$, a) !== null) {
let g = a;
if (!this.f.d("xaxis")) {
this.a(g, "xaxis", AxisDefaults.h);
}
g.ab2 = 0;
if (!this.f.d("yaxis")) {
this.a(g, "yaxis", AxisDefaults.h);
}
g.acj = 0;
}
}
}
r(a, b) {
if (this.h(b, "Exponential")) {
if (a.trendLineTypes == null) {
a.trendLineTypes = new TrendLineTypeCollection();
}
a.trendLineTypes.clear();
a.trendLineTypes.add(7);
}
else {
a.trendLineTypes.clear();
}
}
u(a, b) {
if (this.h(b, "Linear")) {
if (a.trendLineTypes == null) {
a.trendLineTypes = new TrendLineTypeCollection();
}
a.trendLineTypes.clear();
a.trendLineTypes.add(1);
}
else {
a.trendLineTypes.clear();
}
}
v(a, b) {
if (this.h(b, "Logarithmic")) {
if (a.trendLineTypes == null) {
a.trendLineTypes = new TrendLineTypeCollection();
}
a.trendLineTypes.clear();
a.trendLineTypes.add(6);
}
else {
a.trendLineTypes.clear();
}
}
y(a, b) {
if (this.h(b, "NoTrends")) {
a.trendLineTypes.clear();
}
}
w(a, b) {
if (this.h(b, "MaxValue")) {
if (a.valueLines == null) {
a.valueLines = new ValueModeCollection();
}
if (a.valueLinesBrushes == null) {
a.valueLinesBrushes = new BrushCollection();
}
a.valueLines.add(5);
}
else {
for (let c = 0; c < a.valueLines.count; c++) {
if (a.valueLines._inner[c] == 5) {
a.valueLines.removeAt(c);
c--;
}
}
}
}
x(a, b) {
if (this.h(b, "MinValue")) {
if (a.valueLines == null) {
a.valueLines = new ValueModeCollection();
}
if (a.valueLinesBrushes == null) {
a.valueLinesBrushes = new BrushCollection();
}
a.valueLines.add(4);
}
else {
for (let c = 0; c < a.valueLines.count; c++) {
if (a.valueLines._inner[c] == 4) {
a.valueLines.removeAt(c);
c--;
}
}
}
}
l(a, b) {
if (this.h(b, "Average")) {
if (a.valueLines == null) {
a.valueLines = new ValueModeCollection();
}
if (a.valueLinesBrushes == null) {
a.valueLinesBrushes = new BrushCollection();
}
a.valueLines.add(6);
}
else {
for (let c = 0; c < a.valueLines.count; c++) {
if (a.valueLines._inner[c] == 6) {
a.valueLines.removeAt(c);
c--;
}
}
}
}
z(a, b) {
if (this.h(b, "SeriesAvg")) {
if (a.valueLines == null) {
a.valueLines = new ValueModeCollection();
}
if (a.valueLinesBrushes == null) {
a.valueLinesBrushes = new BrushCollection();
}
a.valueLines.add(3);
}
else {
for (let c = 0; c < a.valueLines.count; c++) {
if (a.valueLines._inner[c] == 3) {
a.valueLines.removeAt(c);
c--;
}
}
}
}
ab(a, b) {
if (this.h(b, "ShowValueLabels")) {
a.autoCalloutsVisible = true;
}
else {
a.autoCalloutsVisible = false;
}
}
aa(a, b) {
if (this.h(b, "ShowLastValueLabel")) {
a.finalValueAnnotationsVisible = true;
a.shouldAvoidAxisAnnotationCollisions = true;
}
else {
a.finalValueAnnotationsVisible = false;
}
}
p(a, b) {
this.e = b;
a.captureTargetImageToClipboard(runOn(this, this.t));
}
n(a, b) {
this.m(a, b, "AxisFieldLabel");
}
o(a, b) {
this.m(a, b, "AxisFieldValue");
}
m(a, b, c) {
if (b.argumentsList.length != 3) {
return;
}
let d = b.argumentsList[2].value;
let e = (d[0]);
let f = false;
if (a.includedProperties != null) {
let i = a.includedProperties;
for (let h = 0; h < i.length; h++) {
let g = i[h];
if (g == e) {
f = true;
break;
}
}
}
let j = false;
if (a.excludedProperties != null) {
let m = a.excludedProperties;
for (let l = 0; l < m.length; l++) {
let k = m[l];
if (k == e) {
j = true;
break;
}
}
}
if (this.h(b, c)) {
if (a.includedProperties == null) {
a.includedProperties = new Array(0);
}
if (!f) {
let n = new Array(a.includedProperties.length + 1);
for (let o = 0; o < a.includedProperties.length; ++o) {
n[o] = a.includedProperties[o];
}
n[a.includedProperties.length] = e;
a.includedProperties = n;
}
if (j) {
if (a.excludedProperties.length == 1) {
a.excludedProperties = new Array(0);
}
else {
let p = new Array(a.excludedProperties.length - 1);
let q = -1;
let r = 0;
while (r < p.length) {
q++;
if (a.excludedProperties[q] == e) {
continue;
}
p[r] = a.excludedProperties[q];
r++;
}
a.excludedProperties = p;
}
}
}
else if ((a.includedProperties == null || a.includedProperties.length == 0) && (this.b.b.length + this.c.b.length > 1)) {
let s = this.b.b.length + this.c.b.length - 1;
let t = new Array(s);
let u = 0;
for (let v = 0; v < this.b.b.length; v++) {
if (this.b.b[v] == e) {
continue;
}
t[u] = this.b.b[v];
u++;
}
for (let w = 0; w < this.c.b.length; w++) {
if (this.c.b[w] == e) {
continue;
}
t[u] = this.c.b[w];
u++;
}
a.includedProperties = t;
}
else if (f) {
if (a.includedProperties.length == 1) {
a.includedProperties = new Array(0);
}
else {
let x = new Array(a.includedProperties.length - 1);
let y = -1;
let z = 0;
while (z < x.length) {
y++;
if (a.includedProperties[y] == e) {
continue;
}
x[z] = a.includedProperties[y];
z++;
}
a.includedProperties = x;
}
}
}
t(a, b) {
let c = b;
if (this.e.argumentsList == null || this.e.argumentsList.length < 1) {
this.e.argumentsList = new Array(1);
this.e.argumentsList[0] = ((() => {
let $ret = new ToolCommandArgument();
$ret.argumentName = "image";
return $ret;
})());
}
this.e.argumentsList[0].value = c.base64Data;
if (this.d != null) {
this.d.sendCommandCompleted(this.e);
}
}
ad(a, b) {
a.zoomIn(0.05);
}
ae(a, b) {
a.zoomOut(0.05);
}
af(a, b) {
a.resetZoom();
}
}
DomainChartToolbarProvider.$t = /*@__PURE__*/ markType(DomainChartToolbarProvider, 'DomainChartToolbarProvider', Base.$, [IDomainChartToolbarProvider_$type]);
return DomainChartToolbarProvider;
})();