UNPKG

@visactor/vrender-components

Version:

components library for dp visualization

63 lines (58 loc) 3.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.MarkCommonLine = void 0; const vutils_1 = require("@visactor/vutils"), tag_1 = require("../tag"), limit_shape_1 = require("../util/limit-shape"), constant_1 = require("../constant"), base_1 = require("./base"), animate_1 = require("./animate/animate"); class MarkCommonLine extends base_1.Marker { constructor() { super(...arguments), this.name = "markCommonLine", this.defaultUpdateAnimation = animate_1.DefaultUpdateMarkLineAnimation, this.defaultExitAnimation = animate_1.DefaultExitMarkerAnimation; } getLine() { return this._line; } getLabel() { return this._label; } setLabelPos() { const {label: label = {}, limitRect: limitRect} = this.attribute, {position: position, confine: confine, autoRotate: autoRotate} = label, labelPoint = this.getPointAttrByPosition(position), labelAngle = position.toString().toLocaleLowerCase().includes("start") ? this._line.getStartAngle() || 0 : this._line.getEndAngle() || 0; if (this._label.setAttributes(Object.assign(Object.assign({}, labelPoint.position), { angle: autoRotate ? this.getRotateByAngle(labelPoint.angle) : 0, textStyle: Object.assign(Object.assign({}, this.getTextStyle(position, labelAngle, autoRotate)), label.textStyle) })), limitRect && confine) { const {x: x, y: y, width: width, height: height} = limitRect; (0, limit_shape_1.limitShapeInBounds)(this._label, { x1: x, y1: y, x2: x + width, y2: y + height }); } } initMarker(container) { const {label: label, state: state} = this.attribute, line = this.createSegment(); line.name = "mark-common-line-line", this._line = line, container.add(line); const markLabel = new tag_1.Tag(Object.assign(Object.assign({}, label), { state: { panel: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.labelBackground), text: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.label) } })); markLabel.name = "mark-common-line-label", this._label = markLabel, container.add(markLabel), this.setLabelPos(); } updateMarker() { const {label: label, state: state} = this.attribute; this.setLineAttributes(), this._label && (this._label.setAttributes(Object.assign(Object.assign({ dx: 0, dy: 0 }, label), { state: { panel: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.labelBackground), text: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.label) } })), this.setLabelPos()); } } exports.MarkCommonLine = MarkCommonLine; //# sourceMappingURL=common-line.js.map