@visactor/vrender-components 0.18.10-alpha.1 → 0.18.10-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 (97) hide show
  1. package/cjs/index.d.ts +1 -1
  2. package/cjs/index.js +1 -1
  3. package/cjs/index.js.map +1 -1
  4. package/cjs/label/arc.d.ts +2 -2
  5. package/cjs/label/base.d.ts +2 -2
  6. package/{es/marker/polar/area.d.ts → cjs/marker/arc-area.d.ts} +15 -9
  7. package/cjs/marker/arc-area.js +123 -0
  8. package/cjs/marker/arc-area.js.map +1 -0
  9. package/cjs/marker/arc-line.d.ts +23 -0
  10. package/cjs/marker/arc-line.js +103 -0
  11. package/cjs/marker/arc-line.js.map +1 -0
  12. package/cjs/marker/{cartesian/area.d.ts → area.d.ts} +13 -8
  13. package/cjs/marker/{cartesian/area.js → area.js} +16 -17
  14. package/cjs/marker/area.js.map +1 -0
  15. package/cjs/marker/base-line.d.ts +2 -2
  16. package/cjs/marker/base-line.js +4 -18
  17. package/cjs/marker/base-line.js.map +1 -1
  18. package/cjs/marker/config.d.ts +55 -12
  19. package/cjs/marker/config.js +54 -43
  20. package/cjs/marker/config.js.map +1 -1
  21. package/cjs/marker/index.d.ts +4 -4
  22. package/cjs/marker/index.js +3 -3
  23. package/cjs/marker/index.js.map +1 -1
  24. package/cjs/marker/line.d.ts +28 -0
  25. package/cjs/marker/line.js +153 -0
  26. package/cjs/marker/line.js.map +1 -0
  27. package/cjs/marker/point.d.ts +1 -1
  28. package/cjs/marker/register.d.ts +4 -5
  29. package/cjs/marker/register.js +8 -12
  30. package/cjs/marker/register.js.map +1 -1
  31. package/cjs/marker/type.d.ts +30 -38
  32. package/cjs/marker/type.js +21 -21
  33. package/cjs/marker/type.js.map +1 -1
  34. package/cjs/tag/tag.d.ts +5 -0
  35. package/cjs/tag/tag.js +11 -2
  36. package/cjs/tag/tag.js.map +1 -1
  37. package/es/index.d.ts +1 -1
  38. package/es/index.js +1 -1
  39. package/es/index.js.map +1 -1
  40. package/es/label/arc.d.ts +2 -2
  41. package/es/label/base.d.ts +2 -2
  42. package/{cjs/marker/polar/area.d.ts → es/marker/arc-area.d.ts} +15 -9
  43. package/es/marker/arc-area.js +133 -0
  44. package/es/marker/arc-area.js.map +1 -0
  45. package/es/marker/arc-line.d.ts +23 -0
  46. package/es/marker/arc-line.js +109 -0
  47. package/es/marker/arc-line.js.map +1 -0
  48. package/es/marker/{cartesian/area.d.ts → area.d.ts} +13 -8
  49. package/es/marker/{cartesian/area.js → area.js} +20 -21
  50. package/es/marker/area.js.map +1 -0
  51. package/es/marker/base-line.d.ts +2 -2
  52. package/es/marker/base-line.js +2 -20
  53. package/es/marker/base-line.js.map +1 -1
  54. package/es/marker/config.d.ts +55 -12
  55. package/es/marker/config.js +54 -43
  56. package/es/marker/config.js.map +1 -1
  57. package/es/marker/index.d.ts +4 -4
  58. package/es/marker/index.js +4 -4
  59. package/es/marker/index.js.map +1 -1
  60. package/es/marker/line.d.ts +28 -0
  61. package/es/marker/line.js +159 -0
  62. package/es/marker/line.js.map +1 -0
  63. package/es/marker/point.d.ts +1 -1
  64. package/es/marker/register.d.ts +4 -5
  65. package/es/marker/register.js +4 -8
  66. package/es/marker/register.js.map +1 -1
  67. package/es/marker/type.d.ts +30 -38
  68. package/es/marker/type.js +22 -22
  69. package/es/marker/type.js.map +1 -1
  70. package/es/tag/tag.d.ts +5 -0
  71. package/es/tag/tag.js +11 -2
  72. package/es/tag/tag.js.map +1 -1
  73. package/package.json +3 -3
  74. package/cjs/marker/cartesian/area.js.map +0 -1
  75. package/cjs/marker/cartesian/line.d.ts +0 -14
  76. package/cjs/marker/cartesian/line.js +0 -57
  77. package/cjs/marker/cartesian/line.js.map +0 -1
  78. package/cjs/marker/polar/arc-line.d.ts +0 -11
  79. package/cjs/marker/polar/arc-line.js +0 -50
  80. package/cjs/marker/polar/arc-line.js.map +0 -1
  81. package/cjs/marker/polar/area.js +0 -117
  82. package/cjs/marker/polar/area.js.map +0 -1
  83. package/cjs/marker/polar/line.d.ts +0 -1
  84. package/cjs/marker/polar/line.js +0 -3
  85. package/cjs/marker/polar/line.js.map +0 -1
  86. package/es/marker/cartesian/area.js.map +0 -1
  87. package/es/marker/cartesian/line.d.ts +0 -14
  88. package/es/marker/cartesian/line.js +0 -61
  89. package/es/marker/cartesian/line.js.map +0 -1
  90. package/es/marker/polar/arc-line.d.ts +0 -11
  91. package/es/marker/polar/arc-line.js +0 -54
  92. package/es/marker/polar/arc-line.js.map +0 -1
  93. package/es/marker/polar/area.js +0 -127
  94. package/es/marker/polar/area.js.map +0 -1
  95. package/es/marker/polar/line.d.ts +0 -1
  96. package/es/marker/polar/line.js +0 -3
  97. package/es/marker/polar/line.js.map +0 -1
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.18.10-alpha.1";
1
+ export declare const version = "0.18.10-alpha.3";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
package/cjs/index.js CHANGED
@@ -17,7 +17,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
17
17
 
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
- }), exports.version = void 0, exports.version = "0.18.10-alpha.1", __exportStar(require("./core/base"), exports),
20
+ }), exports.version = void 0, exports.version = "0.18.10-alpha.3", __exportStar(require("./core/base"), exports),
21
21
  __exportStar(require("./core/type"), exports), __exportStar(require("./scrollbar"), exports),
