@visactor/vchart 1.7.2 → 1.7.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 (223) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +16937 -13789
  3. package/build/index.min.js +1 -1
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/animation/utils.d.ts +1 -0
  6. package/cjs/animation/utils.js +16 -8
  7. package/cjs/animation/utils.js.map +1 -1
  8. package/cjs/chart/bar/bar-3d.d.ts +2 -2
  9. package/cjs/chart/bar/bar-3d.js +2 -2
  10. package/cjs/chart/bar/bar-3d.js.map +1 -1
  11. package/cjs/chart/base-chart.js +2 -0
  12. package/cjs/chart/base-chart.js.map +1 -1
  13. package/cjs/chart/cartesian/interface.d.ts +1 -1
  14. package/cjs/chart/cartesian/interface.js.map +1 -1
  15. package/cjs/chart/sequence/sequence.js +1 -0
  16. package/cjs/chart/sequence/sequence.js.map +1 -1
  17. package/cjs/component/axis/cartesian/axis.js +4 -2
  18. package/cjs/component/axis/cartesian/axis.js.map +1 -1
  19. package/cjs/component/axis/cartesian/band-axis.js +2 -2
  20. package/cjs/component/axis/cartesian/band-axis.js.map +1 -1
  21. package/cjs/component/axis/cartesian/util/common.d.ts +0 -2
  22. package/cjs/component/axis/cartesian/util/common.js +2 -14
  23. package/cjs/component/axis/cartesian/util/common.js.map +1 -1
  24. package/cjs/component/axis/interface/common.d.ts +1 -0
  25. package/cjs/component/axis/interface/common.js.map +1 -1
  26. package/cjs/component/axis/polar/axis.js +3 -1
  27. package/cjs/component/axis/polar/axis.js.map +1 -1
  28. package/cjs/component/axis/polar/interface/common.d.ts +2 -3
  29. package/cjs/component/axis/polar/interface/common.js.map +1 -1
  30. package/cjs/component/base/base-component.js +1 -1
  31. package/cjs/component/base/base-component.js.map +1 -1
  32. package/cjs/component/crosshair/base.d.ts +4 -5
  33. package/cjs/component/crosshair/base.js +38 -25
  34. package/cjs/component/crosshair/base.js.map +1 -1
  35. package/cjs/component/crosshair/cartesian.d.ts +11 -34
  36. package/cjs/component/crosshair/cartesian.js +118 -109
  37. package/cjs/component/crosshair/cartesian.js.map +1 -1
  38. package/cjs/component/crosshair/config.d.ts +6 -0
  39. package/cjs/component/crosshair/config.js +8 -2
  40. package/cjs/component/crosshair/config.js.map +1 -1
  41. package/cjs/component/crosshair/interface/spec.d.ts +7 -3
  42. package/cjs/component/crosshair/interface/spec.js.map +1 -1
  43. package/cjs/component/crosshair/polar.d.ts +12 -54
  44. package/cjs/component/crosshair/polar.js +109 -82
  45. package/cjs/component/crosshair/polar.js.map +1 -1
  46. package/cjs/component/legend/continuous/interface.d.ts +1 -0
  47. package/cjs/component/legend/continuous/interface.js.map +1 -1
  48. package/cjs/component/legend/continuous/legend.js +5 -3
  49. package/cjs/component/legend/continuous/legend.js.map +1 -1
  50. package/cjs/component/marker/base-marker.d.ts +22 -24
  51. package/cjs/component/marker/base-marker.js +39 -50
  52. package/cjs/component/marker/base-marker.js.map +1 -1
  53. package/cjs/component/marker/interface.d.ts +19 -9
  54. package/cjs/component/marker/interface.js.map +1 -1
  55. package/cjs/component/marker/mark-area/interface/spec.d.ts +10 -12
  56. package/cjs/component/marker/mark-area/interface/spec.js.map +1 -1
  57. package/cjs/component/marker/mark-area/mark-area.d.ts +3 -2
  58. package/cjs/component/marker/mark-area/mark-area.js +12 -22
  59. package/cjs/component/marker/mark-area/mark-area.js.map +1 -1
  60. package/cjs/component/marker/mark-line/interface/spec.d.ts +20 -9
  61. package/cjs/component/marker/mark-line/interface/spec.js.map +1 -1
  62. package/cjs/component/marker/mark-line/mark-line.d.ts +4 -2
  63. package/cjs/component/marker/mark-line/mark-line.js +60 -60
  64. package/cjs/component/marker/mark-line/mark-line.js.map +1 -1
  65. package/cjs/component/marker/mark-point/interface/spec.d.ts +8 -6
  66. package/cjs/component/marker/mark-point/interface/spec.js.map +1 -1
  67. package/cjs/component/marker/mark-point/mark-point.d.ts +3 -2
  68. package/cjs/component/marker/mark-point/mark-point.js +15 -19
  69. package/cjs/component/marker/mark-point/mark-point.js.map +1 -1
  70. package/cjs/component/marker/utils.d.ts +13 -2
  71. package/cjs/component/marker/utils.js +108 -39
  72. package/cjs/component/marker/utils.js.map +1 -1
  73. package/cjs/component/tooltip/tooltip.js +3 -2
  74. package/cjs/component/tooltip/tooltip.js.map +1 -1
  75. package/cjs/core/index.d.ts +1 -1
  76. package/cjs/core/index.js +1 -1
  77. package/cjs/core/index.js.map +1 -1
  78. package/cjs/core/vchart.js +1 -0
  79. package/cjs/core/vchart.js.map +1 -1
  80. package/cjs/data/transforms/aggregation.d.ts +3 -3
  81. package/cjs/data/transforms/aggregation.js +5 -7
  82. package/cjs/data/transforms/aggregation.js.map +1 -1
  83. package/cjs/event/events/dimension/util/polar.js +2 -2
  84. package/cjs/event/events/dimension/util/polar.js.map +1 -1
  85. package/cjs/layout/layout3d/index.js +1 -1
  86. package/cjs/layout/layout3d/index.js.map +1 -1
  87. package/cjs/model/base-model.js +4 -4
  88. package/cjs/model/base-model.js.map +1 -1
  89. package/cjs/model/interface.d.ts +1 -0
  90. package/cjs/model/interface.js.map +1 -1
  91. package/cjs/region/region.js +4 -2
  92. package/cjs/region/region.js.map +1 -1
  93. package/cjs/series/bar/bar.js +6 -11
  94. package/cjs/series/bar/bar.js.map +1 -1
  95. package/cjs/series/base/base-series.js +6 -6
  96. package/cjs/series/base/base-series.js.map +1 -1
  97. package/cjs/series/box-plot/box-plot.js +4 -12
  98. package/cjs/series/box-plot/box-plot.js.map +1 -1
  99. package/cjs/series/heatmap/heatmap.js +4 -9
  100. package/cjs/series/heatmap/heatmap.js.map +1 -1
  101. package/cjs/series/pie/pie.js +1 -1
  102. package/cjs/series/pie/pie.js.map +1 -1
  103. package/cjs/series/range-column/range-column.js +7 -15
  104. package/cjs/series/range-column/range-column.js.map +1 -1
  105. package/cjs/series/util/utils.d.ts +5 -0
  106. package/cjs/series/util/utils.js +18 -2
  107. package/cjs/series/util/utils.js.map +1 -1
  108. package/cjs/series/waterfall/waterfall.js +7 -11
  109. package/cjs/series/waterfall/waterfall.js.map +1 -1
  110. package/cjs/theme/builtin/common/component/crosshair.js +0 -8
  111. package/cjs/theme/builtin/common/component/crosshair.js.map +1 -1
  112. package/cjs/typings/visual.d.ts +3 -2
  113. package/cjs/typings/visual.js.map +1 -1
  114. package/esm/animation/utils.d.ts +1 -0
  115. package/esm/animation/utils.js +12 -7
  116. package/esm/animation/utils.js.map +1 -1
  117. package/esm/chart/bar/bar-3d.d.ts +2 -2
  118. package/esm/chart/bar/bar-3d.js +3 -3
  119. package/esm/chart/bar/bar-3d.js.map +1 -1
  120. package/esm/chart/base-chart.js +2 -0
  121. package/esm/chart/base-chart.js.map +1 -1
  122. package/esm/chart/cartesian/interface.d.ts +1 -1
  123. package/esm/chart/cartesian/interface.js.map +1 -1
  124. package/esm/chart/sequence/sequence.js +1 -0
  125. package/esm/chart/sequence/sequence.js.map +1 -1
  126. package/esm/component/axis/cartesian/axis.js +4 -2
  127. package/esm/component/axis/cartesian/axis.js.map +1 -1
  128. package/esm/component/axis/cartesian/band-axis.js +1 -3
  129. package/esm/component/axis/cartesian/band-axis.js.map +1 -1
  130. package/esm/component/axis/cartesian/util/common.d.ts +0 -2
  131. package/esm/component/axis/cartesian/util/common.js +0 -11
  132. package/esm/component/axis/cartesian/util/common.js.map +1 -1
  133. package/esm/component/axis/interface/common.d.ts +1 -0
  134. package/esm/component/axis/interface/common.js.map +1 -1
  135. package/esm/component/axis/polar/axis.js +3 -1
  136. package/esm/component/axis/polar/axis.js.map +1 -1
  137. package/esm/component/axis/polar/interface/common.d.ts +2 -3
  138. package/esm/component/axis/polar/interface/common.js.map +1 -1
  139. package/esm/component/base/base-component.js +1 -1
  140. package/esm/component/base/base-component.js.map +1 -1
  141. package/esm/component/crosshair/base.d.ts +4 -5
  142. package/esm/component/crosshair/base.js +37 -25
  143. package/esm/component/crosshair/base.js.map +1 -1
  144. package/esm/component/crosshair/cartesian.d.ts +11 -34
  145. package/esm/component/crosshair/cartesian.js +111 -102
  146. package/esm/component/crosshair/cartesian.js.map +1 -1
  147. package/esm/component/crosshair/config.d.ts +6 -0
  148. package/esm/component/crosshair/config.js +7 -0
  149. package/esm/component/crosshair/config.js.map +1 -1
  150. package/esm/component/crosshair/interface/spec.d.ts +7 -3
  151. package/esm/component/crosshair/interface/spec.js.map +1 -1
  152. package/esm/component/crosshair/polar.d.ts +12 -54
  153. package/esm/component/crosshair/polar.js +109 -78
  154. package/esm/component/crosshair/polar.js.map +1 -1
  155. package/esm/component/legend/continuous/interface.d.ts +1 -0
  156. package/esm/component/legend/continuous/interface.js.map +1 -1
  157. package/esm/component/legend/continuous/legend.js +5 -3
  158. package/esm/component/legend/continuous/legend.js.map +1 -1
  159. package/esm/component/marker/base-marker.d.ts +22 -24
  160. package/esm/component/marker/base-marker.js +41 -52
  161. package/esm/component/marker/base-marker.js.map +1 -1
  162. package/esm/component/marker/interface.d.ts +19 -9
  163. package/esm/component/marker/interface.js.map +1 -1
  164. package/esm/component/marker/mark-area/interface/spec.d.ts +10 -12
  165. package/esm/component/marker/mark-area/interface/spec.js.map +1 -1
  166. package/esm/component/marker/mark-area/mark-area.d.ts +3 -2
  167. package/esm/component/marker/mark-area/mark-area.js +10 -22
  168. package/esm/component/marker/mark-area/mark-area.js.map +1 -1
  169. package/esm/component/marker/mark-line/interface/spec.d.ts +20 -9
  170. package/esm/component/marker/mark-line/interface/spec.js.map +1 -1
  171. package/esm/component/marker/mark-line/mark-line.d.ts +4 -2
  172. package/esm/component/marker/mark-line/mark-line.js +58 -54
  173. package/esm/component/marker/mark-line/mark-line.js.map +1 -1
  174. package/esm/component/marker/mark-point/interface/spec.d.ts +8 -6
  175. package/esm/component/marker/mark-point/interface/spec.js.map +1 -1
  176. package/esm/component/marker/mark-point/mark-point.d.ts +3 -2
  177. package/esm/component/marker/mark-point/mark-point.js +12 -20
  178. package/esm/component/marker/mark-point/mark-point.js.map +1 -1
  179. package/esm/component/marker/utils.d.ts +13 -2
  180. package/esm/component/marker/utils.js +103 -35
  181. package/esm/component/marker/utils.js.map +1 -1
  182. package/esm/component/tooltip/tooltip.js +3 -1
  183. package/esm/component/tooltip/tooltip.js.map +1 -1
  184. package/esm/core/index.d.ts +1 -1
  185. package/esm/core/index.js +1 -1
  186. package/esm/core/index.js.map +1 -1
  187. package/esm/core/vchart.js +1 -0
  188. package/esm/core/vchart.js.map +1 -1
  189. package/esm/data/transforms/aggregation.d.ts +3 -3
  190. package/esm/data/transforms/aggregation.js +6 -8
  191. package/esm/data/transforms/aggregation.js.map +1 -1
  192. package/esm/event/events/dimension/util/polar.js +2 -2
  193. package/esm/event/events/dimension/util/polar.js.map +1 -1
  194. package/esm/layout/layout3d/index.js +1 -1
  195. package/esm/layout/layout3d/index.js.map +1 -1
  196. package/esm/model/base-model.js +4 -5
  197. package/esm/model/base-model.js.map +1 -1
  198. package/esm/model/interface.d.ts +1 -0
  199. package/esm/model/interface.js.map +1 -1
  200. package/esm/region/region.js +5 -1
  201. package/esm/region/region.js.map +1 -1
  202. package/esm/series/bar/bar.js +5 -9
  203. package/esm/series/bar/bar.js.map +1 -1
  204. package/esm/series/base/base-series.js +4 -4
  205. package/esm/series/base/base-series.js.map +1 -1
  206. package/esm/series/box-plot/box-plot.js +5 -11
  207. package/esm/series/box-plot/box-plot.js.map +1 -1
  208. package/esm/series/heatmap/heatmap.js +4 -8
  209. package/esm/series/heatmap/heatmap.js.map +1 -1
  210. package/esm/series/pie/pie.js +1 -1
  211. package/esm/series/pie/pie.js.map +1 -1
  212. package/esm/series/range-column/range-column.js +6 -12
  213. package/esm/series/range-column/range-column.js.map +1 -1
  214. package/esm/series/util/utils.d.ts +5 -0
  215. package/esm/series/util/utils.js +15 -0
  216. package/esm/series/util/utils.js.map +1 -1
  217. package/esm/series/waterfall/waterfall.js +6 -9
  218. package/esm/series/waterfall/waterfall.js.map +1 -1
  219. package/esm/theme/builtin/common/component/crosshair.js +0 -8
  220. package/esm/theme/builtin/common/component/crosshair.js.map +1 -1
  221. package/esm/typings/visual.d.ts +3 -2
  222. package/esm/typings/visual.js.map +1 -1
  223. package/package.json +8 -8
