UNPKG

@lxlib/chart

Version:

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

267 lines (261 loc) 8.01 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, LxlibUtilModule } from '@lxlib/util'; import { CommonModule } from '@angular/common'; /** * @fileoverview added by tsickle * Generated from: mini-bar.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function G2MiniBarData() { } if (false) { /** @type {?} */ G2MiniBarData.prototype.x; /** @type {?} */ G2MiniBarData.prototype.y; /* Skipping unhandled member: [key: string]: any;*/ } var G2MiniBarComponent = /** @class */ (function () { // #endregion function G2MiniBarComponent(el, ngZone) { this.el = el; this.ngZone = ngZone; // #region fields this.delay = 0; this.color = '#1890FF'; this.height = 0; this.borderWidth = 5; this.padding = [8, 8, 8, 8]; this.data = []; this.yTooltipSuffix = ''; this.tooltipType = 'default'; } /** * @private * @return {?} */ G2MiniBarComponent.prototype.install = /** * @private * @return {?} */ function () { var _a = this, el = _a.el, height = _a.height, padding = _a.padding, yTooltipSuffix = _a.yTooltipSuffix, tooltipType = _a.tooltipType; /** @type {?} */ var chart = (this.chart = new Chart({ container: el.nativeElement, autoFit: true, height: height, padding: padding, })); chart.scale({ x: { type: 'cat', }, y: { min: 0, }, }); chart.legend(false); chart.axis(false); /** @type {?} */ var tooltipOption = { showTitle: false, showMarkers: true, showCrosshairs: false, 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 .interval() .position('x*y') .tooltip('x*y', (/** * @param {?} x * @param {?} y * @return {?} */ function (x, y) { return ({ name: x, value: y + yTooltipSuffix }); })); chart.render(); this.attachChart(); }; /** * @private * @return {?} */ G2MiniBarComponent.prototype.attachChart = /** * @private * @return {?} */ function () { var _a = this, chart = _a.chart, height = _a.height, padding = _a.padding, data = _a.data, color = _a.color, borderWidth = _a.borderWidth; if (!chart || !data || data.length <= 0) return; chart.geometries[0].size(borderWidth).color(color); chart.height = height; chart.padding = padding; chart.changeData(data); }; /** * @return {?} */ G2MiniBarComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; this.ngZone.runOutsideAngular((/** * @return {?} */ function () { return setTimeout((/** * @return {?} */ function () { return _this.install(); }), _this.delay); })); }; /** * @return {?} */ G2MiniBarComponent.prototype.ngOnChanges = /** * @return {?} */ function () { var _this = this; this.ngZone.runOutsideAngular((/** * @return {?} */ function () { return _this.attachChart(); })); }; /** * @return {?} */ G2MiniBarComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { var _this = this; if (this.chart) { this.ngZone.runOutsideAngular((/** * @return {?} */ function () { return _this.chart.destroy(); })); } }; G2MiniBarComponent.decorators = [ { type: Component, args: [{ selector: 'g2-mini-bar', exportAs: 'g2MiniBar', template: "", host: { '[style.height.px]': 'height', }, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ G2MiniBarComponent.ctorParameters = function () { return [ { type: ElementRef }, { type: NgZone } ]; }; G2MiniBarComponent.propDecorators = { delay: [{ type: Input }], color: [{ type: Input }], height: [{ type: Input }], borderWidth: [{ type: Input }], padding: [{ type: Input }], data: [{ type: Input }], yTooltipSuffix: [{ type: Input }], tooltipType: [{ type: Input }] }; __decorate([ InputNumber(), __metadata("design:type", Object) ], G2MiniBarComponent.prototype, "delay", void 0); __decorate([ InputNumber(), __metadata("design:type", Object) ], G2MiniBarComponent.prototype, "height", void 0); __decorate([ InputNumber(), __metadata("design:type", Object) ], G2MiniBarComponent.prototype, "borderWidth", void 0); return G2MiniBarComponent; }()); if (false) { /** * @type {?} * @private */ G2MiniBarComponent.prototype.chart; /** @type {?} */ G2MiniBarComponent.prototype.delay; /** @type {?} */ G2MiniBarComponent.prototype.color; /** @type {?} */ G2MiniBarComponent.prototype.height; /** @type {?} */ G2MiniBarComponent.prototype.borderWidth; /** @type {?} */ G2MiniBarComponent.prototype.padding; /** @type {?} */ G2MiniBarComponent.prototype.data; /** @type {?} */ G2MiniBarComponent.prototype.yTooltipSuffix; /** @type {?} */ G2MiniBarComponent.prototype.tooltipType; /** * @type {?} * @private */ G2MiniBarComponent.prototype.el; /** * @type {?} * @private */ G2MiniBarComponent.prototype.ngZone; } /** * @fileoverview added by tsickle * Generated from: mini-bar.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var COMPONENTS = [G2MiniBarComponent]; var G2MiniBarModule = /** @class */ (function () { function G2MiniBarModule() { } G2MiniBarModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, LxlibUtilModule], declarations: __spread(COMPONENTS), exports: __spread(COMPONENTS), },] } ]; return G2MiniBarModule; }()); /** * @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-bar.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { G2MiniBarComponent, G2MiniBarModule }; //# sourceMappingURL=mini-bar.js.map