@visactor/vchart
Version:
charts lib based @visactor/VGrammar
64 lines (57 loc) • 3.21 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.registerComponentMark = exports.ComponentMark = void 0;
const factory_1 = require("./../core/factory"), base_mark_1 = require("./base/base-mark"), vutils_1 = require("@visactor/vutils"), event_1 = require("../constant/event");
class ComponentMark extends base_mark_1.BaseMark {
constructor(name, option) {
super(name, option), this.type = "component", this._componentType = option.componentType,
this._mode = option.mode;
}
_getDefaultStyle() {
return {};
}
getComponent() {
return this._component;
}
clearComponent() {
this._component && (this._component.parent && this._component.parent.removeChild(this._component),
this._component = null);
}
_getAttrsFromConfig(attrs = {}) {
const configAttrs = super._getAttrsFromConfig(attrs);
return (0, vutils_1.isNil)(this._markConfig.interactive) || (configAttrs.pickable = this._markConfig.interactive),
attrs;
}
setAttributeTransform(t) {
this._attributesTransform = t;
}
renderInner() {
var _a;
const style = null !== (_a = this._simpleStyle) && void 0 !== _a ? _a : this.getAttributesOfState({});
let attrs = this._getAttrsFromConfig(style);
this._attributesTransform && (attrs = this._attributesTransform(attrs)), this._animationConfig && (attrs = Object.assign(Object.assign({}, attrs), {
animation: !0,
animationAppear: this._animationConfig.appear ? Array.isArray(this._animationConfig.appear) ? this._animationConfig.appear[0] : this._animationConfig.appear : void 0,
animationEnter: this._animationConfig.enter ? Array.isArray(this._animationConfig.enter) ? this._animationConfig.enter[0] : this._animationConfig.enter : void 0,
animationUpdate: this._animationConfig.update ? Array.isArray(this._animationConfig.update) ? this._animationConfig.update[0] : this._animationConfig.update : void 0,
animationExit: this._animationConfig.exit ? Array.isArray(this._animationConfig.exit) ? this._animationConfig.exit[0] : this._animationConfig.exit : void 0
})), this._component ? this._component.setAttributes(attrs) : (this._component = factory_1.Factory.createGraphicComponent(this._componentType, attrs, {
mode: this._mode,
skipDefault: this._markConfig.skipTheme
}), this._component && this._product.appendChild(this._component)), this._component && (this._component.context = this._getCommonContext()),
this._markConfig.support3d && this._product && this._product.setMode("3d"), this.model.event.emit(event_1.HOOK_EVENT.AFTER_ELEMENT_ENCODE, {
mark: this,
model: this.model
}), this.needClear = !0;
}
release() {
super.release(), this.removeProduct();
}
}
exports.ComponentMark = ComponentMark, ComponentMark.type = "component";
const registerComponentMark = () => {
factory_1.Factory.registerMark(ComponentMark.type, ComponentMark);
};
exports.registerComponentMark = registerComponentMark;
//# sourceMappingURL=component.js.map