@visactor/vrender-components 0.18.0-alpha.0 → 0.18.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/cjs/axis/base.js +24 -24
  2. package/cjs/axis/base.js.map +1 -1
  3. package/cjs/axis/grid/base.js +1 -1
  4. package/cjs/axis/grid/base.js.map +1 -1
  5. package/cjs/axis/line.js +59 -52
  6. package/cjs/axis/line.js.map +1 -1
  7. package/cjs/axis/overlap/auto-hide.d.ts +1 -0
  8. package/cjs/axis/overlap/auto-hide.js +10 -2
  9. package/cjs/axis/overlap/auto-hide.js.map +1 -1
  10. package/cjs/axis/overlap/auto-limit.d.ts +1 -0
  11. package/cjs/axis/overlap/auto-limit.js +5 -3
  12. package/cjs/axis/overlap/auto-limit.js.map +1 -1
  13. package/cjs/axis/type.d.ts +1 -0
  14. package/cjs/axis/type.js.map +1 -1
  15. package/cjs/brush/brush.js +4 -4
  16. package/cjs/brush/brush.js.map +1 -1
  17. package/cjs/checkbox/checkbox.js +2 -1
  18. package/cjs/checkbox/checkbox.js.map +1 -1
  19. package/cjs/core/type.d.ts +10 -8
  20. package/cjs/core/type.js.map +1 -1
  21. package/cjs/data-zoom/data-zoom.d.ts +5 -1
  22. package/cjs/data-zoom/data-zoom.js +136 -78
  23. package/cjs/data-zoom/data-zoom.js.map +1 -1
  24. package/cjs/index.d.ts +2 -1
  25. package/cjs/index.js +3 -2
  26. package/cjs/index.js.map +1 -1
  27. package/cjs/indicator/indicator.d.ts +3 -1
  28. package/cjs/indicator/indicator.js +60 -46
  29. package/cjs/indicator/indicator.js.map +1 -1
  30. package/cjs/indicator/type.d.ts +1 -0
  31. package/cjs/indicator/type.js.map +1 -1
  32. package/cjs/label/arc.d.ts +2 -2
  33. package/cjs/label/arc.js +38 -35
  34. package/cjs/label/arc.js.map +1 -1
  35. package/cjs/label/base.d.ts +6 -8
  36. package/cjs/label/base.js +92 -65
  37. package/cjs/label/base.js.map +1 -1
  38. package/cjs/label/line.js +3 -4
  39. package/cjs/label/line.js.map +1 -1
  40. package/cjs/label/type.d.ts +15 -8
  41. package/cjs/label/type.js.map +1 -1
  42. package/cjs/label/util.d.ts +4 -0
  43. package/cjs/label/util.js +24 -3
  44. package/cjs/label/util.js.map +1 -1
  45. package/cjs/legend/base.js +1 -1
  46. package/cjs/legend/base.js.map +1 -1
  47. package/cjs/legend/discrete/discrete.d.ts +1 -14
  48. package/cjs/legend/discrete/discrete.js +39 -60
  49. package/cjs/legend/discrete/discrete.js.map +1 -1
  50. package/cjs/legend/discrete/type.d.ts +0 -1
  51. package/cjs/legend/discrete/type.js.map +1 -1
  52. package/cjs/legend/type.d.ts +2 -2
  53. package/cjs/legend/type.js.map +1 -1
  54. package/cjs/marker/area.js +5 -1
  55. package/cjs/marker/area.js.map +1 -1
  56. package/cjs/marker/base.d.ts +1 -0
  57. package/cjs/marker/base.js +6 -3
  58. package/cjs/marker/base.js.map +1 -1
  59. package/cjs/marker/line.js +7 -1
  60. package/cjs/marker/line.js.map +1 -1
  61. package/cjs/marker/point.d.ts +1 -0
  62. package/cjs/marker/point.js +24 -11
  63. package/cjs/marker/point.js.map +1 -1
  64. package/cjs/marker/type.d.ts +1 -0
  65. package/cjs/marker/type.js.map +1 -1
  66. package/cjs/pager/pager.d.ts +0 -2
  67. package/cjs/pager/pager.js +8 -16
  68. package/cjs/pager/pager.js.map +1 -1
  69. package/cjs/pager/type.d.ts +0 -1
  70. package/cjs/pager/type.js.map +1 -1
  71. package/cjs/scrollbar/scrollbar.js +9 -3
  72. package/cjs/scrollbar/scrollbar.js.map +1 -1
  73. package/cjs/segment/segment.js +1 -1
  74. package/cjs/segment/segment.js.map +1 -1
  75. package/cjs/slider/slider.js +1 -1
  76. package/cjs/slider/slider.js.map +1 -1
  77. package/cjs/tag/tag.js +28 -42
  78. package/cjs/tag/tag.js.map +1 -1
  79. package/cjs/title/title.js +2 -2
  80. package/cjs/title/title.js.map +1 -1
  81. package/cjs/tooltip/tooltip.js +1 -1
  82. package/cjs/tooltip/tooltip.js.map +1 -1
  83. package/cjs/util/limit-shape.d.ts +4 -0
  84. package/cjs/util/limit-shape.js +13 -4
  85. package/cjs/util/limit-shape.js.map +1 -1
  86. package/cjs/util/text.d.ts +5 -2
  87. package/cjs/util/text.js +19 -6
  88. package/cjs/util/text.js.map +1 -1
  89. package/es/axis/base.js +22 -26
  90. package/es/axis/base.js.map +1 -1
  91. package/es/axis/grid/base.js +1 -1
  92. package/es/axis/grid/base.js.map +1 -1
  93. package/es/axis/line.js +59 -50
  94. package/es/axis/line.js.map +1 -1
  95. package/es/axis/overlap/auto-hide.d.ts +1 -0
  96. package/es/axis/overlap/auto-hide.js +10 -2
  97. package/es/axis/overlap/auto-hide.js.map +1 -1
  98. package/es/axis/overlap/auto-limit.d.ts +1 -0
  99. package/es/axis/overlap/auto-limit.js +5 -3
  100. package/es/axis/overlap/auto-limit.js.map +1 -1
  101. package/es/axis/type.d.ts +1 -0
  102. package/es/axis/type.js.map +1 -1
  103. package/es/brush/brush.js +4 -4
  104. package/es/brush/brush.js.map +1 -1
  105. package/es/checkbox/checkbox.js +2 -1
  106. package/es/checkbox/checkbox.js.map +1 -1
  107. package/es/core/type.d.ts +10 -8
  108. package/es/core/type.js.map +1 -1
  109. package/es/data-zoom/data-zoom.d.ts +5 -1
  110. package/es/data-zoom/data-zoom.js +135 -74
  111. package/es/data-zoom/data-zoom.js.map +1 -1
  112. package/es/index.d.ts +2 -1
  113. package/es/index.js +3 -1
  114. package/es/index.js.map +1 -1
  115. package/es/indicator/indicator.d.ts +3 -1
  116. package/es/indicator/indicator.js +57 -47
  117. package/es/indicator/indicator.js.map +1 -1
  118. package/es/indicator/type.d.ts +1 -0
  119. package/es/indicator/type.js.map +1 -1
  120. package/es/label/arc.d.ts +2 -2
  121. package/es/label/arc.js +38 -35
  122. package/es/label/arc.js.map +1 -1
  123. package/es/label/base.d.ts +6 -8
  124. package/es/label/base.js +92 -65
  125. package/es/label/base.js.map +1 -1
  126. package/es/label/line.js +3 -4
  127. package/es/label/line.js.map +1 -1
  128. package/es/label/type.d.ts +15 -8
  129. package/es/label/type.js.map +1 -1
  130. package/es/label/util.d.ts +4 -0
  131. package/es/label/util.js +22 -2
  132. package/es/label/util.js.map +1 -1
  133. package/es/legend/base.js +1 -1
  134. package/es/legend/base.js.map +1 -1
  135. package/es/legend/discrete/discrete.d.ts +1 -14
  136. package/es/legend/discrete/discrete.js +40 -58
  137. package/es/legend/discrete/discrete.js.map +1 -1
  138. package/es/legend/discrete/type.d.ts +0 -1
  139. package/es/legend/discrete/type.js.map +1 -1
  140. package/es/legend/type.d.ts +2 -2
  141. package/es/legend/type.js.map +1 -1
  142. package/es/marker/area.js +6 -2
  143. package/es/marker/area.js.map +1 -1
  144. package/es/marker/base.d.ts +1 -0
  145. package/es/marker/base.js +6 -3
  146. package/es/marker/base.js.map +1 -1
  147. package/es/marker/line.js +8 -2
  148. package/es/marker/line.js.map +1 -1
  149. package/es/marker/point.d.ts +1 -0
  150. package/es/marker/point.js +25 -11
  151. package/es/marker/point.js.map +1 -1
  152. package/es/marker/type.d.ts +1 -0
  153. package/es/marker/type.js.map +1 -1
  154. package/es/pager/pager.d.ts +0 -2
  155. package/es/pager/pager.js +8 -17
  156. package/es/pager/pager.js.map +1 -1
  157. package/es/pager/type.d.ts +0 -1
  158. package/es/pager/type.js.map +1 -1
  159. package/es/scrollbar/scrollbar.js +9 -3
  160. package/es/scrollbar/scrollbar.js.map +1 -1
  161. package/es/segment/segment.js +1 -1
  162. package/es/segment/segment.js.map +1 -1
  163. package/es/slider/slider.js +1 -1
  164. package/es/slider/slider.js.map +1 -1
  165. package/es/tag/tag.js +29 -45
  166. package/es/tag/tag.js.map +1 -1
  167. package/es/title/title.js +3 -3
  168. package/es/title/title.js.map +1 -1
  169. package/es/tooltip/tooltip.js +1 -1
  170. package/es/tooltip/tooltip.js.map +1 -1
  171. package/es/util/limit-shape.d.ts +4 -0
  172. package/es/util/limit-shape.js +11 -3
  173. package/es/util/limit-shape.js.map +1 -1
  174. package/es/util/text.d.ts +5 -2
  175. package/es/util/text.js +17 -5
  176. package/es/util/text.js.map +1 -1
  177. package/package.json +5 -5
  178. package/dist/index.js +0 -29932
  179. package/dist/index.min.js +0 -1