@@ -1,7 +1,6 @@
1
1
  import type { IComponentOption } from '../interface';
2
2
  import { ComponentTypeEnum } from '../interface/type';
3
3
  import type { ICartesianCrosshairSpec } from './interface';
4
- import type { IHair } from './base';
5
4
  import { BaseCrossHair } from './base';
6
5
  import type { IGraphic } from '@visactor/vrender-core';
7
6
  import type { IAxis } from '../axis/interface';
@@ -12,16 +11,8 @@ export declare class CartesianCrossHair<T extends ICartesianCrosshairSpec = ICar
12
11
  static type: ComponentTypeEnum;
13
12
  type: ComponentTypeEnum;
14
13
  name: string;
15
- currValueX: Map<number, {
16
- v: StringOrNumber;
17
- axis: IAxis;
18
- }>;
19
- currValueY: Map<number, {
20
- v: StringOrNumber;
21
- axis: IAxis;
22
- }>;
23
- xHair: IHair | undefined;
24
- yHair: IHair | undefined;
14
+ private _xHair;
15
+ private _yHair;
25
16
  private _cacheXCrossHairInfo;
26
17
  private _cacheYCrossHairInfo;
27
18
  private _xCrosshair;
@@ -30,37 +21,23 @@ export declare class CartesianCrossHair<T extends ICartesianCrosshairSpec = ICar
30
21
  private _yCrosshair;
