@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
package/es/core/type.d.ts CHANGED
@@ -28,16 +28,18 @@ export type Padding = number | number[] | {
28
28
  right?: number;
29
29
  };
30
30
  type CommonTextContent = {
31
- type?: 'text';
32
- text?: string | string[] | number | number[];
31
+ text?: string | string[] | number | number[] | {
32
+ type?: 'text';
33
+ text: string | string[] | number | number[];
34
+ };
33
35
  };
34
36
  type RichTextContent = {
35
- type?: 'rich';
36
- text?: IRichTextCharacter[];
37
+ text?: {
38
+ type: 'rich';
39
+ text: IRichTextCharacter[];
40
+ };
37
41
  };
38
- type HtmlTextContent = {
39
- type?: 'html';
40
- text?: string | HTMLElement;
42
+ export type TextContent = (CommonTextContent | RichTextContent) & {
43
+ type?: 'text' | 'rich';
41
44
  };
42
- export type TextContent = CommonTextContent | RichTextContent | HtmlTextContent;
43
45
  export {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IRichTextCharacter } from '@visactor/vrender-core';\n\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport interface LocationCfg {\n [key: string]: any;\n}\n\nexport interface PointLocationCfg extends LocationCfg {\n /**\n * 位置 x\n * @type {number}\n */\n x: number;\n /**\n * 位置 y\n * @type {number}\n */\n y: number;\n}\n\nexport interface RegionLocationCfg extends LocationCfg {\n /**\n * 起始点\n */\n start: Point;\n /**\n * 结束点\n */\n end: Point;\n}\n\nexport type State<T> = {\n [key: string]: T;\n};\n\nexport type BaseGraphicAttributes<T> = {\n /**\n * 基础样式设置\n */\n style?: T;\n /**\n * 状态样式设置\n */\n state?: State<T>;\n};\n\nexport type Padding =\n | number\n | number[]\n | {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n };\n\ntype CommonTextContent = {\n type?: 'text';\n text?: string | string[] | number | number[];\n};\n\ntype RichTextContent = {\n type?: 'rich';\n text?: IRichTextCharacter[];\n};\n\ntype HtmlTextContent = {\n type?: 'html';\n text?: string | HTMLElement;\n};\n\nexport type TextContent = CommonTextContent | RichTextContent | HtmlTextContent;\n"]}
1
+ {"version":3,"sources":["../src/core/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IRichTextCharacter } from '@visactor/vrender-core';\n\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport interface LocationCfg {\n [key: string]: any;\n}\n\nexport interface PointLocationCfg extends LocationCfg {\n /**\n * 位置 x\n * @type {number}\n */\n x: number;\n /**\n * 位置 y\n * @type {number}\n */\n y: number;\n}\n\nexport interface RegionLocationCfg extends LocationCfg {\n /**\n * 起始点\n */\n start: Point;\n /**\n * 结束点\n */\n end: Point;\n}\n\nexport type State<T> = {\n [key: string]: T;\n};\n\nexport type BaseGraphicAttributes<T> = {\n /**\n * 基础样式设置\n */\n style?: T;\n /**\n * 状态样式设置\n */\n state?: State<T>;\n};\n\nexport type Padding =\n | number\n | number[]\n | {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n };\n\ntype CommonTextContent = {\n text?:\n | string\n | string[]\n | number\n | number[]\n | {\n type?: 'text';\n text: string | string[] | number | number[];\n };\n};\n\ntype RichTextContent = {\n text?: {\n type: 'rich';\n text: IRichTextCharacter[];\n };\n};\n\nexport type TextContent = (CommonTextContent | RichTextContent) & {\n /** @deprecated */\n type?: 'text' | 'rich';\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { FederatedPointerEvent, IGroup } from '@visactor/vrender-core';
2
- import type { IPointLike } from '@visactor/vutils';
2
+ import type { IBoundsLike, IPointLike } from '@visactor/vutils';
3
3
  import { AbstractComponent } from '../core/base';
4
4
  import type { TagAttributes } from '../tag';
5
5
  import { Tag } from '../tag';
@@ -154,7 +154,9 @@ export declare class DataZoom extends AbstractComponent<Required<DataZoomAttribu
154
154
  private _previewPointsY1;
155
155
  private _statePointToData;
156
156
  private _layoutAttrFromConfig;
157
+ setPropsFromAttrs(): void;
157
158
  constructor(attributes: DataZoomAttributes, options?: ComponentOptions);
159
+ setAttributes(params: Partial<Required<DataZoomAttributes>>, forceUpdateTag?: boolean): void;
158
160
  protected bindEvents(): void;
159
161
  protected dragMaskSize(): number;
160
162
  protected setStateAttr(start: number, end: number, shouldRender: boolean): void;
@@ -170,6 +172,8 @@ export declare class DataZoom extends AbstractComponent<Required<DataZoomAttribu
170
172
  protected backgroundDragZoom(startPos: IPointLike, endPos: IPointLike): void;
171
173
  protected moveZoomWithMiddle(middle: number): void;
172
174
  protected renderDragMask(): void;
175
+ protected isTextOverflow(componentBoundsLike: IBoundsLike, textBounds: IBoundsLike | null, layout: 'start' | 'end'): boolean;
176
+ protected setTextAttr(startTextBounds: IBoundsLike, endTextBounds: IBoundsLike): void;
173
177
  protected renderText(): void;
174
178
  protected getLayoutAttrFromConfig(): any;
175
179
  protected render(): void;
@@ -10,7 +10,7 @@ var __rest = this && this.__rest || function(s, e) {
10
10
 
11
11
  import { vglobal } from "@visactor/vrender-core";
12
12
 
13
- import { array, clamp, debounce, isFunction, isValid, merge, throttle } from "@visactor/vutils";
13
+ import { Bounds, array, clamp, debounce, isFunction, isValid, merge, throttle } from "@visactor/vutils";
14
14
 
15
15
  import { AbstractComponent } from "../core/base";
16
16
 
@@ -30,6 +30,16 @@ const delayMap = {
30
30
  loadDataZoomComponent();
31
31
 
32
32
  export class DataZoom extends AbstractComponent {
33
+ setPropsFromAttrs() {
34
+ const {start: start, end: end, orient: orient, previewData: previewData, previewPointsX: previewPointsX, previewPointsY: previewPointsY, previewPointsX1: previewPointsX1, previewPointsY1: previewPointsY1} = this.attribute;
35
+ start && (this.state.start = start), end && (this.state.end = end);
36
+ const {width: width, height: height} = this.getLayoutAttrFromConfig();
37
+ this._spanCache = this.state.end - this.state.start, this._isHorizontal = "top" === orient || "bottom" === orient,
38
+ this._layoutCache.max = this._isHorizontal ? width : height, this._layoutCache.attPos = this._isHorizontal ? "x" : "y",
39
+ this._layoutCache.attSize = this._isHorizontal ? "width" : "height", previewData && (this._previewData = previewData),
40
+ isFunction(previewPointsX) && (this._previewPointsX = previewPointsX), isFunction(previewPointsY) && (this._previewPointsY = previewPointsY),
41
+ isFunction(previewPointsX1) && (this._previewPointsX1 = previewPointsX1), isFunction(previewPointsY1) && (this._previewPointsY1 = previewPointsY1);
42
+ }
33
43
  constructor(attributes, options) {
34
44
  super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, DataZoom.defaultAttributes, attributes)),
35
45
  this.name = "dataZoom", this._previewData = [], this._activeState = !1, this._activeCache = {
@@ -76,14 +86,12 @@ export class DataZoom extends AbstractComponent {
76
86
  tag: this._activeTag
77
87
  }));
78
88
  }), this.attribute.delayTime);
79
- const {start: start, end: end, size: size, orient: orient, showDetail: showDetail, position: position, previewData: previewData, previewPointsX: previewPointsX, previewPointsY: previewPointsY, previewPointsX1: previewPointsX1, previewPointsY1: previewPointsY1, updateStateCallback: updateStateCallback} = this.attribute, {width: width, height: height} = size;
80
- start && (this.state.start = start), end && (this.state.end = end), this._spanCache = this.state.end - this.state.start,
81
- this._isHorizontal = "top" === orient || "bottom" === orient, this._layoutCache.max = this._isHorizontal ? width : height,
82
- this._layoutCache.attPos = this._isHorizontal ? "x" : "y", this._layoutCache.attSize = this._isHorizontal ? "width" : "height",
89
+ const {position: position, showDetail: showDetail} = attributes;
83
90
  this._activeCache.startPos = position, this._activeCache.lastPos = position, this._showText = "auto" !== showDetail && showDetail,
84
- previewData && (this._previewData = previewData), isFunction(previewPointsX) && (this._previewPointsX = previewPointsX),
85
- isFunction(previewPointsY) && (this._previewPointsY = previewPointsY), isFunction(previewPointsX1) && (this._previewPointsX1 = previewPointsX1),
86
- isFunction(previewPointsY1) && (this._previewPointsY1 = previewPointsY1);
91
+ this.setPropsFromAttrs();
92
+ }
93
+ setAttributes(params, forceUpdateTag) {
94
+ super.setAttributes(params, forceUpdateTag), this.setPropsFromAttrs();
87
95
  }