@@ -4,7 +4,7 @@ import { AbstractComponent } from '../core/base';
4
4
  import type { PointLocationCfg } from '../core/type';
5
5
  import type { Bitmap } from './overlap';
6
6
  import { bitmapTool } from './overlap';
7
- import type { BaseLabelAttrs, ILabelAnimation, LabelItem, ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation } from './type';
7
+ import type { BaseLabelAttrs, ILabelAnimation, LabelItem, ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation, LabelContent } from './type';
8
8
  import type { ComponentOptions } from '../interface';
9
9
  export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {
10
10
  name: string;
@@ -20,10 +20,7 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractCompone
20
20
  setBitmap(bitmap: Bitmap): void;
21
21
  protected _bmpTool?: ReturnType<typeof bitmapTool>;
22
22
  setBitmapTool(bmpTool: ReturnType<typeof bitmapTool>): void;
23
- protected _graphicToText: Map<IGraphic, {
24
- text: IText | IRichText;
25
- labelLine?: ILine;
26
- }>;
23
+ protected _graphicToText: Map<IGraphic, LabelContent>;
27
24
  protected _idToGraphic: Map<string, IGraphic>;
28
25
  protected _idToPoint: Map<string, IPointLike>;
29
26
  onAfterLabelOverlap?: (bitmap: Bitmap) => void;
@@ -35,18 +32,19 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractCompone
35
32
  x: number;
36
33
  y: number;
37
34
  } | undefined;
