@covalent/echarts
Version:
Teradata UI Platform Echarts Module
167 lines (162 loc) • 7.87 kB
JavaScript
import * as i0 from '@angular/core';
import { forwardRef, ChangeDetectionStrategy, Component, Input, NgModule } from '@angular/core';
import { assignDefined, TdSeriesDirective } from '@covalent/echarts/base';
import { TdChartSeriesScatterComponent } from '@covalent/echarts/scatter';
import * as ecStat from 'echarts-stat';
const _c0 = ["td-regression", ""];
class TdChartSeriesRegressionComponent extends TdChartSeriesScatterComponent {
data;
regressionType;
polinomialOrder;
ngOnChanges() {
this.render();
}
getConfig() {
return {
regressionType: this.regressionType,
polinomialOrder: this.polinomialOrder,
coordinateSystem: this.coordinateSystem,
xAxisIndex: this.xAxisIndex,
yAxisIndex: this.yAxisIndex,
polarIndex: this.polarIndex,
geoIndex: this.geoIndex,
calendarIndex: this.calendarIndex,
hoverAnimation: this.hoverAnimation,
legendHoverLink: this.legendHoverLink,
symbol: this.symbol,
symbolSize: this.symbolSize,
symbolRotate: this.symbolRotate,
symbolKeepAspect: this.symbolKeepAspect,
symbolOffset: this.symbolOffset,
large: this.large,
largeThreshold: this.largeThreshold,
cursor: this.cursor,
label: this.label,
itemStyle: this.itemStyle,
emphasis: this.emphasis,
progressive: this.progressive,
progressiveThreshold: this.progressiveThreshold,
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,
silent: this.silent,
};
}
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);
}
render() {
const output = this.data;
const result = ecStat.regression(this.regressionType ?? 'linear', output, this.polinomialOrder ?? 2);
let series = this.optionsService.getOption('series');
if (series) {
for (const item in series) {
if (series[item].type === 'line') {
delete series[item];
}
}
}
else {
series = [];
}
series.push({
type: 'line',
data: result.points,
tooltip: {},
showSymbol: false,
});
this.optionsService.setOption('series', series);
this.setOptions();
}
static ɵfac = /*@__PURE__*/ (() => { let ɵTdChartSeriesRegressionComponent_BaseFactory; return function TdChartSeriesRegressionComponent_Factory(__ngFactoryType__) { return (ɵTdChartSeriesRegressionComponent_BaseFactory || (ɵTdChartSeriesRegressionComponent_BaseFactory = i0.ɵɵgetInheritedFactory(TdChartSeriesRegressionComponent)))(__ngFactoryType__ || TdChartSeriesRegressionComponent); }; })();
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TdChartSeriesRegressionComponent, selectors: [["td-chart-series", "td-regression", ""]], 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", regressionType: "regressionType", polinomialOrder: "polinomialOrder" }, features: [i0.ɵɵProvidersFeature([
{
provide: TdSeriesDirective,
useExisting: forwardRef(() => TdChartSeriesRegressionComponent),
},
]), i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], attrs: _c0, decls: 0, vars: 0, template: function TdChartSeriesRegressionComponent_Template(rf, ctx) { }, encapsulation: 2, changeDetection: 0 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TdChartSeriesRegressionComponent, [{
type: Component,
args: [{
selector: 'td-chart-series[td-regression]',
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
inputs: [
'config',
'id',
'name',
'color',
'data',
'animation',
'animationThreshold',
'animationDuration',
'animationEasing',
'animationDelay',
'animationDurationUpdate',
'animationEasingUpdate',
'animationDelayUpdate',
'tooltip',
],
providers: [
{
provide: TdSeriesDirective,
useExisting: forwardRef(() => TdChartSeriesRegressionComponent),
},
],
}]
}], null, { data: [{
type: Input
}], regressionType: [{
type: Input
}], polinomialOrder: [{
type: Input
}] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TdChartSeriesRegressionComponent, { className: "TdChartSeriesRegressionComponent", filePath: "regression.component.ts", lineNumber: 61 }); })();
const REGRESSION_MODULE_COMPONENTS = [
TdChartSeriesRegressionComponent,
];
/**
* @deprecated This module is deprecated and will be removed in future versions.
* Please migrate to using standalone components as soon as possible.
*/
class CovalentRegressionEchartsModule {
static ɵfac = function CovalentRegressionEchartsModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CovalentRegressionEchartsModule)(); };
static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: CovalentRegressionEchartsModule });
static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CovalentRegressionEchartsModule, [{
type: NgModule,
args: [{
imports: [REGRESSION_MODULE_COMPONENTS],
exports: [REGRESSION_MODULE_COMPONENTS],
}]
}], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(CovalentRegressionEchartsModule, { imports: [TdChartSeriesRegressionComponent], exports: [TdChartSeriesRegressionComponent] }); })();
/**
* Generated bundle index. Do not edit.
*/
export { CovalentRegressionEchartsModule, REGRESSION_MODULE_COMPONENTS, TdChartSeriesRegressionComponent };
//# sourceMappingURL=covalent-echarts-regression.mjs.map