yoyo-ng-modulewindy
Version:
服务于52ABP模板的前端开源的相关组件内容。整合了ng-alain和你NG ZORRO的内容
84 lines • 2.99 kB
JavaScript
import { Component, ElementRef, Input, EventEmitter, Output, HostBinding, } from '@angular/core';
import { fromEvent } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { toNumber } from 'yoyo-ng-module/util';
var G2ChartComponent = /** @class */ (function () {
// endregion
function G2ChartComponent(el) {
this.el = el;
this._resizeTime = 0;
this.render = new EventEmitter();
this.resize = new EventEmitter();
this.destroy = new EventEmitter();
// region: resize
this.resize$ = null;
}
Object.defineProperty(G2ChartComponent.prototype, "height", {
// region: fields
get: function () {
return this._height;
},
set: function (value) {
this._height = toNumber(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(G2ChartComponent.prototype, "resizeTime", {
get: function () {
return this._resizeTime;
},
set: function (value) {
this._resizeTime = toNumber(value);
},
enumerable: true,
configurable: true
});
G2ChartComponent.prototype.renderChart = function () {
this.el.nativeElement.innerHTML = '';
this.render.emit(this.el);
this.installResizeEvent();
};
G2ChartComponent.prototype.ngOnInit = function () {
var _this = this;
setTimeout(function () { return _this.renderChart(); }, 200);
};
G2ChartComponent.prototype.ngOnDestroy = function () {
this.destroy.emit(this.el);
this.uninstallResizeEvent();
};
G2ChartComponent.prototype.installResizeEvent = function () {
var _this = this;
if (this.resizeTime <= 0 || !this.resize$)
return;
if (this.resizeTime <= 200)
this.resizeTime = 200;
this.resize$ = fromEvent(window, 'resize')
.pipe(debounceTime(this.resizeTime))
.subscribe(function () { return _this.resize.emit(_this.el); });
};
G2ChartComponent.prototype.uninstallResizeEvent = function () {
if (this.resize$)
this.resize$.unsubscribe();
};
G2ChartComponent.decorators = [
{ type: Component, args: [{
selector: 'g2-chart',
template: "",
},] },
];
/** @nocollapse */
G2ChartComponent.ctorParameters = function () { return [
{ type: ElementRef }
]; };
G2ChartComponent.propDecorators = {
height: [{ type: HostBinding, args: ['style.height.px',] }, { type: Input }],
resizeTime: [{ type: Input }],
render: [{ type: Output }],
resize: [{ type: Output }],
destroy: [{ type: Output }]
};
return G2ChartComponent;
}());
export { G2ChartComponent };
//# sourceMappingURL=chart.component.js.map