88
96
  bindEvents() {
89
97
  if (this.attribute.disableTriggerEvent) return;
@@ -115,7 +123,7 @@ export class DataZoom extends AbstractComponent {
115
123
  }
116
124
  eventPosToStagePos(e) {
117
125
  var _a, _b;
118
- const {x: x, y: y} = vglobal.mapToCanvasPoint(e);
126
+ const {x: x, y: y} = vglobal.mapToCanvasPoint(e, this.stage.window.getContext().canvas.nativeCanvas);
119
127
  return {
120
128
  x: x - ((null === (_a = this.stage) || void 0 === _a ? void 0 : _a.x) || 0),
121
129
  y: y - ((null === (_b = this.stage) || void 0 === _b ? void 0 : _b.y) || 0)
@@ -169,55 +177,79 @@ export class DataZoom extends AbstractComponent {
169
177
  height: this._activeState && this._activeTag === DataZoomActiveTag.background && Math.abs(this.dragMaskSize()) || 0
170
178
  }, dragMaskStyle), "rect");
171
179
  }
172
- renderText() {
173
- const {startTextStyle: startTextStyle, endTextStyle: endTextStyle} = this.attribute, {formatMethod: startTextFormat} = startTextStyle, restStartStyle = __rest(startTextStyle, [ "formatMethod" ]), {formatMethod: endTextFormat} = endTextStyle, restEndTextStyle = __rest(endTextStyle, [ "formatMethod" ]), {start: start, end: end} = this.state;
180
+ isTextOverflow(componentBoundsLike, textBounds, layout) {
181
+ if (!textBounds) return !1;
182
+ if (this._isHorizontal) {
183
+ if ("start" === layout) {
184
+ if (textBounds.x1 < componentBoundsLike.x1) return !0;
185
+ } else if (textBounds.x2 > componentBoundsLike.x2) return !0;
186
+ } else if ("start" === layout) {
187
+ if (textBounds.y1 < componentBoundsLike.y1) return !0;
188
+ } else if (textBounds.y2 > componentBoundsLike.y2) return !0;
189
+ return !1;
190
+ }
191
+ setTextAttr(startTextBounds, endTextBounds) {
192
+ const {startTextStyle: startTextStyle, endTextStyle: endTextStyle} = this.attribute, {formatMethod: startTextFormat} = startTextStyle, restStartTextStyle = __rest(startTextStyle, [ "formatMethod" ]), {formatMethod: endTextFormat} = endTextStyle, restEndTextStyle = __rest(endTextStyle, [ "formatMethod" ]), {start: start, end: end} = this.state;
174
193
  this._startValue = this._statePointToData(start), this._endValue = this._statePointToData(end);
175
- const {position: position, width: width, height: height} = this.getLayoutAttrFromConfig();
176
- this._isHorizontal ? (this._startText = this.maybeAddLabel(this._container, merge({}, restStartStyle, {
177
- text: startTextFormat ? startTextFormat(this._startValue) : this._startValue,
194
+ const {position: position, width: width, height: height} = this.getLayoutAttrFromConfig(), startTextValue = startTextFormat ? startTextFormat(this._startValue) : this._startValue, endTextValue = endTextFormat ? endTextFormat(this._endValue) : this._endValue, componentBoundsLike = {
195
+ x1: position.x,
196
+ y1: position.y,
197
+ x2: position.x + width,
198
+ y2: position.y + height
199
+ };
200
+ let startTextPosition, endTextPosition, startTextAlignStyle, endTextAlignStyle;
201
+ this._isHorizontal ? (startTextPosition = {
178
202
  x: position.x + start * width,
179
- y: position.y + height / 2,
180
- visible: this._showText,
181
- pickable: !1,
182
- childrenPickable: !1,
183
- textStyle: {
184
- textAlign: "right",
185
- textBaseline: "middle"
186
- }
187
- }), `data-zoom-start-text-${position}`), this._endText = this.maybeAddLabel(this._container, merge({}, restEndTextStyle, {
188
- text: endTextFormat ? endTextFormat(this._endValue) : this._endValue,
203
+ y: position.y + height / 2
204
+ }, endTextPosition = {
189
205
  x: position.x + end * width,
190
- y: position.y + height / 2,
191
- visible: this._showText,
192
- pickable: !1,
193
- childrenPickable: !1,
194
- textStyle: {
195
- textAlign: "left",
196
- textBaseline: "middle"
197
- }
198
- }), `data-zoom-end-text-${position}`)) : (this._startText = this.maybeAddLabel(this._container, merge({}, restStartStyle, {
199
- text: startTextFormat ? startTextFormat(this._startValue) : this._startValue,
206
+ y: position.y + height / 2
207
+ }, startTextAlignStyle = {
208
+ textAlign: this.isTextOverflow(componentBoundsLike, startTextBounds, "start") ? "left" : "right",
209
+ textBaseline: "middle"
210
+ }, endTextAlignStyle = {
211
+ textAlign: this.isTextOverflow(componentBoundsLike, endTextBounds, "end") ? "right" : "left",
212
+ textBaseline: "middle"
213
+ }) : (startTextPosition = {
200
214
  x: position.x + width / 2,
201
- y: position.y + start * height,
215
+ y: position.y + start * height
216
+ }, endTextPosition = {
217
+ x: position.x + width / 2,
218
+ y: position.y + end * height
219
+ }, startTextAlignStyle = {
220
+ textAlign: "center",
221
+ textBaseline: this.isTextOverflow(componentBoundsLike, startTextBounds, "start") ? "top" : "bottom"
222
+ }, endTextAlignStyle = {
223
+ textAlign: "center",
224
+ textBaseline: this.isTextOverflow(componentBoundsLike, endTextBounds, "end") ? "bottom" : "top"
225
+ }), this._startText = this.maybeAddLabel(this._container, merge({}, restStartTextStyle, {
226
+ text: startTextValue,
227
+ x: startTextPosition.x,
228
+ y: startTextPosition.y,
202
229
  visible: this._showText,
203
230
  pickable: !1,
204
231
  childrenPickable: !1,
205
- textStyle: {
206
- textAlign: "center",
207
- textBaseline: "bottom"
208
- }
232
+ textStyle: startTextAlignStyle
209
233
  }), `data-zoom-start-text-${position}`), this._endText = this.maybeAddLabel(this._container, merge({}, restEndTextStyle, {
210
- text: endTextFormat ? endTextFormat(this._endValue) : this._endValue,
211
- x: position.x + width / 2,
212
- y: position.y + end * height,
234
+ text: endTextValue,
235
+ x: endTextPosition.x,
236
+ y: endTextPosition.y,
213
237
  visible: this._showText,
214
238
  pickable: !1,
215
239
  childrenPickable: !1,
216
- textStyle: {
217
- textAlign: "center",
218
- textBaseline: "top"
219
- }
220
- }), `data-zoom-end-text-${position}`));
240
+ textStyle: endTextAlignStyle
241
+ }), `data-zoom-end-text-${position}`);
242
+ }
243
+ renderText() {
244
+ let startTextBounds = null, endTextBounds = null;
245
+ this.setTextAttr(startTextBounds, endTextBounds), startTextBounds = this._startText.AABBBounds,
246
+ endTextBounds = this._endText.AABBBounds, this.setTextAttr(startTextBounds, endTextBounds),
247
+ startTextBounds = this._startText.AABBBounds, endTextBounds = this._endText.AABBBounds;
248
+ const {x1: x1, x2: x2, y1: y1, y2: y2} = startTextBounds, {dx: startTextDx = 0, dy: startTextDy = 0} = this.attribute.startTextStyle;
249
+ if ((new Bounds).set(x1, y1, x2, y2).intersects(endTextBounds)) {
250
+ const direction = "bottom" === this.attribute.orient || "right" === this.attribute.orient ? -1 : 1;
251
+ this._isHorizontal ? this._startText.setAttribute("dy", startTextDy + direction * Math.abs(endTextBounds.y1 - endTextBounds.y2)) : this._startText.setAttribute("dx", startTextDx + direction * Math.abs(endTextBounds.x1 - endTextBounds.x2));
252
+ } else this._isHorizontal ? this._startText.setAttribute("dy", startTextDy) : this._startText.setAttribute("dx", startTextDx);
221
253
  }
222
254
  getLayoutAttrFromConfig() {
223
255
  var _a, _b, _c, _d;
@@ -249,59 +281,72 @@ export class DataZoom extends AbstractComponent {
249
281
  render() {
250
282
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
251
283
  this._layoutAttrFromConfig = null;
252
- const {orient: orient, backgroundStyle: backgroundStyle, backgroundChartStyle: backgroundChartStyle = {}, selectedBackgroundStyle: selectedBackgroundStyle = {}, selectedBackgroundChartStyle: selectedBackgroundChartStyle = {}, middleHandlerStyle: middleHandlerStyle = {}, startHandlerStyle: startHandlerStyle = {}, endHandlerStyle: endHandlerStyle = {}, brushSelect: brushSelect} = this.attribute, {start: start, end: end} = this.state, {position: position, width: width, height: height} = this.getLayoutAttrFromConfig(), startHandlerMinSize = null !== (_a = startHandlerStyle.triggerMinSize) && void 0 !== _a ? _a : 40, endHandlerMinSize = null !== (_b = endHandlerStyle.triggerMinSize) && void 0 !== _b ? _b : 40, group = this.createOrUpdateChild("dataZoom-container", {}, "group");
253
- if (this._container = group, this._background = group.createOrUpdateChild("background", Object.assign({
284
+ const {orient: orient, backgroundStyle: backgroundStyle, backgroundChartStyle: backgroundChartStyle = {}, selectedBackgroundStyle: selectedBackgroundStyle = {}, selectedBackgroundChartStyle: selectedBackgroundChartStyle = {}, middleHandlerStyle: middleHandlerStyle = {}, startHandlerStyle: startHandlerStyle = {}, endHandlerStyle: endHandlerStyle = {}, brushSelect: brushSelect, zoomLock: zoomLock} = this.attribute, {start: start, end: end} = this.state, {position: position, width: width, height: height} = this.getLayoutAttrFromConfig(), startHandlerMinSize = null !== (_a = startHandlerStyle.triggerMinSize) && void 0 !== _a ? _a : 40, endHandlerMinSize = null !== (_b = endHandlerStyle.triggerMinSize) && void 0 !== _b ? _b : 40, group = this.createOrUpdateChild("dataZoom-container", {}, "group");
285
+ if (this._container = group, this._background = group.createOrUpdateChild("background", Object.assign(Object.assign({
254
286
  x: position.x,
255
287
  y: position.y,
256
288
  width: width,
257
289
  height: height,
258
290
  cursor: brushSelect ? "crosshair" : "auto"
259
- }, backgroundStyle), "rect"), (null === (_c = backgroundChartStyle.line) || void 0 === _c ? void 0 : _c.visible) && this.setPreviewAttributes("line", group),
291
+ }, backgroundStyle), {
292
+ pickable: !zoomLock
293
+ }), "rect"), (null === (_c = backgroundChartStyle.line) || void 0 === _c ? void 0 : _c.visible) && this.setPreviewAttributes("line", group),
260
294
  (null === (_d = backgroundChartStyle.area) || void 0 === _d ? void 0 : _d.visible) && this.setPreviewAttributes("area", group),
261
- brushSelect && this.renderDragMask(), this._isHorizontal ? this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign({
295
+ brushSelect && this.renderDragMask(), this._isHorizontal ? this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
262
296
  x: position.x + start * width,
263
297
  y: position.y,
264
298
  width: (end - start) * width,
265
299
  height: height,
266
300
  cursor: brushSelect ? "crosshair" : "move"
267
- }, selectedBackgroundStyle), "rect") : this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign({
301
+ }, selectedBackgroundStyle), {
302
+ pickable: !zoomLock
303
+ }), "rect") : this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
268
304
  x: position.x,
269
305
  y: position.y + start * height,
270
306
  width: width,
271
307
  height: (end - start) * height,
272
308
  cursor: brushSelect ? "crosshair" : "move"
273
- }, selectedBackgroundStyle), "rect"), (null === (_e = selectedBackgroundChartStyle.line) || void 0 === _e ? void 0 : _e.visible) && this.setSelectedPreviewAttributes("line", group),
309
+ }, selectedBackgroundStyle), {
310
+ pickable: !zoomLock
311
+ }), "rect"), (null === (_e = selectedBackgroundChartStyle.line) || void 0 === _e ? void 0 : _e.visible) && this.setSelectedPreviewAttributes("line", group),
274
312
  (null === (_f = selectedBackgroundChartStyle.area) || void 0 === _f ? void 0 : _f.visible) && this.setSelectedPreviewAttributes("area", group),
