UNPKG

@antv/g2plot

Version:

G2 Plot, a market of plots built with the Grammar of Graphics'

43 lines 1.56 kB
import { __assign, __extends } from "tslib"; import EventEmitter from '@antv/event-emitter'; var BaseComponent = /** @class */ (function (_super) { __extends(BaseComponent, _super); function BaseComponent(config) { var _this = _super.call(this) || this; _this.container = config.container; _this.destroyed = false; _this.group = _this.container.addGroup(); _this.config = config; _this.init(config); return _this; } BaseComponent.prototype.getGroup = function () { return this.group; }; BaseComponent.prototype.getBBox = function () { return this.getGroup().getBBox(); }; BaseComponent.prototype.render = function () { this.renderInner(this.group); this.getCanvas().draw(); }; BaseComponent.prototype.update = function (config) { this.config = __assign(__assign({}, this.config), config); this.init(__assign(__assign({}, this.config), { config: config })); this.group.clear(); this.renderInner(this.group); this.getCanvas().draw(); }; BaseComponent.prototype.destroy = function () { this.group.remove(true); this.destroyed = true; }; BaseComponent.prototype.getCanvas = function () { return this.container.get('canvas'); }; BaseComponent.prototype.init = function (config) { }; BaseComponent.prototype.renderInner = function (group) { }; return BaseComponent; }(EventEmitter)); export default BaseComponent; //# sourceMappingURL=base.js.map