UNPKG

@ohayojp/chart

Version:

Cache the dictionary, city data etc.

187 lines (181 loc) 5.65 kB
import { __decorate, __metadata } from 'tslib'; import { Platform } from '@angular/cdk/platform'; import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, Input, Output, NgModule } from '@angular/core'; import { OhayoConfigService, InputNumber, OhayoUtilModule } from '@ohayojp/util'; import { fromEvent } from 'rxjs'; import { debounceTime } from 'rxjs/operators'; import { CommonModule } from '@angular/common'; /** * @fileoverview added by tsickle * Generated from: custom.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class G2CustomComponent { // #endregion /** * @param {?} el * @param {?} configSrv * @param {?} platform */ constructor(el, configSrv, platform) { this.el = el; this.platform = platform; this.resize$ = null; // #region fields this.delay = 0; this.resizeTime = 0; this.render = new EventEmitter(); // tslint:disable-next-line:no-output-native this.resize = new EventEmitter(); this.destroy = new EventEmitter(); configSrv.attachKey(this, 'chart', 'theme'); } /** * @private * @return {?} */ renderChart() { this.el.nativeElement.innerHTML = ''; this.render.emit(this.el); this.installResizeEvent(); } /** * @private * @return {?} */ installResizeEvent() { if (this.resizeTime <= 0 || this.resize$) return; this.resize$ = fromEvent(window, 'resize') .pipe(debounceTime(Math.min(200, this.resizeTime))) .subscribe((/** * @return {?} */ () => this.resize.emit(this.el))); } /** * @return {?} */ ngAfterViewInit() { if (!this.platform.isBrowser) { return; } setTimeout((/** * @return {?} */ () => this.renderChart()), this.delay); } /** * @return {?} */ ngOnDestroy() { this.destroy.emit(this.el); if (this.resize$) this.resize$.unsubscribe(); } } G2CustomComponent.decorators = [ { type: Component, args: [{ selector: 'g2,g2-custom', exportAs: 'g2Custom', template: ` <ng-content></ng-content> `, host: { '[style.height.px]': 'height', }, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }] } ]; /** @nocollapse */ G2CustomComponent.ctorParameters = () => [ { type: ElementRef }, { type: OhayoConfigService }, { type: Platform } ]; G2CustomComponent.propDecorators = { delay: [{ type: Input }], height: [{ type: Input }], resizeTime: [{ type: Input }], theme: [{ type: Input }], render: [{ type: Output }], resize: [{ type: Output }], destroy: [{ type: Output }] }; __decorate([ InputNumber(), __metadata("design:type", Object) ], G2CustomComponent.prototype, "delay", void 0); __decorate([ InputNumber(), __metadata("design:type", Number) ], G2CustomComponent.prototype, "height", void 0); __decorate([ InputNumber(), __metadata("design:type", Object) ], G2CustomComponent.prototype, "resizeTime", void 0); if (false) { /** @type {?} */ G2CustomComponent.ngAcceptInputType_delay; /** @type {?} */ G2CustomComponent.ngAcceptInputType_height; /** @type {?} */ G2CustomComponent.ngAcceptInputType_resizeTime; /** * @type {?} * @private */ G2CustomComponent.prototype.resize$; /** @type {?} */ G2CustomComponent.prototype.delay; /** @type {?} */ G2CustomComponent.prototype.height; /** @type {?} */ G2CustomComponent.prototype.resizeTime; /** @type {?} */ G2CustomComponent.prototype.theme; /** @type {?} */ G2CustomComponent.prototype.render; /** @type {?} */ G2CustomComponent.prototype.resize; /** @type {?} */ G2CustomComponent.prototype.destroy; /** * @type {?} * @private */ G2CustomComponent.prototype.el; /** * @type {?} * @private */ G2CustomComponent.prototype.platform; } /** * @fileoverview added by tsickle * Generated from: custom.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const COMPONENTS = [G2CustomComponent]; class G2CustomModule { } G2CustomModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule, OhayoUtilModule], declarations: [...COMPONENTS], exports: [...COMPONENTS], },] } ]; /** * @fileoverview added by tsickle * Generated from: public_api.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @fileoverview added by tsickle * Generated from: g2Custom.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ export { G2CustomComponent, G2CustomModule }; //# sourceMappingURL=g2Custom.js.map