UNPKG

@covalent/echarts

Version:

Teradata UI Platform Echarts Module

152 lines (147 loc) 7.74 kB
import * as i0 from '@angular/core'; import { forwardRef, Component, ChangeDetectionStrategy, Input, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import * as i1 from '@covalent/echarts/base'; import { assignDefined, TdSeriesDirective } from '@covalent/echarts/base'; import { TdChartSeriesBarComponent } from '@covalent/echarts/bar'; import * as ecStat from 'echarts-stat'; class TdChartSeriesHistogramComponent extends TdChartSeriesBarComponent { constructor(_optionsService) { super(_optionsService); } ngOnChanges() { var _a, _b, _c, _d, _e; let output = []; if (!this.source) { const dataset = this.optionsService.getOption('dataset'); this.source = (_a = dataset === null || dataset === void 0 ? void 0 : dataset.source) !== null && _a !== void 0 ? _a : []; } if ((_b = this.source) === null || _b === void 0 ? void 0 : _b.some((item) => Array.isArray(item))) { const config = this.getConfig(); const index = (_c = config.datasetIndex) !== null && _c !== void 0 ? _c : 1; const source = this.source; const indexedOutput = source[0].map((_, colIndex) => source.map((row) => row[colIndex])); output = (_d = indexedOutput[index - 1]) !== null && _d !== void 0 ? _d : []; } else { output = this.source; } const bins = ecStat.histogram(output, (_e = this.method) !== null && _e !== void 0 ? _e : 'squareRoot'); this.data = bins.data; this.setOptions(); } getConfig() { return { method: this.method, coordinateSystem: this.coordinateSystem, xAxisIndex: this.xAxisIndex, yAxisIndex: this.yAxisIndex, legendHoverLink: this.legendHoverLink, stack: this.stack, cursor: this.cursor, label: this.label, itemStyle: this.itemStyle, emphasis: this.emphasis, barWidth: this.barWidth, barMaxWidth: this.barMaxWidth, barMinHeight: this.barMinHeight, barGap: this.barGap, barCategoryGap: this.barCategoryGap, large: this.large, largeThreshold: this.largeThreshold, progressive: this.progressive, progressiveThreshold: this.progressiveThreshold, progressiveChunkMode: this.progressiveChunkMode, dimensions: this.dimensions, encode: this.encode, seriesLayoutBy: this.seriesLayoutBy, datasetIndex: this.datasetIndex, markPoint: this.markPoint, markLine: this.markLine, markArea: this.markArea, zlevel: this.zlevel, z: this.z, }; } setOptions() { const config = assignDefined(this._state, { id: this.id, type: this.type, name: this.name, color: this.color, data: this.data, animation: this.animation, animationThreshold: this.animationThreshold, animationDuration: this.animationDuration, animationEasing: this.animationEasing, animationDelay: this.animationDelay, animationDurationUpdate: this.animationDurationUpdate, animationEasingUpdate: this.animationEasingUpdate, animationDelayUpdate: this.animationDelayUpdate, tooltip: this.tooltip, }, this.getConfig(), this._options, this.config ? this.config : {}); this.optionsService.setArrayOption('series', config); } } TdChartSeriesHistogramComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdChartSeriesHistogramComponent, deps: [{ token: i1.TdChartOptionsService }], target: i0.ɵɵFactoryTarget.Component }); TdChartSeriesHistogramComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdChartSeriesHistogramComponent, selector: "td-chart-series[td-histogram]", inputs: { config: "config", id: "id", name: "name", color: "color", data: "data", animation: "animation", animationThreshold: "animationThreshold", animationDuration: "animationDuration", animationEasing: "animationEasing", animationDelay: "animationDelay", animationDurationUpdate: "animationDurationUpdate", animationEasingUpdate: "animationEasingUpdate", animationDelayUpdate: "animationDelayUpdate", tooltip: "tooltip", source: "source", method: "method" }, providers: [ { provide: TdSeriesDirective, useExisting: forwardRef(() => TdChartSeriesHistogramComponent), }, ], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdChartSeriesHistogramComponent, decorators: [{ type: Component, args: [{ selector: 'td-chart-series[td-histogram]', template: '', changeDetection: ChangeDetectionStrategy.OnPush, inputs: [ 'config', 'id', 'name', 'color', 'data', 'animation', 'animationThreshold', 'animationDuration', 'animationEasing', 'animationDelay', 'animationDurationUpdate', 'animationEasingUpdate', 'animationDelayUpdate', 'tooltip', ], providers: [ { provide: TdSeriesDirective, useExisting: forwardRef(() => TdChartSeriesHistogramComponent), }, ], }] }], ctorParameters: function () { return [{ type: i1.TdChartOptionsService }]; }, propDecorators: { source: [{ type: Input }], method: [{ type: Input }] } }); const HISTOGRAM_MODULE_COMPONENTS = [ TdChartSeriesHistogramComponent, ]; class CovalentHistogramEchartsModule { } CovalentHistogramEchartsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CovalentHistogramEchartsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); CovalentHistogramEchartsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: CovalentHistogramEchartsModule, declarations: [TdChartSeriesHistogramComponent], imports: [CommonModule], exports: [TdChartSeriesHistogramComponent] }); CovalentHistogramEchartsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CovalentHistogramEchartsModule, imports: [CommonModule] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CovalentHistogramEchartsModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule], declarations: [HISTOGRAM_MODULE_COMPONENTS], exports: [HISTOGRAM_MODULE_COMPONENTS], }] }] }); /** * Generated bundle index. Do not edit. */ export { CovalentHistogramEchartsModule, HISTOGRAM_MODULE_COMPONENTS, TdChartSeriesHistogramComponent }; //# sourceMappingURL=covalent-echarts-histogram.mjs.map