UNPKG

igniteui-webcomponents-charts

Version:

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

759 lines (757 loc) 26.7 kB
import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core"; import { LabelsPosition_$type } from "./LabelsPosition"; import { Visibility_$type } from "igniteui-webcomponents-core"; import { Style } from "igniteui-webcomponents-core"; import { LeaderLineType_$type } from "./LeaderLineType"; import { OthersCategoryType_$type } from "igniteui-webcomponents-core"; import { IgcPropertyUpdatedEventArgs } from "igniteui-webcomponents-core"; import { ensureEnum, arrayFindByName, toBrushCollection, fromBrushCollection, brushCollectionToString, toSpinal, fromSpinal, getAllPropertyNames, enumToString, ensureBool, initializePropertiesFromCss, NamePatcher, brushToString, stringToBrush } from "igniteui-webcomponents-core"; import { TypeRegistrar } from "igniteui-webcomponents-core"; import { IgcHTMLElement } from "igniteui-webcomponents-core"; let IgcRingSeriesBaseComponent = /*@__PURE__*/ (() => { class IgcRingSeriesBaseComponent extends IgcHTMLElement { createImplementation() { return null; } set dataSource(value) { this._dataSource = value; this.bindData(); } get dataSource() { return this._dataSource; } bindData() { if (this.i != null && this.i !== undefined) { this.i.itemsSource = this._dataSource; } } get i() { return this._implementation; } onImplementationCreated() { } constructor() { super(); this._dataSource = null; this._tooltipTemplate = null; this._tooltipContent = null; this._tooltipContainerTemplate = null; this._showDefaultTooltip = false; this._settingAttributes = false; this._attached = false; this._queuedSetAttributes = []; this._updatingFromAttribute = 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(); } static _createFromInternal(internal) { if (!internal) { return null; } if (!internal.$type) { return null; } let name = internal.$type.name; let externalName = "Igc" + name + "Component"; if (!TypeRegistrar.isRegistered(externalName)) { return null; } return TypeRegistrar.create(externalName); } get legend() { if (this.i.legend != null) return this.i.legend.externalObject; } set legend(v) { if (v != undefined && v != null) this.i.legend = v.i; } set tooltipTemplate(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); } } } get tooltipTemplate() { return this._tooltipTemplate; } set tooltipContainerTemplate(value) { this._tooltipContainerTemplate = value; if (this._tooltipContent != null) { this._tooltipContent.containerTemplate = this._tooltipContainerTemplate; } } get tooltipContainerTemplate() { return this._tooltipContainerTemplate; } /** * Gets or sets whether default tooltip will be shown. */ get showDefaultTooltip() { return this._showDefaultTooltip; } set showDefaultTooltip(v) { this._showDefaultTooltip = ensureBool(v); } _ensureTooltipCreated(createTooltip, createWrapper) { if (this._tooltipTemplate == null) { this.i.toolTip = null; } if (this._tooltipContent == null && this._tooltipTemplate != null) { let tooltip = createTooltip(); if (tooltip == null) { return; } this._tooltipContent = tooltip; tooltip.template = this._tooltipTemplate; this.i.toolTip = createWrapper(tooltip); } } _ensureTooltipDestroyed() { if (this._tooltipContent !== null) { this._tooltipContent.destroy(); this._tooltipContent = null; } } _enqueueSetAttribute(attrName, attrValue) { this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue }); } _flushQueuedAttributes() { this._settingAttributes = true; for (let i = 0; i < this._queuedSetAttributes.length; i++) { this.setAttribute(this._queuedSetAttributes[i].attrName, this._queuedSetAttributes[i].attrValue); } this._settingAttributes = false; this._queuedSetAttributes.length = 0; } _a(attrName, attrValue) { if (this._updatingFromAttribute) { return; } if (attrValue) { attrValue = attrValue.toString(); } this._settingAttributes = true; attrName = toSpinal(attrName); if (this._attached) { this.setAttribute(attrName, attrValue); } else { this._enqueueSetAttribute(attrName, attrValue); } this._settingAttributes = false; } connectedCallback() { if (super["connectedCallback"]) { super["connectedCallback"](); } if (this.i.connectedCallback) { this.i.connectedCallback(); } if (!this._attached) { this._attached = true; this._flushQueuedAttributes(); } } disconnectedCallback() { if (super["disconnectedCallback"]) { super["disconnectedCallback"](); } if (this.i.disconnectedCallback) { this.i.disconnectedCallback(); } if (this._attached) { this._attached = false; } } static get observedAttributes() { if (IgcRingSeriesBaseComponent._observedAttributesIgcRingSeriesBaseComponent == null) { let names = getAllPropertyNames(IgcRingSeriesBaseComponent); for (let i = 0; i < names.length; i++) { names[i] = toSpinal(names[i]); } IgcRingSeriesBaseComponent._observedAttributesIgcRingSeriesBaseComponent = names; } return IgcRingSeriesBaseComponent._observedAttributesIgcRingSeriesBaseComponent; } attributeChangedCallback(name, oldValue, newValue) { if (this._settingAttributes) { return; } let setName = fromSpinal(name); this._updatingFromAttribute = true; this[setName] = newValue; this._updatingFromAttribute = false; } /** * Gets or Sets the property name that contains the values. */ get valueMemberPath() { return this.i.cs; } set valueMemberPath(v) { this.i.cs = v; } /** * Gets or sets the property name that contains the labels. */ get labelMemberPath() { return this.i.bp; } set labelMemberPath(v) { this.i.bp = v; } /** * Gets or sets the property name that contains the legend labels. */ get legendLabelMemberPath() { return this.i.b3; } set legendLabelMemberPath(v) { this.i.b3 = v; } /** * Gets or sets the position of chart labels. */ get labelsPosition() { return this.i.an; } set labelsPosition(v) { this.i.an = ensureEnum(LabelsPosition_$type, v); this._a("labelsPosition", enumToString(LabelsPosition_$type, this.i.an)); } /** * Gets or sets whether the leader lines are visible. */ get leaderLineVisibility() { return this.i.en; } set leaderLineVisibility(v) { this.i.en = ensureEnum(Visibility_$type, v); this._a("leaderLineVisibility", enumToString(Visibility_$type, this.i.en)); } /** * Gets or sets the fill brush. */ get leaderLineFill() { return this.i.ei ? this.i.ei.fill : null; } set leaderLineFill(v) { this.ensureLeaderLineStyle(); this.i.ei.fill = v; } /** * Gets or sets the stroke brush. */ get leaderLineStroke() { return this.i.ei ? this.i.ei.stroke : null; } set leaderLineStroke(v) { this.ensureLeaderLineStyle(); this.i.ei.stroke = v; } /** * Gets or sets the stroke thickness. */ get leaderLineStrokeThickness() { return this.i.ei ? this.i.ei.strokeThickness : NaN; } set leaderLineStrokeThickness(v) { this.ensureLeaderLineStyle(); this.i.ei.strokeThickness = +v; this._a("leaderLineStrokeThickness", this.i.ei.strokeThickness); } /** * Gets or sets the opacity. */ get leaderLineOpacity() { return this.i.ei ? this.i.ei.opacity : NaN; } set leaderLineOpacity(v) { this.ensureLeaderLineStyle(); this.i.ei.opacity = +v; this._a("leaderLineOpacity", this.i.ei.opacity); } ensureLeaderLineStyle() { if (this.i.ei) { return; } this.i.ei = new Style(); } /** * Gets or sets what type of leader lines will be used for the outside end labels. */ get leaderLineType() { return this.i.ao; } set leaderLineType(v) { this.i.ao = ensureEnum(LeaderLineType_$type, v); this._a("leaderLineType", enumToString(LeaderLineType_$type, this.i.ao)); } /** * Gets or sets the margin between a label and its leader line. The default is 6 pixels. */ get leaderLineMargin() { return this.i.a7; } set leaderLineMargin(v) { this.i.a7 = +v; this._a("leaderLineMargin", this.i.a7); } /** * Gets or sets the threshold value that determines if slices are grouped into the Others slice. */ get othersCategoryThreshold() { return this.i.a8; } set othersCategoryThreshold(v) { this.i.a8 = +v; this._a("othersCategoryThreshold", this.i.a8); } /** * Gets or sets whether to use numeric or percent-based threshold value. */ get othersCategoryType() { return this.i.ap; } set othersCategoryType(v) { this.i.ap = ensureEnum(OthersCategoryType_$type, v); this._a("othersCategoryType", enumToString(OthersCategoryType_$type, this.i.ap)); } /** * Gets or sets the label of the Others slice. */ get othersCategoryText() { return this.i.ca; } set othersCategoryText(v) { this.i.ca = v; } /** * Sets or gets a function which takes an object that produces a formatted label for displaying in the chart. */ get formatLabel() { return this.i.aq; } set formatLabel(v) { this.i.aq = v; } /** * Sets or gets a function which takes an object that produces a formatted label for displaying in the chart's legend. */ get formatLegendLabel() { return this.i.ar; } set formatLegendLabel(v) { this.i.ar = v; } /** * Gets or sets the label format string to use for the label. */ get labelFormat() { return this.i.bl; } set labelFormat(v) { this.i.bl = v; } /** * Gets or sets the format specifiers to use with the LabelFormat string. */ get labelFormatSpecifiers() { return this.i.ag; } set labelFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.ag = v; } /** * Gets or sets the label format string to use for the label. */ get othersLabelFormat() { return this.i.ce; } set othersLabelFormat(v) { this.i.ce = v; } /** * Gets or sets the format specifiers to use with the OthersLabelFormat string. */ get othersLabelFormatSpecifiers() { return this.i.aj; } set othersLabelFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.aj = v; } /** * Gets or sets the label format string to use for the label. */ get legendLabelFormat() { return this.i.b0; } set legendLabelFormat(v) { this.i.b0 = v; } /** * Gets or sets the format specifiers to use with the LegendLabelFormat string. */ get legendLabelFormatSpecifiers() { return this.i.ah; } set legendLabelFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.ah = v; } /** * Gets or sets the label format string to use for the label. */ get legendOthersLabelFormat() { return this.i.b5; } set legendOthersLabelFormat(v) { this.i.b5 = v; } /** * Gets or sets the format specifiers to use with the LegendOthersLabelFormat string. */ get legendOthersLabelFormatSpecifiers() { return this.i.ai; } set legendOthersLabelFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.ai = v; } /** * Gets or sets the pixel amount by which the labels are offset from the edge of the slices. */ get labelExtent() { return this.i.a6; } set labelExtent(v) { this.i.a6 = +v; this._a("labelExtent", this.i.a6); } /** * Gets or sets the starting angle of the chart. * The default zero value is equivalent to 3 o'clock. */ get startAngle() { return this.i.ba; } set startAngle(v) { this.i.ba = +v; this._a("startAngle", this.i.ba); } /** * Gets or sets the fill brush. */ get othersCategoryFill() { return this.i.ej ? this.i.ej.fill : null; } set othersCategoryFill(v) { this.ensureOthersCategoryStyle(); this.i.ej.fill = v; } /** * Gets or sets the stroke brush. */ get othersCategoryStroke() { return this.i.ej ? this.i.ej.stroke : null; } set othersCategoryStroke(v) { this.ensureOthersCategoryStyle(); this.i.ej.stroke = v; } /** * Gets or sets the stroke thickness. */ get othersCategoryStrokeThickness() { return this.i.ej ? this.i.ej.strokeThickness : NaN; } set othersCategoryStrokeThickness(v) { this.ensureOthersCategoryStyle(); this.i.ej.strokeThickness = +v; this._a("othersCategoryStrokeThickness", this.i.ej.strokeThickness); } /** * Gets or sets the opacity. */ get othersCategoryOpacity() { return this.i.ej ? this.i.ej.opacity : NaN; } set othersCategoryOpacity(v) { this.ensureOthersCategoryStyle(); this.i.ej.opacity = +v; this._a("othersCategoryOpacity", this.i.ej.opacity); } ensureOthersCategoryStyle() { if (this.i.ej) { return; } this.i.ej = new Style(); } /** * Gets or sets the fill brush. */ get selectedSliceFill() { return this.i.ek ? this.i.ek.fill : null; } set selectedSliceFill(v) { this.ensureSelectedStyle(); this.i.ek.fill = v; } /** * Gets or sets the stroke brush. */ get selectedSliceStroke() { return this.i.ek ? this.i.ek.stroke : null; } set selectedSliceStroke(v) { this.ensureSelectedStyle(); this.i.ek.stroke = v; } /** * Gets or sets the stroke thickness. */ get selectedSliceStrokeThickness() { return this.i.ek ? this.i.ek.strokeThickness : NaN; } set selectedSliceStrokeThickness(v) { this.ensureSelectedStyle(); this.i.ek.strokeThickness = +v; this._a("selectedSliceStrokeThickness", this.i.ek.strokeThickness); } /** * Gets or sets the opacity. */ get selectedSliceOpacity() { return this.i.ek ? this.i.ek.opacity : NaN; } set selectedSliceOpacity(v) { this.ensureSelectedStyle(); this.i.ek.opacity = +v; this._a("selectedSliceOpacity", this.i.ek.opacity); } ensureSelectedStyle() { if (this.i.ek) { return; } this.i.ek = new Style(); } /** * Gets or sets the palette of brushes to use for coloring the slices. */ get brushes() { return fromBrushCollection(this.i.ak); } set brushes(v) { this.i.ak = toBrushCollection(v); this._a("brushes", brushCollectionToString(this.i.ak)); } /** * Gets or sets the palette of brushes to use for outlines on the slices. */ get outlines() { return fromBrushCollection(this.i.al); } set outlines(v) { this.i.al = toBrushCollection(v); this._a("outlines", brushCollectionToString(this.i.al)); } /** * Gets or sets the color for labels rendered outside of the pie chart. */ get labelOuterColor() { return brushToString(this.i.eg); } set labelOuterColor(v) { this.i.eg = stringToBrush(v); this._a("labelOuterColor", brushToString(this.i.eg)); } /** * Gets or sets the color for labels rendered inside of the pie chart. */ get labelInnerColor() { return brushToString(this.i.ef); } set labelInnerColor(v) { this.i.ef = stringToBrush(v); this._a("labelInnerColor", brushToString(this.i.ef)); } /** * Gets or sets the text style to use for labels. */ get textStyle() { return this.i.co; } set textStyle(v) { this.i.co = v; } /** * Gets or sets whether all surface interactions with the plot area should be disabled. */ get isSurfaceInteractionDisabled() { return this.i.a3; } set isSurfaceInteractionDisabled(v) { this.i.a3 = ensureBool(v); this._a("isSurfaceInteractionDisabled", this.i.a3); } /** * Gets or sets the scaling factor of the chart's radius. Value between 0 and 1. */ get radiusFactor() { return this.i.a9; } set radiusFactor(v) { this.i.a9 = +v; this._a("radiusFactor", this.i.a9); } findByName(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; } get hasUserValues() { return this._hasUserValues; } __m(propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } } _styling(container, component, parent) { if (this._inStyling) { return; } this._inStyling = true; this._stylingContainer = container; this._stylingParent = component; let genericPrefix = ""; let typeName = this.i.$type.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } genericPrefix = toSpinal("RingSeriesBaseComponent"); let additionalPrefixes = []; let prefix = toSpinal(typeName); additionalPrefixes.push(prefix + "-"); let 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); } let basePrefix = toSpinal(typeName); additionalPrefixes.push(basePrefix + "-"); b = b.baseType; } if (parent) { let parentTypeName = parent.i.$type.name; if (parentTypeName.indexOf("Xam") === 0) { parentTypeName = parentTypeName.substring(3); } let 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. */ provideContainer(container) { this.i.c5(container); } /** * Event raised when a property (including "effective" and non-dependency property) value changes. */ get propertyUpdated() { return this._propertyUpdated; } set propertyUpdated(ev) { 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 = (o, e) => { let outerArgs = new IgcPropertyUpdatedEventArgs(); 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); ; } } IgcRingSeriesBaseComponent._observedAttributesIgcRingSeriesBaseComponent = null; return IgcRingSeriesBaseComponent; })(); export { IgcRingSeriesBaseComponent };