@visactor/vrender-components 0.19.4-alpha.1 → 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.
Files changed (143) hide show
  1. package/cjs/axis/util.js +2 -1
  2. package/cjs/brush/type.js +1 -2
  3. package/cjs/index.d.ts +1 -1
  4. package/cjs/index.js +1 -1
  5. package/cjs/index.js.map +1 -1
  6. package/cjs/label/arc.js +1 -2
  7. package/cjs/label/base.js +1 -1
  8. package/cjs/label/base.js.map +1 -1
  9. package/cjs/label/line.js +1 -1
  10. package/cjs/label/polygon.js +1 -1
  11. package/cjs/legend/base.js +1 -1
  12. package/cjs/legend/constant.js +1 -1
  13. package/cjs/legend/discrete/discrete.d.ts +1 -0
  14. package/cjs/legend/discrete/discrete.js +3 -0
  15. package/cjs/legend/discrete/discrete.js.map +1 -1
  16. package/cjs/legend/index.js +1 -1
  17. package/cjs/legend/register.js +1 -1
  18. package/cjs/legend/type.js +2 -1
  19. package/cjs/legend/util.js +1 -1
  20. package/cjs/link-path/index.js +1 -1
  21. package/cjs/link-path/link-path.js +1 -1
  22. package/cjs/link-path/register.js +1 -1
  23. package/cjs/link-path/type.js +1 -1
  24. package/cjs/marker/animate/common.js +4 -8
  25. package/cjs/marker/animate/common.js.map +1 -1
  26. package/cjs/marker/arc-area.js +4 -10
  27. package/cjs/marker/arc-area.js.map +1 -1
  28. package/cjs/marker/arc-line.js +2 -7
  29. package/cjs/marker/arc-line.js.map +1 -1
  30. package/cjs/marker/area.js +4 -10
  31. package/cjs/marker/area.js.map +1 -1
  32. package/cjs/marker/base.d.ts +1 -1
  33. package/cjs/marker/base.js.map +1 -1
  34. package/cjs/marker/common-line.d.ts +1 -1
  35. package/cjs/marker/common-line.js +5 -10
  36. package/cjs/marker/common-line.js.map +1 -1
  37. package/cjs/marker/config.d.ts +4 -16
  38. package/cjs/marker/config.js +56 -132
  39. package/cjs/marker/config.js.map +1 -1
  40. package/cjs/marker/line.d.ts +3 -3
  41. package/cjs/marker/line.js +7 -19
  42. package/cjs/marker/line.js.map +1 -1
  43. package/cjs/marker/point.d.ts +7 -41
  44. package/cjs/marker/point.js +69 -141
  45. package/cjs/marker/point.js.map +1 -1
  46. package/cjs/marker/register.js +2 -2
  47. package/cjs/marker/register.js.map +1 -1
  48. package/cjs/marker/type.d.ts +4 -12
  49. package/cjs/marker/type.js.map +1 -1
  50. package/cjs/scrollbar/scrollbar.js +4 -2
  51. package/cjs/scrollbar/scrollbar.js.map +1 -1
  52. package/cjs/scrollbar/type.d.ts +2 -0
  53. package/cjs/scrollbar/type.js.map +1 -1
  54. package/cjs/segment/arc-segment.d.ts +0 -3
  55. package/cjs/segment/arc-segment.js +1 -7
  56. package/cjs/segment/arc-segment.js.map +1 -1
  57. package/cjs/segment/register.d.ts +2 -2
  58. package/cjs/segment/register.js +2 -2
  59. package/cjs/segment/register.js.map +1 -1
  60. package/cjs/segment/segment.d.ts +0 -1
  61. package/cjs/segment/segment.js +1 -1
  62. package/cjs/segment/segment.js.map +1 -1
  63. package/cjs/util/common.d.ts +0 -3
  64. package/cjs/util/common.js +2 -13
  65. package/cjs/util/common.js.map +1 -1
  66. package/cjs/util/index.d.ts +0 -1
  67. package/cjs/util/index.js +1 -2
  68. package/cjs/util/index.js.map +1 -1
  69. package/es/axis/util.js +2 -1
  70. package/es/brush/type.js +1 -2
  71. package/es/index.d.ts +1 -1
  72. package/es/index.js +1 -1
  73. package/es/index.js.map +1 -1
  74. package/es/label/arc.js +1 -2
  75. package/es/label/base.js +1 -1
  76. package/es/label/base.js.map +1 -1
  77. package/es/label/line.js +1 -1
  78. package/es/label/polygon.js +1 -1
  79. package/es/legend/base.js +1 -1
  80. package/es/legend/constant.js +1 -1
  81. package/es/legend/discrete/discrete.d.ts +1 -0
  82. package/es/legend/discrete/discrete.js +3 -0
  83. package/es/legend/discrete/discrete.js.map +1 -1
  84. package/es/legend/index.js +1 -1
  85. package/es/legend/register.js +1 -1
  86. package/es/legend/type.js +2 -1
  87. package/es/legend/util.js +1 -1
  88. package/es/link-path/index.js +1 -1
  89. package/es/link-path/link-path.js +1 -1
  90. package/es/link-path/register.js +1 -1
  91. package/es/link-path/type.js +1 -1
  92. package/es/marker/animate/common.js +4 -8
  93. package/es/marker/animate/common.js.map +1 -1
  94. package/es/marker/arc-area.js +4 -10
  95. package/es/marker/arc-area.js.map +1 -1
  96. package/es/marker/arc-line.js +2 -7
  97. package/es/marker/arc-line.js.map +1 -1
  98. package/es/marker/area.js +4 -10
  99. package/es/marker/area.js.map +1 -1
  100. package/es/marker/base.d.ts +1 -1
  101. package/es/marker/base.js.map +1 -1
  102. package/es/marker/common-line.d.ts +1 -1
  103. package/es/marker/common-line.js +5 -10
  104. package/es/marker/common-line.js.map +1 -1
  105. package/es/marker/config.d.ts +4 -16
  106. package/es/marker/config.js +56 -132
  107. package/es/marker/config.js.map +1 -1
  108. package/es/marker/line.d.ts +3 -3
  109. package/es/marker/line.js +6 -20
  110. package/es/marker/line.js.map +1 -1
  111. package/es/marker/point.d.ts +7 -41
  112. package/es/marker/point.js +69 -142
  113. package/es/marker/point.js.map +1 -1
  114. package/es/marker/register.js +1 -2
  115. package/es/marker/register.js.map +1 -1
  116. package/es/marker/type.d.ts +4 -12
  117. package/es/marker/type.js.map +1 -1
  118. package/es/scrollbar/scrollbar.js +4 -2
  119. package/es/scrollbar/scrollbar.js.map +1 -1
  120. package/es/scrollbar/type.d.ts +2 -0
  121. package/es/scrollbar/type.js.map +1 -1
  122. package/es/segment/arc-segment.d.ts +0 -3
  123. package/es/segment/arc-segment.js +1 -7
  124. package/es/segment/arc-segment.js.map +1 -1
  125. package/es/segment/register.d.ts +2 -2
  126. package/es/segment/register.js +2 -2
  127. package/es/segment/register.js.map +1 -1
  128. package/es/segment/segment.d.ts +0 -1
  129. package/es/segment/segment.js +1 -1
  130. package/es/segment/segment.js.map +1 -1
  131. package/es/util/common.d.ts +0 -3
  132. package/es/util/common.js +0 -10
  133. package/es/util/common.js.map +1 -1
  134. package/es/util/index.d.ts +0 -1
  135. package/es/util/index.js +0 -2
  136. package/es/util/index.js.map +1 -1
  137. package/package.json +3 -3
  138. package/cjs/util/polar.d.ts +0 -2
  139. package/cjs/util/polar.js +0 -17
  140. package/cjs/util/polar.js.map +0 -1
  141. package/es/util/polar.d.ts +0 -2
  142. package/es/util/polar.js +0 -7
  143. 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(), 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);
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 (isPostiveXAxis(angle) ? angle : angle - Math.PI) + (null !== (_a = this.attribute.label.refAngle) && void 0 !== _a ? _a : 0);
54
+ return angle + (null !== (_a = this.attribute.label.refAngle) && void 0 !== _a ? _a : 0);
58
55
  }
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];
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, state: state} = this.attribute;
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() {
@@ -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;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,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,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,U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ACR;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,C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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,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,49 +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 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;
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, 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): {
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, 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
- };
88
+ protected setDecorativeLineAttr(itemLine: IItemLine, itemPosition: Point, visible: boolean): void;
89
+ protected setAllOfItemsAttr(itemPosition: Point): void;
124
90
  protected initMarker(container: IGroup): void;
