UNPKG

igniteui-react-charts

Version:

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

368 lines (367 loc) 10.7 kB
import { DataAnnotationDisplayMode_$type } from "./DataAnnotationDisplayMode"; import { AnnotationAppearanceMode_$type } from "./AnnotationAppearanceMode"; import { IgrAxis } from "./igr-axis"; import { DataAnnotationTargetMode_$type } from "./DataAnnotationTargetMode"; import { IgrAnnotationLayer } from "./igr-annotation-layer"; import { ensureBool, ensureEnum, brushToString, stringToBrush } from "igniteui-react-core"; import { Thickness } from "igniteui-react-core"; /** * Represents a base annotation layer that displays annotations over an axis. */ export class IgrDataAnnotationAxisLayer extends IgrAnnotationLayer { /** * @hidden */ get i() { return this._implementation; } constructor(props) { super(props); this._targetAxisName = null; } /** * Gets whether the series is a data annotation layer that support binding to data source */ get isAnnotationDataLayer() { return this.i.es; } /** * Gets or sets display mode of label on axis annotation. */ get annotationLabelDisplayMode() { return this.i.aaw; } set annotationLabelDisplayMode(v) { this.i.aaw = ensureEnum(DataAnnotationDisplayMode_$type, v); } /** * Gets or sets whether to show all annotations over target axis */ get annotationLabelVisible() { return this.i.aa2; } set annotationLabelVisible(v) { this.i.aa2 = ensureBool(v); } /** * Gets or sets the text color used in the axis annotation. */ get annotationTextColor() { return brushToString(this.i.ac8); } set annotationTextColor(v) { this.i.ac8 = stringToBrush(v); } /** * Gets or sets the mode used for shifting the text color in axis annotation. */ get annotationTextColorMode() { return this.i.aau; } set annotationTextColorMode(v) { this.i.aau = ensureEnum(AnnotationAppearanceMode_$type, v); } /** * Gets or sets the percentage used to shift AnnotationTextColor. Value must range between -1.0 to 1.0, where 0 means no color shift. */ get annotationTextColorShift() { return this.i.abd; } set annotationTextColorShift(v) { this.i.abd = +v; } /** * Gets or sets whether the annotation text color matches brush of the layer */ get annotationTextColorMatchLayer() { return this.i.aa3; } set annotationTextColorMatchLayer(v) { this.i.aa3 = ensureBool(v); } /** * Gets or sets the color used for backing of the axis annotation. */ get annotationBackground() { return brushToString(this.i.ac4); } set annotationBackground(v) { this.i.ac4 = stringToBrush(v); } /** * Gets or sets the border radius used for displaying the axis annotation. */ get annotationBorderRadius() { return this.i.aba; } set annotationBorderRadius(v) { this.i.aba = +v; } /** * Gets or sets the mode used for shifting the background of axis annotation. */ get annotationBackgroundMode() { return this.i.aas; } set annotationBackgroundMode(v) { this.i.aas = ensureEnum(AnnotationAppearanceMode_$type, v); } /** * Gets or sets the percentage used to shift AnnotationBackground. Value must range between -1.0 to 1.0, where 0 means no color shift. */ get annotationBackgroundShift() { return this.i.aa5; } set annotationBackgroundShift(v) { this.i.aa5 = +v; } /** * Gets or sets whether the annotation background matches brush of the layer */ get annotationBackgroundMatchLayer() { return this.i.aaz; } set annotationBackgroundMatchLayer(v) { this.i.aaz = ensureBool(v); } /** * Gets or sets whether the annotation border matches outline of the layer (if it has a fill visual) otherwise brush of the layer */ get annotationBorderMatchLayer() { return this.i.aa1; } set annotationBorderMatchLayer(v) { this.i.aa1 = ensureBool(v); } /** * Gets or sets the color used for border color of the axis annotation. */ get annotationBorderColor() { return brushToString(this.i.ac7); } set annotationBorderColor(v) { this.i.ac7 = stringToBrush(v); } /** * Gets or sets the mode used for shifting border color of the axis annotation. */ get annotationBorderMode() { return this.i.aat; } set annotationBorderMode(v) { this.i.aat = ensureEnum(AnnotationAppearanceMode_$type, v); } /** * Gets or sets the percentage amount used to shift AnnotationBorderColor. Value must range between -1.0 to 1.0, where 0 means no color shift. */ get annotationBorderShift() { return this.i.abb; } set annotationBorderShift(v) { this.i.abb = +v; } get annotationPaddingBottom() { return this.i.ac9 ? this.i.ac9.bottom : NaN; } set annotationPaddingBottom(v) { this.ensureAnnotationPadding(); this.i.ac9.bottom = +v; this.i.ac9 = this.i.ac9; } get annotationPaddingLeft() { return this.i.ac9 ? this.i.ac9.left : NaN; } set annotationPaddingLeft(v) { this.ensureAnnotationPadding(); this.i.ac9.left = +v; this.i.ac9 = this.i.ac9; } get annotationPaddingRight() { return this.i.ac9 ? this.i.ac9.right : NaN; } set annotationPaddingRight(v) { this.ensureAnnotationPadding(); this.i.ac9.right = +v; this.i.ac9 = this.i.ac9; } get annotationPaddingTop() { return this.i.ac9 ? this.i.ac9.top : NaN; } set annotationPaddingTop(v) { this.ensureAnnotationPadding(); this.i.ac9.top = +v; this.i.ac9 = this.i.ac9; } ensureAnnotationPadding() { if (this.i.ac9) { return; } this.i.ac9 = new Thickness(2); } /** * Gets or sets border thickness of the axis annotations. */ get annotationBorderThickness() { return this.i.abc; } set annotationBorderThickness(v) { this.i.abc = +v; } /** * Gets or sets maximum precision for displaying values on axis annotation. */ get annotationValueMaxPrecision() { return this.i.abe; } set annotationValueMaxPrecision(v) { this.i.abe = +v; } /** * Gets or sets minimum precision for displaying values on axis annotation. */ get annotationValueMinPrecision() { return this.i.abf; } set annotationValueMinPrecision(v) { this.i.abf = +v; } /** * Gets or sets the target axis for this annotation. If null, this annotation will use TargetMode to determine target axis. */ get targetAxis() { const r = this.i.aav; if (r == null) { return null; } if (!r.externalObject) { let e = IgrAxis._createFromInternal(r); if (e) { e._implementation = r; } r.externalObject = e; } return r.externalObject; } set targetAxis(v) { if (v != null && this._stylingContainer && v._styling) v._styling(this._stylingContainer, this, this); v == null ? this.i.aav = null : this.i.aav = v.i; } /** * Gets or sets the name to use to resolve targetAxis from markup. */ get targetAxisName() { return this._targetAxisName; } set targetAxisName(v) { this._targetAxisName = v; } /** * Gets or sets the mode for targeting axes present in the chart. Defaults to targeting all category-axes present in the chart */ get targetMode() { return this.i.aax; } set targetMode(v) { this.i.aax = ensureEnum(DataAnnotationTargetMode_$type, v); } /** * Gets or sets whether the badge are rendered in annotations. */ get annotationBadgeEnabled() { return this.i.aa0; } set annotationBadgeEnabled(v) { this.i.aa0 = ensureBool(v); } /** * Gets or sets background of the badge annotations. */ get annotationBadgeBackground() { return brushToString(this.i.ac5); } set annotationBadgeBackground(v) { this.i.ac5 = stringToBrush(v); } /** * Gets or sets border outline of the badge annotations. */ get annotationBadgeOutline() { return brushToString(this.i.ac6); } set annotationBadgeOutline(v) { this.i.ac6 = stringToBrush(v); } /** * Gets or sets border thickness of the badge annotations. */ get annotationBadgeOutlineThickness() { return this.i.aa8; } set annotationBadgeOutlineThickness(v) { this.i.aa8 = +v; } /** * Gets or sets border radius of the badge annotations. */ get annotationBadgeCornerRadius() { return this.i.aa6; } set annotationBadgeCornerRadius(v) { this.i.aa6 = +v; } /** * Gets or sets a member path for displaying an image in the badge annotations. */ get annotationBadgeImagePath() { return this.i.abn; } set annotationBadgeImagePath(v) { this.i.abn = v; } /** * Gets or sets size of the badge annotations. */ get annotationBadgeSize() { return this.i.aa9; } set annotationBadgeSize(v) { this.i.aa9 = +v; } /** * Gets or sets margin of the badge annotations. */ get annotationBadgeMargin() { return this.i.aa7; } set annotationBadgeMargin(v) { this.i.aa7 = +v; } bindAxes(axes) { super.bindAxes(axes); for (let i = 0; i < axes.length; i++) { if (this.targetAxisName && this.targetAxisName.length > 0 && axes[i].name == this.targetAxisName) { this.targetAxis = axes[i]; } } } findByName(name) { var baseResult = super.findByName(name); if (baseResult) { return baseResult; } if (this.targetAxis && this.targetAxis.name && this.targetAxis.name == name) { return this.targetAxis; } return null; } _styling(container, component, parent) { super._styling(container, component, parent); this._inStyling = true; if (this.targetAxis && this.targetAxis._styling) { this.targetAxis._styling(container, component, this); } this._inStyling = false; } }