275
- this._showText && this.renderText(), this._isHorizontal) {
313
+ this._isHorizontal) {
276
314
  if (middleHandlerStyle.visible) {
277
315
  const middleHandlerBackgroundSize = (null === (_g = middleHandlerStyle.background) || void 0 === _g ? void 0 : _g.size) || 10;
278
- this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign({
316
+ this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign(Object.assign({
279
317
  x: position.x + start * width,
280
318
  y: position.y - middleHandlerBackgroundSize,
281
319
  width: (end - start) * width,
282
320
  height: middleHandlerBackgroundSize
283
- }, null === (_h = middleHandlerStyle.background) || void 0 === _h ? void 0 : _h.style), "rect"),
284
- this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign({
321
+ }, null === (_h = middleHandlerStyle.background) || void 0 === _h ? void 0 : _h.style), {
322
+ pickable: !zoomLock
323
+ }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
285
324
  x: position.x + (start + end) / 2 * width,
286
325
  y: position.y - middleHandlerBackgroundSize / 2,
287
326
  strokeBoundsBuffer: 0,
288
327
  angle: 0,
289
328
  symbolType: null !== (_k = null === (_j = middleHandlerStyle.icon) || void 0 === _j ? void 0 : _j.symbolType) && void 0 !== _k ? _k : "square"
290
- }, middleHandlerStyle.icon), "symbol");
329
+ }, middleHandlerStyle.icon), {
330
+ pickable: !zoomLock
331
+ }), "symbol");
291
332
  }