125
91
  protected updateMarker(): void;
126
92
  protected isValidPoints(): boolean;
@@ -2,7 +2,7 @@ import { graphicCreator } from "@visactor/vrender-core";
2
2
 
3
3
  import { isValidNumber, merge } from "@visactor/vutils";
4
4
 
5
- import { ArcSegment, Segment } from "../segment";
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,36 +36,21 @@ export class MarkPoint extends Marker {
38
36
  this.defaultExitAnimation = DefaultExitMarkerAnimation;
39
37
  }
40
38
  setLabelPos() {}
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;
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: 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);
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);
54
43
  "text" === itemType ? item.setAttributes(Object.assign(Object.assign({}, textStyle), {
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),
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),
71
54
  angle: autoRotate && itemAngle + refAngle
72
55
  });
73
56
  }
@@ -81,85 +64,49 @@ export class MarkPoint extends Marker {
81
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;
82
65
  return position.includes("top") || position.includes("Top") ? -height : position.includes("middle") || position.includes("Middle") ? -height / 2 : 0;
83
66
  }
84
- initItem(itemContent, newItemPosition) {
67
+ initItem(itemContent, itemPosition) {
85
68
  const {state: state} = this.attribute, {type: type = "text", symbolStyle: symbolStyle, richTextStyle: richTextStyle, imageStyle: imageStyle, renderCustomCallback: renderCustomCallback} = itemContent;
86
69
  let item;
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), {
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), {
89
72
  state: {
90
73
  panel: merge({}, DEFAULT_STATES, null == state ? void 0 : state.textBackground),
91
74
  text: merge({}, DEFAULT_STATES, null == state ? void 0 : state.text)
92
75
  }
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)),
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)),
95
78
  item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.image)) : "custom" === type && renderCustomCallback && (item = renderCustomCallback(),
96
79
  item.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.customMark)),
