@visactor/vrender-components 0.18.10-alpha.3 → 0.18.10-alpha.4

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 (59) hide show
  1. package/cjs/axis/base.js +4 -20
  2. package/cjs/axis/base.js.map +1 -1
  3. package/cjs/brush/brush.js +1 -2
  4. package/cjs/brush/type.js +2 -1
  5. package/cjs/index.d.ts +1 -1
  6. package/cjs/index.js +1 -1
  7. package/cjs/index.js.map +1 -1
  8. package/cjs/marker/arc-area.d.ts +1 -1
  9. package/cjs/marker/arc-area.js +4 -4
  10. package/cjs/marker/arc-area.js.map +1 -1
  11. package/cjs/marker/arc-line.d.ts +5 -5
  12. package/cjs/marker/arc-line.js +11 -15
  13. package/cjs/marker/arc-line.js.map +1 -1
  14. package/cjs/marker/area.d.ts +3 -3
  15. package/cjs/marker/area.js +12 -12
  16. package/cjs/marker/area.js.map +1 -1
  17. package/cjs/marker/base.d.ts +1 -0
  18. package/cjs/marker/base.js +12 -26
  19. package/cjs/marker/base.js.map +1 -1
  20. package/cjs/marker/{base-line.d.ts → common-line.d.ts} +3 -2
  21. package/cjs/marker/{base-line.js → common-line.js} +11 -9
  22. package/cjs/marker/common-line.js.map +1 -0
  23. package/cjs/marker/line.d.ts +6 -6
  24. package/cjs/marker/line.js +23 -27
  25. package/cjs/marker/line.js.map +1 -1
  26. package/cjs/util/interaction.d.ts +4 -0
  27. package/cjs/util/interaction.js +37 -0
  28. package/cjs/util/interaction.js.map +1 -0
  29. package/es/axis/base.js +7 -21
  30. package/es/axis/base.js.map +1 -1
  31. package/es/brush/brush.js +1 -2
  32. package/es/brush/type.js +2 -1
  33. package/es/index.d.ts +1 -1
  34. package/es/index.js +1 -1
  35. package/es/index.js.map +1 -1
  36. package/es/marker/arc-area.d.ts +1 -1
  37. package/es/marker/arc-area.js +4 -4
  38. package/es/marker/arc-area.js.map +1 -1
  39. package/es/marker/arc-line.d.ts +5 -5
  40. package/es/marker/arc-line.js +11 -15
  41. package/es/marker/arc-line.js.map +1 -1
  42. package/es/marker/area.d.ts +3 -3
  43. package/es/marker/area.js +12 -12
  44. package/es/marker/area.js.map +1 -1
  45. package/es/marker/base.d.ts +1 -0
  46. package/es/marker/base.js +12 -30
  47. package/es/marker/base.js.map +1 -1
  48. package/es/marker/{base-line.d.ts → common-line.d.ts} +3 -2
  49. package/es/marker/{base-line.js → common-line.js} +9 -7
  50. package/es/marker/common-line.js.map +1 -0
  51. package/es/marker/line.d.ts +6 -6
  52. package/es/marker/line.js +23 -27
  53. package/es/marker/line.js.map +1 -1
  54. package/es/util/interaction.d.ts +4 -0
  55. package/es/util/interaction.js +30 -0
  56. package/es/util/interaction.js.map +1 -0
  57. package/package.json +3 -3
  58. package/cjs/marker/base-line.js.map +0 -1
  59. package/es/marker/base-line.js.map +0 -1
@@ -15,6 +15,7 @@ export declare abstract class Marker<T extends MarkerAttrs> extends AbstractComp
15
15
  protected abstract isValidPoints(): any;
16
16
  setAttribute(key: string, value: any, forceUpdateTag?: boolean | undefined): void;
17
17
  private _bindEvent;
18
+ private _releaseEvent;
18
19
  private _onHover;
19
20
  private _onUnHover;
20
21
  private _onClick;
package/es/marker/base.js CHANGED
@@ -2,36 +2,16 @@ import { graphicCreator } from "@visactor/vrender-core";
2
2
 
3
3
  import { AbstractComponent } from "../core/base";
4
4
 
5
- import { StateValue } from "../constant";
6
-
7
- import { traverseGroup } from "../util";
8
-
9
- import { isEmpty } from "@visactor/vutils";
5
+ import { dispatchClickState, dispatchHoverState, dispatchUnHoverState } from "../util/interaction";
10
6
 
11
7
  export class Marker extends AbstractComponent {
12
8
  constructor() {
13
9
  super(...arguments), this.name = "marker", this._onHover = e => {
14
- const target = e.target;
15
- target !== this._lastHover && target.name && !isEmpty(target.states) && (target.addState(StateValue.hover, !0),
16
- traverseGroup(this._container, (node => {
17
- node !== target && node.name && !isEmpty(node.states) && node.addState(StateValue.hoverReverse, !0);
18
- })), this._lastHover = target);
10
+ this._lastHover = dispatchHoverState(e, this._container, this._lastHover);
19
11
  }, this._onUnHover = e => {
20
- this._lastHover && (traverseGroup(this._container, (node => {
21
- node.name && !isEmpty(node.states) && (node.removeState(StateValue.hoverReverse),
22
- node.removeState(StateValue.hover));
23
- })), this._lastHover = null);
12
+ this._lastHover = dispatchUnHoverState(e, this._container, this._lastHover);
24
13
  }, this._onClick = e => {
25
- const target = e.target;
26
- if (this._lastSelect === target && target.hasState(StateValue.selected)) return this._lastSelect = null,
27
- void traverseGroup(this._container, (node => {
28
- node.name && !isEmpty(node.states) && (node.removeState(StateValue.selectedReverse),
29
- node.removeState(StateValue.selected));
30
- }));
31
- target.name && !isEmpty(target.states) && (target.addState(StateValue.selected, !0),
32
- traverseGroup(this._container, (node => {
33
- node !== target && node.name && !isEmpty(node.states) && node.addState(StateValue.selectedReverse, !0);
34
- })), this._lastSelect = target);
14
+ this._lastSelect = dispatchClickState(e, this._container, this._lastSelect);
35
15
  };
36
16
  }
37
17
  setAttribute(key, value, forceUpdateTag) {
@@ -45,6 +25,12 @@ export class Marker extends AbstractComponent {
45
25
  null === (_b = this._container) || void 0 === _b || _b.addEventListener("pointerout", this._onUnHover)),
46
26
  select && (null === (_c = this._container) || void 0 === _c || _c.addEventListener("pointerdown", this._onClick));
47
27
  }
28
+ _releaseEvent() {
29
+ var _a, _b, _c;
30
+ null === (_a = this._container) || void 0 === _a || _a.removeEventListener("pointermove", this._onHover),
31
+ null === (_b = this._container) || void 0 === _b || _b.removeEventListener("pointerout", this._onUnHover),
32
+ null === (_c = this._container) || void 0 === _c || _c.removeEventListener("pointerdown", this._onClick);
33
+ }
48
34
  _initContainer() {
49
35
  var _a, _b;
50
36
  const {limitRect: limitRect = {}, clipInRange: clipInRange} = this.attribute;
@@ -82,14 +68,10 @@ export class Marker extends AbstractComponent {
82
68
  !1 === this.attribute.interactive && this.setAttribute("childrenPickable", !1),
83
69
  markerVisible && this.isValidPoints() ? this._container ? (this._updateContainer(),
84
70
  this.updateMarker()) : (this._initContainer(), this.initMarker(this._container)) : (this._container = null,
85
- this.removeAllChild(!0)), this._bindEvent();
71
+ this.removeAllChild(!0)), this._releaseEvent(), this._bindEvent();
86
72
  }
87
73
  release() {
88
- var _a, _b, _c;
89
- super.release(), null === (_a = this._container) || void 0 === _a || _a.removeEventListener("pointermove", this._onHover),
90
- null === (_b = this._container) || void 0 === _b || _b.removeEventListener("pointerout", this._onUnHover),
91
- null === (_c = this._container) || void 0 === _c || _c.removeEventListener("pointerdown", this._onClick),
92
- this._container = null;
74
+ super.release(), this._releaseEvent(), this._container = null;
93
75
  }
94
76
  }
