@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;
@@ -4,14 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.registerCartesianCrossHair = exports.CartesianCrossHair = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), type_1 = require("../interface/type"), vscale_1 = require("@visactor/vscale"), vrender_components_1 = require("@visactor/vrender-components"), base_1 = require("./base"), util_1 = require("./util"), util_2 = require("../axis/util"), common_1 = require("../axis/cartesian/util/common"), factory_1 = require("../../core/factory");
8
-
9
- var LayoutType;
10
-
11
- !function(LayoutType) {
12
- LayoutType[LayoutType.ALL = 3] = "ALL", LayoutType[LayoutType.HORIZONTAL = 2] = "HORIZONTAL",
13
- LayoutType[LayoutType.VERTICAL = 1] = "VERTICAL", LayoutType[LayoutType.NONE = 0] = "NONE";
14
- }(LayoutType || (LayoutType = {}));
7
+ const vutils_1 = require("@visactor/vutils"), type_1 = require("../interface/type"), vscale_1 = require("@visactor/vscale"), vrender_components_1 = require("@visactor/vrender-components"), base_1 = require("./base"), util_1 = require("./util"), util_2 = require("../axis/util"), common_1 = require("../axis/cartesian/util/common"), factory_1 = require("../../core/factory"), config_1 = require("./config");
15
8
 