97
- item.name = `mark-point-${type}`, this.setItemAttributes(item, itemContent, newItemPosition, type),
80
+ item.name = `mark-point-${type}`, this.setItemAttributes(item, itemContent, itemPosition, type),
98
81
  item;
99
82
  }
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
- };
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;
130
96
  }
131
- setItemLineAttr(itemLine, newPosition, newItemPosition, visible) {
97
+ setItemLineAttr(itemLine, position, itemPosition, visible) {
132
98
  if (this._line) {
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), {
99
+ const {startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle} = itemLine, points = this.getItemLineAttr(itemLine, position, itemPosition);
100
+ this._line.setAttributes({
101
+ points: points,
135
102
  startSymbol: startSymbol,
136
103
  endSymbol: endSymbol,
137
104
  lineStyle: lineStyle,
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
- }
105
+ visible: visible
106
+ });
160
107
  }
161
108
  }
162
- getDecorativeLineAttr(itemLine) {
109
+ getDecorativeLineAttr(itemLine, itemPosition) {
163
110
  var _a;
164
111
  const decorativeLength = (null === (_a = null == itemLine ? void 0 : itemLine.decorativeLine) || void 0 === _a ? void 0 : _a.length) || 10, itemAngle = this._line.getEndAngle() || 0;
165
112
  return {
@@ -169,34 +116,25 @@ export class MarkPoint extends Marker {
169
116
  endPointOffsetY: -decorativeLength / 2 * Math.sin(itemAngle - Math.PI / 2)
170
117
  };
171
118
  }
172
- setDecorativeLineAttr(itemLine, newItemPosition, visible) {
173
- var _a;
119
+ setDecorativeLineAttr(itemLine, itemPosition, visible) {
174
120
  if (this._decorativeLine) {
175
- 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);
176
122
  this._decorativeLine.setAttributes(Object.assign(Object.assign({
177
123
  points: [ {
178
- x: newItemPosition.x + startPointOffsetX,
179
- y: newItemPosition.y + startPointOffsetY
124
+ x: itemPosition.x + startPointOffsetX,
125
+ y: itemPosition.y + startPointOffsetY
180
126
  }, {
181
- x: newItemPosition.x + endPointOffsetX,
182
- y: newItemPosition.y + endPointOffsetY
127
+ x: itemPosition.x + endPointOffsetX,
128
+ y: itemPosition.y + endPointOffsetY
183
129
  } ]
184
130
  }, lineStyle), {
185
131
  visible: visible
186
- })), this._decorativeLine.states = merge({}, DEFAULT_STATES, null === (_a = this.attribute.state) || void 0 === _a ? void 0 : _a.line);
132
+ }));
187
133
  }
