@lxlib/chart
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
151 lines (145 loc) • 4.33 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, Input, Output, NgModule } from '@angular/core';
import { InputNumber, LxlibUtilModule } from '@lxlib/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,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class G2CustomComponent {
// #endregion
/**
* @param {?} el
*/
constructor(el) {
this.el = el;
this.resize$ = null;
this.resizeTime = 0;
this.render = new EventEmitter();
// tslint:disable-next-line:no-output-native
this.resize = new EventEmitter();
this.destroy = new EventEmitter();
}
/**
* @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() {
this.renderChart();
}
/**
* @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 }
];
G2CustomComponent.propDecorators = {
height: [{ type: Input }],
resizeTime: [{ type: Input }],
render: [{ type: Output }],
resize: [{ type: Output }],
destroy: [{ type: Output }]
};
__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 {?}
* @private
*/
G2CustomComponent.prototype.resize$;
/** @type {?} */
G2CustomComponent.prototype.height;
/** @type {?} */
G2CustomComponent.prototype.resizeTime;
/** @type {?} */
G2CustomComponent.prototype.render;
/** @type {?} */
G2CustomComponent.prototype.resize;
/** @type {?} */
G2CustomComponent.prototype.destroy;
/**
* @type {?}
* @private
*/
G2CustomComponent.prototype.el;
}
/**
* @fileoverview added by tsickle
* Generated from: custom.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const COMPONENTS = [G2CustomComponent];
class G2CustomModule {
}
G2CustomModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule, LxlibUtilModule],
declarations: [...COMPONENTS],
exports: [...COMPONENTS],
},] }
];
/**
* @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: g2Custom.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { G2CustomComponent, G2CustomModule };
//# sourceMappingURL=g2Custom.js.map