22
22
  __exportStar(require("./tag"), exports), __exportStar(require("./poptip"), exports),
23
23
  __exportStar(require("./crosshair"), exports), __exportStar(require("./label"), exports),
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.10-alpha.1\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.10-alpha.3\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './util';\n"]}
@@ -40,12 +40,12 @@ export declare class ArcLabel extends LabelBase<ArcLabelAttrs> {
40
40
  private _arcLeft;
41
41
  private _arcRight;
42
42
  constructor(attributes: ArcLabelAttrs, options?: ComponentOptions);
43
- protected _overlapping(labels: (IText | IRichText)[]): (IRichText | IText)[];
43
+ protected _overlapping(labels: (IText | IRichText)[]): (IText | IRichText)[];
44
44
  protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): {
45
45
  x: number;
46
46
  y: number;
47
47
  } | undefined;
48
- protected _layout(texts: (IText | IRichText)[]): (IRichText | IText)[];
48
+ protected _layout(texts: (IText | IRichText)[]): (IText | IRichText)[];
49
49
  protected layoutArcLabels(position: BaseLabelAttrs['position'], attribute: any, currentMarks?: IGraphic[], data?: LabelItem[], textBoundsArray?: any, ellipsisWidth?: number): ArcInfo[];
50
50
  private _layoutInsideLabels;
51
51
  private _layoutOutsideLabels;
@@ -40,12 +40,12 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractCompone
40
40
  private _onHover;
41
41
  private _onUnHover;
42
42
  private _onClick;
43
- protected _createLabelText(attributes: LabelItem): IRichText | IText;
43
+ protected _createLabelText(attributes: LabelItem): IText | IRichText;
44
44
  private _prepare;
45
45
  protected getRelatedGraphic(item: LabelItem): IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
46
46
  protected _initText(data?: LabelItem[]): (IText | IRichText)[];
47
47
  protected _layout(texts: (IText | IRichText)[]): (IText | IRichText)[];
48
- protected _overlapping(labels: (IText | IRichText)[]): (IRichText | IText)[];
48
+ protected _overlapping(labels: (IText | IRichText)[]): (IText | IRichText)[];
49
49
  protected getBaseMarkGroup(): IGroup;
50
50
  protected getGraphicBounds(graphic?: IGraphic, point?: Partial<PointLocationCfg>, position?: string): IBoundsLike;
51
51
  protected _renderLabels(labels: (IText | IRichText)[]): void;
@@ -1,14 +1,14 @@
1
1
  import type { IArc, IGroup } from '@visactor/vrender-core';