188
134
  }
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) {
135
+ setAllOfItemsAttr(itemPosition) {
198
136
  var _a;
199
- const {position: position, itemLine: itemLine = {}, itemContent: itemContent = {}, limitRect: limitRect, targetItemContent: targetItemContent} = this.attribute, {type: type = "text", confine: confine} = itemContent;
137
+ const {position: position, itemLine: itemLine = {}, itemContent: itemContent = {}, limitRect: limitRect} = this.attribute, {type: type = "text", confine: confine} = itemContent;
200
138
  if (limitRect && confine) {
201
139
  const {x: x, y: y, width: width, height: height} = limitRect, {dx: dx, dy: dy} = computeOffsetForlimit(this._item, {
202
140
  x1: x,
@@ -204,51 +142,40 @@ export class MarkPoint extends Marker {
204
142
  x2: x + width,
205
143
  y2: y + height
206
144
  });
207
- newItemPosition.x = newItemPosition.x + dx, newItemPosition.y = newItemPosition.y + dy;
145
+ itemPosition.x = itemPosition.x + dx, itemPosition.y = itemPosition.y + dy;
208
146
  }
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
- };
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);
225
149
  }
226
150
  initMarker(container) {
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)({
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({
228
155
  points: [],
229
156
  pickable: !1,
230
- center: {
231
- x: 0,
232
- y: 0
233
- },
234
- radius: 0,
235
- startAngle: 0,
236
- 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
+ }
237
162
  });
238
163
  line.name = "mark-point-line", this._line = line, container.add(line);
239
164
  const decorativeLine = graphicCreator.line({
240
165
  points: []
241
166
  });
167
+ decorativeLine.states = merge({}, DEFAULT_STATES, null == state ? void 0 : state.line),
242
168
  decorativeLine.name = "mark-point-decorativeLine", this._decorativeLine = decorativeLine,
243
169
  container.add(decorativeLine);
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);
170
+ const item = this.initItem(itemContent, itemPosition);
171
+ this._item = item, this.setAllOfItemsAttr(itemPosition), container.add(item);
248
172
  }
249
173
  updateMarker() {
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);
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);
252
179
  }
253
180
  isValidPoints() {
254
181
  const {position: position} = this.attribute;