31
22
  private _yLeftLabel;
32
23
  private _yRightLabel;
24
+ private _currValueX;
25
+ private _currValueY;
33
26
  static createComponent(spec: any, options: IComponentOption): CartesianCrossHair<any> | CartesianCrossHair<ICartesianCrosshairSpec>[];
34
27
  constructor(spec: T, options: IComponentOption);
35
- protected _showDefaultCrosshair(): void;
36
- private defaultCrosshair;
37
- findAllAxisContains(relativeX: number, relativeY: number): {
38
- xAxisMap: Map<number, {
39
- x1: number;
40
- y1: number;
41
- x2: number;
42
- y2: number;
43
- } & {
44
- axis: IAxis;
45
- }>;
46
- yAxisMap: Map<number, {
47
- x1: number;
48
- y1: number;
49
- x2: number;
50
- y2: number;
51
- } & {
52
- axis: IAxis;
53
- }>;
54
- };
55
- private getValueAt;
28
+ protected _showDefaultCrosshairBySpec(): void;
29
+ private _defaultCrosshair;
30
+ private _findAllAxisContains;
31
+ private _getValueAt;
56
32
  clearAxisValue(): void;
57
33
  setAxisValue(v: StringOrNumber, axis: IAxis): void;
58
- private getAllAxisValues;
34
+ private _getAllAxisValues;
59
35
  protected _layoutCrosshair(relativeX: number, relativeY: number): void;
