UNPKG

igniteui-angular-charts

Version:

Ignite UI Angular charting components for building rich data visualizations for modern web apps.

408 lines (407 loc) 16 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 { Output, Component, Input, EventEmitter } from "@angular/core"; import { delegateCombine, TypeRegistrar } from "igniteui-angular-core"; import { TimeAxisLabelFormat } from "./TimeAxisLabelFormat"; import { arrayFindByName, toSpinal, initializePropertiesFromCss } from "igniteui-angular-core"; import { IgxLabelFormatOverrideEventArgs } from "./igx-label-format-override-event-args"; import * as i0 from "@angular/core"; export class IgxTimeAxisLabelFormatComponent { get i() { return this._implementation; } onImplementationCreated() { } constructor() { this._renderer = null; this.__p = null; this._hasUserValues = new Set(); this._stylingContainer = null; this._stylingParent = null; this._inStyling = false; this._labelFormatOverride = null; this._zoneRunner = null; this._implementation = this.createImplementation(); this._implementation.externalObject = this; this.onImplementationCreated(); } createImplementation() { return new TimeAxisLabelFormat(); } ngOnInit() { } _provideRenderer(renderer) { this._renderer = renderer; this._zoneRunner = (act) => renderer._ngZone.run(act); } static _createFromInternal(internal) { if (!internal) { return null; } if (!internal.$type) { return null; } let name = internal.$type.name; let externalName = "Igx" + name + "Component"; if (!TypeRegistrar.isRegistered(externalName)) { return null; } return TypeRegistrar.create(externalName); } /** * The visible axis range at which to apply this label format. * * The `Range` property provide the visible axis range at which to apply this label format. * * ```ts * let labelFormat = new TimeAxisLabelFormat(); * labelFormat.format = "hh:mm:ss"; * labelFormat.range = 1000; * this.xAxis.labelFormats.add(labelFormat); * labelFormat = new TimeAxisLabelFormat(); * labelFormat.format = "hh:mm"; * labelFormat.range = 60 * 1000; * this.xAxis.labelFormats.add(labelFormat); * labelFormat = new TimeAxisLabelFormat(); * labelFormat.format = "MMM-dd-yy"; * labelFormat.range = 24 * 60 * 60 * 1000; * this.xAxis.labelFormats.add(labelFormat); * ``` * * ```html * <igx-data-chart * [dataSource]="data"> * <igx-time-x-axis * [labelFormats]="labelFormats" * dateTimeMemberPath="time" * #xAxis> * </igx-time-x-axis> * </igx-data-chart> * ``` */ get range() { return this.i.at; } set range(v) { this.i.at = +v; } /** * The DateTime format string to apply. * Some common DateTime format strings are: yyyy, MM/dd/yy, and hh:mm:ss. * This property is deprecated. Use LabelFormat and LabelFormatSpecifiers instead. * * The `Format` property provide the DateTime format string to apply. * * ```ts * let labelFormat = new TimeAxisLabelFormat(); * labelFormat.format = "hh:mm:ss"; * labelFormat.range = 1000; * this.xAxis.labelFormats.add(labelFormat); * labelFormat = new TimeAxisLabelFormat(); * labelFormat.format = "hh:mm"; * labelFormat.range = 60 * 1000; * this.xAxis.labelFormats.add(labelFormat); * labelFormat = new TimeAxisLabelFormat(); * labelFormat.format = "MMM-dd-yy"; * labelFormat.range = 24 * 60 * 60 * 1000; * this.xAxis.labelFormats.add(labelFormat); * ``` * * ```html * <igx-data-chart * [dataSource]="data"> * <igx-time-x-axis * [labelFormats]="labelFormats" * dateTimeMemberPath="time" * #xAxis> * </igx-time-x-axis> * </igx-data-chart> * ``` * @deprecated This property is deprecated. Use LabelFormat and LabelFormatSpecifiers instead. */ get format() { return this.i.x; } set format(v) { this.i.x = v; } /** * The DateTime format string to apply, if the year is repeated from the prior date. * Some common DateTime format strings are: yyyy, MM/dd/yy, and hh:mm:ss. * This property is deprecated. Use RepeatedYearLabelFormat and RepeatedYearLabelFormatSpecifiers instead. * @deprecated This property is deprecated. Use RepeatedYearLabelFormat and RepeatedYearLabelFormatSpecifiers instead. */ get repeatedYearFormat() { return this.i.an; } set repeatedYearFormat(v) { this.i.an = v; } /** * The DateTime format string to apply, if the month is repeated from the prior date. * Some common DateTime format strings are: yyyy, MM/dd/yy, and hh:mm:ss. * This property is deprecated. Use RepeatedMonthLabelFormat and RepeatedMonthLabelFormatSpecifiers instead. * @deprecated This property is deprecated. Use RepeatedMonthLabelFormat and RepeatedMonthLabelFormatSpecifiers instead. */ get repeatedMonthFormat() { return this.i.ai; } set repeatedMonthFormat(v) { this.i.ai = v; } /** * The DateTime format string to apply, if the day is repeated from the prior date. * Some common DateTime format strings are: yyyy, MM/dd/yy, and hh:mm:ss. * This property is deprecated. Use RepeatedDayLabelFormat and RepeatedDayLabelFormatSpecifiers instead. * @deprecated This property is deprecated. Use RepeatedDayLabelFormat and RepeatedDayLabelFormatSpecifiers instead. */ get repeatedDayFormat() { return this.i.ad; } set repeatedDayFormat(v) { this.i.ad = v; } /** * The label format template string to apply, using {0} placeholders processed by BindingFormatter. * Use this together with LabelFormatSpecifiers to control how DateTime values are formatted. * For example, set LabelFormat to "{0}" and assign a DateTimeFormatSpecifier to LabelFormatSpecifiers. */ get labelFormat() { return this.i.z; } set labelFormat(v) { this.i.z = v; } /** * The format specifiers to apply to the label format placeholders. * Assign an array of FormatSpecifier objects (e.g. DateTimeFormatSpecifier) to control * how the {0} placeholder in LabelFormat is formatted. */ get labelFormatSpecifiers() { return this.i.e; } set labelFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.e = v; } /** * The label format template string to apply when the year is repeated from the prior date. * Use this together with RepeatedYearLabelFormatSpecifiers to control how DateTime values are formatted * when the year is repeated. */ get repeatedYearLabelFormat() { return this.i.ap; } set repeatedYearLabelFormat(v) { this.i.ap = v; } /** * The format specifiers to apply when the year is repeated from the prior date. */ get repeatedYearLabelFormatSpecifiers() { return this.i.h; } set repeatedYearLabelFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.h = v; } /** * The label format template string to apply when the month is repeated from the prior date. * Use this together with RepeatedMonthLabelFormatSpecifiers to control how DateTime values are formatted * when the month is repeated. */ get repeatedMonthLabelFormat() { return this.i.ak; } set repeatedMonthLabelFormat(v) { this.i.ak = v; } /** * The format specifiers to apply when the month is repeated from the prior date. */ get repeatedMonthLabelFormatSpecifiers() { return this.i.g; } set repeatedMonthLabelFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.g = v; } /** * The label format template string to apply when the day is repeated from the prior date. * Use this together with RepeatedDayLabelFormatSpecifiers to control how DateTime values are formatted * when the day is repeated. */ get repeatedDayLabelFormat() { return this.i.af; } set repeatedDayLabelFormat(v) { this.i.af = v; } /** * The format specifiers to apply when the day is repeated from the prior date. */ get repeatedDayLabelFormatSpecifiers() { return this.i.f; } set repeatedDayLabelFormatSpecifiers(v) { if (v && !Array.isArray(v) && typeof (v) == "string") { const re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.f = v; } findByName(name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } if (this.labelFormatSpecifiers != null && arrayFindByName(this.labelFormatSpecifiers, name)) { return arrayFindByName(this.labelFormatSpecifiers, name); } if (this.repeatedYearLabelFormatSpecifiers != null && arrayFindByName(this.repeatedYearLabelFormatSpecifiers, name)) { return arrayFindByName(this.repeatedYearLabelFormatSpecifiers, name); } if (this.repeatedMonthLabelFormatSpecifiers != null && arrayFindByName(this.repeatedMonthLabelFormatSpecifiers, name)) { return arrayFindByName(this.repeatedMonthLabelFormatSpecifiers, name); } if (this.repeatedDayLabelFormatSpecifiers != null && arrayFindByName(this.repeatedDayLabelFormatSpecifiers, name)) { return arrayFindByName(this.repeatedDayLabelFormatSpecifiers, 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("TimeAxisLabelFormatComponent"); 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; } /** * Gets or sets a label formatting override callback, allowing the user to take full control of label generation for the TimeXAxis. */ get labelFormatOverride() { if (this._labelFormatOverride == null) { this._labelFormatOverride = new EventEmitter(); this.i.labelFormatOverride = delegateCombine(this.i.labelFormatOverride, (o, e) => { this._runInZone(() => { let outerArgs = new IgxLabelFormatOverrideEventArgs(); outerArgs._provideImplementation(e); if (this.beforeLabelFormatOverride) { this.beforeLabelFormatOverride(this, outerArgs); } this._labelFormatOverride.emit({ sender: this, args: outerArgs }); }); }); } return this._labelFormatOverride; } _runInZone(act) { if (this._zoneRunner != null) { this._zoneRunner(act); } else { act(); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0-rc.1", ngImport: i0, type: IgxTimeAxisLabelFormatComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0-rc.1", type: IgxTimeAxisLabelFormatComponent, isStandalone: true, selector: "igx-time-axis-label-format", inputs: { range: "range", format: "format", repeatedYearFormat: "repeatedYearFormat", repeatedMonthFormat: "repeatedMonthFormat", repeatedDayFormat: "repeatedDayFormat", labelFormat: "labelFormat", labelFormatSpecifiers: "labelFormatSpecifiers", repeatedYearLabelFormat: "repeatedYearLabelFormat", repeatedYearLabelFormatSpecifiers: "repeatedYearLabelFormatSpecifiers", repeatedMonthLabelFormat: "repeatedMonthLabelFormat", repeatedMonthLabelFormatSpecifiers: "repeatedMonthLabelFormatSpecifiers", repeatedDayLabelFormat: "repeatedDayLabelFormat", repeatedDayLabelFormatSpecifiers: "repeatedDayLabelFormatSpecifiers" }, outputs: { labelFormatOverride: "labelFormatOverride" }, providers: [], ngImport: i0, template: ``, isInline: true }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0-rc.1", ngImport: i0, type: IgxTimeAxisLabelFormatComponent, decorators: [{ type: Component, args: [{ selector: 'igx-time-axis-label-format', template: ``, providers: [] }] }], ctorParameters: () => [], propDecorators: { range: [{ type: Input }], format: [{ type: Input }], repeatedYearFormat: [{ type: Input }], repeatedMonthFormat: [{ type: Input }], repeatedDayFormat: [{ type: Input }], labelFormat: [{ type: Input }], labelFormatSpecifiers: [{ type: Input }], repeatedYearLabelFormat: [{ type: Input }], repeatedYearLabelFormatSpecifiers: [{ type: Input }], repeatedMonthLabelFormat: [{ type: Input }], repeatedMonthLabelFormatSpecifiers: [{ type: Input }], repeatedDayLabelFormat: [{ type: Input }], repeatedDayLabelFormatSpecifiers: [{ type: Input }], labelFormatOverride: [{ type: Output }] } });