292
- this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign({
333
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
293
334
  x: position.x + start * width,
294
335
  y: position.y + height / 2,
295
336
  size: height,
296
337
  symbolType: null !== (_l = startHandlerStyle.symbolType) && void 0 !== _l ? _l : "square"
297
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), startHandlerStyle), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign({
338
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), startHandlerStyle), {
339
+ pickable: !zoomLock
340
+ }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
298
341
  x: position.x + end * width,
299
342
  y: position.y + height / 2,
300
343
  size: height,
301
344
  symbolType: null !== (_m = endHandlerStyle.symbolType) && void 0 !== _m ? _m : "square"
302
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), endHandlerStyle), "symbol");
345
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), endHandlerStyle), {
346
+ pickable: !zoomLock
347
+ }), "symbol");
303
348
  const startHandlerWidth = Math.max(this._startHandler.AABBBounds.width(), startHandlerMinSize), startHandlerHeight = Math.max(this._startHandler.AABBBounds.height(), startHandlerMinSize), endHandlerWidth = Math.max(this._endHandler.AABBBounds.width(), endHandlerMinSize), endHandlerHeight = Math.max(this._endHandler.AABBBounds.height(), endHandlerMinSize);
304
- this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign({
349
+ this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign(Object.assign({
305
350
  x: position.x + start * width - startHandlerWidth / 2,
306
351
  y: position.y + height / 2 - startHandlerHeight / 2,
307
352
  width: startHandlerWidth,
@@ -309,7 +354,9 @@ export class DataZoom extends AbstractComponent {
309
354
  fill: "white",
310
355
  fillOpacity: 0,
311
356
  zIndex: 999
312
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign({
357
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
358
+ pickable: !zoomLock
359
+ }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
313
360
  x: position.x + end * width - endHandlerWidth / 2,
314
361
  y: position.y + height / 2 - endHandlerHeight / 2,
315
362
  width: endHandlerWidth,
@@ -317,37 +364,46 @@ export class DataZoom extends AbstractComponent {
317
364
  fill: "white",
318
365
  fillOpacity: 0,
319
366
  zIndex: 999
320
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), "rect");
367
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
368
+ pickable: !zoomLock
369
+ }), "rect");
321
370
  } else {
322
371
  if (middleHandlerStyle.visible) {
323
372
  const middleHandlerBackgroundSize = (null === (_o = middleHandlerStyle.background) || void 0 === _o ? void 0 : _o.size) || 10;
324
- this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign({
373
+ this._middleHandlerRect = group.createOrUpdateChild("middleHandlerRect", Object.assign(Object.assign({
325
374
  x: "left" === orient ? position.x - middleHandlerBackgroundSize : position.x + width,
326
375
  y: position.y + start * height,
327
376
  width: middleHandlerBackgroundSize,
328
377
  height: (end - start) * height
329
- }, null === (_p = middleHandlerStyle.background) || void 0 === _p ? void 0 : _p.style), "rect"),
330
- this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign({
378
+ }, null === (_p = middleHandlerStyle.background) || void 0 === _p ? void 0 : _p.style), {
379
+ pickable: !zoomLock
380
+ }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
331
381
  x: "left" === orient ? position.x - middleHandlerBackgroundSize / 2 : position.x + width + middleHandlerBackgroundSize / 2,
332
382
  y: position.y + (start + end) / 2 * height,
333
383
  angle: Math.PI / 180 * 90,
334
384
  symbolType: null !== (_r = null === (_q = middleHandlerStyle.icon) || void 0 === _q ? void 0 : _q.symbolType) && void 0 !== _r ? _r : "square",
335
385
  strokeBoundsBuffer: 0
336
- }, middleHandlerStyle.icon), "symbol");
386
+ }, middleHandlerStyle.icon), {
387
+ pickable: !zoomLock
388
+ }), "symbol");
337
389
  }
