@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
@@ -2,11 +2,11 @@ import type { DataView } from '@visactor/vdataset';
2
2
  import type { IModelRenderOption } from '../../model/interface';
3
3
  import type { IRegion } from '../../region/interface';
4
4
  import type { ICartesianSeries } from '../../series/interface';
5
- import type { ILayoutRect, ILayoutType, IRect, StringOrNumber } from '../../typings';
5
+ import type { ILayoutRect, ILayoutType, IRect } from '../../typings';
6
6
  import { BaseComponent } from '../base/base-component';
7
- import type { IAggrType, IDataPos, IDataPosCallback, IMarkerAxisSpec, IMarkerSpec } from './interface';
8
- import type { IGraphic } from '@visactor/vrender-core';
9
- export declare abstract class BaseMarker<T extends IMarkerSpec & IMarkerAxisSpec> extends BaseComponent<T> {
7
+ import type { IAggrType, IDataPos, IDataPosCallback, IMarkerSpec } from './interface';
8
+ import type { IGraphic, IGroup } from '@visactor/vrender-core';
9
+ export declare abstract class BaseMarker<T extends IMarkerSpec> extends BaseComponent<T> {
10
10
  layoutType: ILayoutType | 'none';
11
11
  protected _startRelativeSeries: ICartesianSeries;
12
12
  protected _endRelativeSeries: ICartesianSeries;
@@ -16,55 +16,53 @@ export declare abstract class BaseMarker<T extends IMarkerSpec & IMarkerAxisSpec
16
16
  protected _markerComponent: any;
17
17
  protected _layoutOffsetX: number;
18
18
  protected _layoutOffsetY: number;
19
+ private _firstSeries;
19
20
  created(): void;
20
- private _isSpecAggr;
21
21
  private _getAllRelativeSeries;
22
+ private _getFieldInfoFromSpec;
22
23
  protected _processSpecX(specX: IDataPos | IDataPosCallback): {
23
24
  getRelativeSeries: () => ICartesianSeries;
24
25
  getStartRelativeSeries: () => ICartesianSeries;
25
26
  getEndRelativeSeries: () => ICartesianSeries;
26
- x: {
27
+ x: string | number | IDataPosCallback | {
27
28
  field: any;
28
29
  aggrType: IAggrType;
29
30
  };
30
- } | {
31
- getRelativeSeries: () => ICartesianSeries;
32
- getStartRelativeSeries: () => ICartesianSeries;
33
- getEndRelativeSeries: () => ICartesianSeries;
34
- x: IDataPos | IDataPosCallback;
35
31
  };
36
32
  protected _processSpecY(specY: IDataPos | IDataPosCallback): {
37
33
  getRelativeSeries: () => ICartesianSeries;
38
34
  getStartRelativeSeries: () => ICartesianSeries;
39
35
  getEndRelativeSeries: () => ICartesianSeries;
40
- y: {
36
+ y: string | number | IDataPosCallback | {
41
37
  field: any;
42
38
  aggrType: IAggrType;
43
39
  };
44
- } | {
40
+ };
41
+ protected _processSpecXY(specX: IDataPos | IDataPosCallback, specY: IDataPos | IDataPosCallback): {
45
42
  getRelativeSeries: () => ICartesianSeries;
46
43
  getStartRelativeSeries: () => ICartesianSeries;
47
44
  getEndRelativeSeries: () => ICartesianSeries;
48
- y: IDataPos | IDataPosCallback;
45
+ x: string | number | IDataPosCallback | {
46
+ field: any;
47
+ aggrType: IAggrType;
48
+ };
49
+ y: string | number | IDataPosCallback | {
50
+ field: any;
51
+ aggrType: IAggrType;
52
+ };
49
53
  };
50
- protected _processSpecXY(specX: IDataPos | IDataPosCallback, specY: IDataPos | IDataPosCallback): any;
51
54
  protected _processSpecCoo(spec: any): any;
52
55
  updateLayoutAttribute(): void;
53
- protected _getSeriesByIdOrIndex(seriesUserId: StringOrNumber, seriesIndex: number): ICartesianSeries;
56
+ private _getSeriesByIdOrIndex;
54
57
  protected _bindSeries(): void;
55
- protected _computeClipRange(regions: IRegion[]): {
56
- minX: number;
57
- maxX: number;
58
- minY: number;
59
- maxY: number;
60
- };
61
58
  protected abstract _initDataView(): void;
62
- protected abstract _createMarkerComponent(): void;
59
+ protected abstract _createMarkerComponent(): IGroup;
63
60
  protected abstract _markerLayout(): void;
64
61
  protected initEvent(): void;
65
62
  onRender(ctx: IModelRenderOption): void;
66
63
  changeRegions(regions: IRegion[]): void;
67
- protected getFirstSeries(): ICartesianSeries;
64
+ clear(): void;
65
+ private _getFirstSeries;
68
66
  protected _getNeedClearVRenderComponents(): IGraphic[];
69
67
  onLayoutStart(layoutRect: IRect, chartViewRect: ILayoutRect, ctx: any): void;
70
68
  }
@@ -1,11 +1,11 @@
1
- import { array, isValid, isNil } from "@visactor/vutils";
2
-
3
- import { AGGR_TYPE } from "../../constant/marker";
1
+ import { array, isValid, isNil, isString } from "@visactor/vutils";
4
2
 
5
3
  import { BaseComponent } from "../base/base-component";
6
4
 
7
5
  import { calcLayoutNumber } from "../../util/space";
8
6
 
7
+ import { isAggrSpec } from "./utils";
8
+
9
9
  export class BaseMarker extends BaseComponent {
10
10
  constructor() {
11
11
  super(...arguments), this.layoutType = "none", this._layoutOffsetX = 0, this._layoutOffsetY = 0;
@@ -16,9 +16,6 @@ export class BaseMarker extends BaseComponent {
16
16
  created() {
17
17
  super.created(), this.initEvent(), this._bindSeries(), this._initDataView();
18
18
  }
19
- _isSpecAggr(spec) {
20
- return AGGR_TYPE.includes(spec);
21
- }
22
19
  _getAllRelativeSeries() {
23
20
  return {
24
21
  getRelativeSeries: () => this._relativeSeries,
@@ -26,37 +23,31 @@ export class BaseMarker extends BaseComponent {
26
23
  getEndRelativeSeries: () => this._endRelativeSeries
27
24
  };
28
25
  }
26
+ _getFieldInfoFromSpec(dim, spec, relativeSeries) {
27
+ const field = "x" === dim ? relativeSeries.getSpec().xField : relativeSeries.getSpec().yField;
28
+ return isString(spec) && isAggrSpec(spec) ? {
29
+ field: field,
30
+ aggrType: spec
31
+ } : spec;
32
+ }
29
33
  _processSpecX(specX) {
30
34
  const relativeSeries = this._relativeSeries;
31
- return this._isSpecAggr(specX) ? Object.assign({
32
- x: {
33
- field: relativeSeries.getSpec().xField,
34
- aggrType: specX
35
- }
36
- }, this._getAllRelativeSeries()) : Object.assign({
37
- x: specX
35
+ return Object.assign({
36
+ x: this._getFieldInfoFromSpec("x", specX, relativeSeries)
38
37
  }, this._getAllRelativeSeries());
39
38
  }
40
39
  _processSpecY(specY) {
41
40
  const relativeSeries = this._relativeSeries;
42
- return this._isSpecAggr(specY) ? Object.assign({
43
- y: {
44
- field: relativeSeries.getSpec().yField,
45
- aggrType: specY
46
- }
47
- }, this._getAllRelativeSeries()) : Object.assign({
48
- y: specY
41
+ return Object.assign({
42
+ y: this._getFieldInfoFromSpec("y", specY, relativeSeries)
49
43
  }, this._getAllRelativeSeries());
50
44
  }
51
45
  _processSpecXY(specX, specY) {
52
- const result = Object.assign({}, this._getAllRelativeSeries()), relativeSeries = this._relativeSeries;
53
- return this._isSpecAggr(specX) ? result.x = {
54
- field: relativeSeries.getSpec().xField,
55
- aggrType: specX
56
- } : result.x = specX, this._isSpecAggr(specY) ? result.y = {
57
- field: relativeSeries.getSpec().yField,
58
- aggrType: specY
59
- } : result.y = specY, result;
46
+ const relativeSeries = this._relativeSeries;
47
+ return Object.assign({
48
+ x: this._getFieldInfoFromSpec("x", specX, relativeSeries),
49
+ y: this._getFieldInfoFromSpec("y", specY, relativeSeries)
50
+ }, this._getAllRelativeSeries());
60
51
  }
61
52
  _processSpecCoo(spec) {
62
53
  var _a;
@@ -70,10 +61,10 @@ export class BaseMarker extends BaseComponent {
70
61
  x: void 0,
71
62
  y: void 0
72
63
  }, this._getAllRelativeSeries());
73
- return this._isSpecAggr(coordinate[bindXField]) ? option.x = {
64
+ return isString(coordinate[bindXField]) && isAggrSpec(coordinate[bindXField]) ? option.x = {
74
65
  field: bindXField,
75
66
  aggrType: coordinate[bindXField]
76
- } : option.x = array(bindXField).map((field => coordinate[field])), this._isSpecAggr(coordinate[bindYField]) ? option.y = {
67
+ } : option.x = array(bindXField).map((field => coordinate[field])), isString(coordinate[bindYField]) && isAggrSpec(coordinate[bindYField]) ? option.y = {
77
68
  field: bindYField,
78
69
  aggrType: coordinate[bindYField]
79
70
  } : option.y = array(bindYField).map((field => coordinate[field])), option.getRefRelativeSeries = () => refRelativeSeries,
@@ -81,16 +72,24 @@ export class BaseMarker extends BaseComponent {
81
72
  }));
82
73
  }
83
74
  updateLayoutAttribute() {
84
- var _a;
85
- (null === (_a = this._spec.visible) || void 0 === _a || _a) && (this._markerComponent || (this._createMarkerComponent(),
86
- this._markerComponent.on("*", ((event, type) => this._delegateEvent(this._markerComponent, event, type)))),
87
- this._markerLayout()), super.updateLayoutAttribute();
75
+ var _a, _b, _c;
76
+ if (null === (_a = this._spec.visible) || void 0 === _a || _a) {
77
+ if (!this._markerComponent) {
78
+ const markerComponent = this._createMarkerComponent();
79
+ markerComponent.name = null !== (_b = this._spec.name) && void 0 !== _b ? _b : this.type,
80
+ markerComponent.id = null !== (_c = this._spec.id) && void 0 !== _c ? _c : `${this.type}-${this.id}`,
81
+ this._markerComponent = markerComponent, this.getContainer().add(this._markerComponent),
82
+ this._markerComponent.on("*", ((event, type) => this._delegateEvent(this._markerComponent, event, type)));
83
+ }
84
+ this._markerLayout();
85
+ }
86
+ super.updateLayoutAttribute();
88
87
  }
89
88
  _getSeriesByIdOrIndex(seriesUserId, seriesIndex) {
90
89
  var _a, _b;
91
90
  let series;
92
- return series = null === (_a = this._option.getSeriesInUserIdOrIndex(array(seriesUserId), [ seriesIndex ])) || void 0 === _a ? void 0 : _a[0],
93
- series || (series = null !== (_b = this._relativeSeries) && void 0 !== _b ? _b : this.getFirstSeries()),
91
+ return series = null === (_a = this._option.getSeriesInUserIdOrIndex(isValid(seriesUserId) ? [ seriesUserId ] : [], [ seriesIndex ])) || void 0 === _a ? void 0 : _a[0],
92
+ series || (series = null !== (_b = this._relativeSeries) && void 0 !== _b ? _b : this._getFirstSeries()),
94
93
  series;
95
94
  }
96
95
  _bindSeries() {
@@ -99,30 +98,20 @@ export class BaseMarker extends BaseComponent {
99
98
  this._startRelativeSeries = this._getSeriesByIdOrIndex(spec.startRelativeSeriesId, spec.startRelativeSeriesIndex),
100
99
  this._endRelativeSeries = this._getSeriesByIdOrIndex(spec.endRelativeSeriesId, spec.endRelativeSeriesIndex);
101
100
  }
102
- _computeClipRange(regions) {
103
- let minX = 1 / 0, maxX = -1 / 0, minY = 1 / 0, maxY = -1 / 0;
104
- return regions.forEach((region => {
105
- region.getLayoutStartPoint().x < minX && (minX = region.getLayoutStartPoint().x),
106
- region.getLayoutStartPoint().x + region.getLayoutRect().width > maxX && (maxX = region.getLayoutStartPoint().x + region.getLayoutRect().width),
107
- region.getLayoutStartPoint().y < minY && (minY = region.getLayoutStartPoint().y),
108
- region.getLayoutStartPoint().y + region.getLayoutRect().height > maxY && (maxY = region.getLayoutStartPoint().y + region.getLayoutRect().height);
109
- })), {
110
- minX: minX,
111
- maxX: maxX,
112
- minY: minY,
113
- maxY: maxY
114
- };
115
- }
116
101
  initEvent() {}
117
102
  onRender(ctx) {}
118
103
  changeRegions(regions) {}
119
- getFirstSeries() {
104
+ clear() {
105
+ super.clear(), this._firstSeries = null;
106
+ }
107
+ _getFirstSeries() {
120
108
  var _a;
109
+ if (this._firstSeries) return this._firstSeries;
121
110
  for (let i = 0; i < this._regions.length; i++) {
122
111
  const series = this._regions[i].getSeries();
123
112
  for (let j = 0; j < series.length; j++) {
124
113
  const s = series[j];
125
- if (s) return s;
114
+ if (s) return this._firstSeries = s, s;
126
115
  }
127
116
  }
128
117
  return null === (_a = this._option) || void 0 === _a || _a.onError("need at least one series"),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/marker/base-marker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAc,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAMlD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,OAAgB,UAAoD,SAAQ,aAAgB;IAAlG;;QACE,eAAU,GAAyB,MAAM,CAAC;QAchC,mBAAc,GAAW,CAAC,CAAC;QAC3B,mBAAc,GAAW,CAAC,CAAC;IA+NvC,CAAC;IAzOC,iBAAiB;QACf,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAUD,OAAO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IACtD,CAAC;CACF","file":"base-marker.js","sourcesContent":["import type { DataView } from '@visactor/vdataset';\nimport { array, isFunction, isValid, isNil } from '@visactor/vutils';\nimport { AGGR_TYPE } from '../../constant/marker';\nimport type { IOptionAggr } from '../../data/transforms/aggregation';\nimport type { IModelRenderOption } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport type { ICartesianSeries } from '../../series/interface';\nimport type { ILayoutRect, ILayoutType, IRect, StringOrNumber } from '../../typings';\nimport { BaseComponent } from '../base/base-component';\nimport type { IAggrType, IDataPointSpec, IDataPos, IDataPosCallback, IMarkerAxisSpec, IMarkerSpec } from './interface';\nimport type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport { calcLayoutNumber } from '../../util/space';\n\nexport abstract class BaseMarker<T extends IMarkerSpec & IMarkerAxisSpec> extends BaseComponent<T> {\n layoutType: ILayoutType | 'none' = 'none';\n\n protected _startRelativeSeries!: ICartesianSeries;\n protected _endRelativeSeries!: ICartesianSeries;\n protected _relativeSeries!: ICartesianSeries;\n getRelativeSeries() {\n return this._relativeSeries;\n }\n\n // marker 组件数据\n protected _markerData!: DataView;\n // marker 组件\n protected _markerComponent!: any;\n\n protected _layoutOffsetX: number = 0;\n protected _layoutOffsetY: number = 0;\n\n created() {\n super.created();\n // event\n this.initEvent();\n this._bindSeries();\n this._initDataView();\n }\n\n private _isSpecAggr(spec: IDataPos | IDataPosCallback) {\n return AGGR_TYPE.includes(spec as any);\n }\n\n private _getAllRelativeSeries() {\n return {\n getRelativeSeries: () => this._relativeSeries,\n getStartRelativeSeries: () => this._startRelativeSeries,\n getEndRelativeSeries: () => this._endRelativeSeries\n };\n }\n\n protected _processSpecX(specX: IDataPos | IDataPosCallback) {\n const relativeSeries = this._relativeSeries;\n if (this._isSpecAggr(specX)) {\n return {\n x: {\n field: relativeSeries.getSpec().xField,\n aggrType: specX as unknown as IAggrType\n },\n ...this._getAllRelativeSeries()\n };\n }\n return { x: specX, ...this._getAllRelativeSeries() };\n }\n\n protected _processSpecY(specY: IDataPos | IDataPosCallback) {\n const relativeSeries = this._relativeSeries;\n if (this._isSpecAggr(specY)) {\n return {\n y: {\n field: relativeSeries.getSpec().yField,\n aggrType: specY as unknown as IAggrType\n },\n ...this._getAllRelativeSeries()\n };\n }\n return { y: specY, ...this._getAllRelativeSeries() };\n }\n\n protected _processSpecXY(specX: IDataPos | IDataPosCallback, specY: IDataPos | IDataPosCallback) {\n const result: any = {\n ...this._getAllRelativeSeries()\n };\n const relativeSeries = this._relativeSeries;\n if (this._isSpecAggr(specX)) {\n result.x = {\n field: relativeSeries.getSpec().xField,\n aggrType: specX as unknown as IAggrType\n };\n } else {\n result.x = specX;\n }\n\n if (this._isSpecAggr(specY)) {\n result.y = {\n field: relativeSeries.getSpec().yField,\n aggrType: specY as unknown as IAggrType\n };\n } else {\n result.y = specY;\n }\n\n return result;\n }\n\n protected _processSpecCoo(spec: any) {\n const coordinates = spec.coordinates ?? array(spec.coordinate);\n return coordinates.map((coordinate: IDataPointSpec) => {\n const refRelativeSeries = this._getSeriesByIdOrIndex(\n coordinate.refRelativeSeriesId,\n coordinate.refRelativeSeriesIndex\n );\n\n const { xField, yField } = refRelativeSeries.getSpec();\n const { xFieldDim, xFieldIndex, yFieldDim, yFieldIndex } = coordinate;\n let bindXField = xField;\n if (isValid(xFieldIndex)) {\n bindXField = array(xField)[xFieldIndex];\n }\n if (xFieldDim && array(xField).includes(xFieldDim)) {\n bindXField = xFieldDim;\n }\n\n let bindYField = yField;\n if (isValid(yFieldIndex)) {\n bindYField = array(yField)[yFieldIndex];\n }\n if (yFieldDim && array(yField).includes(yFieldDim)) {\n bindYField = yFieldDim;\n }\n\n // const { [xField]: coordinateX, [yField]: coordinateY } = coordinate;\n const option: IOptionAggr = {\n x: undefined,\n y: undefined,\n ...this._getAllRelativeSeries()\n };\n\n if (this._isSpecAggr(coordinate[bindXField])) {\n option.x = { field: bindXField, aggrType: coordinate[bindXField] as IAggrType };\n } else {\n option.x = array(bindXField).map(field => coordinate[field]);\n }\n\n if (this._isSpecAggr(coordinate[bindYField])) {\n option.y = { field: bindYField, aggrType: coordinate[bindYField] as IAggrType };\n } else {\n option.y = array(bindYField).map(field => coordinate[field]);\n }\n option.getRefRelativeSeries = () => refRelativeSeries;\n return option;\n });\n }\n\n updateLayoutAttribute(): void {\n const markerVisible = this._spec.visible ?? true;\n if (markerVisible) {\n // 创建marker组件\n if (!this._markerComponent) {\n this._createMarkerComponent();\n // 代理 marker 组件上的事件\n this._markerComponent.on('*', (event: any, type: string) =>\n this._delegateEvent(this._markerComponent as unknown as IGraphic, event, type)\n );\n }\n this._markerLayout();\n }\n\n super.updateLayoutAttribute();\n }\n\n protected _getSeriesByIdOrIndex(seriesUserId: StringOrNumber, seriesIndex: number) {\n let series: ICartesianSeries;\n series = this._option.getSeriesInUserIdOrIndex(array(seriesUserId), [seriesIndex])?.[0] as ICartesianSeries;\n if (!series) {\n series = this._relativeSeries ?? this.getFirstSeries();\n }\n return series;\n }\n\n protected _bindSeries() {\n const spec = this._spec;\n this._relativeSeries = this._getSeriesByIdOrIndex(spec.relativeSeriesId, spec.relativeSeriesIndex);\n this._startRelativeSeries = this._getSeriesByIdOrIndex(spec.startRelativeSeriesId, spec.startRelativeSeriesIndex);\n this._endRelativeSeries = this._getSeriesByIdOrIndex(spec.endRelativeSeriesId, spec.endRelativeSeriesIndex);\n }\n\n protected _computeClipRange(regions: IRegion[]) {\n let minX = Infinity;\n let maxX = -Infinity;\n let minY = Infinity;\n let maxY = -Infinity;\n regions.forEach((region: IRegion) => {\n if (region.getLayoutStartPoint().x < minX) {\n minX = region.getLayoutStartPoint().x;\n }\n if (region.getLayoutStartPoint().x + region.getLayoutRect().width > maxX) {\n maxX = region.getLayoutStartPoint().x + region.getLayoutRect().width;\n }\n if (region.getLayoutStartPoint().y < minY) {\n minY = region.getLayoutStartPoint().y;\n }\n if (region.getLayoutStartPoint().y + region.getLayoutRect().height > maxY) {\n maxY = region.getLayoutStartPoint().y + region.getLayoutRect().height;\n }\n });\n return { minX, maxX, minY, maxY };\n }\n\n protected abstract _initDataView(): void;\n protected abstract _createMarkerComponent(): void;\n protected abstract _markerLayout(): void;\n\n protected initEvent() {\n // do nothing\n }\n onRender(ctx: IModelRenderOption): void {\n // do nothing\n }\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n protected getFirstSeries(): ICartesianSeries {\n for (let i = 0; i < this._regions.length; i++) {\n const r = this._regions[i];\n const series = r.getSeries();\n for (let j = 0; j < series.length; j++) {\n const s = series[j];\n if (s) {\n return s as ICartesianSeries;\n }\n }\n }\n this._option?.onError('need at least one series');\n return null;\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._markerComponent] as unknown as IGroup[];\n }\n\n onLayoutStart(layoutRect: IRect, chartViewRect: ILayoutRect, ctx: any): void {\n // offset\n if (!isNil(this._spec.offsetX)) {\n this._layoutOffsetX = calcLayoutNumber(this._spec.offsetX, chartViewRect.width, chartViewRect);\n }\n if (!isNil(this._spec.offsetY)) {\n this._layoutOffsetY = calcLayoutNumber(this._spec.offsetY, chartViewRect.height, chartViewRect);\n }\n super.onLayoutStart(layoutRect, chartViewRect, ctx);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/component/marker/base-marker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKnE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAUvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,OAAgB,UAAkC,SAAQ,aAAgB;IAAhF;;QACE,eAAU,GAAyB,MAAM,CAAC;QAchC,mBAAc,GAAW,CAAC,CAAC;QAC3B,mBAAc,GAAW,CAAC,CAAC;IA2MvC,CAAC;IArNC,iBAAiB;QACf,OAAO,IAAI,CAAC,eAA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I,CAAC,gBAAgB,CAAwB,CAAC;IACxD,CAAC;IAED,aAAa,CAAC,UAAiB,EAAE,aAA0B,EAAE,GAAQ;QAEnE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;YAC9B,IAAI,CAAC,cAAc,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;SAChG;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;YAC9B,IAAI,CAAC,cAAc,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;SACjG;QACD,KAAK,CAAC,aAAa,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;CACF","file":"base-marker.js","sourcesContent":["import type { DataView } from '@visactor/vdataset';\nimport { array, isValid, isNil, isString } from '@visactor/vutils';\nimport type { IModelRenderOption } from '../../model/interface';\nimport type { IRegion } from '../../region/interface';\nimport type { ICartesianSeries } from '../../series/interface';\nimport type { ILayoutRect, ILayoutType, IRect, StringOrNumber } from '../../typings';\nimport { BaseComponent } from '../base/base-component';\nimport type {\n IAggrType,\n ICoordinateOption,\n IDataPointSpec,\n IDataPos,\n IDataPosCallback,\n IMarkerSpec\n} from './interface';\nimport type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport { calcLayoutNumber } from '../../util/space';\nimport { isAggrSpec } from './utils';\n\nexport abstract class BaseMarker<T extends IMarkerSpec> extends BaseComponent<T> {\n layoutType: ILayoutType | 'none' = 'none';\n\n protected _startRelativeSeries!: ICartesianSeries;\n protected _endRelativeSeries!: ICartesianSeries;\n protected _relativeSeries!: ICartesianSeries;\n getRelativeSeries() {\n return this._relativeSeries;\n }\n\n // marker 组件数据\n protected _markerData!: DataView;\n // marker 组件\n protected _markerComponent!: any;\n\n protected _layoutOffsetX: number = 0;\n protected _layoutOffsetY: number = 0;\n\n private _firstSeries: ICartesianSeries;\n\n created() {\n super.created();\n // event\n this.initEvent();\n this._bindSeries();\n this._initDataView();\n }\n\n private _getAllRelativeSeries() {\n return {\n getRelativeSeries: () => this._relativeSeries,\n getStartRelativeSeries: () => this._startRelativeSeries,\n getEndRelativeSeries: () => this._endRelativeSeries\n };\n }\n\n private _getFieldInfoFromSpec(dim: 'x' | 'y', spec: IDataPos | IDataPosCallback, relativeSeries: ICartesianSeries) {\n const field = dim === 'x' ? relativeSeries.getSpec().xField : relativeSeries.getSpec().yField;\n if (isString(spec) && isAggrSpec(spec)) {\n return {\n field,\n aggrType: spec as unknown as IAggrType\n };\n }\n return spec;\n }\n\n protected _processSpecX(specX: IDataPos | IDataPosCallback) {\n const relativeSeries = this._relativeSeries;\n return {\n x: this._getFieldInfoFromSpec('x', specX, relativeSeries),\n ...this._getAllRelativeSeries()\n };\n }\n\n protected _processSpecY(specY: IDataPos | IDataPosCallback) {\n const relativeSeries = this._relativeSeries;\n return {\n y: this._getFieldInfoFromSpec('y', specY, relativeSeries),\n ...this._getAllRelativeSeries()\n };\n }\n\n protected _processSpecXY(specX: IDataPos | IDataPosCallback, specY: IDataPos | IDataPosCallback) {\n const relativeSeries = this._relativeSeries;\n\n return {\n x: this._getFieldInfoFromSpec('x', specX, relativeSeries),\n y: this._getFieldInfoFromSpec('y', specY, relativeSeries),\n ...this._getAllRelativeSeries()\n };\n }\n\n protected _processSpecCoo(spec: any) {\n const coordinates = spec.coordinates ?? array(spec.coordinate);\n return coordinates.map((coordinate: IDataPointSpec) => {\n const refRelativeSeries = this._getSeriesByIdOrIndex(\n coordinate.refRelativeSeriesId,\n coordinate.refRelativeSeriesIndex\n );\n\n const { xField, yField } = refRelativeSeries.getSpec();\n const { xFieldDim, xFieldIndex, yFieldDim, yFieldIndex } = coordinate;\n let bindXField = xField;\n if (isValid(xFieldIndex)) {\n bindXField = array(xField)[xFieldIndex];\n }\n if (xFieldDim && array(xField).includes(xFieldDim)) {\n bindXField = xFieldDim;\n }\n\n let bindYField = yField;\n if (isValid(yFieldIndex)) {\n bindYField = array(yField)[yFieldIndex];\n }\n if (yFieldDim && array(yField).includes(yFieldDim)) {\n bindYField = yFieldDim;\n }\n\n const option: ICoordinateOption = {\n x: undefined,\n y: undefined,\n ...this._getAllRelativeSeries()\n };\n\n if (isString(coordinate[bindXField]) && isAggrSpec(coordinate[bindXField] as IDataPos)) {\n option.x = { field: bindXField, aggrType: coordinate[bindXField] as IAggrType };\n } else {\n option.x = array(bindXField).map(field => coordinate[field]);\n }\n\n if (isString(coordinate[bindYField]) && isAggrSpec(coordinate[bindYField] as IDataPos)) {\n option.y = { field: bindYField, aggrType: coordinate[bindYField] as IAggrType };\n } else {\n option.y = array(bindYField).map(field => coordinate[field]);\n }\n option.getRefRelativeSeries = () => refRelativeSeries;\n return option;\n });\n }\n\n updateLayoutAttribute(): void {\n const markerVisible = this._spec.visible ?? true;\n if (markerVisible) {\n // 创建marker组件\n if (!this._markerComponent) {\n const markerComponent = this._createMarkerComponent();\n markerComponent.name = this._spec.name ?? this.type;\n markerComponent.id = this._spec.id ?? `${this.type}-${this.id}`;\n this._markerComponent = markerComponent;\n\n this.getContainer().add(this._markerComponent);\n // 代理 marker 组件上的事件\n this._markerComponent.on('*', (event: any, type: string) =>\n this._delegateEvent(this._markerComponent as unknown as IGraphic, event, type)\n );\n }\n this._markerLayout();\n }\n\n super.updateLayoutAttribute();\n }\n\n private _getSeriesByIdOrIndex(seriesUserId: StringOrNumber, seriesIndex: number) {\n let series: ICartesianSeries;\n series = this._option.getSeriesInUserIdOrIndex(isValid(seriesUserId) ? [seriesUserId] : [], [\n seriesIndex\n ])?.[0] as ICartesianSeries;\n if (!series) {\n series = this._relativeSeries ?? this._getFirstSeries();\n }\n return series;\n }\n\n protected _bindSeries() {\n const spec = this._spec;\n this._relativeSeries = this._getSeriesByIdOrIndex(spec.relativeSeriesId, spec.relativeSeriesIndex);\n this._startRelativeSeries = this._getSeriesByIdOrIndex(\n (spec as any).startRelativeSeriesId,\n (spec as any).startRelativeSeriesIndex\n );\n this._endRelativeSeries = this._getSeriesByIdOrIndex(\n (spec as any).endRelativeSeriesId,\n (spec as any).endRelativeSeriesIndex\n );\n }\n\n protected abstract _initDataView(): void;\n protected abstract _createMarkerComponent(): IGroup;\n protected abstract _markerLayout(): void;\n\n protected initEvent() {\n // do nothing\n }\n onRender(ctx: IModelRenderOption): void {\n // do nothing\n }\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n clear(): void {\n super.clear();\n this._firstSeries = null;\n }\n\n private _getFirstSeries(): ICartesianSeries {\n if (this._firstSeries) {\n return this._firstSeries;\n }\n for (let i = 0; i < this._regions.length; i++) {\n const r = this._regions[i];\n const series = r.getSeries();\n for (let j = 0; j < series.length; j++) {\n const s = series[j];\n if (s) {\n this._firstSeries = s as ICartesianSeries;\n return s as ICartesianSeries;\n }\n }\n }\n this._option?.onError('need at least one series');\n return null;\n }\n\n protected _getNeedClearVRenderComponents(): IGraphic[] {\n return [this._markerComponent] as unknown as IGroup[];\n }\n\n onLayoutStart(layoutRect: IRect, chartViewRect: ILayoutRect, ctx: any): void {\n // offset\n if (!isNil(this._spec.offsetX)) {\n this._layoutOffsetX = calcLayoutNumber(this._spec.offsetX, chartViewRect.width, chartViewRect);\n }\n if (!isNil(this._spec.offsetY)) {\n this._layoutOffsetY = calcLayoutNumber(this._spec.offsetY, chartViewRect.height, chartViewRect);\n }\n super.onLayoutStart(layoutRect, chartViewRect, ctx);\n }\n}\n"]}
@@ -3,11 +3,18 @@ import type { SymbolType, IRichTextCharacter } from '@visactor/vrender-core';
3
3
  import type { IRectMarkSpec, ISymbolMarkSpec, ITextMarkSpec, StringOrNumber } from '../../typings';
4
4
  import type { IComponentSpec } from '../base/interface';
5
5
  import type { Datum } from '@visactor/vrender-components';
6
+ import type { ICartesianSeries } from '../../series/interface';
7
+ import type { IOptionAggrField, IOptionSeries } from '../../data/transforms/aggregation';
8
+ export type OffsetPoint = {
9
+ x?: number | string;
10
+ y?: number | string;
11
+ };
6
12
  export type IAggrType = 'sum' | 'average' | 'min' | 'max' | 'variance' | 'standardDeviation' | 'median';
7
13
  export type IDataPos = StringOrNumber | IAggrType;
8
- export type IDataPosCallback = (relativeSeriesData: any, startRelativeSeriesData: any, endRelativeSeriesData: any) => IDataPos;
14
+ export type IDataPosCallback = (relativeSeriesData: Datum[], startRelativeSeriesData: Datum[], endRelativeSeriesData: Datum[], relativeSeries: ICartesianSeries, startRelativeSeries: ICartesianSeries, endRelativeSeries: ICartesianSeries) => StringOrNumber;
15
+ export type IDataPointCallback = (relativeSeriesData: Datum[], relativeSeries: ICartesianSeries) => StringOrNumber;
9
16
  export type IDataPointSpec = {
10
- [key: string]: IDataPos;
17
+ [key: string]: IDataPos | IDataPointCallback;
11
18
  refRelativeSeriesIndex?: number;
12
19
  refRelativeSeriesId?: StringOrNumber;
13
20
  xFieldIndex?: number;
@@ -15,12 +22,17 @@ export type IDataPointSpec = {
15
22
  yFieldIndex?: number;
16
23
  yFieldDim?: string;
17
24
  };
18
- type Point = {
19
- x: number;
20
- y: number;
25
+ export type MarkerPositionPoint = {
26
+ x: StringOrNumber;
27
+ y: StringOrNumber;
21
28
  };
29
+ export type ICoordinateOption = {
30
+ x?: IOptionAggrField | (IDataPointCallback | StringOrNumber)[];
31
+ y?: IOptionAggrField | (IDataPointCallback | StringOrNumber)[];
32
+ getRefRelativeSeries?: () => ICartesianSeries;
33
+ } & IOptionSeries;
22
34
  export type IMarkerPositionsSpec = {
23
- positions: Point[];
35
+ positions: MarkerPositionPoint[];
24
36
  regionRelative?: boolean;
25
37
  };
26
38
  export type IMarkerLabelWithoutRefSpec = {
@@ -52,12 +64,11 @@ export interface IMarkerRef {
52
64
  refY?: number;
53
65
  refAngle?: number;
54
66
  }
55
- export interface IMarkerAxisSpec {
67
+ export interface IMarkerCrossSeriesSpec {
56
68
  startRelativeSeriesIndex?: number;
57
69
  endRelativeSeriesIndex?: number;
58
70
  startRelativeSeriesId?: string;
59
71
  endRelativeSeriesId?: string;
60
- relativeRelativeSeriesIndex?: number;
61
72
  }
62
73
  export interface IMarkerSpec extends IComponentSpec {
63
74
  relativeSeriesIndex?: number;
@@ -74,4 +85,3 @@ export interface IMarkerSymbol extends IMarkerRef {
74
85
  size?: number;
75
86
  style?: Omit<ISymbolMarkSpec, 'visible'>;
76
87
  }
77
- export {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/marker/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { IPadding } from '@visactor/vutils';\nimport type { SymbolType, IRichTextCharacter } from '@visactor/vrender-core';\nimport type { IRectMarkSpec, ISymbolMarkSpec, ITextMarkSpec, StringOrNumber } from '../../typings';\nimport type { IComponentSpec } from '../base/interface';\nimport type { Datum } from '@visactor/vrender-components';\n\nexport type IAggrType = 'sum' | 'average' | 'min' | 'max' | 'variance' | 'standardDeviation' | 'median';\nexport type IDataPos = StringOrNumber | IAggrType;\nexport type IDataPosCallback = (\n relativeSeriesData: any,\n startRelativeSeriesData: any,\n endRelativeSeriesData: any\n) => IDataPos;\nexport type IDataPointSpec = {\n [key: string]: IDataPos;\n /**\n * 具体某个数据元素关联的series(仅在标注目标:数据元素下有效)\n */\n refRelativeSeriesIndex?: number;\n refRelativeSeriesId?: StringOrNumber;\n /**\n * 指定使用 xField 上的那个维度索引,因为 xField 字段有可能会包含多个维度,比如分组场景\n * @default 0\n * @since 1.7.0\n */\n xFieldIndex?: number;\n /**\n * 指定使用 xField 上的维度名称,因为 xField 字段有可能会包含多个维度,比如分组场景。\n * `xFieldIndex` 和 `xFieldDim` 声明一个即可,同时声明则 `xFieldDim` 优先级更高。\n * @since 1.7.0\n */\n xFieldDim?: string;\n /**\n * 指定使用 yField 上的那个维度索引,因为 yField 字段有可能会包含多个维度,比如分组场景。\n * @default 0\n * @since 1.7.0\n */\n yFieldIndex?: number;\n /**\n * 指定使用 yField 上的维度名称,因为 yField 字段有可能会包含多个维度,比如分组场景。\n * `yFieldIndex` 和 `yFieldDim` 声明一个即可,同时声明则 `yFieldDim` 优先级更高。\n * @since 1.7.0\n */\n yFieldDim?: string;\n};\n\ntype Point = {\n x: number;\n y: number;\n};\nexport type IMarkerPositionsSpec = {\n positions: Point[];\n /**\n * 是否为相对 region 的坐标,默认为 false,即相对画布的坐标\n * @default false\n * @since 1.7.0\n */\n regionRelative?: boolean;\n};\n\nexport type IMarkerLabelWithoutRefSpec = {\n visible?: boolean;\n /**\n * label整体 - 是否自动旋转\n */\n autoRotate?: boolean;\n /**\n * label整体 - 最小宽度,像素值\n * @default 30\n */\n minWidth?: number;\n /**\n * label整体 - 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n /**\n * label整体 - 背景面板配置\n */\n labelBackground?: {\n visible?: boolean;\n /**\n * 内部边距\n */\n padding?: IPadding | number[] | number;\n /**\n * 背景面板样式\n */\n style?: Omit<IRectMarkSpec, 'visible'>;\n };\n /**\n * 文本类型:text, rich, html\n */\n type?: 'text' | 'rich' | 'html';\n /**\n * 文本内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n * 支持富文本内容, 如textConfig, html, 设置富文本时要配置type类型为'rich'或'html'\n */\n text?: string | string[] | number | number[] | IRichTextCharacter[];\n /**\n * label文本 - 文本格式化\n * @param markData 组成标注的数据\n * @param seriesData 标注关联的数据\n * @returns 格式化后的文本\n */\n formatMethod?: (\n markData: Datum[],\n seriesData: Datum[]\n ) => string | string[] | number | number[] | IRichTextCharacter[];\n /**\n * label文本 - 文本样式\n */\n style?: Omit<ITextMarkSpec, 'visible'>;\n\n /**\n * label文本 - 文本前 mark 图元\n */\n shape?: {\n visible?: boolean;\n style: Omit<ISymbolMarkSpec, 'visible'>;\n };\n /**\n * label文本 - shape 同文本之间的间距\n */\n space?: number;\n\n /**\n * 是否自动调整 label 使其展示在 marker 可见区域内。\n * @default false\n * @since 1.4.0\n */\n confine?: boolean;\n /**\n * 水平方向的偏移\n */\n dx?: number;\n /**\n * 垂直方向的偏移\n */\n dy?: number;\n};\n\nexport type IMarkerLabelSpec = IMarkerLabelWithoutRefSpec & IMarkerRef;\n\nexport interface IMarkerRef {\n /**\n * label or symbol 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label or symbol 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label or symbol 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n}\n\nexport interface IMarkerAxisSpec {\n /**\n * 起点和终点关联的series(仅在标注目标:坐标空间下有效)\n */\n startRelativeSeriesIndex?: number;\n endRelativeSeriesIndex?: number;\n startRelativeSeriesId?: string;\n endRelativeSeriesId?: string;\n /**\n * 被标注数据关联的series\n */\n relativeRelativeSeriesIndex?: number;\n}\n\nexport interface IMarkerSpec extends IComponentSpec {\n /**\n * 标注数据关联的series\n */\n relativeSeriesIndex?: number;\n relativeSeriesId?: number | string;\n /**\n * marker组件是否可见\n * @default true\n */\n visible?: boolean;\n /**\n * marker组件是否可交互\n * @default false\n */\n interactive?: boolean;\n /**\n * marker组件是否自动拓展轴范围\n * @default false\n * @since 1.1.0\n */\n autoRange?: boolean;\n /**\n * marker组件超出图表区域是否被裁剪\n * @default false\n * @since 1.3.0\n */\n clip?: boolean;\n\n /**\n * 标注组件的名称标识\n * @since 1.7.0\n */\n name?: string;\n}\n\nexport interface IMarkerSymbol extends IMarkerRef {\n /** 是否展示 symbol */\n visible: boolean;\n /**\n * symbol 形状,默认为带左右方向的箭头\n */\n symbolType?: SymbolType;\n /**\n * symbol 大小\n */\n size?: number;\n style?: Omit<ISymbolMarkSpec, 'visible'>;\n}\n"]}
1
+ {"version":3,"sources":["../src/component/marker/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type { IPadding } from '@visactor/vutils';\nimport type { SymbolType, IRichTextCharacter } from '@visactor/vrender-core';\nimport type { IRectMarkSpec, ISymbolMarkSpec, ITextMarkSpec, StringOrNumber } from '../../typings';\nimport type { IComponentSpec } from '../base/interface';\nimport type { Datum } from '@visactor/vrender-components';\nimport type { ICartesianSeries } from '../../series/interface';\nimport type { IOptionAggrField, IOptionSeries } from '../../data/transforms/aggregation';\n\nexport type OffsetPoint = {\n /**\n * x 方向的偏移\n * 1. number 类型表示像素值,如 12\n * 2. string 类型表示百分比,如 '10%' 表示相对于所在 region 宽度的占比\n */\n x?: number | string;\n /**\n * y 方向的偏移\n * 1. number 类型表示像素值,如 12\n * 2. string 类型表示百分比,如 '10%' 表示相对于所在 region 高度的占比\n */\n y?: number | string;\n};\n\nexport type IAggrType = 'sum' | 'average' | 'min' | 'max' | 'variance' | 'standardDeviation' | 'median';\nexport type IDataPos = StringOrNumber | IAggrType;\nexport type IDataPosCallback = (\n relativeSeriesData: Datum[],\n startRelativeSeriesData: Datum[],\n endRelativeSeriesData: Datum[],\n relativeSeries: ICartesianSeries,\n startRelativeSeries: ICartesianSeries,\n endRelativeSeries: ICartesianSeries\n) => StringOrNumber;\n\nexport type IDataPointCallback = (relativeSeriesData: Datum[], relativeSeries: ICartesianSeries) => StringOrNumber;\nexport type IDataPointSpec = {\n /**\n * 数据字段配置\n */\n [key: string]: IDataPos | IDataPointCallback;\n /**\n * 具体某个数据元素关联的series(仅在标注目标:数据元素下有效)\n */\n refRelativeSeriesIndex?: number;\n refRelativeSeriesId?: StringOrNumber;\n /**\n * 指定使用 xField 上的那个维度索引,因为 xField 字段有可能会包含多个维度,比如分组场景\n * @default 0\n * @since 1.7.0\n */\n xFieldIndex?: number;\n /**\n * 指定使用 xField 上的维度名称,因为 xField 字段有可能会包含多个维度,比如分组场景。\n * `xFieldIndex` 和 `xFieldDim` 声明一个即可,同时声明则 `xFieldDim` 优先级更高。\n * @since 1.7.0\n */\n xFieldDim?: string;\n /**\n * 指定使用 yField 上的那个维度索引,因为 yField 字段有可能会包含多个维度,比如分组场景。\n * @default 0\n * @since 1.7.0\n */\n yFieldIndex?: number;\n /**\n * 指定使用 yField 上的维度名称,因为 yField 字段有可能会包含多个维度,比如分组场景。\n * `yFieldIndex` 和 `yFieldDim` 声明一个即可,同时声明则 `yFieldDim` 优先级更高。\n * @since 1.7.0\n */\n yFieldDim?: string;\n};\n\nexport type MarkerPositionPoint = {\n /**\n * x 坐标位置,number 类型表示像素值,string 类型表示相对画布宽度或者 region 宽度的占比(从左往右)\n */\n x: StringOrNumber;\n /**\n * y 坐标位置,number 类型表示像素值,string 类型表示相对画布高度或者 region 高度的占比(从上至下)\n */\n y: StringOrNumber;\n};\n\nexport type ICoordinateOption = {\n x?: IOptionAggrField | (IDataPointCallback | StringOrNumber)[];\n y?: IOptionAggrField | (IDataPointCallback | StringOrNumber)[];\n getRefRelativeSeries?: () => ICartesianSeries;\n} & IOptionSeries;\n\nexport type IMarkerPositionsSpec = {\n /**\n * 画布坐标\n */\n positions: MarkerPositionPoint[];\n /**\n * 是否为相对 region 的坐标,默认为 false,即相对画布的坐标\n * @default false\n * @since 1.7.0\n */\n regionRelative?: boolean;\n};\n\nexport type IMarkerLabelWithoutRefSpec = {\n visible?: boolean;\n /**\n * label整体 - 是否自动旋转\n */\n autoRotate?: boolean;\n /**\n * label整体 - 最小宽度,像素值\n * @default 30\n */\n minWidth?: number;\n /**\n * label整体 - 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n /**\n * label整体 - 背景面板配置\n */\n labelBackground?: {\n visible?: boolean;\n /**\n * 内部边距\n */\n padding?: IPadding | number[] | number;\n /**\n * 背景面板样式\n */\n style?: Omit<IRectMarkSpec, 'visible'>;\n };\n /**\n * 文本类型:text, rich, html\n */\n type?: 'text' | 'rich' | 'html';\n /**\n * 文本内容,如果需要进行换行,则使用数组形式,如 ['abc', '123']\n * 支持富文本内容, 如textConfig, html, 设置富文本时要配置type类型为'rich'或'html'\n */\n text?: string | string[] | number | number[] | IRichTextCharacter[];\n /**\n * label文本 - 文本格式化\n * @param markData 组成标注的数据\n * @param seriesData 标注关联的数据\n * @returns 格式化后的文本\n */\n formatMethod?: (\n markData: Datum[],\n seriesData: Datum[]\n ) => string | string[] | number | number[] | IRichTextCharacter[];\n /**\n * label文本 - 文本样式\n */\n style?: Omit<ITextMarkSpec, 'visible'>;\n\n /**\n * label文本 - 文本前 mark 图元\n */\n shape?: {\n visible?: boolean;\n style: Omit<ISymbolMarkSpec, 'visible'>;\n };\n /**\n * label文本 - shape 同文本之间的间距\n */\n space?: number;\n\n /**\n * 是否自动调整 label 使其展示在 marker 可见区域内。\n * @default false\n * @since 1.4.0\n */\n confine?: boolean;\n /**\n * 水平方向的偏移\n */\n dx?: number;\n /**\n * 垂直方向的偏移\n */\n dy?: number;\n};\n\nexport type IMarkerLabelSpec = IMarkerLabelWithoutRefSpec & IMarkerRef;\n\nexport interface IMarkerRef {\n /**\n * label or symbol 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * label or symbol 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * label or symbol 相对默认角度的偏移 (label跟随line的角度做自动旋转时,默认按照line的平行向量作为初始角度)\n */\n refAngle?: number;\n}\n\n// 跨越系列的配置\nexport interface IMarkerCrossSeriesSpec {\n /**\n * 起点和终点关联的series(仅在标注目标:坐标空间下有效)\n */\n startRelativeSeriesIndex?: number;\n endRelativeSeriesIndex?: number;\n startRelativeSeriesId?: string;\n endRelativeSeriesId?: string;\n}\n\nexport interface IMarkerSpec extends IComponentSpec {\n /**\n * 标注数据关联的series\n */\n relativeSeriesIndex?: number;\n relativeSeriesId?: number | string;\n /**\n * marker组件是否可见\n * @default true\n */\n visible?: boolean;\n /**\n * marker组件是否可交互\n * @default false\n */\n interactive?: boolean;\n /**\n * marker组件是否自动拓展轴范围\n * @default false\n * @since 1.1.0\n */\n autoRange?: boolean;\n /**\n * marker组件超出图表区域是否被裁剪\n * @default false\n * @since 1.3.0\n */\n clip?: boolean;\n\n /**\n * 标注组件的名称标识\n * @since 1.7.0\n */\n name?: string;\n}\n\nexport interface IMarkerSymbol extends IMarkerRef {\n /** 是否展示 symbol */\n visible: boolean;\n /**\n * symbol 形状,默认为带左右方向的箭头\n */\n symbolType?: SymbolType;\n /**\n * symbol 大小\n */\n size?: number;\n style?: Omit<ISymbolMarkSpec, 'visible'>;\n}\n"]}
@@ -1,26 +1,24 @@
1
1
  import type { IComponent } from '../../../interface';
2
- import type { IMarkerPositionsSpec, IDataPointSpec, IDataPos, IMarkerSpec, IMarkerAxisSpec, IDataPosCallback } from '../../interface';
2
+ import type { IMarkerPositionsSpec, IDataPointSpec, IDataPos, IMarkerSpec, IDataPosCallback, IMarkerCrossSeriesSpec, OffsetPoint } from '../../interface';
3
3
  import type { IMarkAreaTheme } from './theme';
4
4
  export type IMarkArea = IComponent;
5
5
  export type IRegressType = 'regression';
6
- export type IMarkAreaSpec = IMarkerSpec & (IMarkAreaXSpec | IMarkAreaYSpec | (IMarkAreaXSpec & IMarkAreaYSpec) | IMarkAreaCoordinateSpec | IMarkAreaPositionsSpec) & IMarkAreaTheme;
7
- export interface IMarkAreaXSpec extends IMarkerAxisSpec {
6
+ export type IMarkAreaSpec = IMarkerSpec & (IMarkAreaXSpec | IMarkAreaYSpec | IMarkAreaXYSpec | IMarkAreaCoordinateSpec | IMarkerPositionsSpec) & IMarkAreaTheme;
7
+ export interface IMarkAreaXSpec extends IMarkerCrossSeriesSpec {
8
8
  x: IDataPos | IDataPosCallback;
9
9
  x1: IDataPos | IDataPosCallback;
10
10
  }
11
- export interface IMarkAreaYSpec extends IMarkerAxisSpec {
11
+ export interface IMarkAreaYSpec extends IMarkerCrossSeriesSpec {
12
12
  y: IDataPos | IDataPosCallback;
13
13
  y1: IDataPos | IDataPosCallback;
14
14
  }
15
- export interface IMarkAreaAngleSpec extends IMarkerAxisSpec {
16
- startAngle: IDataPos | IDataPosCallback;
17
- endAngle: IDataPos | IDataPosCallback;
18
- }
19
- export interface IMarkAreaRadiusSpec extends IMarkerAxisSpec {
20
- startRadius: IDataPos | IDataPosCallback;
21
- endRadius: IDataPos | IDataPosCallback;
15
+ export interface IMarkAreaXYSpec extends IMarkerCrossSeriesSpec {
16
+ x: IDataPos | IDataPosCallback;
17
+ x1: IDataPos | IDataPosCallback;
18
+ y: IDataPos | IDataPosCallback;
19
+ y1: IDataPos | IDataPosCallback;
22
20
  }
23
21
  export type IMarkAreaCoordinateSpec = {
24
22
  coordinates: IDataPointSpec[];
23
+ coordinatesOffset?: OffsetPoint[];
25
24
  };
26
- export type IMarkAreaPositionsSpec = IMarkerPositionsSpec;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/marker/mark-area/interface/spec.ts"],"names":[],"mappings":"","file":"spec.js","sourcesContent":["import type { IComponent } from '../../../interface';\nimport type {\n IMarkerPositionsSpec,\n IDataPointSpec,\n IDataPos,\n IMarkerSpec,\n IMarkerAxisSpec,\n IDataPosCallback\n} from '../../interface';\nimport type { IMarkAreaTheme } from './theme';\n\nexport type IMarkArea = IComponent;\n\nexport type IRegressType = 'regression';\n\nexport type IMarkAreaSpec = IMarkerSpec &\n (\n | IMarkAreaXSpec // 标注目标:笛卡尔坐标系坐标空间\n | IMarkAreaYSpec // 标注目标:笛卡尔坐标系坐标空间\n | (IMarkAreaXSpec & IMarkAreaYSpec)\n // | IMarkAreaAngleSpec // TODO: 标注目标:极坐标系坐标空间\n // | IMarkAreaRadiusSpec // TODO: 标注目标:极坐标系坐标空间\n | IMarkAreaCoordinateSpec // 标注目标:数据元素\n | IMarkAreaPositionsSpec\n ) &\n IMarkAreaTheme; // 标注目标:任意位置\n\nexport interface IMarkAreaXSpec extends IMarkerAxisSpec {\n /**\n * x轴上的参考线。可以配置参考线在x轴上的值,或者聚合计算类型\n * 可以将 x 配置为 '15%' 百分比的形式,用于表示将 x 绘制在 marker 所在 region 横轴(从左往右)的百分之 15 位置处\n */\n x: IDataPos | IDataPosCallback;\n x1: IDataPos | IDataPosCallback;\n}\n\nexport interface IMarkAreaYSpec extends IMarkerAxisSpec {\n /**\n * y轴上的参考线。可以配置参考线在y轴上的值,或者聚合计算类型\n * 可以将 y 配置为 '15%' 百分比的形式,用于表示将 y 绘制在 marker 所在 region 纵轴(从上到下)的百分之 15 位置处\n */\n y: IDataPos | IDataPosCallback;\n y1: IDataPos | IDataPosCallback;\n}\n\nexport interface IMarkAreaAngleSpec extends IMarkerAxisSpec {\n /**\n * todo: angle轴上的参考线。可以配置参考线在angle轴上的值,或者聚合计算类型\n */\n startAngle: IDataPos | IDataPosCallback;\n endAngle: IDataPos | IDataPosCallback;\n}\n\nexport interface IMarkAreaRadiusSpec extends IMarkerAxisSpec {\n /**\n * todo: radius轴上的参考线。可以配置参考线在radius轴上的值,或者聚合计算类型\n */\n startRadius: IDataPos | IDataPosCallback;\n endRadius: IDataPos | IDataPosCallback;\n}\n\nexport type IMarkAreaCoordinateSpec = {\n /**\n * 指定数据点的参考线。基于指定数据点进行参考线的绘制,可以对数据点进行数据处理\n */\n coordinates: IDataPointSpec[];\n};\n\n/**\n * 指定坐标点的参考线。基于指定坐标进行参考线的绘制\n */\nexport type IMarkAreaPositionsSpec = IMarkerPositionsSpec;\n"]}
1
+ {"version":3,"sources":["../src/component/marker/mark-area/interface/spec.ts"],"names":[],"mappings":"","file":"spec.js","sourcesContent":["import type { IComponent } from '../../../interface';\nimport type {\n IMarkerPositionsSpec,\n IDataPointSpec,\n IDataPos,\n IMarkerSpec,\n IDataPosCallback,\n IMarkerCrossSeriesSpec,\n OffsetPoint\n} from '../../interface';\nimport type { IMarkAreaTheme } from './theme';\n\nexport type IMarkArea = IComponent;\n\nexport type IRegressType = 'regression';\n\nexport type IMarkAreaSpec = IMarkerSpec &\n (\n | IMarkAreaXSpec // 标注目标:笛卡尔坐标系坐标空间\n | IMarkAreaYSpec // 标注目标:笛卡尔坐标系坐标空间\n | IMarkAreaXYSpec // 标注目标:笛卡尔坐标系坐标空间\n | IMarkAreaCoordinateSpec // 标注目标:数据元素\n | IMarkerPositionsSpec\n ) &\n IMarkAreaTheme; // 标注目标:任意位置\n\nexport interface IMarkAreaXSpec extends IMarkerCrossSeriesSpec {\n /**\n * x轴上的参考线。可以配置参考线在x轴上的值,或者聚合计算类型\n * 可以将 x 配置为 '15%' 百分比的形式,用于表示将 x 绘制在 marker 所在 region 横轴(从左往右)的百分之 15 位置处\n */\n x: IDataPos | IDataPosCallback;\n x1: IDataPos | IDataPosCallback;\n}\n\nexport interface IMarkAreaYSpec extends IMarkerCrossSeriesSpec {\n /**\n * y轴上的参考线。可以配置参考线在y轴上的值,或者聚合计算类型\n * 可以将 y 配置为 '15%' 百分比的形式,用于表示将 y 绘制在 marker 所在 region 纵轴(从上到下)的百分之 15 位置处\n */\n y: IDataPos | IDataPosCallback;\n y1: IDataPos | IDataPosCallback;\n}\n\nexport interface IMarkAreaXYSpec extends IMarkerCrossSeriesSpec {\n /**\n * x轴上的参考线。可以配置参考线在x轴上的值,或者聚合计算类型\n * 可以将 x 配置为 '15%' 百分比的形式,用于表示将 x 绘制在 marker 所在 region 横轴(从左往右)的百分之 15 位置处\n */\n x: IDataPos | IDataPosCallback;\n x1: IDataPos | IDataPosCallback;\n /**\n * y轴上的参考线。可以配置参考线在y轴上的值,或者聚合计算类型\n * 可以将 y 配置为 '15%' 百分比的形式,用于表示将 y 绘制在 marker 所在 region 纵轴(从上到下)的百分之 15 位置处\n */\n y: IDataPos | IDataPosCallback;\n y1: IDataPos | IDataPosCallback;\n}\n\nexport type IMarkAreaCoordinateSpec = {\n /**\n * 指定数据点的参考线。基于指定数据点进行参考线的绘制,可以对数据点进行数据处理\n */\n coordinates: IDataPointSpec[];\n\n /**\n * 对每个数据点转化后的画布坐标点进行偏移,该偏移值可以是像素值,也可以是 string 类型,如 '20%' 代表百分比\n * 每个元素对应一个坐标点的偏移量\n * @since 1.7.3\n */\n coordinatesOffset?: OffsetPoint[];\n};\n"]}
@@ -3,7 +3,8 @@ import type { IComponentOption } from '../../interface';
3
3
  import { ComponentTypeEnum } from '../../interface/type';
4
4
  import { MarkArea as MarkAreaComponent } from '@visactor/vrender-components';
5
5
  import { BaseMarker } from '../base-marker';
6
- export declare class MarkArea extends BaseMarker<IMarkAreaSpec & IMarkAreaTheme> implements IMarkArea {
6
+ import type { IGroup } from '@visactor/vrender-core';
7
+ export declare class MarkArea extends BaseMarker<IMarkAreaSpec> implements IMarkArea {
7
8
  static type: ComponentTypeEnum;
8
9
  type: ComponentTypeEnum;
9
10
  name: string;
@@ -11,7 +12,7 @@ export declare class MarkArea extends BaseMarker<IMarkAreaSpec & IMarkAreaTheme>
11
12
  protected _theme: IMarkAreaTheme;
12
13
  protected _markerComponent: MarkAreaComponent;
13
14
  static createComponent(spec: any, options: IComponentOption): MarkArea | MarkArea[];
14
- protected _createMarkerComponent(): void;
15
+ protected _createMarkerComponent(): IGroup;
15
16
  protected _markerLayout(): void;
16
17
  protected _initDataView(): void;
17
18
  }
@@ -4,7 +4,7 @@ import { ComponentTypeEnum } from "../../interface/type";
4
4
 
5
5
  import { markerAggregation } from "../../../data/transforms/aggregation";
6
6
 
7
- import { coordinateLayout, xyLayout } from "../utils";
7
+ import { computeClipRange, coordinateLayout, positionLayout, xyLayout } from "../utils";
8
8
 
9
9
  import { registerDataSetInstanceTransform } from "../../../data/register";
10
10
 
@@ -18,8 +18,6 @@ import { BaseMarker } from "../base-marker";
18
18
 
19
19
  import { LayoutZIndex } from "../../../constant";
20
20
 
21
- import { markerRegression } from "../../../data/transforms/regression";
22
-
23
21
  import { Factory } from "../../../core/factory";
24
22
 
25
23
  export class MarkArea extends BaseMarker {
@@ -39,8 +37,8 @@ export class MarkArea extends BaseMarker {
39
37
  })), markAreas;
40
38
  }
41
39
  _createMarkerComponent() {
42
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
43
- const markArea = new MarkAreaComponent({
40
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
41
+ return new MarkAreaComponent({
44
42
  zIndex: this.layoutZIndex,
45
43
  interactive: null !== (_a = this._spec.interactive) && void 0 !== _a && _a,
46
44
  points: [ {
@@ -60,34 +58,24 @@ export class MarkArea extends BaseMarker {
60
58
  }),
61
59
  clipInRange: null !== (_q = this._spec.clip) && void 0 !== _q && _q
62
60
  });
63
- this._markerComponent = markArea, this._markerComponent.name = null !== (_r = this._spec.name) && void 0 !== _r ? _r : this.type,
64
- this._markerComponent.id = null !== (_s = this._spec.id) && void 0 !== _s ? _s : `${this.type}-${this.id}`,
65
- this.getContainer().add(this._markerComponent);
66
61
  }
67
62
  _markerLayout() {
68
63
  var _a, _b, _c, _d, _e, _f, _g, _h;
69
64
  const spec = this._spec, data = this._markerData, startRelativeSeries = this._startRelativeSeries, endRelativeSeries = this._endRelativeSeries, relativeSeries = this._relativeSeries, isXLayout = isValid(spec.x) && isValid(spec.x1), isYLayout = isValid(spec.y) && isValid(spec.y1), isXYLayout = isXLayout && isYLayout, isCoordinateLayout = isValid(spec.coordinates), isPositionLayout = isValid(spec.positions), autoRange = null !== (_a = spec.autoRange) && void 0 !== _a && _a;
70
65
  let points = [], lines = [];
71
- if (isXYLayout) lines = xyLayout(data, startRelativeSeries, endRelativeSeries, relativeSeries, autoRange),
66
+ isXYLayout ? (lines = xyLayout(data, startRelativeSeries, endRelativeSeries, relativeSeries, autoRange),
72
67
  points = [ {
73
68
  x: lines[0][0].x,
74
69
  y: lines[1][0].y
75
70
  }, lines[0][0], {
76
71
  x: lines[1][0].x,
77
72
  y: lines[0][0].y
78
- }, lines[1][0] ]; else if (isXLayout) lines = xyLayout(data, startRelativeSeries, endRelativeSeries, relativeSeries, autoRange),
79
- points = [ ...lines[0], lines[1][1], lines[1][0] ]; else if (isYLayout) lines = xyLayout(data, startRelativeSeries, endRelativeSeries, relativeSeries, autoRange),
80
- points = [ ...lines[0], lines[1][1], lines[1][0] ]; else if (isCoordinateLayout) points = coordinateLayout(data, relativeSeries, autoRange); else if (isPositionLayout) if (spec.regionRelative) {
81
- const region = relativeSeries.getRegion(), {x: regionStartX, y: regionStartY} = region.getLayoutStartPoint();
82
- points = spec.positions.map((point => ({
83
- x: point.x + regionStartX,
84
- y: point.y + regionStartY
85
- })));
86
- } else points = spec.positions;
73
+ }, lines[1][0] ]) : isXLayout || isYLayout ? (lines = xyLayout(data, startRelativeSeries, endRelativeSeries, relativeSeries, autoRange),
74
+ points = [ ...lines[0], lines[1][1], lines[1][0] ]) : isCoordinateLayout ? points = coordinateLayout(data, relativeSeries, autoRange, spec.coordinatesOffset) : isPositionLayout && (points = positionLayout(spec.positions, relativeSeries, spec.regionRelative));
87
75
  const seriesData = this._relativeSeries.getViewData().latestData, dataPoints = data ? data.latestData[0].latestData ? data.latestData[0].latestData : data.latestData : seriesData;
88
76
  let limitRect;
89
77
  if (spec.clip || (null === (_b = spec.label) || void 0 === _b ? void 0 : _b.confine)) {
90
- const {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = this._computeClipRange([ startRelativeSeries.getRegion(), endRelativeSeries.getRegion(), relativeSeries.getRegion() ]);
78
+ const {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = computeClipRange([ startRelativeSeries.getRegion(), endRelativeSeries.getRegion(), relativeSeries.getRegion() ]);
91
79
  limitRect = {
92
80
  x: minX,
93
81
  y: minY,
@@ -109,13 +97,13 @@ export class MarkArea extends BaseMarker {
109
97
  const spec = this._spec, relativeSeries = this._relativeSeries, isXProcess = isValid(spec.x) && isValid(spec.x1), isYProcess = isValid(spec.y) && isValid(spec.y1), isXYProcess = isXProcess && isYProcess, isCoordinateProcess = isValid(spec.coordinates);
110
98
  if (!isXProcess && !isYProcess && !isCoordinateProcess) return null;
111
99
  let options;
112
- registerDataSetInstanceTransform(this._option.dataSet, "markerAggregation", markerAggregation),
113
- registerDataSetInstanceTransform(this._option.dataSet, "markerRegression", markerRegression),
114
100
  isXYProcess ? options = [ this._processSpecXY(spec.x, spec.y), this._processSpecXY(spec.x1, spec.y1) ] : isXProcess ? options = [ this._processSpecX(spec.x), this._processSpecX(spec.x1) ] : isYProcess ? options = [ this._processSpecY(spec.y), this._processSpecY(spec.y1) ] : isCoordinateProcess && (options = this._processSpecCoo(spec));
101
+ const seriesData = relativeSeries.getViewData();
102
+ registerDataSetInstanceTransform(this._option.dataSet, "markerAggregation", markerAggregation);
115
103
  const data = new DataView(this._option.dataSet, {
116
104
  name: `${this.type}_${this.id}_data`
117
105
  });
118
- data.parse([ relativeSeries.getViewData() ], {
106
+ data.parse([ seriesData ], {
119
107
  type: "dataview"
120
108
  }), data.transform({
121
109
  type: "markerAggregation",