95
77
  //# sourceMappingURL=base.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marker/base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,OAAgB,MAA8B,SAAQ,iBAA8B;IAA1F;;QACE,SAAI,GAAG,QAAQ,CAAC;QAoCR,aAAQ,GAAG,CAAC,CAAwB,EAAE,EAAE;YAC9C,MAAM,MAAM,GAAG,CAAC,CAAC,MAA6B,CAAC;YAC/C,IAAI,MAAM,KAAK,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;gBACxE,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBACxC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,IAAc,EAAE,EAAE;oBAChD,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI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B,CAAC,aAAa,EAAE,IAAI,CAAC,QAA8C,CAAC,CAAC;QACzG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;CACF","file":"base.js","sourcesContent":["import type { FederatedPointerEvent, IGraphic, IGroup } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport type { Tag } from '../tag';\nimport type { MarkerAttrs } from './type';\nimport { StateValue } from '../constant';\nimport { traverseGroup } from '../util';\nimport { isEmpty } from '@visactor/vutils';\n\nexport abstract class Marker<T extends MarkerAttrs> extends AbstractComponent<Required<T>> {\n name = 'marker';\n private _containerClip!: IGroup;\n private _container!: IGroup;\n\n protected _label!: Tag;\n private _lastHover: IGraphic;\n private _lastSelect: IGraphic;\n\n protected abstract setLabelPos(): any;\n protected abstract initMarker(container: IGroup): any;\n protected abstract updateMarker(): any;\n protected abstract isValidPoints(): any;\n\n setAttribute(key: string, value: any, forceUpdateTag?: boolean | undefined): void {\n super.setAttribute(key, value, forceUpdateTag);\n if (key === 'visible') {\n this.render();\n }\n }\n\n private _bindEvent() {\n if (!this.attribute.interactive) {\n return;\n }\n const { hover, select } = this.attribute;\n\n if (hover) {\n this._container?.addEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n this._container?.addEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n }\n\n if (select) {\n this._container?.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (target !== this._lastHover && target.name && !isEmpty(target.states)) {\n target.addState(StateValue.hover, true);\n traverseGroup(this._container, (node: IGraphic) => {\n if (node !== target && node.name && !isEmpty(node.states)) {\n node.addState(StateValue.hoverReverse, true);\n }\n });\n this._lastHover = target;\n }\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n if (this._lastHover) {\n traverseGroup(this._container, (node: IGraphic) => {\n if (node.name && !isEmpty(node.states)) {\n node.removeState(StateValue.hoverReverse);\n node.removeState(StateValue.hover);\n }\n });\n this._lastHover = null;\n }\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n const target = e.target as unknown as IGraphic;\n if (this._lastSelect === target && target.hasState(StateValue.selected)) {\n // 取消选中\n this._lastSelect = null;\n traverseGroup(this._container, (node: IGraphic) => {\n if (node.name && !isEmpty(node.states)) {\n node.removeState(StateValue.selectedReverse);\n node.removeState(StateValue.selected);\n }\n });\n return;\n }\n\n if (target.name && !isEmpty(target.states)) {\n target.addState(StateValue.selected, true);\n traverseGroup(this._container, (node: IGraphic) => {\n if (node !== target && node.name && !isEmpty(node.states)) {\n node.addState(StateValue.selectedReverse, true);\n }\n });\n this._lastSelect = target;\n }\n };\n\n private _initContainer() {\n const { limitRect = {} as T['limitRect'], clipInRange } = this.attribute;\n let group;\n if (clipInRange) {\n // 如果用户配置了剪切\n const groupClip = graphicCreator.group({\n ...limitRect,\n clip: true,\n pickable: false\n });\n group = graphicCreator.group({\n x: -(limitRect.x ?? 0),\n y: -(limitRect.y ?? 0),\n pickable: false\n });\n groupClip.add(group);\n this._containerClip = groupClip;\n this.add(groupClip);\n } else {\n group = graphicCreator.group({\n x: 0,\n y: 0,\n pickable: false\n });\n this.add(group);\n }\n group.name = 'marker-container';\n this._container = group;\n }\n\n private _updateContainer() {\n const { limitRect = {} as T['limitRect'], clipInRange } = this.attribute;\n if (this._containerClip) {\n this._containerClip.setAttributes({\n ...limitRect\n });\n }\n\n this._container.setAttributes({\n x: clipInRange ? -(limitRect.x ?? 0) : 0,\n y: clipInRange ? -(limitRect.y ?? 0) : 0\n });\n }\n\n protected render() {\n // 因为标注本身不规则,所以默认将组件的 group 设置为不可拾取\n this.setAttribute('pickable', false);\n\n const markerVisible = this.attribute.visible ?? true;\n if (this.attribute.interactive === false) {\n this.setAttribute('childrenPickable', false);\n }\n\n if (markerVisible && this.isValidPoints()) {\n if (!this._container) {\n this._initContainer();\n this.initMarker(this._container);\n } else {\n this._updateContainer();\n this.updateMarker();\n }\n } else {\n this._container = null;\n this.removeAllChild(true);\n }\n\n this._bindEvent();\n }\n\n release(): void {\n super.release();\n this._container?.removeEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n this._container?.removeEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n this._container?.removeEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n this._container = null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/marker/base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMjD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEnG,MAAM,OAAgB,MAA8B,SAAQ,iBAA8B;IAA1F;;QACE,SAAI,GAAG,QAAQ,CAAC;QA0CR,aAAQ,GAAG,CAAC,CAAwB,EAAE,EAAE;YAC9C,IAAI,CAAC,UAAU,GAAG,kBAAkB,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5E,CAAC,CAAC;QAEM,eAAU,GAAG,CAAC,CAAwB,EAAE,EAAE;YAChD,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9E,CAAC,CAAC;QAEM,aAAQ,GAAG,CAAC,CAAwB,EAAE,EAAE;YAC9C,IAAI,CAAC,WAAW,GAAG,kBAAkB,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9E,CAAC,CAAC;IA8EJ,CAAC;IArHC,YAAY,CAAC,GAAW,EAAE,KAAU,EAAE,cAAoC;QACxE,KAAK,CAAC,YAAY,CAAC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AAK,CAAC,CAAC;QAErC,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,SAAS,CAAC,OAAO,mCAAI,IAAI,CAAC;QACrD,IAAI,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,KAAK,EAAE;YACxC,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;SAC9C;QAED,IAAI,aAAa,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE;YACzC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBACpB,IAAI,CAAC,cAAc,EAAE,CAAC;gBACtB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aAClC;iBAAM;gBACL,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACxB,IAAI,CAAC,YAAY,EAAE,CAAC;aACrB;SACF;aAAM;YACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;SAC3B;QAGD,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;CACF","file":"base.js","sourcesContent":["import type { FederatedPointerEvent, IGraphic, IGroup } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport type { Tag } from '../tag';\nimport type { MarkerAttrs } from './type';\nimport { StateValue } from '../constant';\nimport { traverseGroup } from '../util';\nimport { isEmpty } from '@visactor/vutils';\nimport { dispatchClickState, dispatchHoverState, dispatchUnHoverState } from '../util/interaction';\n\nexport abstract class Marker<T extends MarkerAttrs> extends AbstractComponent<Required<T>> {\n name = 'marker';\n private _containerClip!: IGroup;\n private _container!: IGroup;\n\n protected _label!: Tag;\n private _lastHover: IGraphic;\n private _lastSelect: IGraphic;\n\n protected abstract setLabelPos(): any;\n protected abstract initMarker(container: IGroup): any;\n protected abstract updateMarker(): any;\n protected abstract isValidPoints(): any;\n\n setAttribute(key: string, value: any, forceUpdateTag?: boolean | undefined): void {\n super.setAttribute(key, value, forceUpdateTag);\n if (key === 'visible') {\n this.render();\n }\n }\n\n private _bindEvent() {\n if (!this.attribute.interactive) {\n return;\n }\n const { hover, select } = this.attribute;\n\n if (hover) {\n this._container?.addEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n this._container?.addEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n }\n\n if (select) {\n this._container?.addEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n }\n\n private _releaseEvent() {\n this._container?.removeEventListener('pointermove', this._onHover as EventListenerOrEventListenerObject);\n this._container?.removeEventListener('pointerout', this._onUnHover as EventListenerOrEventListenerObject);\n this._container?.removeEventListener('pointerdown', this._onClick as EventListenerOrEventListenerObject);\n }\n\n private _onHover = (e: FederatedPointerEvent) => {\n this._lastHover = dispatchHoverState(e, this._container, this._lastHover);\n };\n\n private _onUnHover = (e: FederatedPointerEvent) => {\n this._lastHover = dispatchUnHoverState(e, this._container, this._lastHover);\n };\n\n private _onClick = (e: FederatedPointerEvent) => {\n this._lastSelect = dispatchClickState(e, this._container, this._lastSelect);\n };\n\n private _initContainer() {\n const { limitRect = {} as T['limitRect'], clipInRange } = this.attribute;\n let group;\n if (clipInRange) {\n // 如果用户配置了剪切\n const groupClip = graphicCreator.group({\n ...limitRect,\n clip: true,\n pickable: false\n });\n group = graphicCreator.group({\n x: -(limitRect.x ?? 0),\n y: -(limitRect.y ?? 0),\n pickable: false\n });\n groupClip.add(group);\n this._containerClip = groupClip;\n this.add(groupClip);\n } else {\n group = graphicCreator.group({\n x: 0,\n y: 0,\n pickable: false\n });\n this.add(group);\n }\n group.name = 'marker-container';\n this._container = group;\n }\n\n private _updateContainer() {\n const { limitRect = {} as T['limitRect'], clipInRange } = this.attribute;\n if (this._containerClip) {\n this._containerClip.setAttributes({\n ...limitRect\n });\n }\n\n this._container.setAttributes({\n x: clipInRange ? -(limitRect.x ?? 0) : 0,\n y: clipInRange ? -(limitRect.y ?? 0) : 0\n });\n }\n\n protected render() {\n // 因为标注本身不规则,所以默认将组件的 group 设置为不可拾取\n this.setAttribute('pickable', false);\n\n const markerVisible = this.attribute.visible ?? true;\n if (this.attribute.interactive === false) {\n this.setAttribute('childrenPickable', false);\n }\n\n if (markerVisible && this.isValidPoints()) {\n if (!this._container) {\n this._initContainer();\n this.initMarker(this._container);\n } else {\n this._updateContainer();\n this.updateMarker();\n }\n } else {\n this._container = null;\n this.removeAllChild(true);\n }\n\n // 先把之前的event都release掉,否则会重复触发\n this._releaseEvent();\n this._bindEvent();\n }\n\n release(): void {\n super.release();\n this._releaseEvent();\n this._container = null;\n }\n}\n"]}
