UNPKG

@lxlib/chart

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

322 lines (316 loc) 9.89 kB
import { __decorate, __metadata, __spread } from 'tslib'; import { Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, NgZone, Input, NgModule } from '@angular/core'; import { Chart } from '@antv/g2'; import { InputNumber, InputBoolean, LxlibUtilModule } from '@lxlib/util'; import { CommonModule } from '@angular/common'; /** * @fileoverview added by tsickle * Generated from: mini-area.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function G2MiniAreaData() { } if (false) { /** @type {?} */ G2MiniAreaData.prototype.x; /** @type {?} */ G2MiniAreaData.prototype.y; /* Skipping unhandled member: [key: string]: any;*/ } var G2MiniAreaComponent = /** @class */ (function () { // #endregion function G2MiniAreaComponent(el, ngZone) { this.el = el; this.ngZone = ngZone; // #region fields this.delay = 0; this.color = 'rgba(24, 144, 255, 0.2)'; this.borderColor = '#1890FF'; this.borderWidth = 2; this.height = 56; this.fit = true; this.line = false; this.animate = true; this.padding = [8, 8, 8, 8]; this.data = []; this.yTooltipSuffix = ''; this.tooltipType = 'default'; } /** * @private * @return {?} */ G2MiniAreaComponent.prototype.install = /** * @private * @return {?} */ function () { var _a = this, el = _a.el, fit = _a.fit, height = _a.height, padding = _a.padding, xAxis = _a.xAxis, yAxis = _a.yAxis, yTooltipSuffix = _a.yTooltipSuffix, tooltipType = _a.tooltipType, line = _a.line; /** @type {?} */ var chart = (this.chart = new Chart({ container: el.nativeElement, autoFit: fit, height: height, padding: padding, })); if (!xAxis && !yAxis) { chart.axis(false); } if (xAxis) { chart.axis('x', xAxis); } else { chart.axis('x', false); } if (yAxis) { chart.axis('y', yAxis); } else { chart.axis('y', false); } chart.legend(false); /** @type {?} */ var tooltipOption = { showTitle: false, showMarkers: true, enterable: true, domStyles: { 'g2-tooltip': { padding: '0px' }, 'g2-tooltip-title': { display: 'none' }, 'g2-tooltip-list-item': { margin: '4px' }, }, }; if (tooltipType === 'mini') { tooltipOption.position = 'top'; (/** @type {?} */ (tooltipOption.domStyles))['g2-tooltip'] = { padding: '0px', backgroundColor: 'transparent', boxShadow: 'none' }; tooltipOption.itemTpl = "<li>{value}</li>"; tooltipOption.offset = 0; } chart.tooltip(tooltipOption); chart .area() .position('x*y') .tooltip('x*y', (/** * @param {?} x * @param {?} y * @return {?} */ function (x, y) { return ({ name: x, value: y + yTooltipSuffix }); })) .shape('smooth'); if (line) { chart.line().position('x*y').shape('smooth').tooltip(false); } chart.render(); this.attachChart(); }; /** * @private * @return {?} */ G2MiniAreaComponent.prototype.attachChart = /** * @private * @return {?} */ function () { var _a = this, chart = _a.chart, line = _a.line, fit = _a.fit, height = _a.height, animate = _a.animate, padding = _a.padding, data = _a.data, color = _a.color, borderColor = _a.borderColor, borderWidth = _a.borderWidth; if (!chart || !data || data.length <= 0) { return; } /** @type {?} */ var geoms = chart.geometries; geoms.forEach((/** * @param {?} g * @return {?} */ function (g) { return g.color(color); })); if (line) { geoms[1].color(borderColor).size(borderWidth); } chart.autoFit = fit; chart.height = height; chart.animate(animate); chart.padding = padding; chart.changeData(data); }; /** * @return {?} */ G2MiniAreaComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; this.ngZone.runOutsideAngular((/** * @return {?} */ function () { return setTimeout((/** * @return {?} */ function () { return _this.install(); }), _this.delay); })); }; /** * @return {?} */ G2MiniAreaComponent.prototype.ngOnChanges = /** * @return {?} */ function () { var _this = this; this.ngZone.runOutsideAngular((/** * @return {?} */ function () { return _this.attachChart(); })); }; /** * @return {?} */ G2MiniAreaComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { var _this = this; if (this.chart) { this.ngZone.runOutsideAngular((/** * @return {?} */ function () { return _this.chart.destroy(); })); } }; G2MiniAreaComponent.decorators = [ { type: Component, args: [{ selector: 'g2-mini-area', exportAs: 'g2MiniArea', template: "", host: { '[style.height.px]': 'height', }, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ G2MiniAreaComponent.ctorParameters = function () { return [ { type: ElementRef }, { type: NgZone } ]; }; G2MiniAreaComponent.propDecorators = { delay: [{ type: Input }], color: [{ type: Input }], borderColor: [{ type: Input }], borderWidth: [{ type: Input }], height: [{ type: Input }], fit: [{ type: Input }], line: [{ type: Input }], animate: [{ type: Input }], xAxis: [{ type: Input }], yAxis: [{ type: Input }], padding: [{ type: Input }], data: [{ type: Input }], yTooltipSuffix: [{ type: Input }], tooltipType: [{ type: Input }] }; __decorate([ InputNumber(), __metadata("design:type", Object) ], G2MiniAreaComponent.prototype, "delay", void 0); __decorate([ InputNumber(), __metadata("design:type", Object) ], G2MiniAreaComponent.prototype, "borderWidth", void 0); __decorate([ InputNumber(), __metadata("design:type", Object) ], G2MiniAreaComponent.prototype, "height", void 0); __decorate([ InputBoolean(), __metadata("design:type", Object) ], G2MiniAreaComponent.prototype, "fit", void 0); __decorate([ InputBoolean(), __metadata("design:type", Object) ], G2MiniAreaComponent.prototype, "line", void 0); __decorate([ InputBoolean(), __metadata("design:type", Object) ], G2MiniAreaComponent.prototype, "animate", void 0); return G2MiniAreaComponent; }()); if (false) { /** * @type {?} * @private */ G2MiniAreaComponent.prototype.chart; /** @type {?} */ G2MiniAreaComponent.prototype.delay; /** @type {?} */ G2MiniAreaComponent.prototype.color; /** @type {?} */ G2MiniAreaComponent.prototype.borderColor; /** @type {?} */ G2MiniAreaComponent.prototype.borderWidth; /** @type {?} */ G2MiniAreaComponent.prototype.height; /** @type {?} */ G2MiniAreaComponent.prototype.fit; /** @type {?} */ G2MiniAreaComponent.prototype.line; /** @type {?} */ G2MiniAreaComponent.prototype.animate; /** @type {?} */ G2MiniAreaComponent.prototype.xAxis; /** @type {?} */ G2MiniAreaComponent.prototype.yAxis; /** @type {?} */ G2MiniAreaComponent.prototype.padding; /** @type {?} */ G2MiniAreaComponent.prototype.data; /** @type {?} */ G2MiniAreaComponent.prototype.yTooltipSuffix; /** @type {?} */ G2MiniAreaComponent.prototype.tooltipType; /** * @type {?} * @private */ G2MiniAreaComponent.prototype.el; /** * @type {?} * @private */ G2MiniAreaComponent.prototype.ngZone; } /** * @fileoverview added by tsickle * Generated from: mini-area.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var COMPONENTS = [G2MiniAreaComponent]; var G2MiniAreaModule = /** @class */ (function () { function G2MiniAreaModule() { } G2MiniAreaModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, LxlibUtilModule], declarations: __spread(COMPONENTS), exports: __spread(COMPONENTS), },] } ]; return G2MiniAreaModule; }()); /** * @fileoverview added by tsickle * Generated from: public_api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: mini-area.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { G2MiniAreaComponent, G2MiniAreaModule }; //# sourceMappingURL=mini-area.js.map