@visactor/vrender-components 0.19.4-alpha.2 → 0.19.4-alpha.3
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/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/label/arc.js +1 -2
- package/cjs/label/index.js +2 -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/discrete/discrete.d.ts +1 -0
- package/cjs/legend/discrete/discrete.js +3 -0
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/link-path/index.js +1 -1
- package/cjs/link-path/link-path.js +1 -1
- package/cjs/link-path/register.js +1 -1
- package/cjs/link-path/type.js +1 -1
- package/cjs/marker/animate/common.js +4 -8
- package/cjs/marker/animate/common.js.map +1 -1
- package/cjs/marker/arc-area.js +4 -10
- package/cjs/marker/arc-area.js.map +1 -1
- package/cjs/marker/arc-line.js +2 -7
- package/cjs/marker/arc-line.js.map +1 -1
- package/cjs/marker/area.js +4 -10
- 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 +5 -10
- package/cjs/marker/common-line.js.map +1 -1
- package/cjs/marker/config.d.ts +4 -16
- package/cjs/marker/config.js +56 -132
- package/cjs/marker/config.js.map +1 -1
- package/cjs/marker/line.d.ts +3 -3
- package/cjs/marker/line.js +7 -19
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +7 -35
- package/cjs/marker/point.js +70 -147
- 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 +4 -12
- package/cjs/marker/type.js.map +1 -1
- package/cjs/scrollbar/scrollbar.js +4 -2
- package/cjs/scrollbar/scrollbar.js.map +1 -1
- package/cjs/scrollbar/type.d.ts +2 -0
- package/cjs/scrollbar/type.js.map +1 -1
- package/cjs/segment/arc-segment.d.ts +0 -3
- package/cjs/segment/arc-segment.js +1 -7
- 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 +0 -1
- package/cjs/segment/segment.js +1 -1
- package/cjs/segment/segment.js.map +1 -1
- package/cjs/util/common.d.ts +0 -3
- package/cjs/util/common.js +2 -13
- package/cjs/util/common.js.map +1 -1
- package/cjs/util/index.d.ts +0 -1
- package/cjs/util/index.js +1 -2
- package/cjs/util/index.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/label/arc.js +1 -2
- package/es/label/index.js +2 -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/discrete/discrete.d.ts +1 -0
- package/es/legend/discrete/discrete.js +3 -0
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/link-path/index.js +1 -1
- package/es/link-path/link-path.js +1 -1
- package/es/link-path/register.js +1 -1
- package/es/link-path/type.js +1 -1
- package/es/marker/animate/common.js +4 -8
- package/es/marker/animate/common.js.map +1 -1
- package/es/marker/arc-area.js +4 -10
- package/es/marker/arc-area.js.map +1 -1
- package/es/marker/arc-line.js +2 -7
- package/es/marker/arc-line.js.map +1 -1
- package/es/marker/area.js +4 -10
- 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 +5 -10
- package/es/marker/common-line.js.map +1 -1
- package/es/marker/config.d.ts +4 -16
- package/es/marker/config.js +56 -132
- package/es/marker/config.js.map +1 -1
- package/es/marker/line.d.ts +3 -3
- package/es/marker/line.js +6 -20
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +7 -35
- package/es/marker/point.js +70 -148
- package/es/marker/point.js.map +1 -1
- package/es/marker/register.js +1 -2
- package/es/marker/register.js.map +1 -1
- package/es/marker/type.d.ts +4 -12
- package/es/marker/type.js.map +1 -1
- package/es/scrollbar/scrollbar.js +4 -2
- package/es/scrollbar/scrollbar.js.map +1 -1
- package/es/scrollbar/type.d.ts +2 -0
- package/es/scrollbar/type.js.map +1 -1
- package/es/segment/arc-segment.d.ts +0 -3
- package/es/segment/arc-segment.js +1 -7
- 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 +0 -1
- package/es/segment/segment.js +1 -1
- package/es/segment/segment.js.map +1 -1
- package/es/util/common.d.ts +0 -3
- package/es/util/common.js +0 -10
- package/es/util/common.js.map +1 -1
- package/es/util/index.d.ts +0 -1
- package/es/util/index.js +0 -2
- package/es/util/index.js.map +1 -1
- package/package.json +3 -3
- package/cjs/util/polar.d.ts +0 -2
- package/cjs/util/polar.js +0 -17
- package/cjs/util/polar.js.map +0 -1
- package/es/util/polar.d.ts +0 -2
- package/es/util/polar.js +0 -7
- package/es/util/polar.js.map +0 -1
package/es/marker/line.js
CHANGED
|
@@ -12,8 +12,6 @@ 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
|
-
|
|
17
15
|
loadMarkLineComponent();
|
|
18
16
|
|
|
19
17
|
export function registerMarkLineAnimate() {
|
|
@@ -30,8 +28,7 @@ export class MarkLine extends MarkCommonLine {
|
|
|
30
28
|
}
|
|
31
29
|
getPointAttrByPosition(position) {
|
|
32
30
|
var _a;
|
|
33
|
-
const {label: label = {}} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, points = this._line.getMainSegmentPoints(),
|
|
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);
|
|
31
|
+
const {label: label = {}} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, points = this._line.getMainSegmentPoints(), labelAngle = null !== (_a = this._line.getEndAngle()) && void 0 !== _a ? _a : 0, labelOffsetX = refX * Math.cos(labelAngle) + refX * Math.cos(labelAngle - Math.PI / 2), labelOffsetY = refX * Math.sin(labelAngle) + refY * Math.sin(labelAngle - Math.PI / 2);
|
|
35
32
|
return position.includes("start") || position.includes("Start") ? {
|
|
36
33
|
position: {
|
|
37
34
|
x: points[0].x + labelOffsetX,
|
|
@@ -54,16 +51,10 @@ export class MarkLine extends MarkCommonLine {
|
|
|
54
51
|
}
|
|
55
52
|
getRotateByAngle(angle) {
|
|
56
53
|
var _a;
|
|
57
|
-
return
|
|
54
|
+
return angle + (null !== (_a = this.attribute.label.refAngle) && void 0 !== _a ? _a : 0);
|
|
58
55
|
}
|
|
59
|
-
getTextStyle(position
|
|
60
|
-
return
|
|
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];
|
|
56
|
+
getTextStyle(position) {
|
|
57
|
+
return DEFAULT_CARTESIAN_MARK_LINE_TEXT_STYLE_MAP[position];
|
|
67
58
|
}
|
|
68
59
|
createSegment() {
|
|
69
60
|
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, mainSegmentIndex: mainSegmentIndex, multiSegment: multiSegment, state: state} = this.attribute;
|
|
@@ -83,19 +74,14 @@ export class MarkLine extends MarkCommonLine {
|
|
|
83
74
|
});
|
|
84
75
|
}
|
|
85
76
|
setLineAttributes() {
|
|
86
|
-
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, mainSegmentIndex: mainSegmentIndex, multiSegment: multiSegment
|
|
77
|
+
const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, mainSegmentIndex: mainSegmentIndex, multiSegment: multiSegment} = this.attribute;
|
|
87
78
|
this._line && this._line.setAttributes({
|
|
88
79
|
points: points,
|
|
89
80
|
startSymbol: startSymbol,
|
|
90
81
|
endSymbol: endSymbol,
|
|
91
82
|
lineStyle: lineStyle,
|
|
92
83
|
mainSegmentIndex: mainSegmentIndex,
|
|
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
|
-
}
|
|
84
|
+
multiSegment: multiSegment
|
|
99
85
|
});
|
|
100
86
|
}
|
|
101
87
|
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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,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,CAAC;iBAC3D;aACF,CAAC,CAAC;SACJ;IACH,CAAC;IAES,aAAa;QACrB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,SAA0B,CAAC;QACnD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;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;;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"]}
|
|
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,uBAAuB;IACrC,QAAQ,CAAC,QAAQ,GAAG,qBAAqB,CAAC;AAC5C,CAAC;AAED,MAAM,OAAO,QAAS,SAAQ,cAA6D;IAO/E,aAAa,CAAC,KAA2B;QACjD,IAAI,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC9C,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;SAC1E;IACH,CAAC;IAED,YAAY,UAAyB,EAAE,OAA0B;QAC/D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC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AAI,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"]}
|
package/es/marker/point.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { IGroup, IImage, ISymbol, IImageGraphicAttribute, IRichText, IRichTextGraphicAttribute } from '@visactor/vrender-core';
|
|
2
|
-
import type { IPointLike } from '@visactor/vutils';
|
|
3
2
|
import { Tag } from '../tag';
|
|
4
3
|
import { Marker } from './base';
|
|
5
4
|
import type { IItemContent, IItemLine, MarkPointAnimationType, MarkPointAttrs, MarkerAnimationState } from './type';
|
|
@@ -11,14 +10,6 @@ export declare class MarkPoint extends Marker<MarkPointAttrs, MarkPointAnimation
|
|
|
11
10
|
name: string;
|
|
12
11
|
static defaultAttributes: {
|
|
13
12
|
interactive: boolean;
|
|
14
|
-
targetItemContent: {
|
|
15
|
-
visible: boolean;
|
|
16
|
-
margin: number;
|
|
17
|
-
symbolType: string;
|
|
18
|
-
size: number;
|
|
19
|
-
fill: boolean;
|
|
20
|
-
stroke: string;
|
|
21
|
-
};
|
|
22
13
|
itemLine: {
|
|
23
14
|
visible: boolean;
|
|
24
15
|
decorativeLine: {
|
|
@@ -78,43 +69,24 @@ export declare class MarkPoint extends Marker<MarkPointAttrs, MarkPointAnimation
|
|
|
78
69
|
defaultExitAnimation: import("./type").MarkerExitAnimation;
|
|
79
70
|
protected markerAnimate(state: MarkerAnimationState): void;
|
|
80
71
|
private _item;
|
|
81
|
-
private _targetItem;
|
|
82
72
|
private _line?;
|
|
83
73
|
private _decorativeLine;
|
|
84
74
|
constructor(attributes: MarkPointAttrs, options?: ComponentOptions);
|
|
85
75
|
protected setLabelPos(): void;
|
|
86
|
-
protected
|
|
87
|
-
textAlign: string;
|
|
88
|
-
textBaseline: string;
|
|
89
|
-
};
|
|
90
|
-
protected setItemAttributes(item: ISymbol | Tag | IImage | IRichText, itemContent: IItemContent, newPosition: Point, newItemPosition: Point, itemType: 'symbol' | 'text' | 'image' | 'richText' | 'custom'): void;
|
|
76
|
+
protected setItemAttributes(item: ISymbol | Tag | IImage | IRichText, itemContent: IItemContent, itemPosition: Point, itemType: 'symbol' | 'text' | 'image' | 'richText' | 'custom'): void;
|
|
91
77
|
protected getItemDx(item: ISymbol | Tag | IImage | IRichText, position: keyof typeof IMarkPointItemPosition, style?: IImageGraphicAttribute | IRichTextGraphicAttribute): number;
|
|
92
78
|
protected getItemDy(item: ISymbol | Tag | IImage | IRichText, position: keyof typeof IMarkPointItemPosition, style?: IImageGraphicAttribute | IRichTextGraphicAttribute): number;
|
|
93
|
-
protected initItem(itemContent: IItemContent,
|
|
94
|
-
protected getItemLineAttr(itemLine: IItemLine,
|
|
95
|
-
|
|
96
|
-
|
|
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): {
|
|
79
|
+
protected initItem(itemContent: IItemContent, itemPosition: Point): IGroup | IRichText | Tag | ISymbol | IImage;
|
|
80
|
+
protected getItemLineAttr(itemLine: IItemLine, position: Point, itemPosition: Point): Point[];
|
|
81
|
+
protected setItemLineAttr(itemLine: IItemLine, position: Point, itemPosition: Point, visible: boolean): void;
|
|
82
|
+
protected getDecorativeLineAttr(itemLine: IItemLine, itemPosition: Point): {
|
|
106
83
|
startPointOffsetX: number;
|
|
107
84
|
startPointOffsetY: number;
|
|
108
85
|
endPointOffsetX: number;
|
|
109
86
|
endPointOffsetY: number;
|
|
110
87
|
};
|
|
111
|
-
protected setDecorativeLineAttr(itemLine: IItemLine,
|
|
112
|
-
protected
|
|
113
|
-
protected setAllOfItemsAttr(newPosition: Point, newItemPosition: Point): void;
|
|
114
|
-
protected computeNewPositionAfterTargetItem(position: Point): {
|
|
115
|
-
newPosition: Point;
|
|
116
|
-
newItemPosition: Point;
|
|
117
|
-
};
|
|
88
|
+
protected setDecorativeLineAttr(itemLine: IItemLine, itemPosition: Point, visible: boolean): void;
|
|
89
|
+
protected setAllOfItemsAttr(itemPosition: Point): void;
|
|
118
90
|
protected initMarker(container: IGroup): void;
|
|
119
91
|
protected updateMarker(): void;
|
|
120
92
|
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 {
|
|
5
|
+
import { Segment } from "../segment";
|
|
6
6
|
|
|
7
7
|
import { Tag } from "../tag";
|
|
8
8
|
|
|
@@ -20,8 +20,6 @@ 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
|
-
|
|
25
23
|
loadMarkPointComponent();
|
|
26
24
|
|
|
27
25
|
export function registerMarkPointAnimate() {
|
|
@@ -38,39 +36,21 @@ export class MarkPoint extends Marker {
|
|
|
38
36
|
this.defaultExitAnimation = DefaultExitMarkerAnimation;
|
|
39
37
|
}
|
|
40
38
|
setLabelPos() {}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
textAlign: "right",
|
|
44
|
-
textBaseline: "middle"
|
|
45
|
-
} : {
|
|
46
|
-
textAlign: "center",
|
|
47
|
-
textBaseline: offsetY > 0 && itemPosition.includes("inside") || offsetY < 0 && !itemPosition.includes("inside") ? "bottom" : "top"
|
|
48
|
-
} : offsetX > 0 ? DEFAULT_MARK_POINT_TEXT_STYLE_MAP.postiveXAxis[itemPosition] : DEFAULT_MARK_POINT_TEXT_STYLE_MAP.negativeXAxis[itemPosition];
|
|
49
|
-
}
|
|
50
|
-
setItemAttributes(item, itemContent, newPosition, newItemPosition, itemType) {
|
|
51
|
-
var _a, _b;
|
|
39
|
+
setItemAttributes(item, itemContent, itemPosition, itemType) {
|
|
40
|
+
var _a;
|
|
52
41
|
if (!item) return;
|
|
53
|
-
const {autoRotate: autoRotate = !0, refX: refX = 0, refY: refY = 0, refAngle: refAngle = 0, textStyle: textStyle = {}, richTextStyle: richTextStyle = {}, imageStyle: imageStyle = {}, position:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
dy: this.getItemDy(item, positionType, richTextStyle) + (richTextStyle.dy || 0)
|
|
66
|
-
}), item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.richText)) : "image" === itemType && (item.setAttributes({
|
|
67
|
-
dx: this.getItemDx(item, positionType, imageStyle) + (imageStyle.dx || 0),
|
|
68
|
-
dy: this.getItemDy(item, positionType, imageStyle) + (imageStyle.dy || 0)
|
|
69
|
-
}), item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.image));
|
|
70
|
-
const itemAngle = isPostiveXAxis(lineEndAngle) ? lineEndAngle : lineEndAngle - Math.PI;
|
|
71
|
-
item.setAttributes({
|
|
72
|
-
x: newItemPosition.x + (itemRefOffsetX || 0),
|
|
73
|
-
y: newItemPosition.y + (itemRefOffsetY || 0),
|
|
42
|
+
const {autoRotate: autoRotate = !0, refX: refX = 0, refY: refY = 0, refAngle: refAngle = 0, textStyle: textStyle = {}, richTextStyle: richTextStyle = {}, imageStyle: imageStyle = {}, position: position = IMarkPointItemPosition.middle} = itemContent, itemAngle = (null === (_a = this._line) || void 0 === _a ? void 0 : _a.getEndAngle()) || 0, itemOffsetX = refX * Math.cos(itemAngle) + refY * Math.cos(itemAngle - Math.PI / 2), itemOffsetY = refX * Math.sin(itemAngle) + refY * Math.sin(itemAngle - Math.PI / 2);
|
|
43
|
+
"text" === itemType ? item.setAttributes(Object.assign(Object.assign({}, textStyle), {
|
|
44
|
+
textStyle: Object.assign(Object.assign({}, DEFAULT_MARK_POINT_TEXT_STYLE_MAP[(null == itemContent ? void 0 : itemContent.position) || "end"]), textStyle.textStyle)
|
|
45
|
+
})) : "richText" === itemType ? item.setAttributes({
|
|
46
|
+
dx: this.getItemDx(item, position, richTextStyle) + (richTextStyle.dx || 0),
|
|
47
|
+
dy: this.getItemDy(item, position, richTextStyle) + (richTextStyle.dy || 0)
|
|
48
|
+
}) : "image" === itemType && item.setAttributes({
|
|
49
|
+
dx: this.getItemDx(item, position, imageStyle) + (imageStyle.dx || 0),
|
|
50
|
+
dy: this.getItemDy(item, position, imageStyle) + (imageStyle.dy || 0)
|
|
51
|
+
}), item.setAttributes({
|
|
52
|
+
x: itemPosition.x + (itemOffsetX || 0),
|
|
53
|
+
y: itemPosition.y + (itemOffsetY || 0),
|
|
74
54
|
angle: autoRotate && itemAngle + refAngle
|
|
75
55
|
});
|
|
76
56
|
}
|
|
@@ -84,85 +64,49 @@ export class MarkPoint extends Marker {
|
|
|
84
64
|
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;
|
|
85
65
|
return position.includes("top") || position.includes("Top") ? -height : position.includes("middle") || position.includes("Middle") ? -height / 2 : 0;
|
|
86
66
|
}
|
|
87
|
-
initItem(itemContent,
|
|
67
|
+
initItem(itemContent, itemPosition) {
|
|
88
68
|
const {state: state} = this.attribute, {type: type = "text", symbolStyle: symbolStyle, richTextStyle: richTextStyle, imageStyle: imageStyle, renderCustomCallback: renderCustomCallback} = itemContent;
|
|
89
69
|
let item;
|
|
90
|
-
return "symbol" === type ? (item = graphicCreator.symbol(Object.assign(Object.assign({},
|
|
91
|
-
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.symbol)) : "text" === type ? item = new Tag(Object.assign(Object.assign({},
|
|
70
|
+
return "symbol" === type ? (item = graphicCreator.symbol(Object.assign(Object.assign({}, itemPosition), symbolStyle)),
|
|
71
|
+
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.symbol)) : "text" === type ? item = new Tag(Object.assign(Object.assign({}, itemPosition), {
|
|
92
72
|
state: {
|
|
93
73
|
panel: merge({}, DEFAULT_STATES, null == state ? void 0 : state.textBackground),
|
|
94
74
|
text: merge({}, DEFAULT_STATES, null == state ? void 0 : state.text)
|
|
95
75
|
}
|
|
96
|
-
})) : "richText" === type ? (item = graphicCreator.richtext(Object.assign(Object.assign({},
|
|
97
|
-
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.richText)) : "image" === type ? (item = graphicCreator.image(Object.assign(Object.assign({},
|
|
76
|
+
})) : "richText" === type ? (item = graphicCreator.richtext(Object.assign(Object.assign({}, itemPosition), richTextStyle)),
|
|
77
|
+
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.richText)) : "image" === type ? (item = graphicCreator.image(Object.assign(Object.assign({}, itemPosition), imageStyle)),
|
|
98
78
|
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.image)) : "custom" === type && renderCustomCallback && (item = renderCustomCallback(),
|
|
99
79
|
item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.customMark)),
|
|
100
|
-
item.name = `mark-point-${type}`, this.setItemAttributes(item, itemContent,
|
|
80
|
+
item.name = `mark-point-${type}`, this.setItemAttributes(item, itemContent, itemPosition, type),
|
|
101
81
|
item;
|
|
102
82
|
}
|
|
103
|
-
getItemLineAttr(itemLine,
|
|
104
|
-
let points = []
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
} else points = "type-do" === type ? [ newPosition, {
|
|
117
|
-
x: (newPosition.x + newItemPosition.x) / 2,
|
|
118
|
-
y: newItemPosition.y
|
|
119
|
-
}, newItemPosition ] : "type-po" === type ? [ newPosition, {
|
|
120
|
-
x: newItemPosition.x,
|
|
121
|
-
y: newPosition.y
|
|
122
|
-
}, newItemPosition ] : "type-op" === type ? [ newPosition, {
|
|
123
|
-
x: newPosition.x,
|
|
124
|
-
y: newItemPosition.y
|
|
125
|
-
}, newItemPosition ] : [ newPosition, newItemPosition ];
|
|
126
|
-
return points = removeRepeatPoint(points), {
|
|
127
|
-
points: points,
|
|
128
|
-
center: center,
|
|
129
|
-
radius: radius,
|
|
130
|
-
startAngle: startAngle,
|
|
131
|
-
endAngle: endAngle
|
|
132
|
-
};
|
|
83
|
+
getItemLineAttr(itemLine, position, itemPosition) {
|
|
84
|
+
let points = [];
|
|
85
|
+
const {type: type = "type-s"} = itemLine;
|
|
86
|
+
return points = "type-do" === type ? [ position, {
|
|
87
|
+
x: (position.x + itemPosition.x) / 2,
|
|
88
|
+
y: itemPosition.y
|
|
89
|
+
}, itemPosition ] : "type-po" === type ? [ position, {
|
|
90
|
+
x: itemPosition.x,
|
|
91
|
+
y: position.y
|
|
92
|
+
}, itemPosition ] : "type-op" === type ? [ position, {
|
|
93
|
+
x: position.x,
|
|
94
|
+
y: itemPosition.y
|
|
95
|
+
}, itemPosition ] : [ position, itemPosition ], points;
|
|
133
96
|
}
|
|
134
|
-
setItemLineAttr(itemLine,
|
|
97
|
+
setItemLineAttr(itemLine, position, itemPosition, visible) {
|
|
135
98
|
if (this._line) {
|
|
136
|
-
const {startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle
|
|
137
|
-
|
|
99
|
+
const {startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle} = itemLine, points = this.getItemLineAttr(itemLine, position, itemPosition);
|
|
100
|
+
this._line.setAttributes({
|
|
101
|
+
points: points,
|
|
138
102
|
startSymbol: startSymbol,
|
|
139
103
|
endSymbol: endSymbol,
|
|
140
104
|
lineStyle: lineStyle,
|
|
141
|
-
visible: visible
|
|
142
|
-
|
|
143
|
-
line: merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
|
|
144
|
-
startSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineStartSymbol),
|
|
145
|
-
endSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineEndSymbol)
|
|
146
|
-
}
|
|
147
|
-
})); else {
|
|
148
|
-
this._line.release();
|
|
149
|
-
const lineConstructor = "type-arc" === type ? ArcSegment : Segment;
|
|
150
|
-
this._container.removeChild(this._line), this._line = new lineConstructor(Object.assign(Object.assign({}, pointsAttr), {
|
|
151
|
-
pickable: !1,
|
|
152
|
-
startSymbol: startSymbol,
|
|
153
|
-
endSymbol: endSymbol,
|
|
154
|
-
lineStyle: lineStyle,
|
|
155
|
-
visible: visible,
|
|
156
|
-
state: {
|
|
157
|
-
line: merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
|
|
158
|
-
startSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineStartSymbol),
|
|
159
|
-
endSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineEndSymbol)
|
|
160
|
-
}
|
|
161
|
-
})), this._container.add(this._line);
|
|
162
|
-
}
|
|
105
|
+
visible: visible
|
|
106
|
+
});
|
|
163
107
|
}
|
|
164
108
|
}
|
|
165
|
-
getDecorativeLineAttr(itemLine) {
|
|
109
|
+
getDecorativeLineAttr(itemLine, itemPosition) {
|
|
166
110
|
var _a;
|
|
167
111
|
const decorativeLength = (null === (_a = null == itemLine ? void 0 : itemLine.decorativeLine) || void 0 === _a ? void 0 : _a.length) || 10, itemAngle = this._line.getEndAngle() || 0;
|
|
168
112
|
return {
|
|
@@ -172,34 +116,25 @@ export class MarkPoint extends Marker {
|
|
|
172
116
|
endPointOffsetY: -decorativeLength / 2 * Math.sin(itemAngle - Math.PI / 2)
|
|
173
117
|
};
|
|
174
118
|
}
|
|
175
|
-
setDecorativeLineAttr(itemLine,
|
|
176
|
-
var _a;
|
|
119
|
+
setDecorativeLineAttr(itemLine, itemPosition, visible) {
|
|
177
120
|
if (this._decorativeLine) {
|
|
178
|
-
const {lineStyle: lineStyle} = itemLine, {startPointOffsetX: startPointOffsetX, startPointOffsetY: startPointOffsetY, endPointOffsetX: endPointOffsetX, endPointOffsetY: endPointOffsetY} = this.getDecorativeLineAttr(itemLine);
|
|
121
|
+
const {lineStyle: lineStyle} = itemLine, {startPointOffsetX: startPointOffsetX, startPointOffsetY: startPointOffsetY, endPointOffsetX: endPointOffsetX, endPointOffsetY: endPointOffsetY} = this.getDecorativeLineAttr(itemLine, itemPosition);
|
|
179
122
|
this._decorativeLine.setAttributes(Object.assign(Object.assign({
|
|
180
123
|
points: [ {
|
|
181
|
-
x:
|
|
182
|
-
y:
|
|
124
|
+
x: itemPosition.x + startPointOffsetX,
|
|
125
|
+
y: itemPosition.y + startPointOffsetY
|
|
183
126
|
}, {
|
|
184
|
-
x:
|
|
185
|
-
y:
|
|
127
|
+
x: itemPosition.x + endPointOffsetX,
|
|
128
|
+
y: itemPosition.y + endPointOffsetY
|
|
186
129
|
} ]
|
|
187
130
|
}, lineStyle), {
|
|
188
131
|
visible: visible
|
|
189
|
-
}))
|
|
132
|
+
}));
|
|
190
133
|
}
|
|
191
134
|
}
|
|
192
|
-
|
|
193
|
-
var _a, _b;
|
|
194
|
-
this._targetItem && (this._targetItem.setAttributes(Object.assign({
|
|
195
|
-
x: position.x,
|
|
196
|
-
y: position.y,
|
|
197
|
-
visible: null !== (_a = targetItem.visible) && void 0 !== _a && _a
|
|
198
|
-
}, targetItem.style)), this._targetItem.states = merge({}, DEFAULT_STATES, null === (_b = this.attribute.state) || void 0 === _b ? void 0 : _b.targetItem));
|
|
199
|
-
}
|
|
200
|
-
setAllOfItemsAttr(newPosition, newItemPosition) {
|
|
135
|
+
setAllOfItemsAttr(itemPosition) {
|
|
201
136
|
var _a;
|
|
202
|
-
const {position: position, itemLine: itemLine = {}, itemContent: itemContent = {}, limitRect: limitRect
|
|
137
|
+
const {position: position, itemLine: itemLine = {}, itemContent: itemContent = {}, limitRect: limitRect} = this.attribute, {type: type = "text", confine: confine} = itemContent;
|
|
203
138
|
if (limitRect && confine) {
|
|
204
139
|
const {x: x, y: y, width: width, height: height} = limitRect, {dx: dx, dy: dy} = computeOffsetForlimit(this._item, {
|
|
205
140
|
x1: x,
|
|
@@ -207,53 +142,40 @@ export class MarkPoint extends Marker {
|
|
|
207
142
|
x2: x + width,
|
|
208
143
|
y2: y + height
|
|
209
144
|
});
|
|
210
|
-
|
|
145
|
+
itemPosition.x = itemPosition.x + dx, itemPosition.y = itemPosition.y + dy;
|
|
211
146
|
}
|
|
212
|
-
this.
|
|
213
|
-
this.
|
|
214
|
-
this.setDecorativeLineAttr(itemLine, newItemPosition, null === (_a = itemLine.decorativeLine) || void 0 === _a ? void 0 : _a.visible);
|
|
215
|
-
}
|
|
216
|
-
computeNewPositionAfterTargetItem(position) {
|
|
217
|
-
var _a;
|
|
218
|
-
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);
|
|
219
|
-
return {
|
|
220
|
-
newPosition: {
|
|
221
|
-
x: position.x + (targetSize + targetItemContentMargin) * Math.cos(targetOffsetAngle),
|
|
222
|
-
y: position.y + (targetSize + targetItemContentMargin) * Math.sin(targetOffsetAngle)
|
|
223
|
-
},
|
|
224
|
-
newItemPosition: {
|
|
225
|
-
x: position.x + (targetSize + targetItemContentMargin) * Math.cos(targetOffsetAngle) + itemContentOffsetX,
|
|
226
|
-
y: position.y + (targetSize + targetItemContentMargin) * Math.sin(targetOffsetAngle) + itemContentOffsetY
|
|
227
|
-
}
|
|
228
|
-
};
|
|
147
|
+
this.setItemAttributes(this._item, itemContent, itemPosition, type), this.setItemLineAttr(itemLine, position, itemPosition, itemLine.visible),
|
|
148
|
+
this.setDecorativeLineAttr(itemLine, itemPosition, null === (_a = itemLine.decorativeLine) || void 0 === _a ? void 0 : _a.visible);
|
|
229
149
|
}
|
|
230
150
|
initMarker(container) {
|
|
231
|
-
const {position: position, itemContent: itemContent = {},
|
|
151
|
+
const {position: position, itemContent: itemContent = {}, state: state} = this.attribute, itemPosition = {
|
|
152
|
+
x: position.x + (itemContent.offsetX || 0),
|
|
153
|
+
y: position.y + (itemContent.offsetY || 0)
|
|
154
|
+
}, line = new Segment({
|
|
232
155
|
points: [],
|
|
233
156
|
pickable: !1,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
startAngle: 0,
|
|
240
|
-
endAngle: 0
|
|
157
|
+
state: {
|
|
158
|
+
line: merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
|
|
159
|
+
startSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineStartSymbol),
|
|
160
|
+
endSymbol: merge({}, DEFAULT_STATES, null == state ? void 0 : state.lineEndSymbol)
|
|
161
|
+
}
|
|
241
162
|
});
|
|
242
163
|
line.name = "mark-point-line", this._line = line, container.add(line);
|
|
243
164
|
const decorativeLine = graphicCreator.line({
|
|
244
165
|
points: []
|
|
245
166
|
});
|
|
167
|
+
decorativeLine.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
|
|
246
168
|
decorativeLine.name = "mark-point-decorativeLine", this._decorativeLine = decorativeLine,
|
|
247
169
|
container.add(decorativeLine);
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
const item = this.initItem(itemContent, newPosition, newItemPosition);
|
|
251
|
-
this._item = item, container.add(item), this.setAllOfItemsAttr(newPosition, newItemPosition);
|
|
170
|
+
const item = this.initItem(itemContent, itemPosition);
|
|
171
|
+
this._item = item, this.setAllOfItemsAttr(itemPosition), container.add(item);
|
|
252
172
|
}
|
|
253
173
|
updateMarker() {
|
|
254
|
-
const {position: position, itemContent: itemContent = {}} = this.attribute, {type: type = "text"} = itemContent,
|
|
255
|
-
|
|
256
|
-
|
|
174
|
+
const {position: position, itemContent: itemContent = {}} = this.attribute, {type: type = "text"} = itemContent, itemPosition = {
|
|
175
|
+
x: position.x + (itemContent.offsetX || 0),
|
|
176
|
+
y: position.y + (itemContent.offsetY || 0)
|
|
177
|
+
};
|
|
178
|
+
this.setItemAttributes(this._item, itemContent, itemPosition, type), this.setAllOfItemsAttr(itemPosition);
|
|
257
179
|
}
|
|
258
180
|
isValidPoints() {
|
|
259
181
|
const {position: position} = this.attribute;
|