UNPKG

igniteui-react-charts

Version:

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

876 lines (875 loc) 31.2 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, __values } from "tslib"; import { Base, String_$type, fromEnum, typeCast, 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 { HashSet$1 } from "igniteui-react-core"; import { ToolActionGroupHeaderInfo } from "igniteui-react-core"; import { ToolActionCheckboxListInfo } from "igniteui-react-core"; import { Dictionary$2 } from "igniteui-react-core"; import { DomainChartCheckboxListItem } from "./DomainChartCheckboxListItem"; import { ToolActionIconMenuInfo } from "igniteui-react-core"; import { DataSeriesAdapterPropertyInfo } from "igniteui-react-core"; import { NativeUIComponent } from "igniteui-react-core"; import { ToolContextBindingInfo } 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 { 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.j(255, 0, 0, 0); LegendTemplates.u(a, 2, c, null, 0, 0, Defaults.legendBadge_ShapeWidth, Defaults.legendBadge_ShapeHeight); }; DomainChartToolbarProvider.prototype.getDesiredToolbarActions = function (a, b, c) { var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f; var _this = this; var d; if (a.itemsSource != null && NativeUIComponent.v(16, 0)) { var e = new ToolActionGroupHeaderInfo(); e.name = "AxisFieldLabelHeader"; e.title = "Label Fields"; var f = new ToolActionCheckboxListInfo(); f.name = "AxisFieldLabel"; var g = new ToolActionGroupHeaderInfo(); g.name = "AxisFieldValueHeader"; g.title = "Value Fields"; var h = new ToolActionCheckboxListInfo(); h.name = "AxisFieldValue"; var i_1 = a.includedProperties == null ? null : new HashSet$1(String_$type, 1, a.includedProperties); var j = 0; if (i_1 != null && a.excludedProperties != null && a.excludedProperties.length > 0) { var k = new HashSet$1(String_$type, 1, a.excludedProperties); try { for (var _g = __values(fromEnum(k)), _h = _g.next(); !_h.done; _h = _g.next()) { var l = _h.value; if (i_1.contains(l)) { i_1.remove(l); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_h && !_h.done && (_a = _g.return)) _a.call(_g); } finally { if (e_1) throw e_1.error; } } var m = i_1.count; var n = new Array(m); j = 0; try { for (var _j = __values(fromEnum(i_1)), _k = _j.next(); !_k.done; _k = _j.next()) { var o = _k.value; n[j] = o; j++; } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_k && !_k.done && (_b = _j.return)) _b.call(_j); } finally { if (e_2) throw e_2.error; } } } a.currentDataAdapter.az(this.b, this.c); var p_1 = new Dictionary$2(String_$type, String_$type, 0); for (var q = 0; q < this.b.b.length; q++) { var r = this.b.b[q]; if (p_1.containsKey(r)) { continue; } p_1.addItem(this.b.b[q], this.b.a[q]); } this.b = ((function () { var $ret = new DataSeriesAdapterPropertyInfo(); $ret.b = new Array(p_1.count); $ret.a = new Array(p_1.count); $ret.c = new Array(p_1.count); return $ret; })()); j = 0; try { for (var _l = __values(fromEnum(p_1)), _m = _l.next(); !_m.done; _m = _l.next()) { var s = _m.value; this.b.b[j] = s.key; this.b.a[j] = s.value; j++; } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_m && !_m.done && (_c = _l.return)) _c.call(_l); } finally { if (e_3) throw e_3.error; } } var t = new Array(p_1.count); var _loop_1 = function (u) { t[u] = ((function () { var $ret = new DomainChartCheckboxListItem(); $ret.key = _this.b.b[u]; $ret.label = _this.b.a[u]; $ret.isSelected = i_1 == null || i_1.contains(_this.b.b[u]); return $ret; })()); }; for (var u = 0; u < this.b.b.length; u++) { _loop_1(u); } try { for (var _o = __values(fromEnum(c)), _p = _o.next(); !_p.done; _p = _o.next()) { var v = _p.value; v.setContextValue("AxisFieldLabels", 7, t); } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_p && !_p.done && (_d = _o.return)) _d.call(_o); } finally { if (e_4) throw e_4.error; } } f.dataMemberPath = "label"; f.selectedMemberPath = "isSelected"; f.primaryKey = ["key"]; f.contextBindings = [((function () { var $ret = new ToolContextBindingInfo(); $ret.bindingMode = 0; $ret.contextKey = "AxisFieldLabels"; $ret.propertyName = "ItemsSource"; return $ret; })())]; p_1 = new Dictionary$2(String_$type, String_$type, 0); for (var w = 0; w < this.c.b.length; w++) { var x = this.c.b[w]; if (p_1.containsKey(x)) { continue; } p_1.addItem(this.c.b[w], this.c.a[w]); } this.c = ((function () { var $ret = new DataSeriesAdapterPropertyInfo(); $ret.b = new Array(p_1.count); $ret.a = new Array(p_1.count); $ret.c = new Array(p_1.count); return $ret; })()); j = 0; try { for (var _q = __values(fromEnum(p_1)), _r = _q.next(); !_r.done; _r = _q.next()) { var y = _r.value; this.c.b[j] = y.key; this.c.a[j] = y.value; j++; } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (_r && !_r.done && (_e = _q.return)) _e.call(_q); } finally { if (e_5) throw e_5.error; } } var z = new Array(p_1.count); var _loop_2 = function (aa) { z[aa] = ((function () { var $ret = new DomainChartCheckboxListItem(); $ret.key = _this.c.b[aa]; $ret.label = _this.c.a[aa]; $ret.isSelected = i_1 == null || i_1.contains(_this.c.b[aa]); return $ret; })()); }; for (var aa = 0; aa < this.c.b.length; aa++) { _loop_2(aa); } try { for (var _s = __values(fromEnum(c)), _t = _s.next(); !_t.done; _t = _s.next()) { var ab = _t.value; ab.setContextValue("AxisFieldValues", 7, z); } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { if (_t && !_t.done && (_f = _s.return)) _f.call(_s); } finally { if (e_6) throw e_6.error; } } h.dataMemberPath = "label"; h.selectedMemberPath = "isSelected"; h.primaryKey = ["key"]; h.contextBindings = [((function () { var $ret = new ToolContextBindingInfo(); $ret.bindingMode = 0; $ret.contextKey = "AxisFieldValues"; $ret.propertyName = "ItemsSource"; return $ret; })())]; var ac = new ToolActionIconMenuInfo(); ac.name = "AxisFieldMenu"; ac.iconName = "analyze-valuelabels-showlast"; ac.iconCollectionName = "ChartToolbarIcons"; ac.iconWidth = 24; ac.iconHeight = 25; ac.actions = [e, f, g, h]; d = new Array(b.length + 1); for (var ad = 0; ad < b.length; ad++) { d[ad] = b[ad]; } d[b.length] = ac; } else { d = b; } for (var ae = 0; ae < d.length; ae++) { this.i(a, d[ae]); } 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.ahl != null && !BrushUtilCore.a(f.ahl) && f.acr > 0 && f.ahs != null && !BrushUtilCore.a(f.ahs) && f.ada > 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.ahl == null || BrushUtilCore.a(a.ahl) ? c : a.ahl; d.a = isNaN_(a.acr) || a.acr == 0 ? DeviceUtils.g(1) : a.acr; this.f.item("xaxis", d); } else { d.b = a.ahs == null || BrushUtilCore.a(a.ahs) ? c : a.ahs; d.a = isNaN_(a.ada) || a.ada == 0 ? DeviceUtils.g(1) : a.ada; 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.ahl || c.acr != 0) { d = true; } else { c.ahl = this.f.item("xaxis").b; c.acr = this.f.item("xaxis").a; d = false; } } if (d) { var e = this.a(c, "xaxis", AxisDefaults.axis_MajorBrush); c.ahl = e.b; c.acr = e.a; } d = true; if (this.f.d("yaxis")) { if (this.f.item("yaxis").b != c.ahs || c.ada != 0) { d = true; } else { c.ahs = this.f.item("yaxis").b; c.ada = this.f.item("yaxis").a; d = false; } } if (d) { var f = this.a(c, "yaxis", AxisDefaults.axis_MajorBrush); c.ahs = f.b; c.ada = f.a; } } } else { if (typeCast(XYChart.$, a) !== null) { var g = a; if (!this.f.d("xaxis")) { this.a(g, "xaxis", AxisDefaults.axis_MajorBrush); } g.acr = 0; if (!this.f.d("yaxis")) { this.a(g, "yaxis", AxisDefaults.axis_MajorBrush); } g.ada = 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 };