38
- protected _labelLine(text: LabelItem): ILine | undefined;
35
+ protected _createLabelLine(text: IText | IRichText, baseMark?: IGraphic): ILine | undefined;
39
36
  protected render(): void;
40
37
  private _bindEvent;
41
38
  private _setStatesOfText;
42
- private _setStatesOfLabelLine;
39
+ protected _setStatesOfLabelLine(target: IGraphic): void;
43
40
  private _onHover;
44
41
  private _onUnHover;
45
42
  private _onClick;
46
43
  protected _createLabelText(attributes: LabelItem): IRichText | IText;
47
44
  private _prepare;
48
45
  protected getRelatedGraphic(item: LabelItem): IGraphic<Partial<import("@visactor/vrender-core").IGraphicAttribute>>;
49
- protected _layout(data?: LabelItem[]): (IText | IRichText)[];
46
+ protected _initText(data?: LabelItem[]): (IText | IRichText)[];
47
+ protected _layout(texts: (IText | IRichText)[]): (IText | IRichText)[];
50
48
  protected _overlapping(labels: (IText | IRichText)[]): (IRichText | IText)[];
51
49
  protected getBaseMarkGroup(): IGroup;
52
50
  protected getGraphicBounds(graphic?: IGraphic, point?: Partial<PointLocationCfg>, position?: string): IBoundsLike;
package/es/label/base.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { graphicCreator, AttributeUpdateType, IContainPointMode } from "@visactor/vrender-core";
2
2
 
3
- import { isFunction, isEmpty, isValid, isString, merge, isRectIntersect, isNil, isArray } from "@visactor/vutils";
3
+ import { isFunction, isEmpty, isValid, isString, merge, isRectIntersect, isNil, isArray, isObject } from "@visactor/vutils";
4
4
 
5
5
  import { AbstractComponent } from "../core/base";
6
6
 
7
7
  import { labelSmartInvert, contrastAccessibilityChecker, smartInvertStrategy } from "../util/label-smartInvert";