2
- import { Tag } from '../../tag';
3
- import { Marker } from '../base';
4
- import { IPolarMarkAreaLabelPosition, type PolarMarkAreaAttrs } from '../type';
5
- import type { ComponentOptions } from '../../interface';
6
- export declare class PolarMarkArea extends Marker<PolarMarkAreaAttrs> {
2
+ import { Tag } from '../tag';
3
+ import { Marker } from './base';
4
+ import { IMarkCommonArcLabelPosition, type MarkArcAreaAttrs } from './type';
5
+ import type { ComponentOptions } from '../interface';
6
+ export declare class MarkArcArea extends Marker<MarkArcAreaAttrs> {
7
7
  name: string;
8
8
  static defaultAttributes: {
9
9
  interactive: boolean;
10
10
  label: {
11
- position: IPolarMarkAreaLabelPosition;
11
+ position: IMarkCommonArcLabelPosition;
12
12
  textStyle: {
13
13
  fill: string;
14
14
  stroke: string;
@@ -17,7 +17,7 @@ export declare class PolarMarkArea extends Marker<PolarMarkAreaAttrs> {
17
17
  fontWeight: string;
18
18
  fontStyle: string;
19
19
  textAlign: string;
20
- textBaseLine: string;
20
+ textBaseline: string;
21
21
  };
22
22
  padding: number[];
23
23
  panel: {
@@ -35,8 +35,14 @@ export declare class PolarMarkArea extends Marker<PolarMarkAreaAttrs> {
35
35
  private _area;
36
36
  getArea(): IArc;
37
37
  getLabel(): Tag;
38
- constructor(attributes: PolarMarkAreaAttrs, options?: ComponentOptions);
39
- private _getPositionByDirection;
38
+ constructor(attributes: MarkArcAreaAttrs, options?: ComponentOptions);
39
+ protected getPositionByDirection(direction: string): {
40
+ position: {
41
+ x: number;
42
+ y: number;
43
+ };
44
+ angle: number;
45
+ };
40
46
  protected setLabelPos(): void;
41
47
  protected initMarker(container: IGroup): void;
42
48
  protected updateMarker(): void;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.MarkArcArea = void 0;
6
+
7
+ const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), tag_1 = require("../tag"), base_1 = require("./base"), config_1 = require("./config"), type_1 = require("./type"), limit_shape_1 = require("../util/limit-shape"), register_1 = require("./register"), constant_1 = require("../constant");
8
+
9
+ (0, register_1.loadMarkArcAreaComponent)();
10
+
11
+ class MarkArcArea extends base_1.Marker {
12
+ getArea() {
13
+ return this._area;
14
+ }
15
+ getLabel() {
16
+ return this._label;
17
+ }
18
+ constructor(attributes, options) {
19
+ super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, MarkArcArea.defaultAttributes, attributes)),
20
+ this.name = "polarMarkArea";
21
+ }
22
+ getPositionByDirection(direction) {
23
+ var _a, _b, _c, _d, _e, _f, _g, _h;
24
+ const {center: center, innerRadius: innerRadius, outerRadius: outerRadius, startAngle: startAngle, endAngle: endAngle, label: label} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, 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);
25
+ let radius, angle, orthogonalOffsetDirection;
26
+ switch (direction) {
27
+ case type_1.IMarkCommonArcLabelPosition.center:
28
+ radius = (innerRadius + outerRadius) / 2, angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = 0;
29
+ break;
30
+
31
+ case type_1.IMarkCommonArcLabelPosition.arcInnerStart:
32
+ radius = innerRadius, angle = startAngle, orthogonalOffsetDirection = -1;
33
+ break;
34
+
35
+ case type_1.IMarkCommonArcLabelPosition.arcOuterStart:
36
+ radius = outerRadius, angle = startAngle, orthogonalOffsetDirection = 1;
37
+ break;
38
+
39
+ case type_1.IMarkCommonArcLabelPosition.arcInnerEnd:
40
+ radius = innerRadius, angle = endAngle, orthogonalOffsetDirection = -1;
41
+ break;
42
+
43
+ case type_1.IMarkCommonArcLabelPosition.arcOuterEnd:
44
+ radius = outerRadius, angle = endAngle, orthogonalOffsetDirection = 1;
45
+ break;
46
+
47
+ case type_1.IMarkCommonArcLabelPosition.arcInnerMiddle:
48
+ radius = innerRadius, angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = -1;
49
+ break;
50
+
51
+ case type_1.IMarkCommonArcLabelPosition.arcOuterMiddle:
52
+ radius = outerRadius, angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = 1;
53
+ break;
54
+
55
+ default:
56
+ radius = innerRadius, angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = -1;
57
+ }
58
+ return {
59
+ position: {
60
+ x: center.x + (radius + orthogonalOffsetDirection * labelHeight / 2 + refY) * Math.cos(angle) + refX * Math.cos(angle - Math.PI / 2),
61
+ y: center.y + (radius + orthogonalOffsetDirection * labelHeight / 2 + refY) * Math.sin(angle) + refX * Math.sin(angle - Math.PI / 2)
62
+ },
63
+ angle: angle
64
+ };
65
+ }
66
+ setLabelPos() {
67
+ var _a;
68
+ if (this._label && this._area) {
69
+ const {label: label = {}} = this.attribute, {position: labelPosition = "arcInnerMiddle", autoRotate: autoRotate = !0} = label, labelAttr = this.getPositionByDirection(labelPosition);
70
+ if (this._label.setAttributes(Object.assign(Object.assign({}, labelAttr.position), {
71
+ angle: autoRotate ? labelAttr.angle - Math.PI / 2 + (null !== (_a = label.refAngle) && void 0 !== _a ? _a : 0) : 0
72
+ })), this.attribute.limitRect && label.confine) {
73
+ const {x: x, y: y, width: width, height: height} = this.attribute.limitRect;
74
+ (0, limit_shape_1.limitShapeInBounds)(this._label, {
75
+ x1: x,
76
+ y1: y,
77
+ x2: x + width,
78
+ y2: y + height
79
+ });
80
+ }
81
+ }
82
+ }
83
+ initMarker(container) {
84
+ const {center: center, innerRadius: innerRadius, outerRadius: outerRadius, startAngle: startAngle, endAngle: endAngle, areaStyle: areaStyle, label: label, state: state} = this.attribute, area = vrender_core_1.graphicCreator.arc(Object.assign({
85
+ x: center.x,
86
+ y: center.y,
87
+ innerRadius: innerRadius,
88
+ outerRadius: outerRadius,
89
+ startAngle: startAngle,
90
+ endAngle: endAngle
91
+ }, areaStyle));
92
+ area.states = (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.area),
93
+ area.name = "polar-mark-area-area", this._area = area, container.add(area);
94
+ const markLabel = new tag_1.Tag(Object.assign(Object.assign({}, label), {
95
+ state: {
96
+ panel: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.labelBackground),
97
+ text: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.label)
98
+ }
99
+ }));
100
+ markLabel.name = "mark-area-label", this._label = markLabel, container.add(markLabel),
101
+ this.setLabelPos();
102
+ }
103
+ updateMarker() {
104
+ const {center: center, innerRadius: innerRadius, outerRadius: outerRadius, startAngle: startAngle, endAngle: endAngle, areaStyle: areaStyle, label: label} = this.attribute;
105
+ this._area && this._area.setAttributes(Object.assign({
106
+ x: center.x,
107
+ y: center.y,
108
+ innerRadius: innerRadius,
109
+ outerRadius: outerRadius,
110
+ startAngle: startAngle,
111
+ endAngle: endAngle
112
+ }, areaStyle)), this._area && this._label.setAttributes(Object.assign({
113
+ dx: 0,
114
+ dy: 0
115
+ }, label)), this.setLabelPos();
116
+ }
117
+ isValidPoints() {
118
+ return !0;
119
+ }
120
+ }
121
+
122
+ exports.MarkArcArea = MarkArcArea, MarkArcArea.defaultAttributes = config_1.DEFAULT_MARK_ARC_AREA_THEME;
123
+ //# sourceMappingURL=arc-area.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/marker/arc-area.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AACxD,6CAAyC;AAGzC,gCAA6B;AAC7B,iCAAgC;AAChC,qCAAuD;AACvD,iCAA4E;AAC5E,qDAAyD;AAEzD,yCAAsD;AACtD,0CAA6C;AAE7C,IAAA,mCAAwB,GAAE,CAAC;AAC3B,MAAa,WAAY,SAAQ,aAAwB;IAKvD,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,YAAY,UAA4B,EAAE,OAA0B;QAClE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,WAAW,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAblG,SAAI,GAAG,eAAe,CAAC;IAcvB,CAAC;IAES,sBAAsB,CAAC,SAAiB;;QAChD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,SAA6B,CAAC;QAC7G,MAAM,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC;QAErC,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAC9B,CAAC,MAAA,MAAA,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,UAAU,0CAAE,EAAE,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,MAAA,IAA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AC,MAAM,CAAC,aAAa,iBACvB,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,CAAC,IACD,KAAuB,EAC3B,CAAC;SACJ;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAES,aAAa;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;;AA5KH,kCA6KC;AA3KQ,6BAAiB,GAAG,oCAA2B,CAAC","file":"arc-area.js","sourcesContent":["import type { IArc, IGroup, INode } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { merge } from '@visactor/vutils';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_MARK_ARC_AREA_THEME } from './config';\nimport { IMarkCommonArcLabelPosition, type MarkArcAreaAttrs } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkArcAreaComponent } from './register';\nimport { DEFAULT_STATES } from '../constant';\n\nloadMarkArcAreaComponent();\nexport class MarkArcArea extends Marker<MarkArcAreaAttrs> {\n name = 'polarMarkArea';\n static defaultAttributes = DEFAULT_MARK_ARC_AREA_THEME;\n private _area!: IArc;\n\n getArea() {\n return this._area;\n }\n\n getLabel() {\n return this._label;\n }\n\n constructor(attributes: MarkArcAreaAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkArcArea.defaultAttributes, attributes));\n }\n\n protected getPositionByDirection(direction: string) {\n const { center, innerRadius, outerRadius, startAngle, endAngle, label } = this.attribute as MarkArcAreaAttrs;\n const { refX = 0, refY = 0 } = label;\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 let radius;\n let angle;\n // tag在正交方向是向内偏移,还是向外偏移\n // 不偏移: 0, 内: -1, 外: 1\n let orthogonalOffsetDirection;\n\n switch (direction) {\n case IMarkCommonArcLabelPosition.center:\n radius = (innerRadius + outerRadius) / 2;\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = 0;\n break;\n case IMarkCommonArcLabelPosition.arcInnerStart:\n radius = innerRadius;\n angle = startAngle;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterStart:\n radius = outerRadius;\n angle = startAngle;\n orthogonalOffsetDirection = 1;\n break;\n case IMarkCommonArcLabelPosition.arcInnerEnd:\n radius = innerRadius;\n angle = endAngle;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterEnd:\n radius = outerRadius;\n angle = endAngle;\n orthogonalOffsetDirection = 1;\n break;\n case IMarkCommonArcLabelPosition.arcInnerMiddle:\n radius = innerRadius;\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterMiddle:\n radius = outerRadius;\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = 1;\n break;\n default: // default arcInnerMiddle\n radius = innerRadius;\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = -1;\n }\n\n return {\n position: {\n x:\n center.x +\n (radius + (orthogonalOffsetDirection * labelHeight) / 2 + refY) * Math.cos(angle) +\n refX * Math.cos(angle - Math.PI / 2),\n y:\n center.y +\n (radius + (orthogonalOffsetDirection * labelHeight) / 2 + refY) * Math.sin(angle) +\n refX * Math.sin(angle - Math.PI / 2)\n },\n angle\n };\n }\n\n protected setLabelPos() {\n if (this._label && this._area) {\n const { label = {} } = this.attribute as MarkArcAreaAttrs;\n const { position: labelPosition = 'arcInnerMiddle', autoRotate = true } = label;\n const labelAttr = this.getPositionByDirection(labelPosition);\n\n this._label.setAttributes({\n ...labelAttr.position,\n angle: autoRotate ? labelAttr.angle - Math.PI / 2 + (label.refAngle ?? 0) : 0\n });\n\n if (this.attribute.limitRect && label.confine) {\n const { x, y, width, height } = this.attribute.limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n }\n\n protected initMarker(container: IGroup) {\n const { center, innerRadius, outerRadius, startAngle, endAngle, areaStyle, label, state } = this\n .attribute as MarkArcAreaAttrs;\n const area = graphicCreator.arc({\n x: center.x,\n y: center.y,\n innerRadius,\n outerRadius,\n startAngle,\n endAngle,\n ...areaStyle\n });\n area.states = merge({}, DEFAULT_STATES, state?.area);\n area.name = 'polar-mark-area-area';\n this._area = area;\n container.add(area);\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-area-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { center, innerRadius, outerRadius, startAngle, endAngle, areaStyle, label } = this\n .attribute as MarkArcAreaAttrs;\n if (this._area) {\n this._area.setAttributes({\n x: center.x,\n y: center.y,\n innerRadius,\n outerRadius,\n startAngle,\n endAngle,\n ...areaStyle\n });\n }\n if (this._area) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes)\n });\n }\n this.setLabelPos();\n }\n\n protected isValidPoints() {\n return true;\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import { ArcSegment } from '../segment';
2
+ import { BaseMarkLine } from './base-line';
3
+ import type { ComponentOptions } from '../interface';
4
+ import type { IArcGraphicAttribute } from '@visactor/vrender-core';
5
+ import { IMarkCommonArcLabelPosition } from './type';
6
+ import type { MarkArcLineAttrs } from './type';
7
+ export declare class MarkArcLine extends BaseMarkLine<IArcGraphicAttribute, IMarkCommonArcLabelPosition> {
8
+ name: string;
9
+ static defaultAttributes: Partial<MarkArcLineAttrs>;
10
+ protected _line: ArcSegment;
11
+ constructor(attributes: MarkArcLineAttrs, options?: ComponentOptions);
12
+ protected isValidPoints(): boolean;
13
+ protected getPositionByDirection(direction: IMarkCommonArcLabelPosition): {
14
+ position: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ angle: number;
19
+ };
20
+ protected setLabelPos(): void;
21
+ protected createSegment(): ArcSegment;
22
+ protected setLineAttributes(): void;
23
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.MarkArcLine = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils"), segment_1 = require("../segment"), register_1 = require("./register"), constant_1 = require("../constant"), base_line_1 = require("./base-line"), type_1 = require("./type"), config_1 = require("./config");
8
+
9
+ (0, register_1.loadMarkArcLineComponent)();
10
+
11
+ class MarkArcLine extends base_line_1.BaseMarkLine {
12
+ constructor(attributes, options) {
13
+ super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, MarkArcLine.defaultAttributes, attributes)),
14
+ this.name = "polarMarkArcLine";
15
+ }
16
+ isValidPoints() {
17
+ return !0;
18
+ }
19
+ getPositionByDirection(direction) {
20
+ var _a, _b, _c, _d, _e, _f, _g, _h;
21
+ const {center: center, radius: radius, startAngle: startAngle, endAngle: endAngle, label: label} = this.attribute, {refX: refX = 0, refY: refY = 0} = label, 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);
22
+ let angle, orthogonalOffsetDirection;
23
+ switch (direction) {
24
+ case type_1.IMarkCommonArcLabelPosition.center:
25
+ angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = 0;
26
+ break;
27
+
28
+ case type_1.IMarkCommonArcLabelPosition.arcInnerStart:
29
+ angle = startAngle, orthogonalOffsetDirection = -1;
30
+ break;
31
+
32
+ case type_1.IMarkCommonArcLabelPosition.arcOuterStart:
33
+ angle = startAngle, orthogonalOffsetDirection = 1;
34
+ break;
35
+
36
+ case type_1.IMarkCommonArcLabelPosition.arcInnerEnd:
37
+ angle = endAngle, orthogonalOffsetDirection = -1;
38
+ break;
39
+
40
+ case type_1.IMarkCommonArcLabelPosition.arcOuterEnd:
41
+ angle = endAngle, orthogonalOffsetDirection = 1;
42
+ break;
43
+
44
+ case type_1.IMarkCommonArcLabelPosition.arcInnerMiddle:
45
+ angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = -1;
46
+ break;
47
+
48
+ case type_1.IMarkCommonArcLabelPosition.arcOuterMiddle:
49
+ angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = 1;
50
+ break;
51
+
52
+ default:
53
+ angle = (startAngle + endAngle) / 2, orthogonalOffsetDirection = -1;
54
+ }
55
+ return {
56
+ position: {
57
+ x: center.x + (radius + orthogonalOffsetDirection * labelHeight / 2 + refY) * Math.cos(angle) + refX * Math.cos(angle - Math.PI / 2),
58
+ y: center.y + (radius + orthogonalOffsetDirection * labelHeight / 2 + refY) * Math.sin(angle) + refX * Math.sin(angle - Math.PI / 2)
59
+ },
60
+ angle: angle
61
+ };
62
+ }
63
+ setLabelPos() {
64
+ var _a;
65
+ super.setLabelPos();
66
+ const {label: label = {}} = this.attribute, {position: position = "arcInnerMiddle", autoRotate: autoRotate = !0} = label, labelAttr = this.getPositionByDirection(position);
67
+ this._label.setAttributes(Object.assign(Object.assign({}, labelAttr.position), {
68
+ angle: autoRotate ? labelAttr.angle - Math.PI / 2 + (null !== (_a = label.refAngle) && void 0 !== _a ? _a : 0) : 0
69
+ }));
70
+ }
71
+ createSegment() {
72
+ const {center: center, radius: radius, startAngle: startAngle, endAngle: endAngle, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle, state: state} = this.attribute;
73
+ return new segment_1.ArcSegment({
74
+ center: center,
75
+ radius: radius,
76
+ startAngle: startAngle,
77
+ endAngle: endAngle,
78
+ startSymbol: startSymbol,
79
+ endSymbol: endSymbol,
80
+ lineStyle: lineStyle,
81
+ state: {
82
+ line: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.line),
83
+ startSymbol: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.lineStartSymbol),
84
+ endSymbol: (0, vutils_1.merge)({}, constant_1.DEFAULT_STATES, null == state ? void 0 : state.lineEndSymbol)
85
+ }
86
+ });
87
+ }
88
+ setLineAttributes() {
89
+ const {center: center, radius: radius, startAngle: startAngle, endAngle: endAngle, startSymbol: startSymbol, endSymbol: endSymbol, lineStyle: lineStyle} = this.attribute;
90
+ this._line && this._line.setAttributes({
91
+ center: center,
92
+ radius: radius,
93
+ startAngle: startAngle,
94
+ endAngle: endAngle,
95
+ startSymbol: startSymbol,
96
+ endSymbol: endSymbol,
97
+ lineStyle: lineStyle
98
+ });
99
+ }
100
+ }
101
+
102
+ exports.MarkArcLine = MarkArcLine, MarkArcLine.defaultAttributes = config_1.DEFAULT_MARK_ARC_LINE_THEME;
103
+ //# sourceMappingURL=arc-line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/marker/arc-line.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,wCAAwC;AACxC,yCAAsD;AACtD,0CAA6C;AAC7C,2CAA2C;AAG3C,iCAAqD;AAGrD,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ACR,WAAW;YACX,SAAS;YACT,SAAS;YACT,KAAK,EAAE;gBACL,IAAI,EAAE,IAAA,cAAK,EAAC,EAAE,EAAE,yBAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAC;gBAC5C,WAAW,EAAE,IAAA,cAAK,EAAC,EAAE,EAAE,yBAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAC;gBAC9D,SAAS,EAAE,IAAA,cAAK,EAAC,EAAE,EAAE,yBAAc,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,CAAC;aAC3D;SACF,CAAC,CAAC;IACL,CAAC;IAES,iBAAiB;QACzB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI;aACrF,SAA6B,CAAC;QACjC,IAAI,IAAI,CAAC,KAAK,EAAE;YACb,IAAI,CAAC,KAAa,CAAC,aAAa,CAAC;gBAChC,MAAM;gBACN,MAAM;gBACN,UAAU;gBACV,QAAQ;gBACR,WAAW;gBACX,SAAS;gBACT,SAAS;aACV,CAAC,CAAC;SACJ;IACH,CAAC;;AA7HH,kCA8HC;AA3HQ,6BAAiB,GAA8B,oCAA0D,CAAC","file":"arc-line.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { ArcSegment } from '../segment';\nimport { loadMarkArcLineComponent } from './register';\nimport { DEFAULT_STATES } from '../constant';\nimport { BaseMarkLine } from './base-line';\nimport type { ComponentOptions } from '../interface';\nimport type { IArcGraphicAttribute } from '@visactor/vrender-core';\nimport { IMarkCommonArcLabelPosition } from './type';\n// eslint-disable-next-line no-duplicate-imports\nimport type { MarkArcLineAttrs } from './type';\nimport { DEFAULT_MARK_ARC_LINE_THEME } from './config';\n\nloadMarkArcLineComponent();\nexport class MarkArcLine extends BaseMarkLine<IArcGraphicAttribute, IMarkCommonArcLabelPosition> {\n name = 'polarMarkArcLine';\n // eslint-disable-next-line max-len\n static defaultAttributes: Partial<MarkArcLineAttrs> = DEFAULT_MARK_ARC_LINE_THEME as unknown as MarkArcLineAttrs;\n protected _line!: ArcSegment;\n\n constructor(attributes: MarkArcLineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkArcLine.defaultAttributes, attributes));\n }\n\n protected isValidPoints() {\n return true;\n }\n\n protected getPositionByDirection(direction: IMarkCommonArcLabelPosition) {\n const { center, radius, startAngle, endAngle, label } = this.attribute as MarkArcLineAttrs;\n const { refX = 0, refY = 0 } = label;\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 let angle;\n // tag在正交方向是向内偏移,还是向外偏移\n // 不偏移: 0, 内: -1, 外: 1\n let orthogonalOffsetDirection;\n\n switch (direction) {\n case IMarkCommonArcLabelPosition.center:\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = 0;\n break;\n case IMarkCommonArcLabelPosition.arcInnerStart:\n angle = startAngle;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterStart:\n angle = startAngle;\n orthogonalOffsetDirection = 1;\n break;\n case IMarkCommonArcLabelPosition.arcInnerEnd:\n angle = endAngle;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterEnd:\n angle = endAngle;\n orthogonalOffsetDirection = 1;\n break;\n case IMarkCommonArcLabelPosition.arcInnerMiddle:\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = -1;\n break;\n case IMarkCommonArcLabelPosition.arcOuterMiddle:\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = 1;\n break;\n default: // default arcInnerMiddle\n angle = (startAngle + endAngle) / 2;\n orthogonalOffsetDirection = -1;\n }\n\n return {\n position: {\n x:\n center.x +\n (radius + (orthogonalOffsetDirection * labelHeight) / 2 + refY) * Math.cos(angle) +\n refX * Math.cos(angle - Math.PI / 2),\n y:\n center.y +\n (radius + (orthogonalOffsetDirection * labelHeight) / 2 + refY) * Math.sin(angle) +\n refX * Math.sin(angle - Math.PI / 2)\n },\n angle\n };\n }\n\n protected setLabelPos(): void {\n super.setLabelPos();\n const { label = {} } = this.attribute as MarkArcLineAttrs;\n const { position = 'arcInnerMiddle', autoRotate = true } = label;\n const labelAttr = this.getPositionByDirection(position as any);\n this._label.setAttributes({\n ...labelAttr.position,\n angle: autoRotate ? labelAttr.angle - Math.PI / 2 + (label.refAngle ?? 0) : 0\n });\n }\n\n protected createSegment() {\n const { center, radius, startAngle, endAngle, startSymbol, endSymbol, lineStyle, state } = this\n .attribute as MarkArcLineAttrs;\n return new ArcSegment({\n center,\n radius,\n startAngle,\n endAngle,\n startSymbol,\n endSymbol,\n lineStyle,\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 { center, radius, startAngle, endAngle, startSymbol, endSymbol, lineStyle } = this\n .attribute as MarkArcLineAttrs;\n if (this._line) {\n (this._line as any).setAttributes({\n center,\n radius,\n startAngle,\n endAngle,\n startSymbol,\n endSymbol,\n lineStyle\n });\n }\n }\n}\n"]}
@@ -1,14 +1,14 @@
1
1
  import type { IGroup, IPolygon } from '@visactor/vrender-core';
