UNPKG

@covalent/echarts

Version:

Teradata UI Platform Echarts Module

154 lines (149 loc) 7.52 kB
import * as i0 from '@angular/core'; import { forwardRef, ChangeDetectionStrategy, Component, Input, NgModule } from '@angular/core'; import { assignDefined, TdSeriesDirective } from '@covalent/echarts/base'; import { TdChartSeriesBarComponent } from '@covalent/echarts/bar'; import * as ecStat from 'echarts-stat'; const _c0 = ["td-histogram", ""]; class TdChartSeriesHistogramComponent extends TdChartSeriesBarComponent { source; method; ngOnChanges() { let output = []; if (!this.source) { const dataset = this.optionsService.getOption('dataset'); this.source = dataset?.source ?? []; } if (this.source?.some((item) => Array.isArray(item))) { const config = this.getConfig(); const index = config.datasetIndex ?? 1; const source = this.source; const indexedOutput = source[0].map((_, colIndex) => source.map((row) => row[colIndex])); output = indexedOutput[index - 1] ?? []; } else { output = this.source; } const bins = ecStat.histogram(output, this.method ?? '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); } static ɵfac = /*@__PURE__*/ (() => { let ɵTdChartSeriesHistogramComponent_BaseFactory; return function TdChartSeriesHistogramComponent_Factory(__ngFactoryType__) { return (ɵTdChartSeriesHistogramComponent_BaseFactory || (ɵTdChartSeriesHistogramComponent_BaseFactory = i0.ɵɵgetInheritedFactory(TdChartSeriesHistogramComponent)))(__ngFactoryType__ || TdChartSeriesHistogramComponent); }; })(); static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TdChartSeriesHistogramComponent, selectors: [["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" }, features: [i0.ɵɵProvidersFeature([ { provide: TdSeriesDirective, useExisting: forwardRef(() => TdChartSeriesHistogramComponent), }, ]), i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], attrs: _c0, decls: 0, vars: 0, template: function TdChartSeriesHistogramComponent_Template(rf, ctx) { }, encapsulation: 2, changeDetection: 0 }); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdChartSeriesHistogramComponent, [{ 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), }, ], }] }], null, { source: [{ type: Input }], method: [{ type: Input }] }); })(); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TdChartSeriesHistogramComponent, { className: "TdChartSeriesHistogramComponent", filePath: "histogram.component.ts", lineNumber: 57 }); })(); const HISTOGRAM_MODULE_COMPONENTS = [ TdChartSeriesHistogramComponent, ]; /** * @deprecated This module is deprecated and will be removed in future versions. * Please migrate to using standalone components as soon as possible. */ class CovalentHistogramEchartsModule { static ɵfac = function CovalentHistogramEchartsModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CovalentHistogramEchartsModule)(); }; static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: CovalentHistogramEchartsModule }); static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CovalentHistogramEchartsModule, [{ type: NgModule, args: [{ imports: [HISTOGRAM_MODULE_COMPONENTS], exports: [HISTOGRAM_MODULE_COMPONENTS], }] }], null, null); })(); (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CovalentHistogramEchartsModule, { imports: [TdChartSeriesHistogramComponent], exports: [TdChartSeriesHistogramComponent] }); })(); /** * Generated bundle index. Do not edit. */ export { CovalentHistogramEchartsModule, HISTOGRAM_MODULE_COMPONENTS, TdChartSeriesHistogramComponent }; //# sourceMappingURL=covalent-echarts-histogram.mjs.map