8
8
 
9
- import { getMarksByName, getNoneGroupMarksByName, traverseGroup } from "../util";
9
+ import { getMarksByName, getNoneGroupMarksByName, isRichText, richTextAttributeTransform, traverseGroup } from "../util";
10
10
 
11
11
  import { StateValue } from "../constant";
12
12
 
@@ -14,9 +14,7 @@ import { bitmapTool, boundToRange, canPlace, clampText, place } from "./overlap"
14
14
 
15
15
  import { DefaultLabelAnimation, getAnimationAttributes, updateAnimation } from "./animate/animate";
16
16
 
17
- import { getPointsOfLineArea } from "./util";
18
-
19
- import { DEFAULT_HTML_TEXT_SPEC } from "../constant";
17
+ import { connectLineBetweenBounds, getPointsOfLineArea } from "./util";
20
18
 
21
19
  import { loadLabelComponent } from "./register";
22
20
 
@@ -51,9 +49,9 @@ export class LabelBase extends AbstractComponent {
51
49
  node === target || isEmpty(node.states) || node.addState(StateValue.selectedReverse, !0);
52
50
  })), this._lastSelect = target);
53
51
  }, this._handleRelatedGraphicSetState = e => {
54
- var _a, _b, _c;
55
- if ((null === (_a = e.detail) || void 0 === _a ? void 0 : _a.type) === AttributeUpdateType.STATE) {
56
- const currentStates = null !== (_c = null === (_b = e.target) || void 0 === _b ? void 0 : _b.currentStates) && void 0 !== _c ? _c : [];
52
+ var _a, _b, _c, _d, _e;
53
+ if ((null === (_a = e.detail) || void 0 === _a ? void 0 : _a.type) === AttributeUpdateType.STATE || (null === (_b = e.detail) || void 0 === _b ? void 0 : _b.type) === AttributeUpdateType.ANIMATE_UPDATE && (null === (_c = e.detail.animationState) || void 0 === _c ? void 0 : _c.isFirstFrameOfStep)) {
54
+ const currentStates = null !== (_e = null === (_d = e.target) || void 0 === _d ? void 0 : _d.currentStates) && void 0 !== _e ? _e : [];
57
55
  (this._isCollectionBase ? [ ...this._graphicToText.values() ] : [ this._graphicToText.get(e.target) ]).forEach((label => {
58
56
  label && (label.text && label.text.useStates(currentStates), label.labelLine && label.labelLine.useStates(currentStates));
59
57
  }));
@@ -61,12 +59,24 @@ export class LabelBase extends AbstractComponent {
61
59
  };
62
60
  }
63
61
  labeling(textBounds, graphicBounds, position, offset) {}
64
- _labelLine(text) {}
62
+ _createLabelLine(text, baseMark) {
63
+ const points = connectLineBetweenBounds(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds);
64
+ if (points) {
65
+ const line = graphicCreator.line({
66
+ points: points
67
+ });
68
+ return baseMark && baseMark.attribute.fill && line.setAttribute("stroke", baseMark.attribute.fill),
69
+ this.attribute.line && !isEmpty(this.attribute.line.style) && line.setAttributes(this.attribute.line.style),
70
+ this._setStatesOfLabelLine(line), line;
71
+ }
72
+ }
65
73
  render() {
66
74
  if (this._prepare(), isNil(this._idToGraphic) || this._isCollectionBase && isNil(this._idToPoint)) return;
67
75
  const {overlap: overlap, smartInvert: smartInvert, dataFilter: dataFilter, customLayoutFunc: customLayoutFunc, customOverlapFunc: customOverlapFunc} = this.attribute;
68
- let labels, data = this.attribute.data;
69
- isFunction(dataFilter) && (data = dataFilter(data)), labels = isFunction(customLayoutFunc) ? customLayoutFunc(data, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null) : this._layout(data),
76
+ let data = this.attribute.data;
77
+ isFunction(dataFilter) && (data = dataFilter(data));
78
+ let labels = this._initText(data);
79
+ labels = isFunction(customLayoutFunc) ? customLayoutFunc(data, labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null) : this._layout(labels),
70
80
  isFunction(customOverlapFunc) ? labels = customOverlapFunc(labels, this.getRelatedGraphic.bind(this), this._isCollectionBase ? d => this._idToPoint.get(d.id) : null) : !1 !== overlap && (labels = this._overlapping(labels)),
71
81
  labels && labels.length && labels.forEach((label => {
72
82
  this._bindEvent(label), this._setStatesOfText(label);
@@ -90,19 +100,7 @@ export class LabelBase extends AbstractComponent {
90
100
  state && !isEmpty(state) && (target.states = state);
91
101
  }
92
102
  _createLabelText(attributes) {
93
- var _a, _b;
94
- if ("rich" === attributes.textType) {
95
- attributes.textConfig = attributes.text, attributes.width = null !== (_a = attributes.width) && void 0 !== _a ? _a : 0,
96
- attributes.height = null !== (_b = attributes.height) && void 0 !== _b ? _b : 0;
97
- return graphicCreator.richtext(attributes);
98
- }
99
- if ("html" === attributes.textType) {
100
- attributes.textConfig = [], attributes.html = Object.assign(Object.assign({
101
- dom: attributes.text
102
- }, DEFAULT_HTML_TEXT_SPEC), attributes);
103
- return graphicCreator.richtext(attributes);
104
- }
105
- return graphicCreator.text(attributes);
103
+ return isRichText(attributes, "textType") ? graphicCreator.richtext(richTextAttributeTransform(attributes)) : graphicCreator.text(attributes);
106
104
  }
107
105
  _prepare() {
108
106
  var _a, _b, _c, _d, _e;
@@ -121,7 +119,7 @@ export class LabelBase extends AbstractComponent {
121
119
  let cur = 0;
122
120
  for (let i = 0; i < currentBaseMarks.length; i++) {
123
121
  const baseMark = currentBaseMarks[i], points = getPointsOfLineArea(baseMark);
124
- if (null == points ? void 0 : points.length) for (let j = 0; j < points.length; j++) {
122
+ if (points && points.length) for (let j = 0; j < points.length; j++) {
125
123
  const textData = data[cur];
126
124
  textData && points[j] && (isValid(textData.id) || (textData.id = `vrender-component-${this.name}-${cur}`),
127
125
  this._idToPoint.set(textData.id, points[j]), this._idToGraphic.set(textData.id, baseMark)),
@@ -133,34 +131,53 @@ export class LabelBase extends AbstractComponent {
133
131
  textData && baseMark && (isValid(textData.id) || (textData.id = `vrender-component-${this.name}-${i}`),
134
132
  this._idToGraphic.set(textData.id, baseMark));
135
133
  }
136
- !1 !== this.attribute.animation && (this._animationConfig = {
137
- enter: merge({}, DefaultLabelAnimation, this.attribute.animation, null !== (_c = this.attribute.animationEnter) && void 0 !== _c ? _c : {}),
138
- exit: merge({}, DefaultLabelAnimation, this.attribute.animation, null !== (_d = this.attribute.animationExit) && void 0 !== _d ? _d : {}),
139
- update: isArray(this.attribute.animationUpdate) ? this.attribute.animationUpdate : merge({}, DefaultLabelAnimation, this.attribute.animation, null !== (_e = this.attribute.animationUpdate) && void 0 !== _e ? _e : {})
140
- });
134
+ if (!1 !== this.attribute.animation) {
135
+ const animation = isObject(this.attribute.animation) ? this.attribute.animation : {};
136
+ this._animationConfig = {
137
+ enter: merge({}, DefaultLabelAnimation, animation, null !== (_c = this.attribute.animationEnter) && void 0 !== _c ? _c : {}),
138
+ exit: merge({}, DefaultLabelAnimation, animation, null !== (_d = this.attribute.animationExit) && void 0 !== _d ? _d : {}),
139
+ update: isArray(this.attribute.animationUpdate) ? this.attribute.animationUpdate : merge({}, DefaultLabelAnimation, animation, null !== (_e = this.attribute.animationUpdate) && void 0 !== _e ? _e : {})
140
+ };
141
+ }
141
142
  }
142
143
  }
143
144
  getRelatedGraphic(item) {
144
145
  return this._idToGraphic.get(item.id);
145
146
  }
146
- _layout(data = []) {
147
- const {textStyle: textStyle = {}, position: position, offset: offset} = this.attribute, labels = [];
147
+ _initText(data = []) {
148
+ const {textStyle: textStyle = {}} = this.attribute, labels = [];
148
149
  for (let i = 0; i < data.length; i++) {
149
- const textData = data[i], baseMark = this.getRelatedGraphic(textData), labelAttribute = Object.assign(Object.assign({
150
+ const textData = data[i], baseMark = this.getRelatedGraphic(textData);
151
+ if (!baseMark) continue;
152
+ const labelAttribute = Object.assign(Object.assign({
150
153
  fill: this._isCollectionBase ? isArray(baseMark.attribute.stroke) ? baseMark.attribute.stroke.find((entry => !!entry && !0 !== entry)) : baseMark.attribute.stroke : baseMark.attribute.fill
151
- }, textStyle), textData), text = this._createLabelText(labelAttribute), textBounds = this.getGraphicBounds(text), actualPosition = isFunction(position) ? position(textData) : position, graphicBounds = this._isCollectionBase ? this.getGraphicBounds(null, this._idToPoint.get(textData.id), actualPosition) : this.getGraphicBounds(baseMark, {
154
+ }, textStyle), textData), text = this._createLabelText(labelAttribute);
155
+ labels.push(text);
156
+ }
157
+ return labels;
158
+ }
159
+ _layout(texts) {
160
+ const {position: position, offset: offset} = this.attribute;
161
+ for (let i = 0; i < texts.length; i++) {
162
+ const text = texts[i];
163
+ if (!text) return;
164
+ const textData = text.attribute, baseMark = this.getRelatedGraphic(textData);
165
+ if (!baseMark) continue;
166
+ text.attachedThemeGraphic = this;
167
+ const textBounds = this.getGraphicBounds(text);
168
+ text.attachedThemeGraphic = null;
169
+ const actualPosition = isFunction(position) ? position(textData) : position, graphicBounds = this._isCollectionBase ? this.getGraphicBounds(null, this._idToPoint.get(textData.id), actualPosition) : this.getGraphicBounds(baseMark, {
152
170
  x: textData.x,
153
171
  y: textData.y
154
172
  }, actualPosition), textLocation = this.labeling(textBounds, graphicBounds, actualPosition, offset);
155
- textLocation && (labelAttribute.x = textLocation.x, labelAttribute.y = textLocation.y,
156
- text.setAttributes(textLocation)), labels.push(text);
173
+ textLocation && text.setAttributes(textLocation);
157
174
  }
158
- return labels;
175
+ return texts;
159
176
  }
160
177
  _overlapping(labels) {
161
178
  var _a, _b, _c, _d;
162
179
  if (0 === labels.length) return [];
163
- const option = this.attribute.overlap, result = [], baseMarkGroup = this.getBaseMarkGroup(), size = null !== (_a = option.size) && void 0 !== _a ? _a : {
180
+ const option = isObject(this.attribute.overlap) ? this.attribute.overlap : {}, result = [], baseMarkGroup = this.getBaseMarkGroup(), size = null !== (_a = option.size) && void 0 !== _a ? _a : {
164
181
  width: null !== (_b = null == baseMarkGroup ? void 0 : baseMarkGroup.AABBBounds.width()) && void 0 !== _b ? _b : 0,
165
182
  height: null !== (_c = null == baseMarkGroup ? void 0 : baseMarkGroup.AABBBounds.height()) && void 0 !== _c ? _c : 0
166
183
  };
@@ -187,7 +204,7 @@ export class LabelBase extends AbstractComponent {
187
204
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
188
205
  continue;
189
206
  }
190
- if (checkBounds && (null == baseMark ? void 0 : baseMark.AABBBounds) && this._canPlaceInside(text.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds)) {
207
+ if (checkBounds && baseMark && baseMark.AABBBounds && this._canPlaceInside(text.AABBBounds, baseMark.AABBBounds)) {
191
208
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
192
209
  continue;
193
210
  }
@@ -231,22 +248,35 @@ export class LabelBase extends AbstractComponent {
231
248
  if (baseMarkGroupName) return this.getRootNode().find((node => node.name === baseMarkGroupName), !0);
232
249
  }
233
250
  getGraphicBounds(graphic, point = {}) {
234
- return (null == graphic ? void 0 : graphic.AABBBounds) || {
235
- x1: point.x,
236
- x2: point.x,
237
- y1: point.y,
238
- y2: point.y
251
+ if (graphic) {
252
+ if (!1 !== graphic.attribute.visible) return graphic.AABBBounds;
253
+ const {x: x, y: y} = graphic.attribute;
254
+ return {
255
+ x1: x,
256
+ x2: x,
257
+ y1: y,
258
+ y2: y
259
+ };
260
+ }
261
+ const {x: x, y: y} = point;
262
+ return {
263
+ x1: x,
264
+ x2: x,
265
+ y1: y,
266
+ y2: y
239
267
  };
240
268
  }
241
269
  _renderLabels(labels) {
242
270
  !1 === this._enableAnimation || !1 === this.attribute.animation ? this._renderWithOutAnimation(labels) : this._renderWithAnimation(labels);
243
271
  }
244
272
  _renderWithAnimation(labels) {
245
- const currentTextMap = new Map, prevTextMap = this._graphicToText || new Map, texts = [], labelLines = [];
273
+ var _a;
274
+ const currentTextMap = new Map, prevTextMap = this._graphicToText || new Map, texts = [], labelLines = [], {visible: showLabelLine} = null !== (_a = this.attribute.line) && void 0 !== _a ? _a : {};
246
275
  labels.forEach(((text, index) => {
247
- var _a, _b, _c, _d, _e, _f, _g;
248
- const labelLine = this._labelLine(text), relatedGraphic = this.getRelatedGraphic(text.attribute), textId = text.attribute.id, textKey = this._isCollectionBase ? textId : relatedGraphic, state = (null == prevTextMap ? void 0 : prevTextMap.get(textKey)) ? "update" : "enter";
249
- if ("enter" === state) {
276
+ const relatedGraphic = this.getRelatedGraphic(text.attribute), textId = text.attribute.id, textKey = this._isCollectionBase ? textId : relatedGraphic, state = (null == prevTextMap ? void 0 : prevTextMap.get(textKey)) ? "update" : "enter";
277
+ let labelLine;
278
+ if (showLabelLine && (labelLine = this._createLabelLine(text, relatedGraphic)),
279
+ "enter" === state) {
250
280
  if (texts.push(text), currentTextMap.set(textKey, labelLine ? {
251
281
  text: text,
252
282
  labelLine: labelLine
@@ -254,8 +284,8 @@ export class LabelBase extends AbstractComponent {
254
284
  text: text
255
285
  }), relatedGraphic) {
256
286
  const {from: from, to: to} = getAnimationAttributes(text.attribute, "fadeIn");
257
- this.add(text), labelLine && (this._setStatesOfLabelLine(labelLine), labelLines.push(labelLine),
258
- this.add(labelLine)), this._syncStateWithRelatedGraphic(relatedGraphic), this._animationConfig.enter.duration > 0 && relatedGraphic.once("animate-bind", (a => {
287
+ this.add(text), labelLine && (labelLines.push(labelLine), this.add(labelLine)),
288
+ this._syncStateWithRelatedGraphic(relatedGraphic), this._animationConfig.enter.duration > 0 && relatedGraphic.once("animate-bind", (a => {
259
289
  text.setAttributes(from), labelLine && labelLine.setAttributes(from);
260
290
  const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, labelLine, labelLines, index, relatedGraphic, to, this._animationConfig.enter);
261
291
  relatedGraphic.on("afterAttributeUpdate", listener);
@@ -265,24 +295,23 @@ export class LabelBase extends AbstractComponent {
265
295
  const prevLabel = prevTextMap.get(textKey);
266
296
  prevTextMap.delete(textKey), currentTextMap.set(textKey, prevLabel);
267
297
  const prevText = prevLabel.text, {duration: duration, easing: easing} = this._animationConfig.update;
268
- updateAnimation(prevText, text, this._animationConfig.update), prevLabel.labelLine && prevLabel.labelLine.animate().to(merge({}, prevLabel.labelLine.attribute, {
269
- visible: null === (_f = null !== (_d = (null === (_b = null === (_a = text.attribute) || void 0 === _a ? void 0 : _a.line) || void 0 === _b ? void 0 : _b.visible) && (null === (_c = text.attribute) || void 0 === _c ? void 0 : _c.visible)) && void 0 !== _d ? _d : null === (_e = text.attribute) || void 0 === _e ? void 0 : _e.visible) || void 0 === _f || _f,
270
- points: null === (_g = text.attribute) || void 0 === _g ? void 0 : _g.points
271
- }), duration, easing);
298
+ updateAnimation(prevText, text, this._animationConfig.update), prevLabel.labelLine && labelLine && prevLabel.labelLine.animate().to(labelLine.attribute, duration, easing);
272
299
  }
273
300
  })), prevTextMap.forEach((label => {
274
301
  var _a;
275
302
  null === (_a = label.text) || void 0 === _a || _a.animate().to(getAnimationAttributes(label.text.attribute, "fadeOut").to, this._animationConfig.exit.duration, this._animationConfig.exit.easing).onEnd((() => {
276
- this.removeChild(label.text), (null == label ? void 0 : label.labelLine) && this.removeChild(label.labelLine);
303
+ this.removeChild(label.text), label.labelLine && this.removeChild(label.labelLine);
277
304
  }));
278
305
  })), this._graphicToText = currentTextMap;
279
306
  }
280
307
  _renderWithOutAnimation(labels) {
281
- const currentTextMap = new Map, prevTextMap = this._graphicToText || new Map, texts = [];
308
+ var _a;
309
+ const currentTextMap = new Map, prevTextMap = this._graphicToText || new Map, texts = [], {visible: showLabelLine} = null !== (_a = this.attribute.line) && void 0 !== _a ? _a : {};
282
310
  labels.forEach((text => {
283
- var _a;
284
- const labelLine = this._labelLine(text), relatedGraphic = this.getRelatedGraphic(text.attribute), state = (null == prevTextMap ? void 0 : prevTextMap.get(relatedGraphic)) ? "update" : "enter", textKey = this._isCollectionBase ? text.attribute.id : relatedGraphic;
285
- if ("enter" === state) texts.push(text), currentTextMap.set(textKey, labelLine ? {
311
+ const relatedGraphic = this.getRelatedGraphic(text.attribute), state = (null == prevTextMap ? void 0 : prevTextMap.get(relatedGraphic)) ? "update" : "enter", textKey = this._isCollectionBase ? text.attribute.id : relatedGraphic;
312
+ let labelLine;
313
+ if (showLabelLine && (labelLine = this._createLabelLine(text, relatedGraphic)),
314
+ "enter" === state) texts.push(text), currentTextMap.set(textKey, labelLine ? {
286
315
  text: text,
287
316
  labelLine: labelLine
288
317
  } : {
@@ -290,12 +319,10 @@ export class LabelBase extends AbstractComponent {
290
319
  }), this.add(text), labelLine && this.add(labelLine), this._syncStateWithRelatedGraphic(relatedGraphic); else if ("update" === state) {
291
320
  const prevLabel = prevTextMap.get(textKey);
292
321
  prevTextMap.delete(textKey), currentTextMap.set(textKey, prevLabel), prevLabel.text.setAttributes(text.attribute),
293
- (null == prevLabel ? void 0 : prevLabel.labelLine) && prevLabel.labelLine.setAttributes({
294
- points: null === (_a = text.attribute) || void 0 === _a ? void 0 : _a.points
295
- });
322
+ prevLabel.labelLine && labelLine && prevLabel.labelLine.setAttributes(labelLine.attribute);
296
323
  }
297
324
  })), prevTextMap.forEach((label => {
298
- this.removeChild(label.text), (null == label ? void 0 : label.labelLine) && this.removeChild(label.labelLine);
325
+ this.removeChild(label.text), label.labelLine && this.removeChild(label.labelLine);
299
326
  })), this._graphicToText = currentTextMap;
300
327
  }
301
328
  _syncStateWithRelatedGraphic(relatedGraphic) {
@@ -345,7 +372,7 @@ export class LabelBase extends AbstractComponent {
345
372
  }
346
373
  _smartInvert(labels) {
347
374
  var _a, _b, _c, _d, _e;
348
- const option = this.attribute.smartInvert || {}, {textType: textType, contrastRatiosThreshold: contrastRatiosThreshold, alternativeColors: alternativeColors, mode: mode} = option, fillStrategy = null !== (_a = option.fillStrategy) && void 0 !== _a ? _a : "invertBase", strokeStrategy = null !== (_b = option.strokeStrategy) && void 0 !== _b ? _b : "base", brightColor = null !== (_c = option.brightColor) && void 0 !== _c ? _c : "#ffffff", darkColor = null !== (_d = option.darkColor) && void 0 !== _d ? _d : "#000000", outsideEnable = null !== (_e = option.outsideEnable) && void 0 !== _e && _e;
375
+ const option = isObject(this.attribute.smartInvert) ? this.attribute.smartInvert : {}, {textType: textType, contrastRatiosThreshold: contrastRatiosThreshold, alternativeColors: alternativeColors, mode: mode} = option, fillStrategy = null !== (_a = option.fillStrategy) && void 0 !== _a ? _a : "invertBase", strokeStrategy = null !== (_b = option.strokeStrategy) && void 0 !== _b ? _b : "base", brightColor = null !== (_c = option.brightColor) && void 0 !== _c ? _c : "#ffffff", darkColor = null !== (_d = option.darkColor) && void 0 !== _d ? _d : "#000000", outsideEnable = null !== (_e = option.outsideEnable) && void 0 !== _e && _e;
349
376
  if ("null" !== fillStrategy || "null" !== strokeStrategy) for (let i = 0; i < labels.length; i++) {
350
377
  const label = labels[i];
351
378
  if (!label) continue;
@@ -360,7 +387,7 @@ export class LabelBase extends AbstractComponent {
360
387
  stroke: stroke
361
388
  });
362
389
  } else {
363
- if (this._canPlaceInside(label.AABBBounds, null == baseMark ? void 0 : baseMark.AABBBounds)) {
390
+ if (this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds)) {
364
391
  const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
365
392
  if (fill && label.setAttributes({
366
393
  fill: fill