2
- import { Tag } from '../../tag';
3
- import { Marker } from '../base';
4
- import type { CartesianMarkAreaAttrs } from '../type';
5
- import type { ComponentOptions } from '../../interface';
6
- export declare class CartesianMarkArea extends Marker<CartesianMarkAreaAttrs> {
2
+ import { Tag } from '../tag';
3
+ import { Marker } from './base';
4
+ import type { MarkAreaAttrs } from './type';
5
+ import type { ComponentOptions } from '../interface';
6
+ export declare class MarkArea extends Marker<MarkAreaAttrs> {
7
7
  name: string;
8
8
  static defaultAttributes: {
9
9
  interactive: boolean;
10
10
  label: {
11
- position: import("../type").ICartesianMarkAreaLabelPosition;
11
+ position: import("./type").IMarkAreaLabelPosition;
12
12
  textStyle: {
13
13
  fill: string;
14
14
  stroke: string;
@@ -16,6 +16,8 @@ export declare class CartesianMarkArea extends Marker<CartesianMarkAreaAttrs> {
16
16
  fontSize: number;
17
17
  fontWeight: string;
18
18
  fontStyle: string;
19
+ textAlign: string;
20
+ textBaseline: string;
19
21
  };
20
22
  padding: number[];
21
23
  panel: {
@@ -33,8 +35,11 @@ export declare class CartesianMarkArea extends Marker<CartesianMarkAreaAttrs> {
33
35
  private _area;
34
36
  getArea(): IPolygon;
35
37
  getLabel(): Tag;
36
- constructor(attributes: CartesianMarkAreaAttrs, options?: ComponentOptions);
37
- private _getPositionByDirection;
38
+ constructor(attributes: MarkAreaAttrs, options?: ComponentOptions);
39
+ protected getPositionByDirection(direction: string): {
40
+ x: number;
41
+ y: number;
42
+ };
38
43
  protected setLabelPos(): void;
39
44
  protected initMarker(container: IGroup): void;
40
45
  protected updateMarker(): void;
@@ -2,13 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.CartesianMarkArea = void 0;
5
+ }), exports.MarkArea = void 0;
6
6
 
7
- const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), tag_1 = require("../../tag"), base_1 = require("../base"), config_1 = require("../config"), limit_shape_1 = require("../../util/limit-shape"), register_1 = require("../register"), constant_1 = require("../../constant");
7
+ const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), tag_1 = require("../tag"), base_1 = require("./base"), config_1 = require("./config"), limit_shape_1 = require("../util/limit-shape"), register_1 = require("./register"), constant_1 = require("../constant");
8
8
 
9
- (0, register_1.loadCartesianMarkAreaComponent)();
9
+ (0, register_1.loadMarkAreaComponent)();
10
10
 
11
- class CartesianMarkArea extends base_1.Marker {
11
+ class MarkArea extends base_1.Marker {
12
12
  getArea() {
13
13
  return this._area;
14
14
  }
@@ -16,23 +16,24 @@ class CartesianMarkArea extends base_1.Marker {
16
16
  return this._label;
17
17
  }
18
18
  constructor(attributes, options) {
19
- super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, CartesianMarkArea.defaultAttributes, attributes)),
20
- this.name = "cartesianMarkArea";
19
+ super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, MarkArea.defaultAttributes, attributes)),
20
+ this.name = "markArea";
21
21
  }
22
- _getPositionByDirection(area, direction) {
23
- const {x1: x1, x2: x2, y1: y1, y2: y2} = this._area.AABBBounds;
22
+ getPositionByDirection(direction) {
23
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
24
+ const {x1: x1, x2: x2, y1: y1, y2: y2} = this._area.AABBBounds, 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);
24
25
  return direction.includes("left") || direction.includes("Left") ? {
25
- x: x1,
26
+ x: x1 + (direction.includes("inside") ? .5 : -.5) * labelWidth,
26
27
  y: (y1 + y2) / 2
27
28
  } : direction.includes("right") || direction.includes("Right") ? {
28
- x: x2,
29
+ x: x2 + (direction.includes("inside") ? -.5 : .5) * labelWidth,
29
30
  y: (y1 + y2) / 2
30
31
  } : direction.includes("top") || direction.includes("Top") ? {
31
32
  x: (x1 + x2) / 2,
32
- y: y1
33
+ y: y1 + (direction.includes("inside") ? .5 : -.5) * labelHeight
33
34
  } : direction.includes("bottom") || direction.includes("Bottom") ? {
34
35
  x: (x1 + x2) / 2,
35
- y: y2
36
+ y: y2 + (direction.includes("inside") ? -.5 : .5) * labelHeight
36
37
  } : {
37
38
  x: (x1 + x2) / 2,
38
39
  y: (y1 + y2) / 2
@@ -41,10 +42,8 @@ class CartesianMarkArea extends base_1.Marker {
41
42
  setLabelPos() {
42
43
  var _a;
43
44
  if (this._label && this._area) {
44
- const {label: label = {}} = this.attribute, labelPosition = null !== (_a = label.position) && void 0 !== _a ? _a : "middle", labelPoint = this._getPositionByDirection(this._area, labelPosition);
45
- if (this._label.setAttributes(Object.assign(Object.assign({}, labelPoint), {
46
- textStyle: Object.assign(Object.assign({}, config_1.DEFAULT_CARTESIAN_MARK_AREA_TEXT_STYLE_MAP[labelPosition]), label.textStyle)
47
- })), this.attribute.limitRect && label.confine) {
45
+ const {label: label = {}} = this.attribute, labelPosition = null !== (_a = label.position) && void 0 !== _a ? _a : "middle", labelPoint = this.getPositionByDirection(labelPosition);
46
+ if (this._label.setAttributes(Object.assign({}, labelPoint)), this.attribute.limitRect && label.confine) {
48
47
  const {x: x, y: y, width: width, height: height} = this.attribute.limitRect;
49
48
  (0, limit_shape_1.limitShapeInBounds)(this._label, {
50
49
  x1: x,
@@ -89,5 +88,5 @@ class CartesianMarkArea extends base_1.Marker {
89
88
  }
90
89
  }
91
90
 
92
- exports.CartesianMarkArea = CartesianMarkArea, CartesianMarkArea.defaultAttributes = config_1.DEFAULT_CARTESIAN_MARK_AREA_THEME;
91
+ exports.MarkArea = MarkArea, MarkArea.defaultAttributes = config_1.DEFAULT_MARK_AREA_THEME;
93
92
  //# sourceMappingURL=area.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/marker/area.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AACxD,6CAAwD;AAGxD,gCAA6B;AAC7B,iCAAgC;AAChC,qCAAmD;AAEnD,qDAAyD;AAEzD,yCAAmD;AAEnD,0CAA6C;AAE7C,IAAA,gCAAqB,GAAE,CAAC;AACxB,MAAa,QAAS,SAAQ,aAAqB;IAIjD,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,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,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAZ/F,SAAI,GAAG,UAAU,CAAC;IAalB,CAAC;IAES,sBAAsB,CAAC,SAAiB;;QAChD,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;QAGjD,MAAM,eAAe,GAAG,IAAI,CAAC,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MAAM,GAAG,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;QACD,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAY,EAAE,EAAE;YAC9B,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAE,KAAe,CAAC,CAAC,CAAC,EAAE;gBAC5E,SAAS,GAAG,KAAK,CAAC;gBAClB,OAAO;aACR;QACH,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;;AAnJH,4BAoJC;AAlJQ,0BAAiB,GAAG,gCAAuB,CAAC","file":"area.js","sourcesContent":["import type { IGroup, INode, IPolygon } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\nimport { isValidNumber, merge } from '@visactor/vutils';\nimport type { TagAttributes } from '../tag';\n// eslint-disable-next-line no-duplicate-imports\nimport { Tag } from '../tag';\nimport { Marker } from './base';\nimport { DEFAULT_MARK_AREA_THEME } from './config';\nimport type { MarkAreaAttrs } from './type';\nimport { limitShapeInBounds } from '../util/limit-shape';\nimport type { ComponentOptions } from '../interface';\nimport { loadMarkAreaComponent } from './register';\nimport type { Point } from '../core/type';\nimport { DEFAULT_STATES } from '../constant';\n\nloadMarkAreaComponent();\nexport class MarkArea extends Marker<MarkAreaAttrs> {\n name = 'markArea';\n static defaultAttributes = DEFAULT_MARK_AREA_THEME;\n private _area!: IPolygon;\n getArea() {\n return this._area;\n }\n\n getLabel() {\n return this._label;\n }\n\n constructor(attributes: MarkAreaAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, MarkArea.defaultAttributes, attributes));\n }\n\n protected getPositionByDirection(direction: string) {\n const { x1, x2, y1, y2 } = this._area.AABBBounds;\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 if (direction.includes('left') || direction.includes('Left')) {\n return {\n x: x1 + (direction.includes('inside') ? 0.5 : -0.5) * labelWidth,\n y: (y1 + y2) / 2\n };\n }\n if (direction.includes('right') || direction.includes('Right')) {\n return {\n x: x2 + (direction.includes('inside') ? -0.5 : 0.5) * labelWidth,\n y: (y1 + y2) / 2\n };\n }\n if (direction.includes('top') || direction.includes('Top')) {\n return {\n x: (x1 + x2) / 2,\n y: y1 + (direction.includes('inside') ? 0.5 : -0.5) * labelHeight\n };\n }\n if (direction.includes('bottom') || direction.includes('Bottom')) {\n return {\n x: (x1 + x2) / 2,\n y: y2 + (direction.includes('inside') ? -0.5 : 0.5) * labelHeight\n };\n }\n\n return {\n x: (x1 + x2) / 2,\n y: (y1 + y2) / 2\n };\n }\n\n protected setLabelPos() {\n if (this._label && this._area) {\n const { label = {} } = this.attribute as MarkAreaAttrs;\n const labelPosition = label.position ?? 'middle';\n const labelPoint = this.getPositionByDirection(labelPosition);\n this._label.setAttributes({\n ...labelPoint\n });\n\n if (this.attribute.limitRect && label.confine) {\n const { x, y, width, height } = this.attribute.limitRect;\n limitShapeInBounds(this._label, {\n x1: x,\n y1: y,\n x2: x + width,\n y2: y + height\n });\n }\n }\n }\n\n protected initMarker(container: IGroup) {\n const { points, label, areaStyle, state } = this.attribute as MarkAreaAttrs;\n const area = graphicCreator.polygon({\n points: points,\n ...areaStyle\n });\n area.states = merge({}, DEFAULT_STATES, state?.area);\n area.name = 'mark-polygon-polygon';\n this._area = area;\n container.add(area);\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-polygon-label';\n this._label = markLabel;\n container.add(markLabel as unknown as INode);\n this.setLabelPos();\n }\n\n protected updateMarker() {\n const { points, label, areaStyle } = this.attribute as MarkAreaAttrs;\n if (this._area) {\n this._area.setAttributes({\n points: points,\n ...areaStyle\n });\n }\n if (this._area) {\n this._label.setAttributes({\n dx: 0,\n dy: 0, // 需要进行复位\n ...(label as TagAttributes)\n });\n }\n this.setLabelPos();\n }\n\n protected isValidPoints() {\n const { points } = this.attribute as MarkAreaAttrs;\n if (!points || points.length < 3) {\n return false;\n }\n let validFlag = true;\n points.forEach((point: Point) => {\n if (!isValidNumber((point as Point).x) || !isValidNumber((point as Point).y)) {\n validFlag = false;\n return;\n }\n });\n return validFlag;\n }\n}\n"]}
@@ -3,12 +3,12 @@ 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 extends Marker<CommonMarkLineAttrs> {
6
+ export declare abstract class BaseMarkLine<LineAttr, LabelPosition> extends Marker<CommonMarkLineAttrs<LineAttr, LabelPosition>> {
7
7
  name: string;
8
- static defaultAttributes: Partial<CommonMarkLineAttrs>;
9
8
  protected _line: Segment | ArcSegment;
10
9
  protected abstract createSegment(): any;
11
10
  protected abstract setLineAttributes(): any;
11
+ protected abstract getPositionByDirection(direction: any): any;
12
12
  getLine(): Segment | ArcSegment;
13
13
  getLabel(): Tag;
14
14
  protected setLabelPos(): void;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.BaseMarkLine = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), tag_1 = require("../tag"), config_1 = require("./config"), limit_shape_1 = require("../util/limit-shape"), constant_1 = require("../constant"), base_1 = require("./base");
7
+ const vutils_1 = require("@visactor/vutils"), tag_1 = require("../tag"), limit_shape_1 = require("../util/limit-shape"), constant_1 = require("../constant"), base_1 = require("./base");
8
8
 
9
9
  class BaseMarkLine extends base_1.Marker {
10
10
  constructor() {
@@ -17,22 +17,8 @@ class BaseMarkLine extends base_1.Marker {
17
17
  return this._label;
18
18
  }
19
19
  setLabelPos() {
20
- var _a, _b;
21
- const {label: label = {}, limitRect: limitRect} = this.attribute, {position: position = "end", refX: refX = 0, refY: refY = 0, confine: confine} = label, points = this._line.getMainSegmentPoints(), labelAngle = null !== (_a = this._line.getEndAngle()) && void 0 !== _a ? _a : 0, labelOffsetX = refX * Math.cos(labelAngle) + refY * Math.cos(labelAngle - Math.PI / 2), labelOffsetY = refX * Math.sin(labelAngle) + refY * Math.sin(labelAngle - Math.PI / 2);
22
- let labelPoint;
23
- if (labelPoint = position.includes("start") || position.includes("Start") ? {
24
- x: points[0].x + labelOffsetX,
25
- y: points[0].y + labelOffsetY
26
- } : position.includes("middle") || position.includes("Middle") ? {
27
- x: (points[0].x + points[points.length - 1].x) / 2 + labelOffsetX,
28
- y: (points[0].y + points[points.length - 1].y) / 2 + labelOffsetY
29
- } : {
30
- x: points[points.length - 1].x + labelOffsetX,
31
- y: points[points.length - 1].y + labelOffsetY
32
- }, this._label.setAttributes(Object.assign(Object.assign({}, labelPoint), {
33
- angle: label.autoRotate ? labelAngle + (null !== (_b = label.refAngle) && void 0 !== _b ? _b : 0) : 0,
34
- textStyle: Object.assign(Object.assign({}, config_1.DEFAULT_COMMON_MARK_LINE_TEXT_STYLE_MAP[position]), label.textStyle)
35
- })), limitRect && confine) {
20
+ const {label: label = {}, limitRect: limitRect} = this.attribute, {position: position = "end", refX: refX = 0, refY: refY = 0, confine: confine} = label, labelPoint = this.getPositionByDirection(position);
21
+ if (this._label.setAttributes(Object.assign({}, labelPoint)), limitRect && confine) {
36
22
  const {x: x, y: y, width: width, height: height} = limitRect;
37
23
  (0, limit_shape_1.limitShapeInBounds)(this._label, {
38
24
  x1: x,
@@ -63,5 +49,5 @@ class BaseMarkLine extends base_1.Marker {
63
49
  }
64
50
  }
65
51
 
66
- exports.BaseMarkLine = BaseMarkLine, BaseMarkLine.defaultAttributes = config_1.DEFAULT_COMMON_MARK_LINE_THEME;
52
+ exports.BaseMarkLine = BaseMarkLine;
67
53
  //# sourceMappingURL=base-line.js.map