UNPKG

@covalent/echarts

Version:

Teradata UI Platform Echarts Module

259 lines (254 loc) 11.7 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 { TdSeriesDirective, assignDefined } from '@covalent/echarts/base'; import * as ecStat from 'echarts-stat'; class TdChartSeriesClusteringComponent extends TdSeriesDirective { constructor(_optionsService) { super('scatter', _optionsService); } ngOnChanges() { if (this.originalData) { this.data = this.originalData; } else { this.originalData = this.data; } const output = this.data; const result = ecStat.clustering.hierarchicalKMeans(output, this.clusterCount, false); const series = []; for (let i = 0; i < result.centroids.length; i++) { series.push({ name: `cluster ${i + 1}`, type: 'scatter', data: result.pointsInCluster[i], markPoint: this.showCentroids ? { symbolSize: 30, itemStyle: { normal: { opacity: 0.8, }, }, data: [ { coord: result.centroids[i], label: { show: false }, name: `centroid ${i + 1}`, value: result.centroids[i], }, ], } : {}, }); } this.optionsService.setOption('series', series); this.data = []; this.setOptions(); } getConfig() { return { clusterCount: this.clusterCount, showCentroids: this.showCentroids, bottom: this.bottom, calendarIndex: this.calendarIndex, circular: this.circular, coordinateSystem: this.coordinateSystem, cursor: this.cursor, edgeLabel: this.edgeLabel, edges: this.edges, edgeSymbol: this.edgeSymbol, edgeSymbolSize: this.edgeSymbolSize, emphasis: this.emphasis, focusNodeAdjacency: this.focusNodeAdjacency, geoIndex: this.geoIndex, height: this.height, hoverAnimation: this.hoverAnimation, itemStyle: this.itemStyle, label: this.label, left: this.left, legendHoverLink: this.legendHoverLink, lineStyle: this.lineStyle, links: this.links, markArea: this.markArea, markLine: this.markLine, markPoint: this.markPoint, nodes: this.nodes, nodeScaleRatio: this.nodeScaleRatio, polarIndex: this.polarIndex, right: this.right, silent: this.silent, symbol: this.symbol, symbolKeepAspect: this.symbolKeepAspect, symbolOffset: this.symbolOffset, symbolRotate: this.symbolRotate, symbolSize: this.symbolSize, top: this.top, width: this.width, xAxisIndex: this.xAxisIndex, yAxisIndex: this.yAxisIndex, z: this.z, zlevel: this.zlevel, }; } 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('scatter', config); } } TdChartSeriesClusteringComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TdChartSeriesClusteringComponent, deps: [{ token: i1.TdChartOptionsService }], target: i0.ɵɵFactoryTarget.Component }); TdChartSeriesClusteringComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TdChartSeriesClusteringComponent, selector: "td-chart-series[td-clustering]", 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", clusterCount: "clusterCount", showCentroids: "showCentroids", bottom: "bottom", calendarIndex: "calendarIndex", circular: "circular", coordinateSystem: "coordinateSystem", cursor: "cursor", edgeLabel: "edgeLabel", edges: "edges", edgeSymbol: "edgeSymbol", edgeSymbolSize: "edgeSymbolSize", emphasis: "emphasis", focusNodeAdjacency: "focusNodeAdjacency", geoIndex: "geoIndex", height: "height", hoverAnimation: "hoverAnimation", itemStyle: "itemStyle", label: "label", left: "left", legendHoverLink: "legendHoverLink", lineStyle: "lineStyle", links: "links", markArea: "markArea", markLine: "markLine", markPoint: "markPoint", nodes: "nodes", nodeScaleRatio: "nodeScaleRatio", polarIndex: "polarIndex", right: "right", silent: "silent", symbol: "symbol", symbolKeepAspect: "symbolKeepAspect", symbolOffset: "symbolOffset", symbolRotate: "symbolRotate", symbolSize: "symbolSize", top: "top", width: "width", xAxisIndex: "xAxisIndex", yAxisIndex: "yAxisIndex", z: "z", zlevel: "zlevel" }, providers: [ { provide: TdSeriesDirective, useExisting: forwardRef(() => TdChartSeriesClusteringComponent), }, ], 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: TdChartSeriesClusteringComponent, decorators: [{ type: Component, args: [{ selector: 'td-chart-series[td-clustering]', template: '', changeDetection: ChangeDetectionStrategy.OnPush, inputs: [ 'config', 'id', 'name', 'color', 'data', 'animation', 'animationThreshold', 'animationDuration', 'animationEasing', 'animationDelay', 'animationDurationUpdate', 'animationEasingUpdate', 'animationDelayUpdate', 'tooltip', ], providers: [ { provide: TdSeriesDirective, useExisting: forwardRef(() => TdChartSeriesClusteringComponent), }, ], }] }], ctorParameters: function () { return [{ type: i1.TdChartOptionsService }]; }, propDecorators: { clusterCount: [{ type: Input }], showCentroids: [{ type: Input }], bottom: [{ type: Input }], calendarIndex: [{ type: Input }], circular: [{ type: Input }], coordinateSystem: [{ type: Input }], cursor: [{ type: Input }], edgeLabel: [{ type: Input }], edges: [{ type: Input }], edgeSymbol: [{ type: Input }], edgeSymbolSize: [{ type: Input }], emphasis: [{ type: Input }], focusNodeAdjacency: [{ type: Input }], geoIndex: [{ type: Input }], height: [{ type: Input }], hoverAnimation: [{ type: Input }], itemStyle: [{ type: Input }], label: [{ type: Input }], left: [{ type: Input }], legendHoverLink: [{ type: Input }], lineStyle: [{ type: Input }], links: [{ type: Input }], markArea: [{ type: Input }], markLine: [{ type: Input }], markPoint: [{ type: Input }], nodes: [{ type: Input }], nodeScaleRatio: [{ type: Input }], polarIndex: [{ type: Input }], right: [{ type: Input }], silent: [{ type: Input }], symbol: [{ type: Input }], symbolKeepAspect: [{ type: Input }], symbolOffset: [{ type: Input }], symbolRotate: [{ type: Input }], symbolSize: [{ type: Input }], top: [{ type: Input }], width: [{ type: Input }], xAxisIndex: [{ type: Input }], yAxisIndex: [{ type: Input }], z: [{ type: Input }], zlevel: [{ type: Input }] } }); const CLUSTERING_MODULE_COMPONENTS = [ TdChartSeriesClusteringComponent, ]; class CovalentClusteringEchartsModule { } CovalentClusteringEchartsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CovalentClusteringEchartsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); CovalentClusteringEchartsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: CovalentClusteringEchartsModule, declarations: [TdChartSeriesClusteringComponent], imports: [CommonModule], exports: [TdChartSeriesClusteringComponent] }); CovalentClusteringEchartsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CovalentClusteringEchartsModule, imports: [CommonModule] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CovalentClusteringEchartsModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule], declarations: [CLUSTERING_MODULE_COMPONENTS], exports: [CLUSTERING_MODULE_COMPONENTS], }] }] }); /** * Generated bundle index. Do not edit. */ export { CLUSTERING_MODULE_COMPONENTS, CovalentClusteringEchartsModule, TdChartSeriesClusteringComponent }; //# sourceMappingURL=covalent-echarts-clustering.mjs.map