UNPKG

igniteui-react-charts

Version:

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

908 lines (906 loc) 29.8 kB
import { __extends, __values } from "tslib"; import * as React from 'react'; import { delegateCombine, delegateRemove, TypeRegistrar } from "igniteui-react-core"; import { LabelsPosition_$type } from "./LabelsPosition"; import { Visibility_$type } from "igniteui-react-core"; import { Style } from "igniteui-react-core"; import { LeaderLineType_$type } from "./LeaderLineType"; import { OthersCategoryType_$type } from "igniteui-react-core"; import { IgrPropertyUpdatedEventArgs } from "igniteui-react-core"; import { ensureEnum, arrayFindByName, toBrushCollection, fromBrushCollection, isValidProp, getModifiedProps, ensureBool, toSpinal, initializePropertiesFromCss, NamePatcher, brushToString, stringToBrush } from "igniteui-react-core"; /** * Represents a * IgxDoughnutChartComponent base series. */ var IgrRingSeriesBase = /** @class */ /*@__PURE__*/ (function (_super) { __extends(IgrRingSeriesBase, _super); function IgrRingSeriesBase(props) { var _this = _super.call(this, props) || this; _this._dataSource = null; _this._tooltipTemplate = null; _this._tooltipContent = null; _this._tooltipContainerTemplate = null; _this._showDefaultTooltip = false; _this.__p = null; _this._hasUserValues = new Set(); _this._stylingContainer = null; _this._stylingParent = null; _this._inStyling = false; _this._propertyUpdated = null; _this._propertyUpdated_wrapped = null; if (_this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this)); } _this._implementation = _this.createImplementation(); _this._implementation.externalObject = _this; _this.onImplementationCreated(); return _this; } IgrRingSeriesBase.prototype.createImplementation = function () { return null; }; Object.defineProperty(IgrRingSeriesBase.prototype, "dataSource", { get: function () { return this._dataSource; }, set: function (value) { this._dataSource = value; this.bindData(); }, enumerable: false, configurable: true }); IgrRingSeriesBase.prototype.bindData = function () { if (this.i != null && this.i !== undefined) { this.i.itemsSource = this._dataSource; } }; Object.defineProperty(IgrRingSeriesBase.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); IgrRingSeriesBase.prototype.onImplementationCreated = function () { }; IgrRingSeriesBase.prototype.componentDidMount = function () { var e_1, _a; try { for (var _b = __values(Object.keys(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { { this[p] = this.props[p]; } } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } }; IgrRingSeriesBase.prototype.shouldComponentUpdate = function (nextProps, nextState) { var e_2, _a; var mod = getModifiedProps(this.props, nextProps); try { for (var _b = __values(Object.keys(mod)), _c = _b.next(); !_c.done; _c = _b.next()) { var p = _c.value; if (isValidProp(this, p)) { this[p] = mod[p]; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_2) throw e_2.error; } } return true; }; IgrRingSeriesBase.prototype.render = function () { return null; }; IgrRingSeriesBase._createFromInternal = function (internal) { if (!internal) { return null; } if (!internal.$type) { return null; } var name = internal.$type.name; var externalName = "Igr" + name; if (!TypeRegistrar.isRegistered(externalName)) { return null; } return TypeRegistrar.create(externalName); }; Object.defineProperty(IgrRingSeriesBase.prototype, "legend", { get: function () { if (this.i.legend != null) return this.i.legend.externalObject; }, set: function (v) { if (v != undefined && v != null) this.i.legend = v.i; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "tooltipTemplate", { get: function () { return this._tooltipTemplate; }, set: function (value) { this._tooltipTemplate = value; if (value == null) { if (this._tooltipContent !== null) { //this._tooltipContent.destroy(); this._tooltipContent = null; } } if (this._tooltipContent != null) { this._tooltipContent.template = this._tooltipTemplate; } else { if (this.owner != null) { this.owner._ensureTooltipCreated(this); } } }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "tooltipContainerTemplate", { get: function () { return this._tooltipContainerTemplate; }, set: function (value) { this._tooltipContainerTemplate = value; if (this._tooltipContent != null) { this._tooltipContent.instance.containerTemplate = this._tooltipContainerTemplate; } }, enumerable: false, configurable: true }); IgrRingSeriesBase.prototype._ensureTooltipCreated = function (createTooltip, createWrapper) { if (this._tooltipTemplate == null) { this.i.toolTip = null; } if (this._tooltipContent == null && this._tooltipTemplate != null) { var tooltip = createTooltip(); if (tooltip == null) { return; } this._tooltipContent = tooltip; tooltip.tooltipTemplate = this._tooltipTemplate; this.i.toolTip = createWrapper(tooltip); } }; IgrRingSeriesBase.prototype._ensureTooltipDestroyed = function () { if (this._tooltipContent !== null) { //this._tooltipContent.destroy(); this._tooltipContent = null; } }; Object.defineProperty(IgrRingSeriesBase.prototype, "showDefaultTooltip", { /** * Gets or sets whether default tooltip will be shown. */ get: function () { return this._showDefaultTooltip; }, set: function (v) { this._showDefaultTooltip = ensureBool(v); }, enumerable: false, configurable: true }); IgrRingSeriesBase.prototype.sychronizeCollections = function () { }; Object.defineProperty(IgrRingSeriesBase.prototype, "valueMemberPath", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.cs; }, set: function (v) { this.i.cs = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "labelMemberPath", { /** * Gets or sets the property name that contains the labels. */ get: function () { return this.i.bp; }, set: function (v) { this.i.bp = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "legendLabelMemberPath", { /** * Gets or sets the property name that contains the legend labels. */ get: function () { return this.i.b3; }, set: function (v) { this.i.b3 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "labelsPosition", { /** * Gets or sets the position of chart labels. */ get: function () { return this.i.an; }, set: function (v) { this.i.an = ensureEnum(LabelsPosition_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "leaderLineVisibility", { /** * Gets or sets whether the leader lines are visible. */ get: function () { return this.i.en; }, set: function (v) { this.i.en = ensureEnum(Visibility_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "leaderLineFill", { /** * Gets or sets the fill brush. */ get: function () { return this.i.ei ? this.i.ei.fill : null; }, set: function (v) { this.ensureLeaderLineStyle(); this.i.ei.fill = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "leaderLineStroke", { /** * Gets or sets the stroke brush. */ get: function () { return this.i.ei ? this.i.ei.stroke : null; }, set: function (v) { this.ensureLeaderLineStyle(); this.i.ei.stroke = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "leaderLineStrokeThickness", { /** * Gets or sets the stroke thickness. */ get: function () { return this.i.ei ? this.i.ei.strokeThickness : NaN; }, set: function (v) { this.ensureLeaderLineStyle(); this.i.ei.strokeThickness = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "leaderLineOpacity", { /** * Gets or sets the opacity. */ get: function () { return this.i.ei ? this.i.ei.opacity : NaN; }, set: function (v) { this.ensureLeaderLineStyle(); this.i.ei.opacity = +v; }, enumerable: false, configurable: true }); IgrRingSeriesBase.prototype.ensureLeaderLineStyle = function () { if (this.i.ei) { return; } this.i.ei = new Style(); }; Object.defineProperty(IgrRingSeriesBase.prototype, "leaderLineType", { /** * Gets or sets what type of leader lines will be used for the outside end labels. */ get: function () { return this.i.ao; }, set: function (v) { this.i.ao = ensureEnum(LeaderLineType_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "leaderLineMargin", { /** * Gets or sets the margin between a label and its leader line. The default is 6 pixels. */ get: function () { return this.i.a7; }, set: function (v) { this.i.a7 = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "othersCategoryThreshold", { /** * Gets or sets the threshold value that determines if slices are grouped into the Others slice. */ get: function () { return this.i.a8; }, set: function (v) { this.i.a8 = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "othersCategoryType", { /** * Gets or sets whether to use numeric or percent-based threshold value. */ get: function () { return this.i.ap; }, set: function (v) { this.i.ap = ensureEnum(OthersCategoryType_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "othersCategoryText", { /** * Gets or sets the label of the Others slice. */ get: function () { return this.i.ca; }, set: function (v) { this.i.ca = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "formatLabel", { /** * Sets or gets a function which takes an object that produces a formatted label for displaying in the chart. */ get: function () { return this.i.aq; }, set: function (v) { this.i.aq = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "formatLegendLabel", { /** * Sets or gets a function which takes an object that produces a formatted label for displaying in the chart's legend. */ get: function () { return this.i.ar; }, set: function (v) { this.i.ar = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "labelFormat", { /** * Gets or sets the label format string to use for the label. */ get: function () { return this.i.bl; }, set: function (v) { this.i.bl = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "labelFormatSpecifiers", { /** * Gets or sets the format specifiers to use with the LabelFormat string. */ get: function () { return this.i.ag; }, set: function (v) { if (v && !Array.isArray(v) && typeof (v) == "string") { var re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.ag = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "othersLabelFormat", { /** * Gets or sets the label format string to use for the label. */ get: function () { return this.i.ce; }, set: function (v) { this.i.ce = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "othersLabelFormatSpecifiers", { /** * Gets or sets the format specifiers to use with the OthersLabelFormat string. */ get: function () { return this.i.aj; }, set: function (v) { if (v && !Array.isArray(v) && typeof (v) == "string") { var re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.aj = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "legendLabelFormat", { /** * Gets or sets the label format string to use for the label. */ get: function () { return this.i.b0; }, set: function (v) { this.i.b0 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "legendLabelFormatSpecifiers", { /** * Gets or sets the format specifiers to use with the LegendLabelFormat string. */ get: function () { return this.i.ah; }, set: function (v) { if (v && !Array.isArray(v) && typeof (v) == "string") { var re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.ah = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "legendOthersLabelFormat", { /** * Gets or sets the label format string to use for the label. */ get: function () { return this.i.b5; }, set: function (v) { this.i.b5 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "legendOthersLabelFormatSpecifiers", { /** * Gets or sets the format specifiers to use with the LegendOthersLabelFormat string. */ get: function () { return this.i.ai; }, set: function (v) { if (v && !Array.isArray(v) && typeof (v) == "string") { var re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.ai = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "labelExtent", { /** * Gets or sets the pixel amount by which the labels are offset from the edge of the slices. */ get: function () { return this.i.a6; }, set: function (v) { this.i.a6 = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "startAngle", { /** * Gets or sets the starting angle of the chart. * The default zero value is equivalent to 3 o'clock. */ get: function () { return this.i.ba; }, set: function (v) { this.i.ba = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "othersCategoryFill", { /** * Gets or sets the fill brush. */ get: function () { return this.i.ej ? this.i.ej.fill : null; }, set: function (v) { this.ensureOthersCategoryStyle(); this.i.ej.fill = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "othersCategoryStroke", { /** * Gets or sets the stroke brush. */ get: function () { return this.i.ej ? this.i.ej.stroke : null; }, set: function (v) { this.ensureOthersCategoryStyle(); this.i.ej.stroke = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "othersCategoryStrokeThickness", { /** * Gets or sets the stroke thickness. */ get: function () { return this.i.ej ? this.i.ej.strokeThickness : NaN; }, set: function (v) { this.ensureOthersCategoryStyle(); this.i.ej.strokeThickness = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "othersCategoryOpacity", { /** * Gets or sets the opacity. */ get: function () { return this.i.ej ? this.i.ej.opacity : NaN; }, set: function (v) { this.ensureOthersCategoryStyle(); this.i.ej.opacity = +v; }, enumerable: false, configurable: true }); IgrRingSeriesBase.prototype.ensureOthersCategoryStyle = function () { if (this.i.ej) { return; } this.i.ej = new Style(); }; Object.defineProperty(IgrRingSeriesBase.prototype, "selectedSliceFill", { /** * Gets or sets the fill brush. */ get: function () { return this.i.ek ? this.i.ek.fill : null; }, set: function (v) { this.ensureSelectedStyle(); this.i.ek.fill = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "selectedSliceStroke", { /** * Gets or sets the stroke brush. */ get: function () { return this.i.ek ? this.i.ek.stroke : null; }, set: function (v) { this.ensureSelectedStyle(); this.i.ek.stroke = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "selectedSliceStrokeThickness", { /** * Gets or sets the stroke thickness. */ get: function () { return this.i.ek ? this.i.ek.strokeThickness : NaN; }, set: function (v) { this.ensureSelectedStyle(); this.i.ek.strokeThickness = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "selectedSliceOpacity", { /** * Gets or sets the opacity. */ get: function () { return this.i.ek ? this.i.ek.opacity : NaN; }, set: function (v) { this.ensureSelectedStyle(); this.i.ek.opacity = +v; }, enumerable: false, configurable: true }); IgrRingSeriesBase.prototype.ensureSelectedStyle = function () { if (this.i.ek) { return; } this.i.ek = new Style(); }; Object.defineProperty(IgrRingSeriesBase.prototype, "brushes", { /** * Gets or sets the palette of brushes to use for coloring the slices. */ get: function () { return fromBrushCollection(this.i.ak); }, set: function (v) { this.i.ak = toBrushCollection(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "outlines", { /** * Gets or sets the palette of brushes to use for outlines on the slices. */ get: function () { return fromBrushCollection(this.i.al); }, set: function (v) { this.i.al = toBrushCollection(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "labelOuterColor", { /** * Gets or sets the color for labels rendered outside of the pie chart. */ get: function () { return brushToString(this.i.eg); }, set: function (v) { this.i.eg = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "labelInnerColor", { /** * Gets or sets the color for labels rendered inside of the pie chart. */ get: function () { return brushToString(this.i.ef); }, set: function (v) { this.i.ef = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "isSurfaceInteractionDisabled", { /** * Gets or sets whether all surface interactions with the plot area should be disabled. */ get: function () { return this.i.a3; }, set: function (v) { this.i.a3 = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgrRingSeriesBase.prototype, "radiusFactor", { /** * Gets or sets the scaling factor of the chart's radius. Value between 0 and 1. */ get: function () { return this.i.a9; }, set: function (v) { this.i.a9 = +v; }, enumerable: false, configurable: true }); IgrRingSeriesBase.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } if (this.legend && this.legend.name && this.legend.name == name) { return this.legend; } if (this.labelFormatSpecifiers != null && arrayFindByName(this.labelFormatSpecifiers, name)) { return arrayFindByName(this.labelFormatSpecifiers, name); } if (this.othersLabelFormatSpecifiers != null && arrayFindByName(this.othersLabelFormatSpecifiers, name)) { return arrayFindByName(this.othersLabelFormatSpecifiers, name); } if (this.legendLabelFormatSpecifiers != null && arrayFindByName(this.legendLabelFormatSpecifiers, name)) { return arrayFindByName(this.legendLabelFormatSpecifiers, name); } if (this.legendOthersLabelFormatSpecifiers != null && arrayFindByName(this.legendOthersLabelFormatSpecifiers, name)) { return arrayFindByName(this.legendOthersLabelFormatSpecifiers, name); } return null; }; Object.defineProperty(IgrRingSeriesBase.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgrRingSeriesBase.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgrRingSeriesBase.prototype._styling = function (container, component, parent) { if (this._inStyling) { return; } this._inStyling = true; this._stylingContainer = container; this._stylingParent = component; var genericPrefix = ""; var typeName = this.i.$type.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } genericPrefix = toSpinal("RingSeriesBase"); var additionalPrefixes = []; var prefix = toSpinal(typeName); additionalPrefixes.push(prefix + "-"); var b = this.i.$type.baseType; while (b && b.name != "Object" && b.name != "Base" && b.name != "Control" && b.Name != "DependencyObject" && b.Name != "FrameworkElement") { typeName = b.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } var basePrefix = toSpinal(typeName); additionalPrefixes.push(basePrefix + "-"); b = b.baseType; } if (parent) { var parentTypeName = parent.i.$type.name; if (parentTypeName.indexOf("Xam") === 0) { parentTypeName = parentTypeName.substring(3); } var parentPrefix = toSpinal(parentTypeName); additionalPrefixes.push(parentPrefix + "-" + genericPrefix + "-"); additionalPrefixes.push(parentPrefix + "-" + prefix + "-"); } initializePropertiesFromCss(container, this, genericPrefix + "-", this.hasUserValues, false, additionalPrefixes); if (this._otherStyling) { this._otherStyling(container, component, parent); } this._inStyling = false; }; /** * Called by the UI framework to provide a UI container for rendering this control. * @param container * The UI container element. */ IgrRingSeriesBase.prototype.provideContainer = function (container) { this.i.c5(container); }; Object.defineProperty(IgrRingSeriesBase.prototype, "propertyUpdated", { /** * Event raised when a property (including "effective" and non-dependency property) value changes. */ get: function () { return this._propertyUpdated; }, set: function (ev) { var _this = this; if (this._propertyUpdated_wrapped !== null) { this.i.propertyUpdated = delegateRemove(this.i.propertyUpdated, this._propertyUpdated_wrapped); this._propertyUpdated_wrapped = null; this._propertyUpdated = null; } this._propertyUpdated = ev; this._propertyUpdated_wrapped = function (o, e) { var outerArgs = new IgrPropertyUpdatedEventArgs(); outerArgs._provideImplementation(e); if (_this.beforePropertyUpdated) { _this.beforePropertyUpdated(_this, outerArgs); } if (_this._propertyUpdated) { _this._propertyUpdated(_this, outerArgs); } }; this.i.propertyUpdated = delegateCombine(this.i.propertyUpdated, this._propertyUpdated_wrapped); ; }, enumerable: false, configurable: true }); return IgrRingSeriesBase; }(React.Component)); export { IgrRingSeriesBase };