338
- this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign({
390
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
339
391
  x: position.x + width / 2,
340
392
  y: position.y + start * height,
341
393
  size: width,
342
394
  symbolType: null !== (_s = startHandlerStyle.symbolType) && void 0 !== _s ? _s : "square"
343
- }, DEFAULT_HANDLER_ATTR_MAP.vertical), startHandlerStyle), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign({
395
+ }, DEFAULT_HANDLER_ATTR_MAP.vertical), startHandlerStyle), {
396
+ pickable: !zoomLock
397
+ }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
344
398
  x: position.x + width / 2,
345
399
  y: position.y + end * height,
346
400
  size: width,
347
401
  symbolType: null !== (_t = endHandlerStyle.symbolType) && void 0 !== _t ? _t : "square"
348
- }, DEFAULT_HANDLER_ATTR_MAP.vertical), endHandlerStyle), "symbol");
402
+ }, DEFAULT_HANDLER_ATTR_MAP.vertical), endHandlerStyle), {
403
+ pickable: !zoomLock
404
+ }), "symbol");
349
405
  const startHandlerWidth = Math.max(this._startHandler.AABBBounds.width(), startHandlerMinSize), startHandlerHeight = Math.max(this._startHandler.AABBBounds.height(), startHandlerMinSize), endHandlerWidth = Math.max(this._endHandler.AABBBounds.width(), endHandlerMinSize), endHandlerHeight = Math.max(this._endHandler.AABBBounds.height(), endHandlerMinSize);