60
36
  hide(): void;
61
- private layoutByValue;
37
+ layoutByValue(tag?: number): void;
62
38
  private _layoutVertical;
63
39
  private _layoutHorizontal;
40
+ private _getRectSize;
64
41
  protected _parseFieldInfo(): void;
65
42
  private _updateCrosshair;
66
43
  private _updateCrosshairLabel;
@@ -16,12 +16,7 @@ import { isXAxis } from "../axis/cartesian/util/common";
16
16
 
17
17
  import { Factory } from "../../core/factory";
18
18
 
19
- var LayoutType;
20
-
21
- !function(LayoutType) {
22
- LayoutType[LayoutType.ALL = 3] = "ALL", LayoutType[LayoutType.HORIZONTAL = 2] = "HORIZONTAL",
23
- LayoutType[LayoutType.VERTICAL = 1] = "VERTICAL", LayoutType[LayoutType.NONE = 0] = "NONE";
24
- }(LayoutType || (LayoutType = {}));
19
+ import { LayoutType } from "./config";
25
20
 
26
21
  export class CartesianCrossHair extends BaseCrossHair {
27
22
  static createComponent(spec, options) {
@@ -37,70 +32,72 @@ export class CartesianCrossHair extends BaseCrossHair {
37
32
  }
38
33
  constructor(spec, options) {
39
34
  super(spec, options), this.specKey = "crosshair", this.type = ComponentTypeEnum.cartesianCrosshair,
40
- this.name = ComponentTypeEnum.cartesianCrosshair, this.currValueX = new Map, this.currValueY = new Map;
35
+ this.name = ComponentTypeEnum.cartesianCrosshair, this._currValueX = new Map, this._currValueY = new Map;
41
36
  }
42
- _showDefaultCrosshair() {
43
- if (!this.showDefault) return;
44
- const {xField: xField = {}, yField: yField = {}} = this._spec;
37
+ _showDefaultCrosshairBySpec() {
38
+ const {xField: xField, yField: yField} = this._spec;
45
39
  if ((null == xField ? void 0 : xField.visible) && xField.defaultSelect) {
46
40
  const {axisIndex: axisIndex, datum: datum} = xField.defaultSelect;
47
- this.defaultCrosshair(axisIndex, datum, LayoutType.VERTICAL, !0), this.layoutByValue(LayoutType.VERTICAL);
41
+ this._defaultCrosshair(axisIndex, datum, LayoutType.VERTICAL);
48
42
  }
49
43
  if ((null == yField ? void 0 : yField.visible) && yField.defaultSelect) {
50
44
  const {axisIndex: axisIndex, datum: datum} = yField.defaultSelect;
51
- this.defaultCrosshair(axisIndex, datum, LayoutType.HORIZONTAL, !1), this.layoutByValue(LayoutType.HORIZONTAL);
45
+ this._defaultCrosshair(axisIndex, datum, LayoutType.HORIZONTAL);
52
46
  }
53
47
  }
54
- defaultCrosshair(axisIndex, datum, tag, vertical) {
48
+ _defaultCrosshair(axisIndex, datum, tag) {
55
49
  const axis = this._option.getComponentsByKey("axes").find((c => c.getSpecIndex() === axisIndex));
56
- axis && (vertical ? (this.currValueX.clear(), this.currValueX.set(axisIndex, {
50
+ axis && (tag === LayoutType.VERTICAL ? (this._currValueX.clear(), this._currValueX.set(axisIndex, {
57
51
  axis: axis,
58
52
  v: datum
59
- })) : (this.currValueY.clear(), this.currValueY.set(axisIndex, {
53
+ })) : (this._currValueY.clear(), this._currValueY.set(axisIndex, {
60
54
  axis: axis,
61
55
  v: datum
62
- })));
56
+ })), this.layoutByValue(tag));
63
57
  }
64
- findAllAxisContains(relativeX, relativeY) {
58
+ _findAllAxisContains(relativeX, relativeY) {
65
59
  const xAxisMap = this._getAxisInfoByField("x"), yAxisMap = this._getAxisInfoByField("y");
66
60
  return {
67
61
  xAxisMap: this._filterAxisByPoint(xAxisMap, relativeX, relativeY),
68
62
  yAxisMap: this._filterAxisByPoint(yAxisMap, relativeX, relativeY)
69
63
  };
70
64
  }
71
- getValueAt(axis, p) {
65
+ _getValueAt(axis, p) {
72
66
  let value = axis.getScale().invert(p);
73
67
  return isContinuous(axis.getScale().type) && isValidNumber(+value) && (value = (+value).toFixed(2)),
74
68
  value;
75
69
  }
76
70
  clearAxisValue() {
77
- this.currValueX.clear(), this.currValueY.clear();
71
+ this._currValueX.clear(), this._currValueY.clear();
78
72
  }
79
73
  setAxisValue(v, axis) {
80
- isXAxis(axis.getOrient()), this.currValueX.set(axis.getSpecIndex(), {
74
+ isXAxis(axis.getOrient()) ? this._currValueX.set(axis.getSpecIndex(), {
75
+ v: v,
76
+ axis: axis
77
+ }) : this._currValueY.set(axis.getSpecIndex(), {
81
78
  v: v,
82
79
  axis: axis
83
80
  });
84
81
  }
85
- getAllAxisValues(axisMap, p, currValue, vertical) {
82
+ _getAllAxisValues(axisMap, p, currValue, vertical) {
86
83
  let discrete = !1;
87
84
  return axisMap.forEach((item => {
88
85
  isDiscrete(item.axis.getScale().type) && (discrete ? this.enable = !1 : discrete = !0);
89
86
  })), !!this.enable && (axisMap.forEach(((item, id) => {
90
87
  const axis = item.axis;
91
88
  currValue.set(id, {
92
- v: this.getValueAt(axis, p - (vertical ? axis.getLayoutStartPoint().x - this.getLayoutStartPoint().x : axis.getLayoutStartPoint().y - this.getLayoutStartPoint().y)),
89
+ v: this._getValueAt(axis, p - (vertical ? axis.getLayoutStartPoint().x - this.getLayoutStartPoint().x : axis.getLayoutStartPoint().y - this.getLayoutStartPoint().y)),
93
90
  axis: axis
94
91
  });
95
92
  })), !0);
96
93
  }
97
94
  _layoutCrosshair(relativeX, relativeY) {
98
- const {xAxisMap: xAxisMap, yAxisMap: yAxisMap} = this.findAllAxisContains(relativeX, relativeY);
95
+ const {xAxisMap: xAxisMap, yAxisMap: yAxisMap} = this._findAllAxisContains(relativeX, relativeY);
99
96
  if (xAxisMap && 0 === xAxisMap.size && yAxisMap && 0 === yAxisMap.size) {
100
97
  if (this.enableRemain) return;
101
98
  this.hide();
102
- } else this.currValueX.clear(), this.currValueY.clear(), xAxisMap && xAxisMap.size && this.getAllAxisValues(xAxisMap, relativeX, this.currValueX, !0),
103
- yAxisMap && yAxisMap.size && this.getAllAxisValues(yAxisMap, relativeY, this.currValueY, !1),
99
+ } else this._currValueX.clear(), this._currValueY.clear(), xAxisMap && xAxisMap.size && this._getAllAxisValues(xAxisMap, relativeX, this._currValueX, !0),
100
+ yAxisMap && yAxisMap.size && this._getAllAxisValues(yAxisMap, relativeY, this._currValueY, !1),
104
101
  this.layoutByValue(LayoutType.ALL);
105
102
  }
106
103
  hide() {
@@ -130,7 +127,8 @@ export class CartesianCrossHair extends BaseCrossHair {
130
127
  dx: 0,
131
128
  dy: 0
132
129
  },
133
- visible: !1
130
+ visible: !1,
131
+ axis: null
134
132
  }, yCrossHairInfo = {
135
133
  width: 0,
136
134
  leftPos: 0,
@@ -148,7 +146,8 @@ export class CartesianCrossHair extends BaseCrossHair {
148
146
  dx: 0,
149
147
  dy: 0
150
148
  },
151
- visible: !1
149
+ visible: !1,
150
+ axis: null
152
151
  };
153
152
  const getRegionArea = (outRegion, currentValue) => {
154
153
  currentValue.forEach((({axis: axis}) => {
@@ -160,15 +159,17 @@ export class CartesianCrossHair extends BaseCrossHair {
160
159
  }));
161
160
  };
162
161
  let x = 0, y = 0;
163
- if (this.currValueX.size) {
164
- const item = Array.from(this.currValueX.values())[0];
165
- x = item.axis.getScale().scale(item.v) + item.axis.getLayoutStartPoint().x - this.getLayoutStartPoint().x;
162
+ if (this._currValueX.size) {
163
+ const item = Array.from(this._currValueX.values())[0];
164
+ x = item.axis.getScale().scale(item.v) + item.axis.getLayoutStartPoint().x - this.getLayoutStartPoint().x,
165
+ xCrossHairInfo.axis = item.axis;
166
166
  }
167
- if (this.currValueY.size) {
168
- const item = Array.from(this.currValueY.values())[0];
169
- y = item.axis.getScale().scale(item.v) + item.axis.getLayoutStartPoint().y - this.getLayoutStartPoint().y;
167
+ if (this._currValueY.size) {
168
+ const item = Array.from(this._currValueY.values())[0];
169
+ y = item.axis.getScale().scale(item.v) + item.axis.getLayoutStartPoint().y - this.getLayoutStartPoint().y,
170
+ yCrossHairInfo.axis = item.axis;
170
171
  }
171
- xCrossHairInfo.visible = !!this.currValueX.size && Number.isFinite(x), yCrossHairInfo.visible = !!this.currValueY.size && Number.isFinite(y);
172
+ xCrossHairInfo.visible = !!this._currValueX.size && Number.isFinite(x), yCrossHairInfo.visible = !!this._currValueY.size && Number.isFinite(y);
172
173
  const xRegion = {
173
174
  x1: 1 / 0,
174
175
  y1: 1 / 0,
@@ -181,15 +182,12 @@ export class CartesianCrossHair extends BaseCrossHair {
181
182
  y2: -1 / 0
182
183
  };
183
184
  let indexWidth, valueHeight;
184
- if (getRegionArea(xRegion, this.currValueX), getRegionArea(yRegion, this.currValueY),
185
- this.xHair && this.currValueX.forEach((({axis: axis, v: v}) => {
186
- var _a, _b, _c;
185
+ if (getRegionArea(xRegion, this._currValueX), getRegionArea(yRegion, this._currValueY),
186
+ this._xHair && this._currValueX.forEach((({axis: axis, v: v}) => {
187
+ var _a;
187
188
  v = null != v ? v : "";
188
189
  const xScale = axis.getScale();
189
- if (isDiscrete(xScale.type)) {
190
- const eachBand = xScale._step;
191
- indexWidth = axis ? null === (_b = (_a = series.getXAxisHelper()).getBandwidth) || void 0 === _b ? void 0 : _b.call(_a, 0) : eachBand;
192
- } else if (isContinuous(xScale.type)) {
190
+ if (isDiscrete(xScale.type)) indexWidth = xScale.bandwidth(); else if (isContinuous(xScale.type)) {
193
191
  const fieldX = series.fieldX[0], fieldX2 = series.fieldX2, datum = getDatumByValue(series.getViewData().latestData, +v, fieldX, fieldX2);
194
192
  if (datum) {
195
193
  const startX = series.dataToPositionX(datum);
@@ -197,20 +195,17 @@ export class CartesianCrossHair extends BaseCrossHair {
197
195
  x = startX;
198
196
  }
199
197
  }
200
- if (null === (_c = this.xHair.label) || void 0 === _c ? void 0 : _c.visible) {
198
+ if (null === (_a = this._xHair.label) || void 0 === _a ? void 0 : _a.visible) {
201
199
  const labelOffset = getAxisLabelOffset(axis.getSpec());
202
200
  "bottom" === axis.getOrient() ? (xCrossHairInfo.bottom.visible = !0, xCrossHairInfo.bottom.text = v,
203
201
  xCrossHairInfo.bottom.dx = 0, xCrossHairInfo.bottom.dy = labelOffset) : "top" === axis.getOrient() && (xCrossHairInfo.top.visible = !0,
204
202
  xCrossHairInfo.top.text = v, xCrossHairInfo.top.dx = 0, xCrossHairInfo.top.dy = -labelOffset);
205
203
  }
206
- })), this.yHair && this.currValueY.forEach((({axis: axis, v: v}) => {
207
- var _a, _b, _c;
204
+ })), this._yHair && this._currValueY.forEach((({axis: axis, v: v}) => {
205
+ var _a;
208
206
  v = null != v ? v : "";
209
207
  const yScale = axis.getScale();
210
- if (isDiscrete(yScale.type)) {
211
- const eachBand = yScale._step;
212
- valueHeight = yScale ? null === (_b = (_a = series.getYAxisHelper()).getBandwidth) || void 0 === _b ? void 0 : _b.call(_a, 0) : eachBand;
213
- } else if (isContinuous(yScale.type)) {
208
+ if (isDiscrete(yScale.type)) valueHeight = yScale.bandwidth(); else if (isContinuous(yScale.type)) {
214
209
  const fieldY = series.fieldY[0], fieldY2 = series.fieldY2, datum = getDatumByValue(series.getViewData().latestData, +v, fieldY, fieldY2);
215
210
  if (datum) {
216
211
  const startY = series.dataToPositionY(datum);
@@ -218,7 +213,7 @@ export class CartesianCrossHair extends BaseCrossHair {
218
213
  y = startY;
219
214
  }
220
215
  }
221
- if (null === (_c = this.yHair.label) || void 0 === _c ? void 0 : _c.visible) {
216
+ if (null === (_a = this._yHair.label) || void 0 === _a ? void 0 : _a.visible) {
222
217
  const labelOffset = getAxisLabelOffset(axis.getSpec());
223
218
  "left" === axis.getOrient() ? (yCrossHairInfo.left.visible = !0, yCrossHairInfo.left.text = v,
224
219
  yCrossHairInfo.left.dx = -labelOffset, yCrossHairInfo.left.dy = 0) : "right" === axis.getOrient() && (yCrossHairInfo.right.visible = !0,
@@ -226,17 +221,17 @@ export class CartesianCrossHair extends BaseCrossHair {
226
221
  }
227
222
  })), this.enableRemain && !xCrossHairInfo.visible && isValid(this._cacheXCrossHairInfo)) xCrossHairInfo = this._cacheXCrossHairInfo; else if (xCrossHairInfo.leftPos = xRegion.x1,
228
223
  xCrossHairInfo.topPos = xRegion.y1, xCrossHairInfo.height = xRegion.y2 - xRegion.y1,
229
- xCrossHairInfo.x = x + this.getLayoutStartPoint().x, null === (_b = null === (_a = this.xHair) || void 0 === _a ? void 0 : _a.label) || void 0 === _b ? void 0 : _b.formatMethod) {
224
+ xCrossHairInfo.x = x + this.getLayoutStartPoint().x, null === (_b = null === (_a = this._xHair) || void 0 === _a ? void 0 : _a.label) || void 0 === _b ? void 0 : _b.formatMethod) {
230
225
  const {top: top, bottom: bottom} = xCrossHairInfo;
231
- bottom.visible && (bottom.text = this.xHair.label.formatMethod(bottom.text, "bottom")),
232
- top.visible && (top.text = this.xHair.label.formatMethod(top.text, "top"));
226
+ bottom.visible && (bottom.text = this._xHair.label.formatMethod(bottom.text, "bottom")),
227
+ top.visible && (top.text = this._xHair.label.formatMethod(top.text, "top"));
233
228
  }
234
229
  if (this.enableRemain && !yCrossHairInfo.visible && isValid(this._cacheYCrossHairInfo)) yCrossHairInfo = this._cacheYCrossHairInfo; else if (yCrossHairInfo.leftPos = yRegion.x1,
235
230
  yCrossHairInfo.topPos = yRegion.y1, yCrossHairInfo.width = yRegion.x2 - yRegion.x1,
236
- yCrossHairInfo.y = y + this.getLayoutStartPoint().y, null === (_d = null === (_c = this.yHair) || void 0 === _c ? void 0 : _c.label) || void 0 === _d ? void 0 : _d.formatMethod) {
231
+ yCrossHairInfo.y = y + this.getLayoutStartPoint().y, null === (_d = null === (_c = this._yHair) || void 0 === _c ? void 0 : _c.label) || void 0 === _d ? void 0 : _d.formatMethod) {
237
232
  const {left: left, right: right} = yCrossHairInfo;
238
- left.visible && (left.text = this.yHair.label.formatMethod(left.text, "left")),
239
- right.visible && (right.text = this.yHair.label.formatMethod(right.text, "right"));
233
+ left.visible && (left.text = this._yHair.label.formatMethod(left.text, "left")),
234
+ right.visible && (right.text = this._yHair.label.formatMethod(right.text, "right"));
240
235
  }
241
236
  tag && (LayoutType.HORIZONTAL && this._layoutHorizontal(yCrossHairInfo, null != valueHeight ? valueHeight : 0),
242
237
  LayoutType.VERTICAL && this._layoutVertical(xCrossHairInfo, null != indexWidth ? indexWidth : 0)),
@@ -247,38 +242,40 @@ export class CartesianCrossHair extends BaseCrossHair {
247
242
  }));
248
243
  }
249
244
  _layoutVertical(crosshairInfo, bandWidth) {
250
- var _a, _b, _c, _d, _e, _f;
251
- if (crosshairInfo._isCache && this.enableRemain || !this.xHair) return;
245
+ var _a, _b;
246
+ if (crosshairInfo._isCache && this.enableRemain || !this._xHair) return;
252
247
  const {x: x, topPos: topPos, height: height, top: top, bottom: bottom, visible: visible} = crosshairInfo;
253
248
  if (visible) {
254
- let extend = 0;
255
- (null === (_b = null === (_a = this.xHair) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.sizePercent) ? extend = (this.xHair.style.sizePercent - 1) * bandWidth : "number" == typeof (null === (_d = null === (_c = this.xHair) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.size) && (extend = this.xHair.style.size - bandWidth);
256
- const type = this.xHair.type;
249
+ const type = this._xHair.type;
257
250
  let positionAttribute;
258
- if ("line" === type ? positionAttribute = {
251
+ if ("line" === type) positionAttribute = {
259
252
  start: {
260
- x: x + bandWidth / 2 - extend / 2,
261
- y: topPos
262
- },
263
- end: {
264
- x: x + bandWidth / 2 + extend / 2,
265
- y: topPos + height
266
- }
267
- } : "rect" === type && (positionAttribute = {
268
- start: {
269
- x: x - extend / 2,
253
+ x: x + bandWidth / 2,
270
254
  y: topPos
271
255
  },
272
256
  end: {
273
- x: x + bandWidth + extend / 2,
257
+ x: x + bandWidth / 2,
274
258
  y: topPos + height
275
259
  }
276
- }), this._updateCrosshair("x", type, positionAttribute), top.visible) {
260
+ }; else if ("rect" === type) {
261
+ const extend = this._getRectSize(this._xHair, bandWidth, crosshairInfo.axis);
262
+ positionAttribute = {
263
+ start: {
264
+ x: x - extend / 2,
265
+ y: topPos
266
+ },
267
+ end: {
268
+ x: x + bandWidth + extend / 2,
269
+ y: topPos + height
270
+ }
271
+ };
272
+ }
273
+ if (this._updateCrosshair("x", type, positionAttribute), top.visible) {
277
274
  const updateAttrs = Object.assign(Object.assign(Object.assign({
278
275
  x: x + bandWidth / 2,
279
276
  y: topPos
280
- }, top), this.xHair.label), {
281
- textStyle: Object.assign(Object.assign({}, null === (_e = this.xHair.label) || void 0 === _e ? void 0 : _e.textStyle), {
277
+ }, top), this._xHair.label), {
278
+ textStyle: Object.assign(Object.assign({}, null === (_a = this._xHair.label) || void 0 === _a ? void 0 : _a.textStyle), {
282
279
  textAlign: "center",
283
280
  textBaseline: "bottom"
284
281
  }),
@@ -292,8 +289,8 @@ export class CartesianCrossHair extends BaseCrossHair {
292
289
  const updateAttrs = Object.assign(Object.assign(Object.assign({
293
290
  x: x + bandWidth / 2,
294
291
  y: topPos + height
295
- }, bottom), this.xHair.label), {
296
- textStyle: Object.assign(Object.assign({}, null === (_f = this.xHair.label) || void 0 === _f ? void 0 : _f.textStyle), {
292
+ }, bottom), this._xHair.label), {
293
+ textStyle: Object.assign(Object.assign({}, null === (_b = this._xHair.label) || void 0 === _b ? void 0 : _b.textStyle), {
297
294
  textAlign: "center",
298
295
  textBaseline: "top"
299
296
  }),
@@ -306,15 +303,13 @@ export class CartesianCrossHair extends BaseCrossHair {
306
303
  }
307
304
  }
308
305
  _layoutHorizontal(crosshairInfo, bandHeight) {
309
- var _a, _b, _c, _d, _e, _f;
310
- if (crosshairInfo._isCache && this.enableRemain || !this.yHair) return;
306
+ var _a, _b;
307
+ if (crosshairInfo._isCache && this.enableRemain || !this._yHair) return;
311
308
  const {leftPos: leftPos, width: width, y: y, left: left, right: right, visible: visible} = crosshairInfo;
312
309
  if (visible) {
313
- let extend = 0;
314
- (null === (_b = null === (_a = this.yHair) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.sizePercent) ? extend = (this.yHair.style.sizePercent - 1) * bandHeight : "number" == typeof (null === (_d = null === (_c = this.yHair) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.size) && (extend = this.yHair.style.size - bandHeight);
315
- const type = this.yHair.type;
310
+ const type = this._yHair.type;
316
311
  let positionAttribute;
317
- if ("line" === type ? positionAttribute = {
312
+ if ("line" === type) positionAttribute = {
318
313
  start: {
319
314
  x: leftPos,
320
315
  y: y + bandHeight / 2
@@ -323,21 +318,25 @@ export class CartesianCrossHair extends BaseCrossHair {
323
318
  x: leftPos + width,
324
319
  y: y + bandHeight / 2
325
320
  }
326
- } : "rect" === type && (positionAttribute = {
327
- start: {
328
- x: leftPos,
329
- y: y - extend / 2
330
- },
331
- end: {
332
- x: leftPos + width,
333
- y: y + bandHeight + extend / 2
334
- }
335
- }), this._updateCrosshair("y", type, positionAttribute), left.visible) {
321
+ }; else if ("rect" === type) {
322
+ const extend = this._getRectSize(this._yHair, bandHeight, crosshairInfo.axis);
323
+ positionAttribute = {
324
+ start: {
325
+ x: leftPos,
326
+ y: y - extend / 2
327
+ },
328
+ end: {
329
+ x: leftPos + width,
330
+ y: y + bandHeight + extend / 2
331
+ }
332
+ };
333
+ }
334
+ if (this._updateCrosshair("y", type, positionAttribute), left.visible) {
336
335
  const updateAttrs = Object.assign(Object.assign(Object.assign({
337
336
  x: leftPos,
338
337
  y: y + bandHeight / 2
339
- }, left), this.yHair.label), {
340
- textStyle: Object.assign(Object.assign({}, null === (_e = this.yHair.label) || void 0 === _e ? void 0 : _e.textStyle), {
338
+ }, left), this._yHair.label), {
339
+ textStyle: Object.assign(Object.assign({}, null === (_a = this._yHair.label) || void 0 === _a ? void 0 : _a.textStyle), {
341
340
  textAlign: "right",
342
341
  textBaseline: "middle"
343
342
  }),
@@ -351,8 +350,8 @@ export class CartesianCrossHair extends BaseCrossHair {
351
350
  const updateAttrs = Object.assign(Object.assign(Object.assign({
352
351
  x: leftPos + width,
353
352
  y: y + bandHeight
354
- }, right), this.yHair.label), {
355
- textStyle: Object.assign(Object.assign({}, null === (_f = this.yHair.label) || void 0 === _f ? void 0 : _f.textStyle), {
353
+ }, right), this._yHair.label), {
354
+ textStyle: Object.assign(Object.assign({}, null === (_b = this._yHair.label) || void 0 === _b ? void 0 : _b.textStyle), {
356
355
  textAlign: "left",
357
356
  textBaseline: "middle"
358
357
  }),
@@ -364,15 +363,25 @@ export class CartesianCrossHair extends BaseCrossHair {
364
363
  } else this._yRightLabel && this._yRightLabel.hideAll();
365
364
  }
366
365
  }
366
+ _getRectSize(hair, bandSize, axis) {
367
+ var _a, _b, _c;
368
+ let extend = 0;
369
+ if (null === (_a = hair.style) || void 0 === _a ? void 0 : _a.sizePercent) extend = (hair.style.sizePercent - 1) * bandSize; else if ("number" == typeof (null === (_b = hair.style) || void 0 === _b ? void 0 : _b.size)) extend = hair.style.size - bandSize; else if ("function" == typeof (null === (_c = hair.style) || void 0 === _c ? void 0 : _c.size)) {
370
+ const axisRect = axis.getLayoutRect();
371
+ extend = hair.style.size(axisRect, axis) - bandSize;
372
+ }
373
+ return extend;
374
+ }
367
375
  _parseFieldInfo() {
368
- const {xField: xField, yField: yField} = this._crosshairConfig;
369
- xField && xField.visible && (this.xHair = this._parseField(xField, "xField")), yField && yField.visible && (this.yHair = this._parseField(yField, "yField"));
376
+ const {xField: xField, yField: yField} = this._spec;
377
+ xField && xField.visible && (this._xHair = this._parseField(xField, "xField")),
378
+ yField && yField.visible && (this._yHair = this._parseField(yField, "yField"));
370
379
  }
371
380
  _updateCrosshair(dim, type, attributes) {
372
381
  const container = this.getContainer();
373
382
  let crosshair, style;
374
- "x" === dim ? (crosshair = this._xCrosshair, style = this.xHair.style) : (crosshair = this._yCrosshair,
375
- style = this.yHair.style), crosshair ? crosshair.setAttributes(attributes) : ("line" === type ? crosshair = new LineCrosshair(Object.assign(Object.assign({}, attributes), {
383
+ "x" === dim ? (crosshair = this._xCrosshair, style = this._xHair.style) : (crosshair = this._yCrosshair,
384
+ style = this._yHair.style), crosshair ? crosshair.setAttributes(attributes) : ("line" === type ? crosshair = new LineCrosshair(Object.assign(Object.assign({}, attributes), {
376
385
  lineStyle: style,
377
386
  zIndex: this.gridZIndex + 1
378
387
  })) : "rect" === type && (crosshair = new RectCrosshair(Object.assign(Object.assign({}, attributes), {
@@ -383,7 +392,7 @@ export class CartesianCrossHair extends BaseCrossHair {
383
392
  _updateCrosshairLabel(label, attributes, callback) {
384
393
  const container = this.getContainer();
385
394
  label ? label.setAttributes(attributes) : (callback(label = new Tag(attributes)),
386
- container.add(label)), limitTagInBounds(label, this._getLimitBounds());
395
+ null == container || container.add(label)), limitTagInBounds(label, this._getLimitBounds());
387
396
  }
388
397
  _getNeedClearVRenderComponents() {
389
398
  return [ this._xCrosshair, this._xTopLabel, this._xBottomLabel, this._yCrosshair, this._yLeftLabel, this._yRightLabel ];