UNPKG

igniteui-react-charts

Version:

Ignite UI React charting components for building rich data visualizations using TypeScript APIs.

674 lines (673 loc) 23.7 kB
/* 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 { 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 */ var DomainChartToolbarProvider = /** @class */ /*@__PURE__*/ (function (_super) { __extends(DomainChartToolbarProvider, _super); function DomainChartToolbarProvider() { var _this = _super !== null && _super.apply(this, arguments) || this; _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; return _this; } Object.defineProperty(DomainChartToolbarProvider.prototype, "container", { get: function () { return this._container; }, set: function (a) { this._container = a; }, enumerable: false, configurable: true }); Object.defineProperty(DomainChartToolbarProvider.prototype, "commandChanged", { get: function () { return this._commandChanged; }, set: function (a) { this._commandChanged = a; }, enumerable: false, configurable: true }); DomainChartToolbarProvider.ag = function (a) { var b = a.data; var c = BrushUtil.h(255, 0, 0, 0); LegendTemplates.u(a, 2, c, null, 0, 0, Defaults.w, Defaults.u); }; DomainChartToolbarProvider.prototype.getDesiredToolbarActions = function (a, b, c) { var d; if (a.itemsSource != null && typeCast(IDataSource_$type, a.itemsSource) !== null && NativeUIComponent.v(16, 0)) { var e = new ToolActionGroupHeaderInfo(); e.name = "AxisFieldLabelHeader"; e.title = "Label Fields"; var f = typeCast(IDataSource_$type, a.itemsSource); var g = new ToolActionFieldSelectorInfo(); g.name = "LabelFieldSelector"; g.fieldType = 0; g.dataSource = f; g.updateDataSource = true; g.singleSelection = true; g.ah = typeCast(IDataLegendTarget_$type, a); var h = new ToolActionGroupHeaderInfo(); h.name = "AxisFieldValueHeader"; h.title = "Value Fields"; var i = new ToolActionFieldSelectorInfo(); i.name = "ValueFieldSelector"; i.fieldType = 1; i.dataSource = f; i.updateDataSource = true; i.ah = typeCast(IDataLegendTarget_$type, a); var 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 (var k = 0; k < b.length; k++) { d[k] = b[k]; } d[b.length] = j; } else { d = b; } for (var l = 0; l < d.length; l++) { this.i(a, d[l]); } return d; }; DomainChartToolbarProvider.prototype.i = function (a, b) { if (b.actions != null && b.actions.length > 0) { for (var c = 0; c < b.actions.length; c++) { this.i(a, b.actions[c]); } } switch (b.name) { case "ShowCrosshairs": { var d = b; d.isChecked = a.crosshairsDisplayMode != 1; } break; case "ShowGridlines": { var e = b; if (typeCast(XYChart.$, a) !== null) { var 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": { var g = b; g.isChecked = a.autoCalloutsVisible; } break; case "ShowLastValueLabel": { var h = b; h.isChecked = a.finalValueAnnotationsVisible; } break; case "MinValue": { if (a.valueLines != null) { var i = b; for (var j = 0; j < a.valueLines.count; j++) { if (a.valueLines._inner[j] == 4) { i.isChecked = true; break; } } } } break; case "MaxValue": { if (a.valueLines != null) { var k = b; for (var l = 0; l < a.valueLines.count; l++) { if (a.valueLines._inner[l] == 5) { k.isChecked = true; break; } } } } break; case "Average": { if (a.valueLines != null) { var m = b; for (var n = 0; n < a.valueLines.count; n++) { if (a.valueLines._inner[n] == 6) { m.isChecked = true; break; } } } } break; case "SeriesAvg": { if (a.valueLines != null) { var o = b; for (var 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); }; DomainChartToolbarProvider.prototype.j = function (a, b) { }; DomainChartToolbarProvider.prototype.onToolCommandExecuting = function (a, b) { this.g = true; var 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; }; DomainChartToolbarProvider.prototype.onTargetPropertyChanged = function (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); }; DomainChartToolbarProvider.prototype.ac = function (a, b, c, d) { }; DomainChartToolbarProvider.prototype.k = function (a, b, c) { if (this.commandChanged != null) { this.commandChanged(((function () { var $ret = new ToolCommandStateChanged(); $ret.c = a; $ret.a = b; $ret.b = c; return $ret; })())); } }; DomainChartToolbarProvider.prototype.h = function (a, b) { if (a.commandId == b) { var e = a.argumentsList; for (var d = 0; d < e.length; d++) { var c = e[d]; if (c.argumentName == "IsChecked") { return c.value; } } } return false; }; DomainChartToolbarProvider.prototype.q = function (a, b) { if (this.h(b, "ShowCrosshairs")) { a.crosshairsDisplayMode = 0; a.crosshairsAnnotationEnabled = true; } else { a.crosshairsDisplayMode = 1; } }; DomainChartToolbarProvider.prototype.a = function (a, b, c) { var 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; }; DomainChartToolbarProvider.prototype.s = function (a, b) { if (this.h(b, "ShowGridlines")) { if (typeCast(XYChart.$, a) !== null) { var c = a; var 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) { var 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) { var f = this.a(c, "yaxis", AxisDefaults.h); c.agv = f.b; c.acj = f.a; } } } else { if (typeCast(XYChart.$, a) !== null) { var 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; } } }; DomainChartToolbarProvider.prototype.r = function (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(); } }; DomainChartToolbarProvider.prototype.u = function (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(); } }; DomainChartToolbarProvider.prototype.v = function (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(); } }; DomainChartToolbarProvider.prototype.y = function (a, b) { if (this.h(b, "NoTrends")) { a.trendLineTypes.clear(); } }; DomainChartToolbarProvider.prototype.w = function (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 (var c = 0; c < a.valueLines.count; c++) { if (a.valueLines._inner[c] == 5) { a.valueLines.removeAt(c); c--; } } } }; DomainChartToolbarProvider.prototype.x = function (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 (var c = 0; c < a.valueLines.count; c++) { if (a.valueLines._inner[c] == 4) { a.valueLines.removeAt(c); c--; } } } }; DomainChartToolbarProvider.prototype.l = function (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 (var c = 0; c < a.valueLines.count; c++) { if (a.valueLines._inner[c] == 6) { a.valueLines.removeAt(c); c--; } } } }; DomainChartToolbarProvider.prototype.z = function (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 (var c = 0; c < a.valueLines.count; c++) { if (a.valueLines._inner[c] == 3) { a.valueLines.removeAt(c); c--; } } } }; DomainChartToolbarProvider.prototype.ab = function (a, b) { if (this.h(b, "ShowValueLabels")) { a.autoCalloutsVisible = true; } else { a.autoCalloutsVisible = false; } }; DomainChartToolbarProvider.prototype.aa = function (a, b) { if (this.h(b, "ShowLastValueLabel")) { a.finalValueAnnotationsVisible = true; a.shouldAvoidAxisAnnotationCollisions = true; } else { a.finalValueAnnotationsVisible = false; } }; DomainChartToolbarProvider.prototype.p = function (a, b) { this.e = b; a.captureTargetImageToClipboard(runOn(this, this.t)); }; DomainChartToolbarProvider.prototype.n = function (a, b) { this.m(a, b, "AxisFieldLabel"); }; DomainChartToolbarProvider.prototype.o = function (a, b) { this.m(a, b, "AxisFieldValue"); }; DomainChartToolbarProvider.prototype.m = function (a, b, c) { if (b.argumentsList.length != 3) { return; } var d = b.argumentsList[2].value; var e = (d[0]); var f = false; if (a.includedProperties != null) { var i = a.includedProperties; for (var h = 0; h < i.length; h++) { var g = i[h]; if (g == e) { f = true; break; } } } var j = false; if (a.excludedProperties != null) { var m = a.excludedProperties; for (var l = 0; l < m.length; l++) { var 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) { var n = new Array(a.includedProperties.length + 1); for (var 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 { var p = new Array(a.excludedProperties.length - 1); var q = -1; var 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)) { var s = this.b.b.length + this.c.b.length - 1; var t = new Array(s); var u = 0; for (var v = 0; v < this.b.b.length; v++) { if (this.b.b[v] == e) { continue; } t[u] = this.b.b[v]; u++; } for (var 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 { var x = new Array(a.includedProperties.length - 1); var y = -1; var z = 0; while (z < x.length) { y++; if (a.includedProperties[y] == e) { continue; } x[z] = a.includedProperties[y]; z++; } a.includedProperties = x; } } }; DomainChartToolbarProvider.prototype.t = function (a, b) { var c = b; if (this.e.argumentsList == null || this.e.argumentsList.length < 1) { this.e.argumentsList = new Array(1); this.e.argumentsList[0] = ((function () { var $ret = new ToolCommandArgument(); $ret.argumentName = "image"; return $ret; })()); } this.e.argumentsList[0].value = c.base64Data; if (this.d != null) { this.d.sendCommandCompleted(this.e); } }; DomainChartToolbarProvider.prototype.ad = function (a, b) { a.zoomIn(0.05); }; DomainChartToolbarProvider.prototype.ae = function (a, b) { a.zoomOut(0.05); }; DomainChartToolbarProvider.prototype.af = function (a, b) { a.resetZoom(); }; DomainChartToolbarProvider.$t = markType(DomainChartToolbarProvider, 'DomainChartToolbarProvider', Base.$, [IDomainChartToolbarProvider_$type]); return DomainChartToolbarProvider; }(Base)); export { DomainChartToolbarProvider };