16
9
  class CartesianCrossHair extends base_1.BaseCrossHair {
17
10
  static createComponent(spec, options) {
@@ -27,79 +20,81 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
27
20
  }
28
21
  constructor(spec, options) {
29
22
  super(spec, options), this.specKey = "crosshair", this.type = type_1.ComponentTypeEnum.cartesianCrosshair,
30
- this.name = type_1.ComponentTypeEnum.cartesianCrosshair, this.currValueX = new Map,
31
- this.currValueY = new Map;
23
+ this.name = type_1.ComponentTypeEnum.cartesianCrosshair, this._currValueX = new Map,
24
+ this._currValueY = new Map;
32
25
  }
33
- _showDefaultCrosshair() {
34
- if (!this.showDefault) return;
35
- const {xField: xField = {}, yField: yField = {}} = this._spec;
26
+ _showDefaultCrosshairBySpec() {
27
+ const {xField: xField, yField: yField} = this._spec;
36
28
  if ((null == xField ? void 0 : xField.visible) && xField.defaultSelect) {
37
29
  const {axisIndex: axisIndex, datum: datum} = xField.defaultSelect;
38
- this.defaultCrosshair(axisIndex, datum, LayoutType.VERTICAL, !0), this.layoutByValue(LayoutType.VERTICAL);
30
+ this._defaultCrosshair(axisIndex, datum, config_1.LayoutType.VERTICAL);
39
31
  }
40
32
  if ((null == yField ? void 0 : yField.visible) && yField.defaultSelect) {
41
33
  const {axisIndex: axisIndex, datum: datum} = yField.defaultSelect;
42
- this.defaultCrosshair(axisIndex, datum, LayoutType.HORIZONTAL, !1), this.layoutByValue(LayoutType.HORIZONTAL);
34
+ this._defaultCrosshair(axisIndex, datum, config_1.LayoutType.HORIZONTAL);
43
35
  }
44
36
  }
45
- defaultCrosshair(axisIndex, datum, tag, vertical) {
37
+ _defaultCrosshair(axisIndex, datum, tag) {
46
38
  const axis = this._option.getComponentsByKey("axes").find((c => c.getSpecIndex() === axisIndex));
47
- axis && (vertical ? (this.currValueX.clear(), this.currValueX.set(axisIndex, {
39
+ axis && (tag === config_1.LayoutType.VERTICAL ? (this._currValueX.clear(), this._currValueX.set(axisIndex, {
48
40
  axis: axis,
49
41
  v: datum
50
- })) : (this.currValueY.clear(), this.currValueY.set(axisIndex, {
42
+ })) : (this._currValueY.clear(), this._currValueY.set(axisIndex, {
51
43
  axis: axis,
52
44
  v: datum
53
- })));
45
+ })), this.layoutByValue(tag));
54
46
  }
55
- findAllAxisContains(relativeX, relativeY) {
47
+ _findAllAxisContains(relativeX, relativeY) {
56
48
  const xAxisMap = this._getAxisInfoByField("x"), yAxisMap = this._getAxisInfoByField("y");
57
49
  return {
58
50
  xAxisMap: this._filterAxisByPoint(xAxisMap, relativeX, relativeY),
59
51
  yAxisMap: this._filterAxisByPoint(yAxisMap, relativeX, relativeY)
60
52
  };
61
53
  }
62
- getValueAt(axis, p) {
54
+ _getValueAt(axis, p) {
63
55
  let value = axis.getScale().invert(p);
64
56
  return (0, vscale_1.isContinuous)(axis.getScale().type) && (0, vutils_1.isValidNumber)(+value) && (value = (+value).toFixed(2)),
65
57
  value;
66
58
  }
67
59
  clearAxisValue() {
68
- this.currValueX.clear(), this.currValueY.clear();
60
+ this._currValueX.clear(), this._currValueY.clear();
69
61
  }
70
62
  setAxisValue(v, axis) {
71
- (0, common_1.isXAxis)(axis.getOrient()), this.currValueX.set(axis.getSpecIndex(), {
63
+ (0, common_1.isXAxis)(axis.getOrient()) ? this._currValueX.set(axis.getSpecIndex(), {
64
+ v: v,
65
+ axis: axis
66
+ }) : this._currValueY.set(axis.getSpecIndex(), {
72
67
  v: v,
73
68
  axis: axis
74
69
  });
75
70
  }
76
- getAllAxisValues(axisMap, p, currValue, vertical) {
71
+ _getAllAxisValues(axisMap, p, currValue, vertical) {
77
72
  let discrete = !1;
78
73
  return axisMap.forEach((item => {
79
74
  (0, vscale_1.isDiscrete)(item.axis.getScale().type) && (discrete ? this.enable = !1 : discrete = !0);
80
75
  })), !!this.enable && (axisMap.forEach(((item, id) => {
81
76
  const axis = item.axis;
82
77
  currValue.set(id, {
83
- v: this.getValueAt(axis, p - (vertical ? axis.getLayoutStartPoint().x - this.getLayoutStartPoint().x : axis.getLayoutStartPoint().y - this.getLayoutStartPoint().y)),
78
+ v: this._getValueAt(axis, p - (vertical ? axis.getLayoutStartPoint().x - this.getLayoutStartPoint().x : axis.getLayoutStartPoint().y - this.getLayoutStartPoint().y)),
84
79
  axis: axis
85
80
  });
86
81
  })), !0);
87
82
  }
88
83
  _layoutCrosshair(relativeX, relativeY) {
89
- const {xAxisMap: xAxisMap, yAxisMap: yAxisMap} = this.findAllAxisContains(relativeX, relativeY);
84
+ const {xAxisMap: xAxisMap, yAxisMap: yAxisMap} = this._findAllAxisContains(relativeX, relativeY);
90
85
  if (xAxisMap && 0 === xAxisMap.size && yAxisMap && 0 === yAxisMap.size) {
91
86
  if (this.enableRemain) return;
92
87
  this.hide();
93
- } else this.currValueX.clear(), this.currValueY.clear(), xAxisMap && xAxisMap.size && this.getAllAxisValues(xAxisMap, relativeX, this.currValueX, !0),
94
- yAxisMap && yAxisMap.size && this.getAllAxisValues(yAxisMap, relativeY, this.currValueY, !1),
95
- this.layoutByValue(LayoutType.ALL);
88
+ } else this._currValueX.clear(), this._currValueY.clear(), xAxisMap && xAxisMap.size && this._getAllAxisValues(xAxisMap, relativeX, this._currValueX, !0),
89
+ yAxisMap && yAxisMap.size && this._getAllAxisValues(yAxisMap, relativeY, this._currValueY, !1),
90
+ this.layoutByValue(config_1.LayoutType.ALL);
96
91
  }
97
92
  hide() {
98
93
  this._xCrosshair && this._xCrosshair.hideAll(), this._xTopLabel && this._xTopLabel.hideAll(),
99
94
  this._xBottomLabel && this._xBottomLabel.hideAll(), this._yCrosshair && this._yCrosshair.hideAll(),
100
95
  this._yLeftLabel && this._yLeftLabel.hideAll(), this._yRightLabel && this._yRightLabel.hideAll();
101
96
  }
102
- layoutByValue(tag = LayoutType.ALL) {
97
+ layoutByValue(tag = config_1.LayoutType.ALL) {
103
98
  var _a, _b, _c, _d;
104
99
  if (!this.enable) return;
105
100
  const series = this._firstSeries();
@@ -121,7 +116,8 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
121
116
  dx: 0,
122
117
  dy: 0
123
118
  },
124
- visible: !1
119
+ visible: !1,
120
+ axis: null
125
121
  }, yCrossHairInfo = {
126
122
  width: 0,
127
123
  leftPos: 0,
@@ -139,7 +135,8 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
139
135
  dx: 0,
140
136
  dy: 0
141
137
  },
142
- visible: !1
138
+ visible: !1,
139
+ axis: null
143
140
  };
144
141
  const getRegionArea = (outRegion, currentValue) => {
145
142
  currentValue.forEach((({axis: axis}) => {
@@ -151,15 +148,17 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
151
148
  }));
152
149
  };
153
150
  let x = 0, y = 0;
154
- if (this.currValueX.size) {
155
- const item = Array.from(this.currValueX.values())[0];
156
- x = item.axis.getScale().scale(item.v) + item.axis.getLayoutStartPoint().x - this.getLayoutStartPoint().x;
151
+ if (this._currValueX.size) {
152
+ const item = Array.from(this._currValueX.values())[0];
153
+ x = item.axis.getScale().scale(item.v) + item.axis.getLayoutStartPoint().x - this.getLayoutStartPoint().x,
154
+ xCrossHairInfo.axis = item.axis;
157
155
  }
158
- if (this.currValueY.size) {
159
- const item = Array.from(this.currValueY.values())[0];
160
- y = item.axis.getScale().scale(item.v) + item.axis.getLayoutStartPoint().y - this.getLayoutStartPoint().y;
156
+ if (this._currValueY.size) {
157
+ const item = Array.from(this._currValueY.values())[0];
158
+ y = item.axis.getScale().scale(item.v) + item.axis.getLayoutStartPoint().y - this.getLayoutStartPoint().y,
159
+ yCrossHairInfo.axis = item.axis;
161
160
  }
162
- xCrossHairInfo.visible = !!this.currValueX.size && Number.isFinite(x), yCrossHairInfo.visible = !!this.currValueY.size && Number.isFinite(y);
161
+ xCrossHairInfo.visible = !!this._currValueX.size && Number.isFinite(x), yCrossHairInfo.visible = !!this._currValueY.size && Number.isFinite(y);
163
162
  const xRegion = {
164
163
  x1: 1 / 0,
165
164
  y1: 1 / 0,
@@ -172,15 +171,13 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
172
171
  y2: -1 / 0
173
172
  };
174
173
  let indexWidth, valueHeight;
175
- if (getRegionArea(xRegion, this.currValueX), getRegionArea(yRegion, this.currValueY),
176
- this.xHair && this.currValueX.forEach((({axis: axis, v: v}) => {
177
- var _a, _b, _c;
174
+ if (getRegionArea(xRegion, this._currValueX), getRegionArea(yRegion, this._currValueY),
175
+ this._xHair && this._currValueX.forEach((({axis: axis, v: v}) => {
176
+ var _a;
178
177
  v = null != v ? v : "";
179
178
  const xScale = axis.getScale();
180
- if ((0, vscale_1.isDiscrete)(xScale.type)) {
181
- const eachBand = xScale._step;
182
- indexWidth = axis ? null === (_b = (_a = series.getXAxisHelper()).getBandwidth) || void 0 === _b ? void 0 : _b.call(_a, 0) : eachBand;
183
- } else if ((0, vscale_1.isContinuous)(xScale.type)) {
179
+ if ((0, vscale_1.isDiscrete)(xScale.type)) indexWidth = xScale.bandwidth(); else if ((0,
180
+ vscale_1.isContinuous)(xScale.type)) {
184
181
  const fieldX = series.fieldX[0], fieldX2 = series.fieldX2, datum = (0, util_1.getDatumByValue)(series.getViewData().latestData, +v, fieldX, fieldX2);
185
182
  if (datum) {
186
183
  const startX = series.dataToPositionX(datum);
@@ -188,20 +185,18 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
188
185
  x = startX;
189
186
  }
190
187
  }
191
- if (null === (_c = this.xHair.label) || void 0 === _c ? void 0 : _c.visible) {
188
+ if (null === (_a = this._xHair.label) || void 0 === _a ? void 0 : _a.visible) {
192
189
  const labelOffset = (0, util_2.getAxisLabelOffset)(axis.getSpec());
193
190
  "bottom" === axis.getOrient() ? (xCrossHairInfo.bottom.visible = !0, xCrossHairInfo.bottom.text = v,
194
191
  xCrossHairInfo.bottom.dx = 0, xCrossHairInfo.bottom.dy = labelOffset) : "top" === axis.getOrient() && (xCrossHairInfo.top.visible = !0,
195
192
  xCrossHairInfo.top.text = v, xCrossHairInfo.top.dx = 0, xCrossHairInfo.top.dy = -labelOffset);
196
193
  }
197
- })), this.yHair && this.currValueY.forEach((({axis: axis, v: v}) => {
198
- var _a, _b, _c;
194
+ })), this._yHair && this._currValueY.forEach((({axis: axis, v: v}) => {
195
+ var _a;
199
196
  v = null != v ? v : "";
200
197
  const yScale = axis.getScale();
201
- if ((0, vscale_1.isDiscrete)(yScale.type)) {
202
- const eachBand = yScale._step;
203
- valueHeight = yScale ? null === (_b = (_a = series.getYAxisHelper()).getBandwidth) || void 0 === _b ? void 0 : _b.call(_a, 0) : eachBand;
204
- } else if ((0, vscale_1.isContinuous)(yScale.type)) {
198
+ if ((0, vscale_1.isDiscrete)(yScale.type)) valueHeight = yScale.bandwidth(); else if ((0,
199
+ vscale_1.isContinuous)(yScale.type)) {
205
200
  const fieldY = series.fieldY[0], fieldY2 = series.fieldY2, datum = (0, util_1.getDatumByValue)(series.getViewData().latestData, +v, fieldY, fieldY2);
206
201
  if (datum) {
207
202
  const startY = series.dataToPositionY(datum);
@@ -209,7 +204,7 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
209
204
  y = startY;
210
205
  }
211
206
  }
212
- if (null === (_c = this.yHair.label) || void 0 === _c ? void 0 : _c.visible) {
207
+ if (null === (_a = this._yHair.label) || void 0 === _a ? void 0 : _a.visible) {
213
208
  const labelOffset = (0, util_2.getAxisLabelOffset)(axis.getSpec());
214
209
  "left" === axis.getOrient() ? (yCrossHairInfo.left.visible = !0, yCrossHairInfo.left.text = v,
215
210
  yCrossHairInfo.left.dx = -labelOffset, yCrossHairInfo.left.dy = 0) : "right" === axis.getOrient() && (yCrossHairInfo.right.visible = !0,
@@ -217,20 +212,20 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
217
212
  }
218
213
  })), this.enableRemain && !xCrossHairInfo.visible && (0, vutils_1.isValid)(this._cacheXCrossHairInfo)) xCrossHairInfo = this._cacheXCrossHairInfo; else if (xCrossHairInfo.leftPos = xRegion.x1,
219
214
  xCrossHairInfo.topPos = xRegion.y1, xCrossHairInfo.height = xRegion.y2 - xRegion.y1,
220
- 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) {
215
+ 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) {
221
216
  const {top: top, bottom: bottom} = xCrossHairInfo;
222
- bottom.visible && (bottom.text = this.xHair.label.formatMethod(bottom.text, "bottom")),
223
- top.visible && (top.text = this.xHair.label.formatMethod(top.text, "top"));
217
+ bottom.visible && (bottom.text = this._xHair.label.formatMethod(bottom.text, "bottom")),
218
+ top.visible && (top.text = this._xHair.label.formatMethod(top.text, "top"));
224
219
  }
225
220
  if (this.enableRemain && !yCrossHairInfo.visible && (0, vutils_1.isValid)(this._cacheYCrossHairInfo)) yCrossHairInfo = this._cacheYCrossHairInfo; else if (yCrossHairInfo.leftPos = yRegion.x1,
226
221
  yCrossHairInfo.topPos = yRegion.y1, yCrossHairInfo.width = yRegion.x2 - yRegion.x1,
227
- 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) {
222
+ 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) {
228
223
  const {left: left, right: right} = yCrossHairInfo;
229
- left.visible && (left.text = this.yHair.label.formatMethod(left.text, "left")),
230
- right.visible && (right.text = this.yHair.label.formatMethod(right.text, "right"));
224
+ left.visible && (left.text = this._yHair.label.formatMethod(left.text, "left")),
225
+ right.visible && (right.text = this._yHair.label.formatMethod(right.text, "right"));
231
226
  }
232
- tag && (LayoutType.HORIZONTAL && this._layoutHorizontal(yCrossHairInfo, null != valueHeight ? valueHeight : 0),
233
- LayoutType.VERTICAL && this._layoutVertical(xCrossHairInfo, null != indexWidth ? indexWidth : 0)),
227
+ tag && (config_1.LayoutType.HORIZONTAL && this._layoutHorizontal(yCrossHairInfo, null != valueHeight ? valueHeight : 0),
228
+ config_1.LayoutType.VERTICAL && this._layoutVertical(xCrossHairInfo, null != indexWidth ? indexWidth : 0)),
234
229
  this.enableRemain && (this._cacheXCrossHairInfo = Object.assign(Object.assign({}, xCrossHairInfo), {
235
230
  _isCache: !0
236
231
  }), this._cacheYCrossHairInfo = Object.assign(Object.assign({}, yCrossHairInfo), {
@@ -238,38 +233,40 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
238
233
  }));
239
234
  }
240
235
  _layoutVertical(crosshairInfo, bandWidth) {
241
- var _a, _b, _c, _d, _e, _f;
242
- if (crosshairInfo._isCache && this.enableRemain || !this.xHair) return;
236
+ var _a, _b;
237
+ if (crosshairInfo._isCache && this.enableRemain || !this._xHair) return;
243
238
  const {x: x, topPos: topPos, height: height, top: top, bottom: bottom, visible: visible} = crosshairInfo;
244
239
  if (visible) {
245
- let extend = 0;
246
- (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);
247
- const type = this.xHair.type;
240
+ const type = this._xHair.type;
248
241
  let positionAttribute;
249
- if ("line" === type ? positionAttribute = {
242
+ if ("line" === type) positionAttribute = {
250
243
  start: {
251
- x: x + bandWidth / 2 - extend / 2,
252
- y: topPos
253
- },
254
- end: {
255
- x: x + bandWidth / 2 + extend / 2,
256
- y: topPos + height
257
- }
258
- } : "rect" === type && (positionAttribute = {
259
- start: {
260
- x: x - extend / 2,
244
+ x: x + bandWidth / 2,
261
245
  y: topPos
262
246
  },
263
247
  end: {
264
- x: x + bandWidth + extend / 2,
248
+ x: x + bandWidth / 2,
265
249
  y: topPos + height
266
250
  }
267
- }), this._updateCrosshair("x", type, positionAttribute), top.visible) {
251
+ }; else if ("rect" === type) {
252
+ const extend = this._getRectSize(this._xHair, bandWidth, crosshairInfo.axis);
253
+ positionAttribute = {
254
+ start: {
255
+ x: x - extend / 2,
256
+ y: topPos
257
+ },
258
+ end: {
259
+ x: x + bandWidth + extend / 2,
260
+ y: topPos + height
261
+ }
262
+ };
263
+ }
264
+ if (this._updateCrosshair("x", type, positionAttribute), top.visible) {
268
265
  const updateAttrs = Object.assign(Object.assign(Object.assign({
269
266
  x: x + bandWidth / 2,
270
267
  y: topPos
271
- }, top), this.xHair.label), {
272
- textStyle: Object.assign(Object.assign({}, null === (_e = this.xHair.label) || void 0 === _e ? void 0 : _e.textStyle), {
268
+ }, top), this._xHair.label), {
269
+ textStyle: Object.assign(Object.assign({}, null === (_a = this._xHair.label) || void 0 === _a ? void 0 : _a.textStyle), {
273
270
  textAlign: "center",
274
271
  textBaseline: "bottom"
275
272
  }),
@@ -283,8 +280,8 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
283
280
  const updateAttrs = Object.assign(Object.assign(Object.assign({
284
281
  x: x + bandWidth / 2,
285
282
  y: topPos + height
286
- }, bottom), this.xHair.label), {
287
- textStyle: Object.assign(Object.assign({}, null === (_f = this.xHair.label) || void 0 === _f ? void 0 : _f.textStyle), {
283
+ }, bottom), this._xHair.label), {
284
+ textStyle: Object.assign(Object.assign({}, null === (_b = this._xHair.label) || void 0 === _b ? void 0 : _b.textStyle), {
288
285
  textAlign: "center",
289
286
  textBaseline: "top"
290
287
  }),
@@ -297,15 +294,13 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
297
294
  }
298
295
  }
299
296
  _layoutHorizontal(crosshairInfo, bandHeight) {
300
- var _a, _b, _c, _d, _e, _f;
301
- if (crosshairInfo._isCache && this.enableRemain || !this.yHair) return;
297
+ var _a, _b;
298
+ if (crosshairInfo._isCache && this.enableRemain || !this._yHair) return;
302
299
  const {leftPos: leftPos, width: width, y: y, left: left, right: right, visible: visible} = crosshairInfo;
303
300
  if (visible) {
304
- let extend = 0;
305
- (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);
306
- const type = this.yHair.type;
301
+ const type = this._yHair.type;
307
302
  let positionAttribute;
308
- if ("line" === type ? positionAttribute = {
303
+ if ("line" === type) positionAttribute = {
309
304
  start: {
310
305
  x: leftPos,
311
306
  y: y + bandHeight / 2
@@ -314,21 +309,25 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
314
309
  x: leftPos + width,
315
310
  y: y + bandHeight / 2
316
311
  }
317
- } : "rect" === type && (positionAttribute = {
318
- start: {
319
- x: leftPos,
320
- y: y - extend / 2
321
- },
322
- end: {
323
- x: leftPos + width,
324
- y: y + bandHeight + extend / 2
325
- }
326
- }), this._updateCrosshair("y", type, positionAttribute), left.visible) {
312
+ }; else if ("rect" === type) {
313
+ const extend = this._getRectSize(this._yHair, bandHeight, crosshairInfo.axis);
314
+ positionAttribute = {
315
+ start: {
316
+ x: leftPos,
317
+ y: y - extend / 2
318
+ },
319
+ end: {
320
+ x: leftPos + width,
321
+ y: y + bandHeight + extend / 2
322
+ }
323
+ };
324
+ }
325
+ if (this._updateCrosshair("y", type, positionAttribute), left.visible) {
327
326
  const updateAttrs = Object.assign(Object.assign(Object.assign({
328
327
  x: leftPos,
329
328
  y: y + bandHeight / 2
330
- }, left), this.yHair.label), {
331
- textStyle: Object.assign(Object.assign({}, null === (_e = this.yHair.label) || void 0 === _e ? void 0 : _e.textStyle), {
329
+ }, left), this._yHair.label), {
330
+ textStyle: Object.assign(Object.assign({}, null === (_a = this._yHair.label) || void 0 === _a ? void 0 : _a.textStyle), {
332
331
  textAlign: "right",
333
332
  textBaseline: "middle"
334
333
  }),
@@ -342,8 +341,8 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
342
341
  const updateAttrs = Object.assign(Object.assign(Object.assign({
343
342
  x: leftPos + width,
344
343
  y: y + bandHeight
345
- }, right), this.yHair.label), {
346
- textStyle: Object.assign(Object.assign({}, null === (_f = this.yHair.label) || void 0 === _f ? void 0 : _f.textStyle), {
344
+ }, right), this._yHair.label), {
345
+ textStyle: Object.assign(Object.assign({}, null === (_b = this._yHair.label) || void 0 === _b ? void 0 : _b.textStyle), {
347
346
  textAlign: "left",
348
347
  textBaseline: "middle"
349
348
  }),
@@ -355,15 +354,25 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
355
354
  } else this._yRightLabel && this._yRightLabel.hideAll();
356
355
  }
357
356
  }
357
+ _getRectSize(hair, bandSize, axis) {
358
+ var _a, _b, _c;
359
+ let extend = 0;
360
+ 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)) {
361
+ const axisRect = axis.getLayoutRect();
362
+ extend = hair.style.size(axisRect, axis) - bandSize;
363
+ }
364
+ return extend;
365
+ }
358
366
  _parseFieldInfo() {
359
- const {xField: xField, yField: yField} = this._crosshairConfig;
360
- xField && xField.visible && (this.xHair = this._parseField(xField, "xField")), yField && yField.visible && (this.yHair = this._parseField(yField, "yField"));
367
+ const {xField: xField, yField: yField} = this._spec;
368
+ xField && xField.visible && (this._xHair = this._parseField(xField, "xField")),
369
+ yField && yField.visible && (this._yHair = this._parseField(yField, "yField"));
361
370
  }
362
371
  _updateCrosshair(dim, type, attributes) {
363
372
  const container = this.getContainer();
364
373
  let crosshair, style;
365
- "x" === dim ? (crosshair = this._xCrosshair, style = this.xHair.style) : (crosshair = this._yCrosshair,
366
- style = this.yHair.style), crosshair ? crosshair.setAttributes(attributes) : ("line" === type ? crosshair = new vrender_components_1.LineCrosshair(Object.assign(Object.assign({}, attributes), {
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 vrender_components_1.LineCrosshair(Object.assign(Object.assign({}, attributes), {
367
376
  lineStyle: style,
368
377
  zIndex: this.gridZIndex + 1
369
378
  })) : "rect" === type && (crosshair = new vrender_components_1.RectCrosshair(Object.assign(Object.assign({}, attributes), {
@@ -374,7 +383,7 @@ class CartesianCrossHair extends base_1.BaseCrossHair {
374
383
  _updateCrosshairLabel(label, attributes, callback) {
375
384
  const container = this.getContainer();
376
385
  label ? label.setAttributes(attributes) : (callback(label = new vrender_components_1.Tag(attributes)),
377
- container.add(label)), (0, util_1.limitTagInBounds)(label, this._getLimitBounds());
386
+ null == container || container.add(label)), (0, util_1.limitTagInBounds)(label, this._getLimitBounds());
378
387
  }
379
388
  _getNeedClearVRenderComponents() {
380
389
  return [ this._xCrosshair, this._xTopLabel, this._xBottomLabel, this._yCrosshair, this._yLeftLabel, this._yRightLabel ];