@visactor/vrender-components 0.19.3 → 0.19.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/axis/util.js +1 -2
- package/cjs/brush/brush.js +2 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/label/index.js +2 -1
- package/cjs/label/line.js +1 -1
- package/cjs/label/polygon.js +1 -1
- package/cjs/label/rect.js +1 -1
- package/cjs/label/register.js +1 -1
- package/cjs/label/symbol.js +1 -1
- package/cjs/label/type.js +1 -1
- package/cjs/legend/base.js +1 -1
- package/cjs/legend/constant.js +1 -1
- package/cjs/legend/index.js +1 -1
- package/cjs/legend/register.js +1 -1
- package/cjs/legend/type.js +1 -2
- package/cjs/legend/util.js +1 -1
- package/cjs/marker/animate/common.js +8 -4
- package/cjs/marker/animate/common.js.map +1 -1
- package/cjs/marker/arc-area.js +10 -4
- package/cjs/marker/arc-area.js.map +1 -1
- package/cjs/marker/arc-line.js +7 -2
- package/cjs/marker/arc-line.js.map +1 -1
- package/cjs/marker/area.js +10 -4
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +1 -1
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/common-line.d.ts +1 -1
- package/cjs/marker/common-line.js +10 -5
- package/cjs/marker/common-line.js.map +1 -1
- package/cjs/marker/config.d.ts +16 -4
- package/cjs/marker/config.js +132 -56
- package/cjs/marker/config.js.map +1 -1
- package/cjs/marker/line.d.ts +3 -3
- package/cjs/marker/line.js +19 -7
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +41 -7
- package/cjs/marker/point.js +141 -69
- package/cjs/marker/point.js.map +1 -1
- package/cjs/marker/register.js +2 -2
- package/cjs/marker/register.js.map +1 -1
- package/cjs/marker/type.d.ts +12 -4
- package/cjs/marker/type.js.map +1 -1
- package/cjs/segment/arc-segment.d.ts +3 -0
- package/cjs/segment/arc-segment.js +7 -1
- package/cjs/segment/arc-segment.js.map +1 -1
- package/cjs/segment/register.d.ts +2 -2
- package/cjs/segment/register.js +2 -2
- package/cjs/segment/register.js.map +1 -1
- package/cjs/segment/segment.d.ts +1 -0
- package/cjs/segment/segment.js +1 -1
- package/cjs/segment/segment.js.map +1 -1
- package/cjs/util/common.d.ts +3 -0
- package/cjs/util/common.js +13 -2
- package/cjs/util/common.js.map +1 -1
- package/cjs/util/index.d.ts +1 -0
- package/cjs/util/index.js +2 -1
- package/cjs/util/index.js.map +1 -1
- package/cjs/util/polar.d.ts +2 -0
- package/cjs/util/polar.js +17 -0
- package/cjs/util/polar.js.map +1 -0
- package/es/axis/util.js +1 -2
- package/es/brush/brush.js +2 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/label/index.js +2 -1
- package/es/label/line.js +1 -1
- package/es/label/polygon.js +1 -1
- package/es/label/rect.js +1 -1
- package/es/label/register.js +1 -1
- package/es/label/symbol.js +1 -1
- package/es/label/type.js +1 -1
- package/es/legend/base.js +1 -1
- package/es/legend/constant.js +1 -1
- package/es/legend/index.js +1 -1
- package/es/legend/register.js +1 -1
- package/es/legend/type.js +1 -2
- package/es/legend/util.js +1 -1
- package/es/marker/animate/common.js +8 -4
- package/es/marker/animate/common.js.map +1 -1
- package/es/marker/arc-area.js +10 -4
- package/es/marker/arc-area.js.map +1 -1
- package/es/marker/arc-line.js +7 -2
- package/es/marker/arc-line.js.map +1 -1
- package/es/marker/area.js +10 -4
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +1 -1
- package/es/marker/base.js.map +1 -1
- package/es/marker/common-line.d.ts +1 -1
- package/es/marker/common-line.js +10 -5
- package/es/marker/common-line.js.map +1 -1
- package/es/marker/config.d.ts +16 -4
- package/es/marker/config.js +132 -56
- package/es/marker/config.js.map +1 -1
- package/es/marker/line.d.ts +3 -3
- package/es/marker/line.js +20 -6
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +41 -7
- package/es/marker/point.js +142 -69
- package/es/marker/point.js.map +1 -1
- package/es/marker/register.js +2 -1
- package/es/marker/register.js.map +1 -1
- package/es/marker/type.d.ts +12 -4
- package/es/marker/type.js.map +1 -1
- package/es/segment/arc-segment.d.ts +3 -0
- package/es/segment/arc-segment.js +7 -1
- package/es/segment/arc-segment.js.map +1 -1
- package/es/segment/register.d.ts +2 -2
- package/es/segment/register.js +2 -2
- package/es/segment/register.js.map +1 -1
- package/es/segment/segment.d.ts +1 -0
- package/es/segment/segment.js +1 -1
- package/es/segment/segment.js.map +1 -1
- package/es/util/common.d.ts +3 -0
- package/es/util/common.js +10 -0
- package/es/util/common.js.map +1 -1
- package/es/util/index.d.ts +1 -0
- package/es/util/index.js +2 -0
- package/es/util/index.js.map +1 -1
- package/es/util/polar.d.ts +2 -0
- package/es/util/polar.js +7 -0
- package/es/util/polar.js.map +1 -0
- package/package.json +3 -3
package/es/marker/line.js
CHANGED
|
@@ -12,6 +12,8 @@ import { DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP, DEFAULT_MARK_LINE_THEME } f
|
|
|
12
12
|
|
|
13
13
|
import { markCommonLineAnimate } from "./animate/animate";
|
|
14
14
|
|
|
15
|
+
import { isPostiveXAxis } from "../util";
|
|
16
|
+
|
|
15
17
|
loadMarkLineComponent();
|
|
16
18
|
|
|
17
19
|
export function registerMarkLineAnimate() {
|
|
@@ -28,7 +30,8 @@ export class MarkLine extends MarkCommonLine {
|
|
|
28
30
|
}
|
|
29
31
|
getPointAttrByPosition(position) {
|
|
30
32
|
var _a;
|
|
31
|
-
const {label: label = {}} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, points = this._line.getMainSegmentPoints(),
|
|
33
|
+
const {label: label = {}} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, points = this._line.getMainSegmentPoints(), lineEndAngle = null !== (_a = this._line.getEndAngle()) && void 0 !== _a ? _a : 0, labelAngle = (isPostiveXAxis(lineEndAngle),
|
|
34
|
+
lineEndAngle), labelOffsetX = refX * Math.cos(labelAngle) + refY * Math.cos(labelAngle - Math.PI / 2), labelOffsetY = refX * Math.sin(labelAngle) + refY * Math.sin(labelAngle - Math.PI / 2);
|
|
32
35
|
return position.includes("start") || position.includes("Start") ? {
|
|
33
36
|
position: {
|
|
34
37
|
x: points[0].x + labelOffsetX,
|
|
@@ -51,10 +54,16 @@ export class MarkLine extends MarkCommonLine {
|
|
|
51
54
|
}
|
|
52
55
|
getRotateByAngle(angle) {
|
|
53
56
|
var _a;
|
|
54
|
-
return angle + (null !== (_a = this.attribute.label.refAngle) && void 0 !== _a ? _a : 0);
|
|
57
|
+
return (isPostiveXAxis(angle) ? angle : angle - Math.PI) + (null !== (_a = this.attribute.label.refAngle) && void 0 !== _a ? _a : 0);
|
|
55
58
|
}
|
|
56
|
-
getTextStyle(position) {
|
|
57
|
-
return
|
|
59
|
+
getTextStyle(position, labelAngle, autoRotate) {
|
|
60
|
+
return Math.abs(labelAngle) === Math.PI / 2 ? autoRotate ? {
|
|
61
|
+
textAlign: "right",
|
|
62
|
+
textBaseline: "middle"
|
|
63
|
+
} : {
|
|
64
|
+
textAlign: "center",
|
|
65
|
+
textBaseline: labelAngle > 0 && position.includes("inside") || labelAngle < 0 && !position.includes("inside") ? "bottom" : "top"
|
|
66
|
+
} : isPostiveXAxis(labelAngle) ? DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP.postiveXAxis[position] : DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP.negativeXAxis[position];
|
|
58
67
|
}
|
|
59
68
|
createSegment() {
|
|
60
69
|
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, mainSegmentIndex: mainSegmentIndex, multiSegment: multiSegment, state: state} = this.attribute;
|
|
@@ -74,14 +83,19 @@ export class MarkLine extends MarkCommonLine {
|
|
|
74
83
|
});
|
|
75
84
|
}
|
|
76
85
|
setLineAttributes() {
|
|
77
|
-
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, mainSegmentIndex: mainSegmentIndex, multiSegment: multiSegment} = this.attribute;
|
|
86
|
+
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, mainSegmentIndex: mainSegmentIndex, multiSegment: multiSegment, state: state} = this.attribute;
|
|
78
87
|
this._line && this._line.setAttributes({
|
|
79
88
|
points: points,
|
|
80
89
|
startSymbol: startSymbol,
|
|
81
90
|
endSymbol: endSymbol,
|
|
82
91
|
lineStyle: lineStyle,
|
|
83
92
|
mainSegmentIndex: mainSegmentIndex,
|
|
84
|
-
multiSegment: multiSegment
|
|
93
|
+
multiSegment: multiSegment,
|
|
94
|
+
state: {
|
|
95
|
+
line: merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
|
|
96
|
+
startSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineStartSymbol),
|
|
97
|
+
endSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineEndSymbol)
|
|
98
|
+
}
|
|
85
99
|
});
|
|
86
100
|
}
|
|
87
101
|
isValidPoints() {
|
package/es/marker/line.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/marker/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,0CAA0C,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAE/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,qBAAqB,EAAE,CAAC;AAExB,MAAM,UAAU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YAChC,OAAO,KAAK,CAAC;SACd;QACD,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAsB,EAAE,EAAE;YACxC,IAAK,KAAa,CAAC,MAAM,EAAE;gBACxB,KAAiB,CAAC,OAAO,CAAC,CAAC,CAAQ,EAAE,EAAE;oBACtC,IAAI,CAAC,aAAa,CAAE,CAAW,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAE,CAAW,CAAC,CAAC,CAAC,EAAE;wBACpE,SAAS,GAAG,KAAK,CAAC;wBAClB,OAAO;qBACR;gBACH,CAAC,CAAC,CAAC;aACJ;iBAAM,IAAI,CAAC,aAAa,CAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBACnF,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AA/GM,0BAAiB,GAA2B,uBAAmD,CAAC","file":"line.js","sourcesContent":["import { isValidNumber, merge } from '@visactor/vutils';\nimport type { IMarkLineLabelPosition } from './type';\n// eslint-disable-next-line no-duplicate-imports\nimport type { MarkLineAttrs, MarkerAnimationState } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkLineComponent } from './register';\nimport type { Point } from '../core/type';\nimport { MarkCommonLine } from './common-line';\nimport type { ArcSegment } from '../segment';\n// eslint-disable-next-line no-duplicate-imports\nimport { Segment } from '../segment';\nimport { DEFAULT_STATES } from '../constant';\nimport { DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP, DEFAULT_MARK_LINE_THEME } from './config';\nimport type { ILineGraphicAttribute } from '@visactor/vrender-core';\nimport { markCommonLineAnimate } from './animate/animate';\nimport { limitShapeInBounds } from '../util/limit-shape';\n\nloadMarkLineComponent();\n\nexport function registerMarkLineAnimate() {\n MarkLine._animate = markCommonLineAnimate;\n}\n\nexport class MarkLine extends MarkCommonLine<ILineGraphicAttribute, IMarkLineLabelPosition> {\n name = 'markLine';\n // eslint-disable-next-line max-len\n static defaultAttributes: Partial<MarkLineAttrs> = DEFAULT_MARK_LINE_THEME as unknown as MarkLineAttrs;\n protected _line!: Segment | ArcSegment;\n\n /** animate */\n protected markerAnimate(state: MarkerAnimationState) {\n if (MarkLine._animate && this._animationConfig) {\n MarkLine._animate(this._line, this._label, this._animationConfig, state);\n }\n }\n\n constructor(attributes: MarkLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkLine.defaultAttributes, attributes));\n }\n\n protected getPointAttrByPosition(position: IMarkLineLabelPosition) {\n const { label = {} } = this.attribute;\n const { refX = 0, refY = 0 } = label;\n const points = this._line.getMainSegmentPoints();\n const labelAngle = this._line.getEndAngle() ?? 0;\n\n const labelOffsetX = refX * Math.cos(labelAngle) + refX * Math.cos(labelAngle - Math.PI / 2);\n const labelOffsetY = refX * Math.sin(labelAngle) + refY * Math.sin(labelAngle - Math.PI / 2);\n\n if (position.includes('start') || position.includes('Start')) {\n return {\n position: {\n x: points[0].x + labelOffsetX,\n y: points[0].y + labelOffsetY\n },\n angle: labelAngle\n };\n } else if (position.includes('middle') || position.includes('Middle')) {\n return {\n position: {\n x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,\n y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY\n },\n angle: labelAngle\n };\n }\n return {\n position: {\n x: points[points.length - 1].x + labelOffsetX,\n y: points[points.length - 1].y + labelOffsetY\n },\n angle: labelAngle\n };\n }\n\n protected getRotateByAngle(angle: number): number {\n return angle + (this.attribute.label.refAngle ?? 0);\n }\n\n protected getTextStyle(position: IMarkLineLabelPosition) {\n return DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP[position];\n }\n\n protected createSegment() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment, state } = this\n .attribute as MarkLineAttrs;\n return new Segment({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment,\n pickable: false, // 组件容器本身不参与拾取\n state: {\n line: merge({}, DEFAULT_STATES, state?.line),\n startSymbol: merge({}, DEFAULT_STATES, state?.lineStartSymbol),\n endSymbol: merge({}, DEFAULT_STATES, state?.lineEndSymbol)\n }\n });\n }\n\n protected setLineAttributes() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment } = this\n .attribute as MarkLineAttrs;\n if (this._line) {\n this._line.setAttributes({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment\n });\n }\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkLineAttrs;\n if (!points || points.length < 2) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point | Point[]) => {\n if ((point as any).length) {\n (point as Point[]).forEach((p: Point) => {\n if (!isValidNumber((p as Point).x) || !isValidNumber((p as Point).y)) {\n validFlag = false;\n return;\n }\n });\n } else if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/marker/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,0CAA0C,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAE/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAqB,EAAE,CAAC;AAExB,MAAM,UAA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AAC;SACd;QACD,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAsB,EAAE,EAAE;YACxC,IAAK,KAAa,CAAC,MAAM,EAAE;gBACxB,KAAiB,CAAC,OAAO,CAAC,CAAC,CAAQ,EAAE,EAAE;oBACtC,IAAI,CAAC,aAAa,CAAE,CAAW,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAE,CAAW,CAAC,CAAC,CAAC,EAAE;wBACpE,SAAS,GAAG,KAAK,CAAC;wBAClB,OAAO;qBACR;gBACH,CAAC,CAAC,CAAC;aACJ;iBAAM,IAAI,CAAC,aAAa,CAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBACnF,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AA1IM,0BAAiB,GAA2B,uBAAmD,CAAC","file":"line.js","sourcesContent":["import { isValidNumber, merge } from '@visactor/vutils';\nimport type { IMarkLineLabelPosition } from './type';\n// eslint-disable-next-line no-duplicate-imports\nimport type { MarkLineAttrs, MarkerAnimationState } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkLineComponent } from './register';\nimport type { Point } from '../core/type';\nimport { MarkCommonLine } from './common-line';\nimport type { ArcSegment } from '../segment';\n// eslint-disable-next-line no-duplicate-imports\nimport { Segment } from '../segment';\nimport { DEFAULT_STATES } from '../constant';\nimport { DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP, DEFAULT_MARK_LINE_THEME } from './config';\nimport type { ILineGraphicAttribute } from '@visactor/vrender-core';\nimport { markCommonLineAnimate } from './animate/animate';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport { isPostiveXAxis } from '../util';\n\nloadMarkLineComponent();\n\nexport function registerMarkLineAnimate() {\n MarkLine._animate = markCommonLineAnimate;\n}\n\nexport class MarkLine extends MarkCommonLine<ILineGraphicAttribute, IMarkLineLabelPosition> {\n name = 'markLine';\n // eslint-disable-next-line max-len\n static defaultAttributes: Partial<MarkLineAttrs> = DEFAULT_MARK_LINE_THEME as unknown as MarkLineAttrs;\n protected _line!: Segment | ArcSegment;\n\n /** animate */\n protected markerAnimate(state: MarkerAnimationState) {\n if (MarkLine._animate && this._animationConfig) {\n MarkLine._animate(this._line, this._label, this._animationConfig, state);\n }\n }\n\n constructor(attributes: MarkLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkLine.defaultAttributes, attributes));\n }\n\n protected getPointAttrByPosition(position: IMarkLineLabelPosition) {\n const { label = {} } = this.attribute;\n const { refX = 0, refY = 0 } = label;\n const points = this._line.getMainSegmentPoints();\n const lineEndAngle = this._line.getEndAngle() ?? 0;\n const labelAngle = isPostiveXAxis(lineEndAngle) ? lineEndAngle : lineEndAngle;\n\n const labelOffsetX = refX * Math.cos(labelAngle) + refY * Math.cos(labelAngle - Math.PI / 2);\n const labelOffsetY = refX * Math.sin(labelAngle) + refY * Math.sin(labelAngle - Math.PI / 2);\n\n if (position.includes('start') || position.includes('Start')) {\n return {\n position: {\n x: points[0].x + labelOffsetX,\n y: points[0].y + labelOffsetY\n },\n angle: labelAngle\n };\n } else if (position.includes('middle') || position.includes('Middle')) {\n return {\n position: {\n x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,\n y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY\n },\n angle: labelAngle\n };\n }\n return {\n position: {\n x: points[points.length - 1].x + labelOffsetX,\n y: points[points.length - 1].y + labelOffsetY\n },\n angle: labelAngle\n };\n }\n\n protected getRotateByAngle(angle: number): number {\n const itemAngle = isPostiveXAxis(angle) ? angle : angle - Math.PI;\n return itemAngle + (this.attribute.label.refAngle ?? 0);\n }\n\n protected getTextStyle(position: IMarkLineLabelPosition, labelAngle: number, autoRotate: boolean) {\n // 垂直方向例外\n if (Math.abs(labelAngle) === Math.PI / 2) {\n if (autoRotate) {\n return {\n textAlign: 'right',\n textBaseline: 'middle'\n };\n }\n return {\n textAlign: 'center',\n textBaseline:\n (labelAngle > 0 && position.includes('inside')) || (labelAngle < 0 && !position.includes('inside'))\n ? 'bottom'\n : 'top'\n };\n }\n\n if (isPostiveXAxis(labelAngle)) {\n return DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP.postiveXAxis[position];\n }\n return DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP.negativeXAxis[position];\n }\n\n protected createSegment() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment, state } = this\n .attribute as MarkLineAttrs;\n return new Segment({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment,\n pickable: false, // 组件容器本身不参与拾取\n state: {\n line: merge({}, DEFAULT_STATES, state?.line),\n startSymbol: merge({}, DEFAULT_STATES, state?.lineStartSymbol),\n endSymbol: merge({}, DEFAULT_STATES, state?.lineEndSymbol)\n }\n });\n }\n\n protected setLineAttributes() {\n const { points, startSymbol, endSymbol, lineStyle, mainSegmentIndex, multiSegment, state } = this\n .attribute as MarkLineAttrs;\n if (this._line) {\n this._line.setAttributes({\n points,\n startSymbol,\n endSymbol,\n lineStyle,\n mainSegmentIndex,\n multiSegment,\n state: {\n line: merge({}, DEFAULT_STATES, state?.line),\n startSymbol: merge({}, DEFAULT_STATES, state?.lineStartSymbol),\n endSymbol: merge({}, DEFAULT_STATES, state?.lineEndSymbol)\n }\n });\n }\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkLineAttrs;\n if (!points || points.length < 2) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point | Point[]) => {\n if ((point as any).length) {\n (point as Point[]).forEach((p: Point) => {\n if (!isValidNumber((p as Point).x) || !isValidNumber((p as Point).y)) {\n validFlag = false;\n return;\n }\n });\n } else if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n}\n"]}
|
package/es/marker/point.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IGroup, IImage, ISymbol, IImageGraphicAttribute, IRichText, IRichTextGraphicAttribute } from '@visactor/vrender-core';
|
|
2
|
+
import type { IPointLike } from '@visactor/vutils';
|
|
2
3
|
import { Tag } from '../tag';
|
|
3
4
|
import { Marker } from './base';
|
|
4
5
|
import type { IItemContent, IItemLine, MarkPointAnimationType, MarkPointAttrs, MarkerAnimationState } from './type';
|
|
@@ -10,6 +11,14 @@ export declare class MarkPoint extends Marker<MarkPointAttrs, MarkPointAnimation
|
|
|
10
11
|
name: string;
|
|
11
12
|
static defaultAttributes: {
|
|
12
13
|
interactive: boolean;
|
|
14
|
+
targetItemContent: {
|
|
15
|
+
visible: boolean;
|
|
16
|
+
margin: number;
|
|
17
|
+
symbolType: string;
|
|
18
|
+
size: number;
|
|
19
|
+
fill: boolean;
|
|
20
|
+
stroke: string;
|
|
21
|
+
};
|
|
13
22
|
itemLine: {
|
|
14
23
|
visible: boolean;
|
|
15
24
|
decorativeLine: {
|
|
@@ -69,24 +78,49 @@ export declare class MarkPoint extends Marker<MarkPointAttrs, MarkPointAnimation
|
|
|
69
78
|
defaultExitAnimation: import("./type").MarkerExitAnimation;
|
|
70
79
|
protected markerAnimate(state: MarkerAnimationState): void;
|
|
71
80
|
private _item;
|
|
81
|
+
private _targetItem;
|
|
72
82
|
private _line?;
|
|
73
83
|
private _decorativeLine;
|
|
74
84
|
constructor(attributes: MarkPointAttrs, options?: ComponentOptions);
|
|
75
85
|
protected setLabelPos(): void;
|
|
76
|
-
protected
|
|
86
|
+
protected getTextAlignAttr(autoRotate: boolean, angle: number, itemPosition: keyof typeof IMarkPointItemPosition): {
|
|
87
|
+
textAlign: string;
|
|
88
|
+
textBaseline: string;
|
|
89
|
+
};
|
|
90
|
+
protected setItemAttributes(item: ISymbol | Tag | IImage | IRichText, itemContent: IItemContent, newItemPosition: Point, itemType: 'symbol' | 'text' | 'image' | 'richText' | 'custom'): void;
|
|
77
91
|
protected getItemDx(item: ISymbol | Tag | IImage | IRichText, position: keyof typeof IMarkPointItemPosition, style?: IImageGraphicAttribute | IRichTextGraphicAttribute): number;
|
|
78
92
|
protected getItemDy(item: ISymbol | Tag | IImage | IRichText, position: keyof typeof IMarkPointItemPosition, style?: IImageGraphicAttribute | IRichTextGraphicAttribute): number;
|
|
79
|
-
protected initItem(itemContent: IItemContent,
|
|
80
|
-
protected getItemLineAttr(itemLine: IItemLine,
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
protected initItem(itemContent: IItemContent, newItemPosition: Point): IGroup | IRichText | Tag | ISymbol | IImage;
|
|
94
|
+
protected getItemLineAttr(itemLine: IItemLine, newPosition: Point, newItemPosition: Point): {
|
|
95
|
+
points: Point[];
|
|
96
|
+
center: {
|
|
97
|
+
x: number;
|
|
98
|
+
y: number;
|
|
99
|
+
};
|
|
100
|
+
radius: number;
|
|
101
|
+
startAngle: number;
|
|
102
|
+
endAngle: number;
|
|
103
|
+
};
|
|
104
|
+
protected setItemLineAttr(itemLine: IItemLine, newPosition: Point, newItemPosition: Point, visible: boolean): void;
|
|
105
|
+
protected getDecorativeLineAttr(itemLine: IItemLine): {
|
|
83
106
|
startPointOffsetX: number;
|
|
84
107
|
startPointOffsetY: number;
|
|
85
108
|
endPointOffsetX: number;
|
|
86
109
|
endPointOffsetY: number;
|
|
87
110
|
};
|
|
88
|
-
protected setDecorativeLineAttr(itemLine: IItemLine,
|
|
89
|
-
protected
|
|
111
|
+
protected setDecorativeLineAttr(itemLine: IItemLine, newItemPosition: Point, visible: boolean): void;
|
|
112
|
+
protected setTargetItemAttributes(targetItem: any, position: IPointLike): void;
|
|
113
|
+
protected setAllOfItemsAttr(newPosition: Point, newItemPosition: Point): void;
|
|
114
|
+
protected computeNewPositionAfterTargetItem(position: Point): {
|
|
115
|
+
newPosition: {
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
};
|
|
119
|
+
newItemPosition: {
|
|
120
|
+
x: number;
|
|
121
|
+
y: number;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
90
124
|
protected initMarker(container: IGroup): void;
|
|
91
125
|
protected updateMarker(): void;
|
|
92
126
|
protected isValidPoints(): boolean;
|
package/es/marker/point.js
CHANGED
|
@@ -2,7 +2,7 @@ import { graphicCreator } from "@visactor/vrender-core";
|
|
|
2
2
|
|
|
3
3
|
import { isValidNumber, merge } from "@visactor/vutils";
|
|
4
4
|
|
|
5
|
-
import { Segment } from "../segment";
|
|
5
|
+
import { ArcSegment, Segment } from "../segment";
|
|
6
6
|
|
|
7
7
|
import { Tag } from "../tag";
|
|
8
8
|
|
|
@@ -20,6 +20,8 @@ import { DEFAULT_STATES } from "../constant";
|
|
|
20
20
|
|
|
21
21
|
import { DefaultExitMarkerAnimation, DefaultUpdateMarkPointAnimation, markPointAnimate } from "./animate/animate";
|
|
22
22
|
|
|
23
|
+
import { deltaXYToAngle, isPostiveXAxis, removeRepeatPoint } from "../util";
|
|
24
|
+
|
|
23
25
|
loadMarkPointComponent();
|
|
24
26
|
|
|
25
27
|
export function registerMarkPointAnimate() {
|
|
@@ -36,21 +38,36 @@ export class MarkPoint extends Marker {
|
|
|
36
38
|
this.defaultExitAnimation = DefaultExitMarkerAnimation;
|
|
37
39
|
}
|
|
38
40
|
setLabelPos() {}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
getTextAlignAttr(autoRotate, angle, itemPosition) {
|
|
42
|
+
return Math.abs(angle) === Math.PI / 2 ? autoRotate ? {
|
|
43
|
+
textAlign: "right",
|
|
44
|
+
textBaseline: "middle"
|
|
45
|
+
} : {
|
|
46
|
+
textAlign: "center",
|
|
47
|
+
textBaseline: angle > 0 && itemPosition.includes("inside") || angle < 0 && !itemPosition.includes("inside") ? "bottom" : "top"
|
|
48
|
+
} : isPostiveXAxis(angle) ? DEFAULT_MARK_POINT_TEXT_STYLE_MAP.postiveXAxis[itemPosition] : DEFAULT_MARK_POINT_TEXT_STYLE_MAP.negativeXAxis[itemPosition];
|
|
49
|
+
}
|
|
50
|
+
setItemAttributes(item, itemContent, newItemPosition, itemType) {
|
|
51
|
+
var _a, _b;
|
|
41
52
|
if (!item) return;
|
|
42
|
-
const {autoRotate: autoRotate = !0, refX: refX = 0, refY: refY = 0, refAngle: refAngle = 0, textStyle: textStyle = {}, richTextStyle: richTextStyle = {}, imageStyle: imageStyle = {}, position:
|
|
53
|
+
const {autoRotate: autoRotate = !0, refX: refX = 0, refY: refY = 0, refAngle: refAngle = 0, textStyle: textStyle = {}, richTextStyle: richTextStyle = {}, imageStyle: imageStyle = {}, position: positionType = IMarkPointItemPosition.middle} = itemContent, {state: state} = this.attribute, lineEndAngle = (null === (_a = this._line) || void 0 === _a ? void 0 : _a.getEndAngle()) || 0, itemRefOffsetX = refX * Math.cos(lineEndAngle) + refY * Math.cos(lineEndAngle - Math.PI / 2), itemRefOffsetY = refX * Math.sin(lineEndAngle) + refY * Math.sin(lineEndAngle - Math.PI / 2);
|
|
43
54
|
"text" === itemType ? item.setAttributes(Object.assign(Object.assign({}, textStyle), {
|
|
44
|
-
textStyle: Object.assign(Object.assign({},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
textStyle: Object.assign(Object.assign({}, this.getTextAlignAttr(autoRotate, lineEndAngle, null !== (_b = itemContent.position) && void 0 !== _b ? _b : "end")), textStyle.textStyle),
|
|
56
|
+
state: {
|
|
57
|
+
panel: merge({}, DEFAULT_STATES, null == state ? void 0 : state.textBackground),
|
|
58
|
+
text: merge({}, DEFAULT_STATES, null == state ? void 0 : state.text)
|
|
59
|
+
}
|
|
60
|
+
})) : "richText" === itemType ? (item.setAttributes({
|
|
61
|
+
dx: this.getItemDx(item, positionType, richTextStyle) + (richTextStyle.dx || 0),
|
|
62
|
+
dy: this.getItemDy(item, positionType, richTextStyle) + (richTextStyle.dy || 0)
|
|
63
|
+
}), item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.richText)) : "image" === itemType && (item.setAttributes({
|
|
64
|
+
dx: this.getItemDx(item, positionType, imageStyle) + (imageStyle.dx || 0),
|
|
65
|
+
dy: this.getItemDy(item, positionType, imageStyle) + (imageStyle.dy || 0)
|
|
66
|
+
}), item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.image));
|
|
67
|
+
const itemAngle = isPostiveXAxis(lineEndAngle) ? lineEndAngle : lineEndAngle - Math.PI;
|
|
68
|
+
item.setAttributes({
|
|
69
|
+
x: newItemPosition.x + (itemRefOffsetX || 0),
|
|
70
|
+
y: newItemPosition.y + (itemRefOffsetY || 0),
|
|
54
71
|
angle: autoRotate && itemAngle + refAngle
|
|
55
72
|
});
|
|
56
73
|
}
|
|
@@ -64,49 +81,85 @@ export class MarkPoint extends Marker {
|
|
|
64
81
|
const height = null !== (_b = null === (_a = null == item ? void 0 : item.AABBBounds) || void 0 === _a ? void 0 : _a.height()) && void 0 !== _b ? _b : (null == style ? void 0 : style.height) || 0;
|
|
65
82
|
return position.includes("top") || position.includes("Top") ? -height : position.includes("middle") || position.includes("Middle") ? -height / 2 : 0;
|
|
66
83
|
}
|
|
67
|
-
initItem(itemContent,
|
|
84
|
+
initItem(itemContent, newItemPosition) {
|
|
68
85
|
const {state: state} = this.attribute, {type: type = "text", symbolStyle: symbolStyle, richTextStyle: richTextStyle, imageStyle: imageStyle, renderCustomCallback: renderCustomCallback} = itemContent;
|
|
69
86
|
let item;
|
|
70
|
-
return "symbol" === type ? (item = graphicCreator.symbol(Object.assign(Object.assign({},
|
|
71
|
-
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.symbol)) : "text" === type ? item = new Tag(Object.assign(Object.assign({},
|
|
87
|
+
return "symbol" === type ? (item = graphicCreator.symbol(Object.assign(Object.assign({}, newItemPosition), symbolStyle)),
|
|
88
|
+
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.symbol)) : "text" === type ? item = new Tag(Object.assign(Object.assign({}, newItemPosition), {
|
|
72
89
|
state: {
|
|
73
90
|
panel: merge({}, DEFAULT_STATES, null == state ? void 0 : state.textBackground),
|
|
74
91
|
text: merge({}, DEFAULT_STATES, null == state ? void 0 : state.text)
|
|
75
92
|
}
|
|
76
|
-
})) : "richText" === type ? (item = graphicCreator.richtext(Object.assign(Object.assign({},
|
|
77
|
-
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.richText)) : "image" === type ? (item = graphicCreator.image(Object.assign(Object.assign({},
|
|
93
|
+
})) : "richText" === type ? (item = graphicCreator.richtext(Object.assign(Object.assign({}, newItemPosition), richTextStyle)),
|
|
94
|
+
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.richText)) : "image" === type ? (item = graphicCreator.image(Object.assign(Object.assign({}, newItemPosition), imageStyle)),
|
|
78
95
|
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.image)) : "custom" === type && renderCustomCallback && (item = renderCustomCallback(),
|
|
79
96
|
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.customMark)),
|
|
80
|
-
item.name = `mark-point-${type}`, this.setItemAttributes(item, itemContent,
|
|
97
|
+
item.name = `mark-point-${type}`, this.setItemAttributes(item, itemContent, newItemPosition, type),
|
|
81
98
|
item;
|
|
82
99
|
}
|
|
83
|
-
getItemLineAttr(itemLine,
|
|
84
|
-
let points = []
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
x:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
getItemLineAttr(itemLine, newPosition, newItemPosition) {
|
|
101
|
+
let points = [], center = {
|
|
102
|
+
x: 0,
|
|
103
|
+
y: 0
|
|
104
|
+
}, radius = 0, startAngle = 0, endAngle = 0;
|
|
105
|
+
const {type: type = "type-s", arcRatio: arcRatio = .8} = itemLine;
|
|
106
|
+
if ("type-arc" === type) {
|
|
107
|
+
const {x: x1, y: y1} = newPosition, {x: x2, y: y2} = newItemPosition, x0 = (x1 + x2) / 2, y0 = (y1 + y2) / 2, k = y1 === y2 ? 0 : -(x1 - x2) / (y1 - y2), centerX = x0 + arcRatio * x0, centerY = (x => k * (x - x0) + y0)(centerX);
|
|
108
|
+
center = {
|
|
109
|
+
x: centerX,
|
|
110
|
+
y: centerY
|
|
111
|
+
}, startAngle = deltaXYToAngle(y1 - centerY, x1 - centerX), endAngle = deltaXYToAngle(y2 - centerY, x2 - centerX),
|
|
112
|
+
radius = Math.sqrt((centerX - x1) * (centerX - x1) + (centerY - y1) * (centerY - y1));
|
|
113
|
+
} else points = "type-do" === type ? [ newPosition, {
|
|
114
|
+
x: (newPosition.x + newItemPosition.x) / 2,
|
|
115
|
+
y: newItemPosition.y
|
|
116
|
+
}, newItemPosition ] : "type-po" === type ? [ newPosition, {
|
|
117
|
+
x: newItemPosition.x,
|
|
118
|
+
y: newPosition.y
|
|
119
|
+
}, newItemPosition ] : "type-op" === type ? [ newPosition, {
|
|
120
|
+
x: newPosition.x,
|
|
121
|
+
y: newItemPosition.y
|
|
122
|
+
}, newItemPosition ] : [ newPosition, newItemPosition ];
|
|
123
|
+
return points = removeRepeatPoint(points), {
|
|
124
|
+
points: points,
|
|
125
|
+
center: center,
|
|
126
|
+
radius: radius,
|
|
127
|
+
startAngle: startAngle,
|
|
128
|
+
endAngle: endAngle
|
|
129
|
+
};
|
|
96
130
|
}
|
|
97
|
-
setItemLineAttr(itemLine,
|
|
131
|
+
setItemLineAttr(itemLine, newPosition, newItemPosition, visible) {
|
|
98
132
|
if (this._line) {
|
|
99
|
-
const {startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle} = itemLine,
|
|
100
|
-
this._line.setAttributes({
|
|
101
|
-
points: points,
|
|
133
|
+
const {startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, type: type = "type-s"} = itemLine, {state: state} = this.attribute, pointsAttr = this.getItemLineAttr(itemLine, newPosition, newItemPosition);
|
|
134
|
+
if ("type-arc" === type && "arc-segment" === this._line.key || "type-arc" !== type && "segment" === this._line.key) this._line.setAttributes(Object.assign(Object.assign({}, pointsAttr), {
|
|
102
135
|
startSymbol: startSymbol,
|
|
103
136
|
endSymbol: endSymbol,
|
|
104
137
|
lineStyle: lineStyle,
|
|
105
|
-
visible: visible
|
|
106
|
-
|
|
138
|
+
visible: visible,
|
|
139
|
+
state: {
|
|
140
|
+
line: merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
|
|
141
|
+
startSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineStartSymbol),
|
|
142
|
+
endSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineEndSymbol)
|
|
143
|
+
}
|
|
144
|
+
})); else {
|
|
145
|
+
this._line.release();
|
|
146
|
+
const lineConstructor = "type-arc" === type ? ArcSegment : Segment;
|
|
147
|
+
this._container.removeChild(this._line), this._line = new lineConstructor(Object.assign(Object.assign({}, pointsAttr), {
|
|
148
|
+
pickable: !1,
|
|
149
|
+
startSymbol: startSymbol,
|
|
150
|
+
endSymbol: endSymbol,
|
|
151
|
+
lineStyle: lineStyle,
|
|
152
|
+
visible: visible,
|
|
153
|
+
state: {
|
|
154
|
+
line: merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
|
|
155
|
+
startSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineStartSymbol),
|
|
156
|
+
endSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineEndSymbol)
|
|
157
|
+
}
|
|
158
|
+
})), this._container.add(this._line);
|
|
159
|
+
}
|
|
107
160
|
}
|
|
108
161
|
}
|
|
109
|
-
getDecorativeLineAttr(itemLine
|
|
162
|
+
getDecorativeLineAttr(itemLine) {
|
|
110
163
|
var _a;
|
|
111
164
|
const decorativeLength = (null === (_a = null == itemLine ? void 0 : itemLine.decorativeLine) || void 0 === _a ? void 0 : _a.length) || 10, itemAngle = this._line.getEndAngle() || 0;
|
|
112
165
|
return {
|
|
@@ -116,25 +169,34 @@ export class MarkPoint extends Marker {
|
|
|
116
169
|
endPointOffsetY: -decorativeLength / 2 * Math.sin(itemAngle - Math.PI / 2)
|
|
117
170
|
};
|
|
118
171
|
}
|
|
119
|
-
setDecorativeLineAttr(itemLine,
|
|
172
|
+
setDecorativeLineAttr(itemLine, newItemPosition, visible) {
|
|
173
|
+
var _a;
|
|
120
174
|
if (this._decorativeLine) {
|
|
121
|
-
const {lineStyle: lineStyle} = itemLine, {startPointOffsetX: startPointOffsetX, startPointOffsetY: startPointOffsetY, endPointOffsetX: endPointOffsetX, endPointOffsetY: endPointOffsetY} = this.getDecorativeLineAttr(itemLine
|
|
175
|
+
const {lineStyle: lineStyle} = itemLine, {startPointOffsetX: startPointOffsetX, startPointOffsetY: startPointOffsetY, endPointOffsetX: endPointOffsetX, endPointOffsetY: endPointOffsetY} = this.getDecorativeLineAttr(itemLine);
|
|
122
176
|
this._decorativeLine.setAttributes(Object.assign(Object.assign({
|
|
123
177
|
points: [ {
|
|
124
|
-
x:
|
|
125
|
-
y:
|
|
178
|
+
x: newItemPosition.x + startPointOffsetX,
|
|
179
|
+
y: newItemPosition.y + startPointOffsetY
|
|
126
180
|
}, {
|
|
127
|
-
x:
|
|
128
|
-
y:
|
|
181
|
+
x: newItemPosition.x + endPointOffsetX,
|
|
182
|
+
y: newItemPosition.y + endPointOffsetY
|
|
129
183
|
} ]
|
|
130
184
|
}, lineStyle), {
|
|
131
185
|
visible: visible
|
|
132
|
-
}));
|
|
186
|
+
})), this._decorativeLine.states = merge({}, DEFAULT_STATES, null === (_a = this.attribute.state) || void 0 === _a ? void 0 : _a.line);
|
|
133
187
|
}
|
|
134
188
|
}
|
|
135
|
-
|
|
189
|
+
setTargetItemAttributes(targetItem, position) {
|
|
190
|
+
var _a, _b;
|
|
191
|
+
this._targetItem && (this._targetItem.setAttributes(Object.assign({
|
|
192
|
+
x: position.x,
|
|
193
|
+
y: position.y,
|
|
194
|
+
visible: null !== (_a = targetItem.visible) && void 0 !== _a && _a
|
|
195
|
+
}, targetItem.style)), this._targetItem.states = merge({}, DEFAULT_STATES, null === (_b = this.attribute.state) || void 0 === _b ? void 0 : _b.targetItem));
|
|
196
|
+
}
|
|
197
|
+
setAllOfItemsAttr(newPosition, newItemPosition) {
|
|
136
198
|
var _a;
|
|
137
|
-
const {position: position, itemLine: itemLine = {}, itemContent: itemContent = {}, limitRect: limitRect} = this.attribute, {type: type = "text", confine: confine} = itemContent;
|
|
199
|
+
const {position: position, itemLine: itemLine = {}, itemContent: itemContent = {}, limitRect: limitRect, targetItemContent: targetItemContent} = this.attribute, {type: type = "text", confine: confine} = itemContent;
|
|
138
200
|
if (limitRect && confine) {
|
|
139
201
|
const {x: x, y: y, width: width, height: height} = limitRect, {dx: dx, dy: dy} = computeOffsetForlimit(this._item, {
|
|
140
202
|
x1: x,
|
|
@@ -142,40 +204,51 @@ export class MarkPoint extends Marker {
|
|
|
142
204
|
x2: x + width,
|
|
143
205
|
y2: y + height
|
|
144
206
|
});
|
|
145
|
-
|
|
207
|
+
newItemPosition.x = newItemPosition.x + dx, newItemPosition.y = newItemPosition.y + dy;
|
|
146
208
|
}
|
|
147
|
-
this.
|
|
148
|
-
this.setDecorativeLineAttr(itemLine,
|
|
209
|
+
this.setTargetItemAttributes(targetItemContent, position), this.setItemLineAttr(itemLine, newPosition, newItemPosition, itemLine.visible),
|
|
210
|
+
this.setItemAttributes(this._item, itemContent, newItemPosition, type), this.setDecorativeLineAttr(itemLine, newItemPosition, null === (_a = itemLine.decorativeLine) || void 0 === _a ? void 0 : _a.visible);
|
|
211
|
+
}
|
|
212
|
+
computeNewPositionAfterTargetItem(position) {
|
|
213
|
+
var _a;
|
|
214
|
+
const {itemContent: itemContent = {}, targetItemContent: targetItemContent} = this.attribute, {offsetX: itemContentOffsetX = 0, offsetY: itemContentOffsetY = 0} = itemContent, {margin: targetItemContentMargin = 0, style: targetItemContentStyle, visible: targetItemvisible = !1, size: targetItemContentSize} = targetItemContent, targetSize = targetItemvisible ? targetItemContentSize || (null !== (_a = targetItemContentStyle.size) && void 0 !== _a ? _a : 10) : 0, targetOffsetAngle = deltaXYToAngle(itemContentOffsetY, itemContentOffsetX);
|
|
215
|
+
return {
|
|
216
|
+
newPosition: {
|
|
217
|
+
x: position.x + (targetSize + targetItemContentMargin) * Math.cos(targetOffsetAngle),
|
|
218
|
+
y: position.y + (targetSize + targetItemContentMargin) * Math.sin(targetOffsetAngle)
|
|
219
|
+
},
|
|
220
|
+
newItemPosition: {
|
|
221
|
+
x: position.x + (targetSize + targetItemContentMargin) * Math.cos(targetOffsetAngle) + itemContentOffsetX,
|
|
222
|
+
y: position.y + (targetSize + targetItemContentMargin) * Math.sin(targetOffsetAngle) + itemContentOffsetY
|
|
223
|
+
}
|
|
224
|
+
};
|
|
149
225
|
}
|
|
150
226
|
initMarker(container) {
|
|
151
|
-
const {position: position, itemContent: itemContent = {},
|
|
152
|
-
x: position.x + (itemContent.offsetX || 0),
|
|
153
|
-
y: position.y + (itemContent.offsetY || 0)
|
|
154
|
-
}, line = new Segment({
|
|
227
|
+
const {position: position, itemContent: itemContent = {}, itemLine: itemLine} = this.attribute, {type: itemLineType = "type-s"} = itemLine, {newPosition: newPosition, newItemPosition: newItemPosition} = this.computeNewPositionAfterTargetItem(position), line = new ("type-arc" === itemLineType ? ArcSegment : Segment)({
|
|
155
228
|
points: [],
|
|
156
229
|
pickable: !1,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
230
|
+
center: {
|
|
231
|
+
x: 0,
|
|
232
|
+
y: 0
|
|
233
|
+
},
|
|
234
|
+
radius: 0,
|
|
235
|
+
startAngle: 0,
|
|
236
|
+
endAngle: 0
|
|
162
237
|
});
|
|
163
238
|
line.name = "mark-point-line", this._line = line, container.add(line);
|
|
164
239
|
const decorativeLine = graphicCreator.line({
|
|
165
240
|
points: []
|
|
166
241
|
});
|
|
167
|
-
decorativeLine.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
|
|
168
242
|
decorativeLine.name = "mark-point-decorativeLine", this._decorativeLine = decorativeLine,
|
|
169
243
|
container.add(decorativeLine);
|
|
170
|
-
const
|
|
171
|
-
|
|
244
|
+
const targetItem = graphicCreator.symbol({});
|
|
245
|
+
targetItem.name = "mark-point-targetItem", this._targetItem = targetItem, container.add(this._targetItem);
|
|
246
|
+
const item = this.initItem(itemContent, newItemPosition);
|
|
247
|
+
this._item = item, container.add(item), this.setAllOfItemsAttr(newPosition, newItemPosition);
|
|
172
248
|
}
|
|
173
249
|
updateMarker() {
|
|
174
|
-
const {position: position, itemContent: itemContent = {}} = this.attribute, {type: type = "text"} = itemContent,
|
|
175
|
-
|
|
176
|
-
y: position.y + (itemContent.offsetY || 0)
|
|
177
|
-
};
|
|
178
|
-
this.setItemAttributes(this._item, itemContent, itemPosition, type), this.setAllOfItemsAttr(itemPosition);
|
|
250
|
+
const {position: position, itemContent: itemContent = {}} = this.attribute, {type: type = "text"} = itemContent, {newPosition: newPosition, newItemPosition: newItemPosition} = this.computeNewPositionAfterTargetItem(position);
|
|
251
|
+
this.setItemAttributes(this._item, itemContent, newItemPosition, type), this.setAllOfItemsAttr(newPosition, newItemPosition);
|
|
179
252
|
}
|
|
180
253
|
isValidPoints() {
|
|
181
254
|
const {position: position} = this.attribute;
|