350
- this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign({
406
+ this._startHandlerMask = group.createOrUpdateChild("startHandlerMask", Object.assign(Object.assign({
351
407
  x: position.x + width / 2 + startHandlerWidth / 2,
352
408
  y: position.y + start * height - startHandlerHeight / 2,
353
409
  width: endHandlerHeight,
@@ -355,7 +411,9 @@ export class DataZoom extends AbstractComponent {
355
411
  fill: "white",
356
412
  fillOpacity: 0,
357
413
  zIndex: 999
358
- }, DEFAULT_HANDLER_ATTR_MAP.vertical), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign({
414
+ }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
415
+ pickable: !zoomLock
416
+ }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
359
417
  x: position.x + width / 2 + endHandlerWidth / 2,
360
418
  y: position.y + end * height - endHandlerHeight / 2,
361
419
  width: endHandlerHeight,
@@ -363,8 +421,11 @@ export class DataZoom extends AbstractComponent {
363
421
  fill: "white",
364
422
  fillOpacity: 0,
365
423
  zIndex: 999
366
- }, DEFAULT_HANDLER_ATTR_MAP.vertical), "rect");
424
+ }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
425
+ pickable: !zoomLock
426
+ }), "rect");
367
427
  }
428
+ this._showText && this.renderText();
368
429
  }
369
430
  computeBasePoints() {
370
431
  const {orient: orient} = this.attribute, {position: position, width: width, height: height} = this.getLayoutAttrFromConfig();