@@ -3,12 +3,13 @@ import type { ArcSegment, Segment } from '../segment';
3
3
  import { Tag } from '../tag';
4
4
  import type { CommonMarkLineAttrs } from './type';
5
5
  import { Marker } from './base';
6
- export declare abstract class BaseMarkLine<LineAttr, LabelPosition> extends Marker<CommonMarkLineAttrs<LineAttr, LabelPosition>> {
6
+ export declare abstract class MarkCommonLine<LineAttr, LabelPosition> extends Marker<CommonMarkLineAttrs<LineAttr, LabelPosition>> {
7
7
  name: string;
8
8
  protected _line: Segment | ArcSegment;
9
9
  protected abstract createSegment(): any;
10
10
  protected abstract setLineAttributes(): any;
11
- protected abstract getPositionByDirection(direction: any): any;
11
+ protected abstract getPointAttrByPosition(position: any): any;
12
+ protected abstract getRotateByAngle(angle: number): number;
12
13
  getLine(): Segment | ArcSegment;
13
14
  getLabel(): Tag;
14
15
  protected setLabelPos(): void;
@@ -8,9 +8,9 @@ import { DEFAULT_STATES } from "../constant";
8
8
 
9
9
  import { Marker } from "./base";
10
10
 
11
- export class BaseMarkLine extends Marker {
11
+ export class MarkCommonLine extends Marker {
12
12
  constructor() {
13
- super(...arguments), this.name = "baseMarkLine";
13
+ super(...arguments), this.name = "markCommonLine";
14
14
  }
15
15
  getLine() {
16
16
  return this._line;
@@ -19,8 +19,10 @@ export class BaseMarkLine extends Marker {
19
19
  return this._label;
20
20
  }
21
21
  setLabelPos() {
22
- const {label: label = {}, limitRect: limitRect} = this.attribute, {position: position = "end", refX: refX = 0, refY: refY = 0, confine: confine} = label, labelPoint = this.getPositionByDirection(position);
23
- if (this._label.setAttributes(Object.assign({}, labelPoint)), limitRect && confine) {
22
+ const {label: label = {}, limitRect: limitRect} = this.attribute, {position: position, confine: confine, autoRotate: autoRotate = !0} = label, labelPoint = this.getPointAttrByPosition(position);
23
+ if (this._label.setAttributes(Object.assign(Object.assign({}, labelPoint.position), {
24
+ angle: autoRotate ? this.getRotateByAngle(labelPoint.angle) : 0
25
+ })), limitRect && confine) {
24
26
  const {x: x, y: y, width: width, height: height} = limitRect;
25
27
  limitShapeInBounds(this._label, {
26
28
  x1: x,
@@ -32,14 +34,14 @@ export class BaseMarkLine extends Marker {
32
34
  }
33
35
  initMarker(container) {
34
36
  const {label: label, state: state} = this.attribute, line = this.createSegment();
35
- line.name = "cartesian-mark-line-line", this._line = line, container.add(line);
37
+ line.name = "mark-common-line-line", this._line = line, container.add(line);
36
38
  const markLabel = new Tag(Object.assign(Object.assign({}, label), {
37
39
  state: {
38
40
  panel: merge({}, DEFAULT_STATES, null == state ? void 0 : state.labelBackground),
39
41
  text: merge({}, DEFAULT_STATES, null == state ? void 0 : state.label)
40
42
  }
41
43
  }));
42
- markLabel.name = "cartesian-mark-line-label", this._label = markLabel, container.add(markLabel),
44
+ markLabel.name = "mark-common-line-label", this._label = markLabel, container.add(markLabel),
43
45
  this.setLabelPos();
44
46
  }
45
47
  updateMarker() {
@@ -50,4 +52,4 @@ export class BaseMarkLine extends Marker {
50
52
  }, label)), this.setLabelPos();
51
53
  }
52
54
  }
53
- //# sourceMappingURL=base-line.js.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{ merge } from '@visactor/vutils';\nimport type { ArcSegment, Segment } from '../segment';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport type { CommonMarkLineAttrs } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport { DEFAULT_STATES } from '../constant';\nimport { Marker } from './base';\n\nexport abstract class MarkCommonLine<LineAttr, LabelPosition> extends Marker<\n CommonMarkLineAttrs<LineAttr, LabelPosition>\n> {\n name = 'markCommonLine';\n\n protected _line!: Segment | ArcSegment;\n\n protected abstract createSegment(): any;\n protected abstract setLineAttributes(): any;\n protected abstract getPointAttrByPosition(position: any): any;\n protected abstract getRotateByAngle(angle: number): number;\n\n getLine() {\n return this._line;\n }\n getLabel() {\n return this._label;\n }\n\n protected setLabelPos() {\n const { label = {}, limitRect } = this.attribute;\n const { position, confine, autoRotate = true } = label;\n const labelPoint = this.getPointAttrByPosition(position);\n this._label.setAttributes({\n ...labelPoint.position,\n angle: autoRotate ? this.getRotateByAngle(labelPoint.angle) : 0\n });\n if (limitRect && confine) {\n const { x, y, width, height } = limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n\n protected initMarker(container: IGroup) {\n const { label, state } = this.attribute as CommonMarkLineAttrs<LineAttr, LabelPosition>;\n const line = this.createSegment();\n line.name = 'mark-common-line-line';\n this._line = line;\n container.add(line as unknown as INode);\n\n const markLabel = new Tag({\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\n });\n markLabel.name = 'mark-common-line-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { label } = this.attribute as CommonMarkLineAttrs<LineAttr, LabelPosition>;\n\n this.setLineAttributes();\n\n if (this._label) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes)\n });\n }\n\n this.setLabelPos();\n }\n}\n"]}
@@ -1,28 +1,28 @@
1
1
  import { IMarkLineLabelPosition } from './type';
2
2
  import type { MarkLineAttrs } from './type';
3
3
  import type { ComponentOptions } from '../interface';
4
- import { BaseMarkLine } from './base-line';
4
+ import { MarkCommonLine } from './common-line';
5
5
  import type { ArcSegment } from '../segment';
6
6
  import { Segment } from '../segment';
7
7
  import type { ILineGraphicAttribute } from '@visactor/vrender-core';
8
- export declare class MarkLine extends BaseMarkLine<ILineGraphicAttribute, IMarkLineLabelPosition> {
8
+ export declare class MarkLine extends MarkCommonLine<ILineGraphicAttribute, IMarkLineLabelPosition> {
9
9
  name: string;
10
10
  static defaultAttributes: Partial<MarkLineAttrs>;
11
11
  protected _line: Segment | ArcSegment;
12
12
  constructor(attributes: MarkLineAttrs, options?: ComponentOptions);
13
- protected isValidPoints(): boolean;
14
- protected getLabelOffsetByDirection(direction: IMarkLineLabelPosition): {
13
+ protected getLabelOffsetByPosition(position: IMarkLineLabelPosition): {
15
14
  offsetX: number;
16
15
  offsetY: number;
17
16
  };
18
- protected getPositionByDirection(direction: IMarkLineLabelPosition): {
17
+ protected getPointAttrByPosition(position: IMarkLineLabelPosition): {
19
18
  position: {
20
19
  x: number;
21
20
  y: number;
22
21
  };
23
22
  angle: number;
24
23
  };
25
- protected setLabelPos(): void;
24
+ protected getRotateByAngle(angle: number): number;
26
25
  protected createSegment(): Segment;
27
26
  protected setLineAttributes(): void;
27
+ protected isValidPoints(): boolean;
28
28
  }
package/es/marker/line.js CHANGED
@@ -4,7 +4,7 @@ import { IMarkLineLabelPosition } from "./type";
4
4
 
5
5
  import { loadMarkLineComponent } from "./register";
6
6
 
7
- import { BaseMarkLine } from "./base-line";
7
+ import { MarkCommonLine } from "./common-line";
8
8
 
9
9
  import { Segment } from "../segment";
10
10
 
@@ -14,25 +14,15 @@ import { DEFAULT_MARK_LINE_THEME } from "./config";
14
14
 
15
15
  loadMarkLineComponent();
16
16
 
17
- export class MarkLine extends BaseMarkLine {
17
+ export class MarkLine extends MarkCommonLine {
18
18
  constructor(attributes, options) {
19
19
  super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, MarkLine.defaultAttributes, attributes)),
20
- this.name = "MarkLine";
20
+ this.name = "markLine";
21
21
  }
22
- isValidPoints() {
23
- const {points: points} = this.attribute;
24
- if (!points || points.length < 2) return !1;
25
- let validFlag = !0;
26
- return points.forEach((point => {
27
- if (point.length) point.forEach((p => {
28
- isValidNumber(p.x) && isValidNumber(p.y) || (validFlag = !1);
29
- })); else if (!isValidNumber(point.x) || !isValidNumber(point.y)) return void (validFlag = !1);
30
- })), validFlag;
31
- }
32
- getLabelOffsetByDirection(direction) {
33
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
34
- const labelRectHeight = Math.abs((null !== (_b = null === (_a = this._label.getTextShape().AABBBounds) || void 0 === _a ? void 0 : _a.y2) && void 0 !== _b ? _b : 0) - (null !== (_d = null === (_c = this._label.getTextShape()) || void 0 === _c ? void 0 : _c.AABBBounds.y1) && void 0 !== _d ? _d : 0)), labelTextHeight = Math.abs((null !== (_f = null === (_e = this._label.getBgRect().AABBBounds) || void 0 === _e ? void 0 : _e.y2) && void 0 !== _f ? _f : 0) - (null !== (_h = null === (_g = this._label.getBgRect()) || void 0 === _g ? void 0 : _g.AABBBounds.y1) && void 0 !== _h ? _h : 0)), labelHeight = Math.max(labelRectHeight, labelTextHeight), labelRectWidth = Math.abs((null !== (_k = null === (_j = this._label.getTextShape().AABBBounds) || void 0 === _j ? void 0 : _j.x2) && void 0 !== _k ? _k : 0) - (null !== (_m = null === (_l = this._label.getTextShape()) || void 0 === _l ? void 0 : _l.AABBBounds.x1) && void 0 !== _m ? _m : 0)), labelTextWidth = Math.abs((null !== (_p = null === (_o = this._label.getBgRect().AABBBounds) || void 0 === _o ? void 0 : _o.x2) && void 0 !== _p ? _p : 0) - (null !== (_r = null === (_q = this._label.getBgRect()) || void 0 === _q ? void 0 : _q.AABBBounds.x1) && void 0 !== _r ? _r : 0)), labelWidth = Math.max(labelRectWidth, labelTextWidth);
35
- switch (direction) {
22
+ getLabelOffsetByPosition(position) {
23
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
24
+ const labelRectHeight = Math.abs((null !== (_c = null === (_b = null === (_a = this._label.getTextShape()) || void 0 === _a ? void 0 : _a.AABBBounds) || void 0 === _b ? void 0 : _b.y2) && void 0 !== _c ? _c : 0) - (null !== (_e = null === (_d = this._label.getTextShape()) || void 0 === _d ? void 0 : _d.AABBBounds.y1) && void 0 !== _e ? _e : 0)), labelTextHeight = Math.abs((null !== (_h = null === (_g = null === (_f = this._label.getBgRect()) || void 0 === _f ? void 0 : _f.AABBBounds) || void 0 === _g ? void 0 : _g.y2) && void 0 !== _h ? _h : 0) - (null !== (_k = null === (_j = this._label.getBgRect()) || void 0 === _j ? void 0 : _j.AABBBounds.y1) && void 0 !== _k ? _k : 0)), labelHeight = Math.max(labelRectHeight, labelTextHeight), labelRectWidth = Math.abs((null !== (_o = null === (_m = null === (_l = this._label.getTextShape()) || void 0 === _l ? void 0 : _l.AABBBounds) || void 0 === _m ? void 0 : _m.x2) && void 0 !== _o ? _o : 0) - (null !== (_q = null === (_p = this._label.getTextShape()) || void 0 === _p ? void 0 : _p.AABBBounds.x1) && void 0 !== _q ? _q : 0)), labelTextWidth = Math.abs((null !== (_t = null === (_s = null === (_r = this._label.getBgRect()) || void 0 === _r ? void 0 : _r.AABBBounds) || void 0 === _s ? void 0 : _s.x2) && void 0 !== _t ? _t : 0) - (null !== (_v = null === (_u = this._label.getBgRect()) || void 0 === _u ? void 0 : _u.AABBBounds.x1) && void 0 !== _v ? _v : 0)), labelWidth = Math.max(labelRectWidth, labelTextWidth);
25
+ switch (position) {
36
26
  case IMarkLineLabelPosition.start:
37
27
  return {
38
28
  offsetX: -labelWidth / 2,
@@ -94,16 +84,16 @@ export class MarkLine extends BaseMarkLine {
94
84
  };
95
85
  }
96
86
  }
97
- getPositionByDirection(direction) {
87
+ getPointAttrByPosition(position) {
98
88
  var _a;
99
- 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, totalRefX = refX + this.getLabelOffsetByDirection(direction).offsetX, totalRefY = refY + this.getLabelOffsetByDirection(direction).offsetY, labelOffsetX = totalRefX * Math.cos(labelAngle) + totalRefY * Math.cos(labelAngle - Math.PI / 2), labelOffsetY = totalRefX * Math.sin(labelAngle) + totalRefY * Math.sin(labelAngle - Math.PI / 2);
100
- return direction.includes("start") || direction.includes("Start") ? {
89
+ 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, totalRefX = refX + this.getLabelOffsetByPosition(position).offsetX, totalRefY = refY + this.getLabelOffsetByPosition(position).offsetY, labelOffsetX = totalRefX * Math.cos(labelAngle) + totalRefY * Math.cos(labelAngle - Math.PI / 2), labelOffsetY = totalRefX * Math.sin(labelAngle) + totalRefY * Math.sin(labelAngle - Math.PI / 2);
90
+ return position.includes("start") || position.includes("Start") ? {
101
91
  position: {
102
92
  x: points[0].x + labelOffsetX,
103
93
  y: points[0].y + labelOffsetY
104
94
  },
105
95
  angle: labelAngle
106
- } : direction.includes("middle") || direction.includes("Middle") ? {
96
+ } : position.includes("middle") || position.includes("Middle") ? {
107
97
  position: {
108
98
  x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
109
99
  y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
@@ -117,13 +107,9 @@ export class MarkLine extends BaseMarkLine {
117
107
  angle: labelAngle
118
108
  };
119
109
  }
120
- setLabelPos() {
110
+ getRotateByAngle(angle) {
121
111
  var _a;
122
- super.setLabelPos();
123
- const {label: label = {}} = this.attribute, {position: position = "end", autoRotate: autoRotate = !0} = label, labelAttr = this.getPositionByDirection(position);
124
- this._label.setAttributes(Object.assign(Object.assign({}, labelAttr.position), {
125
- angle: autoRotate ? labelAttr.angle + (null !== (_a = label.refAngle) && void 0 !== _a ? _a : 0) : 0
126
- }));
112
+ return angle + (null !== (_a = this.attribute.label.refAngle) && void 0 !== _a ? _a : 0);
127
113
  }
128
114
  createSegment() {
129
115
  const {points: points, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, mainSegmentIndex: mainSegmentIndex, multiSegment: multiSegment, state: state} = this.attribute;
@@ -153,6 +139,16 @@ export class MarkLine extends BaseMarkLine {
153
139
  multiSegment: multiSegment
154
140
  });
155
141
  }
142
+ isValidPoints() {
143
+ const {points: points} = this.attribute;
144
+ if (!points || points.length < 2) return !1;
145
+ let validFlag = !0;
146
+ return points.forEach((point => {
147
+ if (point.length) point.forEach((p => {
148
+ isValidNumber(p.x) && isValidNumber(p.y) || (validFlag = !1);
149
+ })); else if (!isValidNumber(point.x) || !isValidNumber(point.y)) return void (validFlag = !1);
150
+ })), validFlag;
151
+ }
156
152
  }
157
153
 
158
154
  MarkLine.defaultAttributes = DEFAULT_MARK_LINE_THEME;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marker/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGnD,qBAAqB,EAAE,CAAC;AACxB,MAAM,OAAO,Q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,SAA0B,CAAC;QAC9B,OAAO,IAAI,OAAO,CAAC;YACjB,MAAM;YACN,WAAW;YACX,SAAS;YACT,SAAS;YACT,gBAAgB;YAChB,YAAY;YACZ,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAC;gBAC5C,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAC;gBAC9D,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,CAAC;aAC3D;SACF,CAAC,CAAC;IACL,CAAC;IAES,iBAAiB;QACzB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,IAAI;aACvF,SAA0B,CAAC;QAC9B,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;gBACvB,MAAM;gBACN,WAAW;gBACX,SAAS;gBACT,SAAS;gBACT,gBAAgB;gBAChB,YAAY;aACb,CAAC,CAAC;SACJ;IACH,CAAC;;AA3LM,0BAAiB,GAA2B,uBAAmD,CAAC","file":"line.js","sourcesContent":["import { isValidNumber, merge } from '@visactor/vutils';\nimport { IMarkLineLabelPosition } from './type';\nimport type { MarkLineAttrs } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkLineComponent } from './register';\nimport type { Point } from '../core/type';\nimport { BaseMarkLine } from './base-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_MARK_LINE_THEME } from './config';\nimport type { ILineGraphicAttribute } from '@visactor/vrender-core';\n\nloadMarkLineComponent();\nexport class MarkLine extends BaseMarkLine<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 constructor(attributes: MarkLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkLine.defaultAttributes, attributes));\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 protected getLabelOffsetByDirection(direction: IMarkLineLabelPosition) {\n // labelHeight\n // eslint-disable-next-line max-len\n const labelRectHeight = Math.abs(\n (this._label.getTextShape().AABBBounds?.y2 ?? 0) - (this._label.getTextShape()?.AABBBounds.y1 ?? 0)\n );\n // eslint-disable-next-line max-len\n const labelTextHeight = Math.abs(\n (this._label.getBgRect().AABBBounds?.y2 ?? 0) - (this._label.getBgRect()?.AABBBounds.y1 ?? 0)\n );\n const labelHeight = Math.max(labelRectHeight, labelTextHeight);\n\n // labelWidth\n // eslint-disable-next-line max-len\n const labelRectWidth = Math.abs(\n (this._label.getTextShape().AABBBounds?.x2 ?? 0) - (this._label.getTextShape()?.AABBBounds.x1 ?? 0)\n );\n // eslint-disable-next-line max-len\n const labelTextWidth = Math.abs(\n (this._label.getBgRect().AABBBounds?.x2 ?? 0) - (this._label.getBgRect()?.AABBBounds.x1 ?? 0)\n );\n const labelWidth = Math.max(labelRectWidth, labelTextWidth);\n\n switch (direction) {\n case IMarkLineLabelPosition.start:\n return {\n offsetX: -labelWidth / 2,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideStartTop:\n return {\n offsetX: labelWidth / 2,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideStartBottom:\n return {\n offsetX: labelWidth / 2,\n offsetY: -labelHeight / 2\n };\n case IMarkLineLabelPosition.middle:\n return {\n offsetX: 0,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideMiddleTop:\n return {\n offsetX: 0,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideMiddleBottom:\n return {\n offsetX: 0,\n offsetY: -labelHeight / 2\n };\n case IMarkLineLabelPosition.end:\n return {\n offsetX: labelWidth / 2,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideEndTop:\n return {\n offsetX: -labelWidth / 2,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideEndBottom:\n return {\n offsetX: -labelWidth / 2,\n offsetY: -labelHeight / 2\n };\n default: // default end\n return {\n offsetX: labelWidth / 2,\n offsetY: 0\n };\n }\n }\n\n protected getPositionByDirection(direction: 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 totalRefX = refX + this.getLabelOffsetByDirection(direction).offsetX;\n const totalRefY = refY + this.getLabelOffsetByDirection(direction).offsetY;\n\n const labelOffsetX = totalRefX * Math.cos(labelAngle) + totalRefY * Math.cos(labelAngle - Math.PI / 2);\n const labelOffsetY = totalRefX * Math.sin(labelAngle) + totalRefY * Math.sin(labelAngle - Math.PI / 2);\n\n if (direction.includes('start') || direction.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 (direction.includes('middle') || direction.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 setLabelPos(): void {\n super.setLabelPos();\n const { label = {} } = this.attribute as MarkLineAttrs;\n const { position = 'end', autoRotate = true } = label;\n const labelAttr = this.getPositionByDirection(position as any);\n this._label.setAttributes({\n ...labelAttr.position,\n angle: autoRotate ? labelAttr.angle + (label.refAngle ?? 0) : 0\n });\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"]}
1
+ {"version":3,"sources":["../src/marker/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAGhD,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,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGn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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;;AAhLM,0BAAiB,GAA2B,uBAAmD,CAAC","file":"line.js","sourcesContent":["import { isValidNumber, merge } from '@visactor/vutils';\nimport { IMarkLineLabelPosition } from './type';\nimport type { MarkLineAttrs } 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_MARK_LINE_THEME } from './config';\nimport type { ILineGraphicAttribute } from '@visactor/vrender-core';\n\nloadMarkLineComponent();\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 constructor(attributes: MarkLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkLine.defaultAttributes, attributes));\n }\n\n protected getLabelOffsetByPosition(position: IMarkLineLabelPosition) {\n // labelHeight\n const labelRectHeight = Math.abs(\n (this._label.getTextShape()?.AABBBounds?.y2 ?? 0) - (this._label.getTextShape()?.AABBBounds.y1 ?? 0)\n );\n const labelTextHeight = Math.abs(\n (this._label.getBgRect()?.AABBBounds?.y2 ?? 0) - (this._label.getBgRect()?.AABBBounds.y1 ?? 0)\n );\n const labelHeight = Math.max(labelRectHeight, labelTextHeight);\n\n // labelWidth\n const labelRectWidth = Math.abs(\n (this._label.getTextShape()?.AABBBounds?.x2 ?? 0) - (this._label.getTextShape()?.AABBBounds.x1 ?? 0)\n );\n const labelTextWidth = Math.abs(\n (this._label.getBgRect()?.AABBBounds?.x2 ?? 0) - (this._label.getBgRect()?.AABBBounds.x1 ?? 0)\n );\n const labelWidth = Math.max(labelRectWidth, labelTextWidth);\n\n switch (position) {\n case IMarkLineLabelPosition.start:\n return {\n offsetX: -labelWidth / 2,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideStartTop:\n return {\n offsetX: labelWidth / 2,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideStartBottom:\n return {\n offsetX: labelWidth / 2,\n offsetY: -labelHeight / 2\n };\n case IMarkLineLabelPosition.middle:\n return {\n offsetX: 0,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideMiddleTop:\n return {\n offsetX: 0,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideMiddleBottom:\n return {\n offsetX: 0,\n offsetY: -labelHeight / 2\n };\n case IMarkLineLabelPosition.end:\n return {\n offsetX: labelWidth / 2,\n offsetY: 0\n };\n case IMarkLineLabelPosition.insideEndTop:\n return {\n offsetX: -labelWidth / 2,\n offsetY: labelHeight / 2\n };\n case IMarkLineLabelPosition.insideEndBottom:\n return {\n offsetX: -labelWidth / 2,\n offsetY: -labelHeight / 2\n };\n default: // default end\n return {\n offsetX: labelWidth / 2,\n offsetY: 0\n };\n }\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 totalRefX = refX + this.getLabelOffsetByPosition(position).offsetX;\n const totalRefY = refY + this.getLabelOffsetByPosition(position).offsetY;\n\n const labelOffsetX = totalRefX * Math.cos(labelAngle) + totalRefY * Math.cos(labelAngle - Math.PI / 2);\n const labelOffsetY = totalRefX * Math.sin(labelAngle) + totalRefY * 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 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"]}
@@ -0,0 +1,4 @@
1
+ import type { FederatedPointerEvent, IGraphic, IGroup } from '@visactor/vrender-core';
2
+ export declare const dispatchHoverState: (e: FederatedPointerEvent, container: IGroup, lastHover: IGraphic | null) => IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
3
+ export declare const dispatchUnHoverState: (e: FederatedPointerEvent, container: IGroup, lastHover: IGraphic | null) => IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
4
+ export declare const dispatchClickState: (e: FederatedPointerEvent, container: IGroup, lastSelect: IGraphic | null) => IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
@@ -0,0 +1,30 @@
1
+ import { StateValue } from "../constant";
2
+
3
+ import { traverseGroup } from "../util";
4
+
5
+ import { isEmpty } from "@visactor/vutils";
6
+
7
+ export const dispatchHoverState = (e, container, lastHover) => {
8
+ const target = e.target;
9
+ return target !== lastHover && target.name && !isEmpty(target.states) ? (target.addState(StateValue.hover, !0),
10
+ traverseGroup(container, (node => {
11
+ node !== target && node.name && !isEmpty(node.states) && node.addState(StateValue.hoverReverse, !0);
12
+ })), target) : lastHover;
13
+ };
14
+
15
+ export const dispatchUnHoverState = (e, container, lastHover) => lastHover ? (traverseGroup(container, (node => {
16
+ node.name && !isEmpty(node.states) && (node.removeState(StateValue.hoverReverse),
17
+ node.removeState(StateValue.hover));
18
+ })), null) : lastHover;
19
+
20
+ export const dispatchClickState = (e, container, lastSelect) => {
21
+ const target = e.target;
22
+ return lastSelect === target && target.hasState(StateValue.selected) ? (traverseGroup(container, (node => {
23
+ node.name && !isEmpty(node.states) && (node.removeState(StateValue.selectedReverse),
24
+ node.removeState(StateValue.selected));
25
+ })), null) : target.name && !isEmpty(target.states) ? (target.addState(StateValue.selected, !0),
26
+ traverseGroup(container, (node => {
27
+ node !== target && node.name && !isEmpty(node.states) && node.addState(StateValue.selectedReverse, !0);
28
+ })), target) : lastSelect;
29
+ };
30
+ //# sourceMappingURL=interaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/util/interaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAwB,EAAE,SAAiB,EAAE,SAA0B,EAAE,EAAE;IAC5G,MAAM,MAAM,GAAG,CAAC,CAAC,MAA6B,CAAC;IAC/C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAClE,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACxC,aAAa,CAAC,SAAS,EAAE,CAAC,IAAc,EAAE,EAAE;YAC1C,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBACzD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;KACf;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAwB,EAAE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,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBACzD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;aACjD;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;KACf;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC","file":"interaction.js","sourcesContent":["import type { FederatedPointerEvent, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { StateValue } from '../constant';\nimport { traverseGroup } from '../util';\nimport { isEmpty } from '@visactor/vutils';\n\nexport const dispatchHoverState = (e: FederatedPointerEvent, container: IGroup, lastHover: IGraphic | null) => {\n const target = e.target as unknown as IGraphic;\n if (target !== lastHover && target.name && !isEmpty(target.states)) {\n target.addState(StateValue.hover, true);\n traverseGroup(container, (node: IGraphic) => {\n if (node !== target && node.name && !isEmpty(node.states)) {\n node.addState(StateValue.hoverReverse, true);\n }\n });\n return target;\n }\n return lastHover;\n};\n\nexport const dispatchUnHoverState = (e: FederatedPointerEvent, container: IGroup, lastHover: IGraphic | null) => {\n if (lastHover) {\n traverseGroup(container, (node: IGraphic) => {\n if (node.name && !isEmpty(node.states)) {\n node.removeState(StateValue.hoverReverse);\n node.removeState(StateValue.hover);\n }\n });\n return null;\n }\n return lastHover;\n};\n\nexport const dispatchClickState = (e: FederatedPointerEvent, container: IGroup, lastSelect: IGraphic | null) => {\n const target = e.target as unknown as IGraphic;\n if (lastSelect === target && target.hasState(StateValue.selected)) {\n traverseGroup(container, (node: IGraphic) => {\n if (node.name && !isEmpty(node.states)) {\n node.removeState(StateValue.selectedReverse);\n node.removeState(StateValue.selected);\n }\n });\n // 取消选中\n return null;\n }\n\n if (target.name && !isEmpty(target.states)) {\n target.addState(StateValue.selected, true);\n traverseGroup(container, (node: IGraphic) => {\n if (node !== target && node.name && !isEmpty(node.states)) {\n node.addState(StateValue.selectedReverse, true);\n }\n });\n return target;\n }\n return lastSelect;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-components",
3
- "version": "0.18.10-alpha.3",
3
+ "version": "0.18.10-alpha.4",
4
4
  "description": "components library for dp visualization",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -12,8 +12,8 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@visactor/vrender-core": "0.18.10-alpha.3",
16
- "@visactor/vrender-kits": "0.18.10-alpha.3",
15
+ "@visactor/vrender-core": "0.18.10-alpha.4",
16
+ "@visactor/vrender-kits": "0.18.10-alpha.4",
17
17
  "@visactor/vutils": "~0.18.1",
18
18
  "@visactor/vscale": "~0.17.3"
19
19
  },
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/marker/base-line.ts"],"names":[],"mappings":";;;AACA,6CAAyC;AAIzC,gCAA6B;AAE7B,qDAAyD;AACzD,0CAA6C;AAC7C,iCAAgC;AAEhC,MAAsB,YAAsC,SAAQ,aAEnE;IAFD;;QAGE,SAAI,GAAG,cAAc,CAAC;IAoExB,CAAC;IA5DC,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAES,WAAW;QACnB,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QACjD,MAAM,EAAE,QAAQ,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;QAChE,MAAM,UAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,CAAC,aAAa,mBACpB,UAAU,EACb,CAAC;QACH,IAAI,SAAS,IAAI,OAAO,EAAE;YACxB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE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EACL,EAAE,EAAE,CAAC,IACD,KAAuB,EAC3B,CAAC;SACJ;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;CACF;AAvED,oCAuEC","file":"base-line.js","sourcesContent":["import type { IGroup, INode } from '@visactor/vrender-core';\nimport { merge } from '@visactor/vutils';\nimport type { ArcSegment, Segment } from '../segment';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport type { CommonMarkLineAttrs } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport { DEFAULT_STATES } from '../constant';\nimport { Marker } from './base';\n\nexport abstract class BaseMarkLine<LineAttr, LabelPosition> extends Marker<\n CommonMarkLineAttrs<LineAttr, LabelPosition>\n> {\n name = 'baseMarkLine';\n\n protected _line!: Segment | ArcSegment;\n\n protected abstract createSegment(): any;\n protected abstract setLineAttributes(): any;\n protected abstract getPositionByDirection(direction: any): any;\n\n getLine() {\n return this._line;\n }\n getLabel() {\n return this._label;\n }\n\n protected setLabelPos() {\n const { label = {}, limitRect } = this.attribute;\n const { position = 'end', refX = 0, refY = 0, confine } = label;\n const labelPoint = this.getPositionByDirection(position);\n this._label.setAttributes({\n ...labelPoint\n });\n if (limitRect && confine) {\n const { x, y, width, height } = limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n\n protected initMarker(container: IGroup) {\n const { label, state } = this.attribute as CommonMarkLineAttrs<LineAttr, LabelPosition>;\n const line = this.createSegment();\n line.name = 'cartesian-mark-line-line';\n this._line = line;\n container.add(line as unknown as INode);\n\n const markLabel = new Tag({\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\n });\n markLabel.name = 'cartesian-mark-line-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { label } = this.attribute as CommonMarkLineAttrs<LineAttr, LabelPosition>;\n\n this.setLineAttributes();\n\n if (this._label) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes)\n });\n }\n\n this.setLabelPos();\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/marker/base-line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,OAAgB,YAAsC,SAAQ,MAEnE;IAFD;;QAGE,SAAI,GAAG,cAAc,CAAC;IAoExB,CAAC;IA5DC,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAES,WAAW;QACnB,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QACjD,MAAM,EAAE,QAAQ,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;QAChE,MAAM,UAAU,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,CAAC,aAAa,mBACpB,UAAU,EACb,CAAC;QACH,IAAI,SAAS,IAAI,OAAO,EAAE;YACxB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;YAC1C,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC9B,EAAE,EAAE,CAAC;gBACL,E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Group, INode } from '@visactor/vrender-core';\nimport { merge } from '@visactor/vutils';\nimport type { ArcSegment, Segment } from '../segment';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport type { CommonMarkLineAttrs } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport { DEFAULT_STATES } from '../constant';\nimport { Marker } from './base';\n\nexport abstract class BaseMarkLine<LineAttr, LabelPosition> extends Marker<\n CommonMarkLineAttrs<LineAttr, LabelPosition>\n> {\n name = 'baseMarkLine';\n\n protected _line!: Segment | ArcSegment;\n\n protected abstract createSegment(): any;\n protected abstract setLineAttributes(): any;\n protected abstract getPositionByDirection(direction: any): any;\n\n getLine() {\n return this._line;\n }\n getLabel() {\n return this._label;\n }\n\n protected setLabelPos() {\n const { label = {}, limitRect } = this.attribute;\n const { position = 'end', refX = 0, refY = 0, confine } = label;\n const labelPoint = this.getPositionByDirection(position);\n this._label.setAttributes({\n ...labelPoint\n });\n if (limitRect && confine) {\n const { x, y, width, height } = limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n\n protected initMarker(container: IGroup) {\n const { label, state } = this.attribute as CommonMarkLineAttrs<LineAttr, LabelPosition>;\n const line = this.createSegment();\n line.name = 'cartesian-mark-line-line';\n this._line = line;\n container.add(line as unknown as INode);\n\n const markLabel = new Tag({\n ...(label as TagAttributes),\n state: {\n panel: merge({}, DEFAULT_STATES, state?.labelBackground),\n text: merge({}, DEFAULT_STATES, state?.label)\n }\n });\n markLabel.name = 'cartesian-mark-line-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { label } = this.attribute as CommonMarkLineAttrs<LineAttr, LabelPosition>;\n\n this.setLineAttributes();\n\n if (this._label) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes)\n });\n }\n\n this.setLabelPos();\n }\n}\n"]}