@visactor/vchart 1.13.9-alpha.6 → 1.13.10-alpha.0

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 (182) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.es.js +1062 -748
  3. package/build/index.js +1062 -747
  4. package/build/index.min.js +1 -1
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/cjs/chart/index.d.ts +1 -1
  7. package/cjs/chart/index.js.map +1 -1
  8. package/cjs/chart/pictogram/interface.d.ts +1 -1
  9. package/cjs/chart/pictogram/interface.js.map +1 -1
  10. package/cjs/chart/progress/linear/linear-progress-transformer.js +1 -1
  11. package/cjs/chart/progress/linear/linear-progress-transformer.js.map +1 -1
  12. package/cjs/compile/mark/compilable-mark.d.ts +1 -0
  13. package/cjs/compile/mark/compilable-mark.js +3 -0
  14. package/cjs/compile/mark/compilable-mark.js.map +1 -1
  15. package/cjs/component/axis/base-axis.js +7 -2
  16. package/cjs/component/axis/base-axis.js.map +1 -1
  17. package/cjs/component/axis/interface/spec.d.ts +7 -2
  18. package/cjs/component/axis/interface/spec.js.map +1 -1
  19. package/cjs/component/brush/brush.d.ts +23 -24
  20. package/cjs/component/brush/brush.js +183 -182
  21. package/cjs/component/brush/brush.js.map +1 -1
  22. package/cjs/component/brush/interface.d.ts +2 -0
  23. package/cjs/component/brush/interface.js.map +1 -1
  24. package/cjs/component/crosshair/base.js +1 -1
  25. package/cjs/component/crosshair/base.js.map +1 -1
  26. package/cjs/component/crosshair/utils/cartesian.js +9 -8
  27. package/cjs/component/crosshair/utils/cartesian.js.map +1 -1
  28. package/cjs/component/data-zoom/data-zoom/interface.d.ts +2 -3
  29. package/cjs/component/data-zoom/data-zoom/interface.js.map +1 -1
  30. package/cjs/component/marker/mark-area/base-mark-area.js +27 -17
  31. package/cjs/component/marker/mark-area/base-mark-area.js.map +1 -1
  32. package/cjs/component/marker/mark-area/interface/theme.d.ts +4 -3
  33. package/cjs/component/marker/mark-area/interface/theme.js.map +1 -1
  34. package/cjs/component/marker/mark-line/base-mark-line.js +31 -20
  35. package/cjs/component/marker/mark-line/base-mark-line.js.map +1 -1
  36. package/cjs/component/marker/mark-line/cartesian-mark-line.js +32 -26
  37. package/cjs/component/marker/mark-line/cartesian-mark-line.js.map +1 -1
  38. package/cjs/component/marker/mark-line/interface/theme.d.ts +4 -3
  39. package/cjs/component/marker/mark-line/interface/theme.js.map +1 -1
  40. package/cjs/component/marker/mark-point/cartesian-mark-point.js +3 -1
  41. package/cjs/component/marker/mark-point/cartesian-mark-point.js.map +1 -1
  42. package/cjs/component/marker/utils.d.ts +12 -0
  43. package/cjs/component/marker/utils.js +22 -7
  44. package/cjs/component/marker/utils.js.map +1 -1
  45. package/cjs/constant/event.d.ts +1 -0
  46. package/cjs/constant/event.js +6 -6
  47. package/cjs/constant/event.js.map +1 -1
  48. package/cjs/constant/funnel.js +1 -2
  49. package/cjs/constant/layout.js +2 -1
  50. package/cjs/core/index.d.ts +1 -1
  51. package/cjs/core/index.js +2 -3
  52. package/cjs/core/index.js.map +1 -1
  53. package/cjs/core/interface.js +2 -1
  54. package/cjs/data/transforms/pictogram.d.ts +1 -9
  55. package/cjs/data/transforms/pictogram.js +3 -3
  56. package/cjs/data/transforms/pictogram.js.map +1 -1
  57. package/cjs/data/transforms/pie.js +1 -1
  58. package/cjs/data/transforms/pie.js.map +1 -1
  59. package/cjs/index-harmony-simple.js.map +1 -1
  60. package/cjs/index.d.ts +1 -0
  61. package/cjs/index.js +8 -7
  62. package/cjs/index.js.map +1 -1
  63. package/cjs/model/base-model.d.ts +1 -0
  64. package/cjs/model/base-model.js +6 -0
  65. package/cjs/model/base-model.js.map +1 -1
  66. package/cjs/plugin/components/tooltip-handler/base.js +8 -0
  67. package/cjs/plugin/components/tooltip-handler/base.js.map +1 -1
  68. package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.js +11 -7
  69. package/cjs/plugin/components/tooltip-handler/dom-tooltip-handler.js.map +1 -1
  70. package/cjs/plugin/components/tooltip-handler/utils/position.d.ts +1 -1
  71. package/cjs/plugin/components/tooltip-handler/utils/position.js +9 -1
  72. package/cjs/plugin/components/tooltip-handler/utils/position.js.map +1 -1
  73. package/cjs/series/bar/bar.js.map +1 -1
  74. package/cjs/series/gauge/gauge.js +7 -5
  75. package/cjs/series/gauge/gauge.js.map +1 -1
  76. package/cjs/series/pictogram/tooltip-helper.d.ts +2 -2
  77. package/cjs/series/pictogram/tooltip-helper.js.map +1 -1
  78. package/cjs/series/pie/pie.js +3 -3
  79. package/cjs/series/pie/pie.js.map +1 -1
  80. package/cjs/series/polar/progress-like/interface.d.ts +1 -0
  81. package/cjs/series/polar/progress-like/interface.js.map +1 -1
  82. package/cjs/series/polar/progress-like/progress-like.js +4 -3
  83. package/cjs/series/polar/progress-like/progress-like.js.map +1 -1
  84. package/cjs/series/progress/linear/interface.d.ts +1 -0
  85. package/cjs/series/progress/linear/interface.js.map +1 -1
  86. package/cjs/series/progress/linear/linear.js +6 -4
  87. package/cjs/series/progress/linear/linear.js.map +1 -1
  88. package/cjs/series/sankey/interface.d.ts +0 -1
  89. package/cjs/series/sankey/interface.js.map +1 -1
  90. package/cjs/typings/tooltip/position.d.ts +1 -1
  91. package/cjs/typings/tooltip/position.js.map +1 -1
  92. package/cjs/typings/visual.d.ts +1 -1
  93. package/cjs/typings/visual.js.map +1 -1
  94. package/esm/chart/index.d.ts +1 -1
  95. package/esm/chart/index.js.map +1 -1
  96. package/esm/chart/pictogram/interface.d.ts +1 -1
  97. package/esm/chart/pictogram/interface.js.map +1 -1
  98. package/esm/chart/progress/linear/linear-progress-transformer.js +1 -1
  99. package/esm/chart/progress/linear/linear-progress-transformer.js.map +1 -1
  100. package/esm/compile/mark/compilable-mark.d.ts +1 -0
  101. package/esm/compile/mark/compilable-mark.js +3 -0
  102. package/esm/compile/mark/compilable-mark.js.map +1 -1
  103. package/esm/component/axis/base-axis.js +7 -2
  104. package/esm/component/axis/base-axis.js.map +1 -1
  105. package/esm/component/axis/interface/spec.d.ts +7 -2
  106. package/esm/component/axis/interface/spec.js.map +1 -1
  107. package/esm/component/brush/brush.d.ts +23 -24
  108. package/esm/component/brush/brush.js +179 -177
  109. package/esm/component/brush/brush.js.map +1 -1
  110. package/esm/component/brush/interface.d.ts +2 -0
  111. package/esm/component/brush/interface.js.map +1 -1
  112. package/esm/component/crosshair/base.js +1 -1
  113. package/esm/component/crosshair/base.js.map +1 -1
  114. package/esm/component/crosshair/utils/cartesian.js +9 -8
  115. package/esm/component/crosshair/utils/cartesian.js.map +1 -1
  116. package/esm/component/data-zoom/data-zoom/interface.d.ts +2 -3
  117. package/esm/component/data-zoom/data-zoom/interface.js.map +1 -1
  118. package/esm/component/marker/mark-area/base-mark-area.js +27 -16
  119. package/esm/component/marker/mark-area/base-mark-area.js.map +1 -1
  120. package/esm/component/marker/mark-area/interface/theme.d.ts +4 -3
  121. package/esm/component/marker/mark-area/interface/theme.js.map +1 -1
  122. package/esm/component/marker/mark-line/base-mark-line.js +30 -19
  123. package/esm/component/marker/mark-line/base-mark-line.js.map +1 -1
  124. package/esm/component/marker/mark-line/cartesian-mark-line.js +31 -26
  125. package/esm/component/marker/mark-line/cartesian-mark-line.js.map +1 -1
  126. package/esm/component/marker/mark-line/interface/theme.d.ts +4 -3
  127. package/esm/component/marker/mark-line/interface/theme.js.map +1 -1
  128. package/esm/component/marker/mark-point/cartesian-mark-point.js +1 -1
  129. package/esm/component/marker/mark-point/cartesian-mark-point.js.map +1 -1
  130. package/esm/component/marker/utils.d.ts +12 -0
  131. package/esm/component/marker/utils.js +19 -4
  132. package/esm/component/marker/utils.js.map +1 -1
  133. package/esm/constant/event.d.ts +1 -0
  134. package/esm/constant/event.js +6 -6
  135. package/esm/constant/event.js.map +1 -1
  136. package/esm/constant/funnel.js +1 -2
  137. package/esm/constant/layout.js +2 -1
  138. package/esm/core/index.d.ts +1 -1
  139. package/esm/core/index.js +2 -3
  140. package/esm/core/index.js.map +1 -1
  141. package/esm/core/interface.js +2 -1
  142. package/esm/data/transforms/pictogram.d.ts +1 -9
  143. package/esm/data/transforms/pictogram.js +3 -3
  144. package/esm/data/transforms/pictogram.js.map +1 -1
  145. package/esm/data/transforms/pie.js +1 -1
  146. package/esm/data/transforms/pie.js.map +1 -1
  147. package/esm/index-harmony-simple.js.map +1 -1
  148. package/esm/index.d.ts +1 -0
  149. package/esm/index.js +2 -0
  150. package/esm/index.js.map +1 -1
  151. package/esm/model/base-model.d.ts +1 -0
  152. package/esm/model/base-model.js +6 -0
  153. package/esm/model/base-model.js.map +1 -1
  154. package/esm/plugin/components/tooltip-handler/base.js +8 -0
  155. package/esm/plugin/components/tooltip-handler/base.js.map +1 -1
  156. package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.js +11 -7
  157. package/esm/plugin/components/tooltip-handler/dom-tooltip-handler.js.map +1 -1
  158. package/esm/plugin/components/tooltip-handler/utils/position.d.ts +1 -1
  159. package/esm/plugin/components/tooltip-handler/utils/position.js +9 -1
  160. package/esm/plugin/components/tooltip-handler/utils/position.js.map +1 -1
  161. package/esm/series/bar/bar.js.map +1 -1
  162. package/esm/series/gauge/gauge.js +6 -4
  163. package/esm/series/gauge/gauge.js.map +1 -1
  164. package/esm/series/pictogram/tooltip-helper.d.ts +2 -2
  165. package/esm/series/pictogram/tooltip-helper.js.map +1 -1
  166. package/esm/series/pie/pie.js +4 -4
  167. package/esm/series/pie/pie.js.map +1 -1
  168. package/esm/series/polar/progress-like/interface.d.ts +1 -0
  169. package/esm/series/polar/progress-like/interface.js.map +1 -1
  170. package/esm/series/polar/progress-like/progress-like.js +4 -3
  171. package/esm/series/polar/progress-like/progress-like.js.map +1 -1
  172. package/esm/series/progress/linear/interface.d.ts +1 -0
  173. package/esm/series/progress/linear/interface.js.map +1 -1
  174. package/esm/series/progress/linear/linear.js +6 -4
  175. package/esm/series/progress/linear/linear.js.map +1 -1
  176. package/esm/series/sankey/interface.d.ts +0 -1
  177. package/esm/series/sankey/interface.js.map +1 -1
  178. package/esm/typings/tooltip/position.d.ts +1 -1
  179. package/esm/typings/tooltip/position.js.map +1 -1
  180. package/esm/typings/visual.d.ts +1 -1
  181. package/esm/typings/visual.js.map +1 -1
  182. package/package.json +18 -18
@@ -28,8 +28,11 @@ export class Brush extends BaseComponent {
28
28
  this.name = ComponentTypeEnum.brush, this.specKey = "brush", this.layoutZIndex = LayoutZIndex.Brush,
29
29
  this._linkedSeries = [], this._itemMap = {}, this._linkedItemMap = {}, this._inBrushElementsMap = {},
30
30
  this._outOfBrushElementsMap = {}, this._linkedInBrushElementsMap = {}, this._linkedOutOfBrushElementsMap = {},
31
- this._needInitOutState = !0, this._cacheInteractiveRangeAttrs = [], this._needDisablePickable = !1,
32
- this._releatedAxes = [], this._regionAxisMap = {}, this._axisDataZoomMap = {}, this._zoomRecord = [];
31
+ this._cacheInteractiveRangeAttrs = [], this._needDisablePickable = !1, this._releatedAxes = [],
32
+ this._regionAxisMap = {}, this._axisDataZoomMap = {}, this._zoomRecord = [];
33
+ }
34
+ static getSpecInfo(chartSpec) {
35
+ return getSpecInfo(chartSpec, this.specKey, this.type, (s => !1 !== s.visible));
33
36
  }
34
37
  init() {
35
38
  const inBrushMarkAttr = this._transformBrushedMarkAttr(this._spec.inBrush), outOfBrushMarkAttr = this._transformBrushedMarkAttr(this._spec.outOfBrush);
@@ -40,42 +43,67 @@ export class Brush extends BaseComponent {
40
43
  }));
41
44
  }));
42
45
  }
43
- static getSpecInfo(chartSpec) {
44
- return getSpecInfo(chartSpec, this.specKey, this.type, (s => !1 !== s.visible));
46
+ _initNeedOperatedItem() {
47
+ const seriesUserId = this._spec.seriesId, seriesIndex = this._spec.seriesIndex;
48
+ this._relativeRegions.forEach((r => {
49
+ const allMarks = [];
50
+ r.getSeries().forEach((s => {
51
+ (seriesUserId && array(seriesUserId).includes(s.userId.toString()) || seriesIndex && array(seriesIndex).includes(s.getSpecIndex()) || !seriesIndex && !seriesUserId) && allMarks.push(...s.getMarksWithoutRoot()),
52
+ this._itemMap[r.id] = allMarks;
53
+ }));
54
+ })), this._linkedSeries.forEach((s => {
55
+ this._linkedItemMap[s.id] = s.getMarksWithoutRoot();
56
+ }));
45
57
  }
46
58
  created() {
47
59
  super.created(), this.initEvent(), this._bindRegions(), this._bindLinkedSeries(),
48
60
  this._initRegionAxisMap(), this._initAxisDataZoomMap(), this._initNeedOperatedItem();
49
61
  }
50
- _extendDataInBrush(elementsMap) {
51
- var _a, _b;
52
- const data = [];
53
- for (const brushName in elementsMap) for (const elementKey in elementsMap[brushName]) data.push(Object.assign({}, null === (_b = null === (_a = elementsMap[brushName][elementKey]) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b[0]));
54
- return data;
62
+ _bindRegions() {
63
+ isValid(this._spec.regionId) || isValid(this._spec.regionIndex) ? this._relativeRegions = this._option.getRegionsInUserIdOrIndex(array(this._spec.regionId), array(this._spec.regionIndex)) : this._relativeRegions = this._option.getAllRegions();
55
64
  }
56
- _extendDatumOutOfBrush(elementsMap) {
57
- var _a;
58
- const data = [];
59
- for (const elementKey in elementsMap) data.push(null === (_a = elementsMap[elementKey].data) || void 0 === _a ? void 0 : _a[0]);
60
- return data;
65
+ _bindLinkedSeries() {
66
+ (isValid(this._spec.brushLinkSeriesId) || isValid(this._spec.brushLinkSeriesIndex)) && (this._linkedSeries = this._option.getSeriesInUserIdOrIndex(array(this._spec.brushLinkSeriesId), array(this._spec.brushLinkSeriesIndex)));
61
67
  }
62
- _getBrushInteractiveAttr(region) {
63
- const regionLayoutPosition = region.getLayoutStartPoint(), regionLayoutRect = region.getLayoutRect(), seriesRegionStartX = regionLayoutPosition.x, seriesRegionEndX = seriesRegionStartX + regionLayoutRect.width, seriesRegionStartY = regionLayoutPosition.y, seriesRegionEndY = seriesRegionStartY + regionLayoutRect.height;
64
- return {
65
- interactiveRange: {
66
- minY: seriesRegionStartY,
67
- maxY: seriesRegionEndY,
68
- minX: seriesRegionStartX,
69
- maxX: seriesRegionEndX
70
- },
71
- xRange: [ seriesRegionStartX, seriesRegionEndX ],
72
- yRange: [ seriesRegionStartY, seriesRegionEndY ]
73
- };
68
+ _initRegionAxisMap() {
69
+ isValid(this._spec.axisId) ? array(this._spec.axisId).forEach((axisId => {
70
+ this._releatedAxes.push(this._option.getComponentByUserId(axisId));
71
+ })) : isValid(this._spec.axisIndex) ? array(this._spec.axisIndex).forEach((axisIndex => {
72
+ this._releatedAxes.push(this._option.getComponentByIndex("axes", axisIndex));
73
+ })) : this._releatedAxes = this._option.getComponentsByKey("axes"), this._releatedAxes.forEach((axis => {
74
+ null == axis || axis.getRegions().forEach((region => {
75
+ this._regionAxisMap["region_" + region.id] ? this._regionAxisMap["region_" + region.id].push(axis) : this._regionAxisMap["region_" + region.id] = [ axis ];
76
+ }));
77
+ }));
78
+ }
79
+ _initAxisDataZoomMap() {
80
+ this._option.getComponentsByKey("dataZoom").forEach((dz => {
81
+ dz.relatedAxisComponent && (this._axisDataZoomMap[dz.relatedAxisComponent.id] = dz);
82
+ }));
83
+ }
84
+ initEvent() {}
85
+ onRender(ctx) {}
86
+ changeRegions(regions) {}
87
+ _compareSpec(spec, prevSpec) {
88
+ this._brushComponents && this._relativeRegions.forEach(((region, index) => {
89
+ this._updateBrushComponent(region, index);
90
+ }));
91
+ const result = super._compareSpec(spec, prevSpec);
92
+ return isEqual(prevSpec, spec) || (result.reRender = !0, result.reMake = !0), result;
93
+ }
94
+ onLayoutEnd(ctx) {
95
+ var _a;
96
+ if (super.onLayoutEnd(ctx), this._option.disableTriggerEvent) return;
97
+ (null === (_a = this._spec.visible) || void 0 === _a || _a) && (this._brushComponents ? this._relativeRegions.forEach(((region, index) => {
98
+ this._updateBrushComponent(region, index);
99
+ })) : (this._brushComponents = [], this._relativeRegions.forEach(((region, index) => {
100
+ this._createBrushComponent(region, index);
101
+ }))));
74
102
  }
75
103
  _updateBrushComponent(region, componentIndex) {
76
104
  const interactiveAttr = this._getBrushInteractiveAttr(region), brushComponent = this._brushComponents[componentIndex];
77
105
  brushComponent.setAttributes(interactiveAttr), this._initMarkBrushState(componentIndex, ""),
78
- brushComponent.children[0].removeAllChild(), this._needInitOutState = !0;
106
+ brushComponent.children[0].removeAllChild();
79
107
  }
80
108
  _createBrushComponent(region, componentIndex) {
81
109
  var _a, _b;
@@ -86,43 +114,75 @@ export class Brush extends BaseComponent {
86
114
  disableTriggerEvent: this._option.disableTriggerEvent
87
115
  }));
88
116
  brush.id = null !== (_b = this._spec.id) && void 0 !== _b ? _b : `brush-${this.id}`,
89
- this.getContainer().add(brush);
90
- const {brushMode: brushMode = "single"} = this._spec;
91
- this._brushComponents.push(brush), this._cacheInteractiveRangeAttrs.push(interactiveAttr),
92
- brush.addEventListener(BrushEvent.drawStart, (e => {
117
+ this.getContainer().add(brush), this._brushComponents.push(brush), this._cacheInteractiveRangeAttrs.push(interactiveAttr),
118
+ brush.addEventListener(BrushEvent.brushActive, (e => {
119
+ this._initMarkBrushState(componentIndex, "outOfBrush"), this._emitEvent(ChartEvent.brushActive, region);
120
+ })), brush.addEventListener(BrushEvent.drawStart, (e => {
93
121
  this._emitEvent(ChartEvent.brushStart, region);
94
122
  })), brush.addEventListener(BrushEvent.moveStart, (e => {
95
123
  this._emitEvent(ChartEvent.brushStart, region);
96
124
  })), brush.addEventListener(BrushEvent.drawing, (e => {
97
- this._needInitOutState && "single" === brushMode && this._initMarkBrushState(componentIndex, "outOfBrush"),
98
- this._needInitOutState = !1, this._needDisablePickable = !0, this._handleBrushChange(ChartEvent.brushChange, region, e),
99
- this._emitEvent(ChartEvent.brushChange, region);
125
+ this._needDisablePickable = !0, this._handleBrushChange(region, e), this._emitEvent(ChartEvent.brushChange, region);
100
126
  })), brush.addEventListener(BrushEvent.moving, (e => {
101
- this._handleBrushChange(ChartEvent.brushChange, region, e), this._emitEvent(ChartEvent.brushChange, region);
127
+ this._handleBrushChange(region, e), this._emitEvent(ChartEvent.brushChange, region);
102
128
  })), brush.addEventListener(BrushEvent.brushClear, (e => {
103
- this._initMarkBrushState(componentIndex, ""), this._needInitOutState = !0, this._needDisablePickable = !1,
104
- this._handleBrushChange(ChartEvent.brushChange, region, e), this._handleBrushChange(ChartEvent.brushClear, region, e),
105
- this._emitEvent(ChartEvent.brushChange, region), this._emitEvent(ChartEvent.brushClear, region);
129
+ this._initMarkBrushState(componentIndex, ""), this._needDisablePickable = !1, this._emitEvent(ChartEvent.brushClear, region);
106
130
  })), brush.addEventListener(BrushEvent.drawEnd, (e => {
107
- this._needInitOutState = !0, this._needDisablePickable = !1;
131
+ var _a;
132
+ this._needDisablePickable = !1;
108
133
  const {operateMask: operateMask} = e.detail;
109
- this._handleBrushChange(ChartEvent.brushEnd, region, e);
110
- const inBrushData = this._extendDataInBrush(this._inBrushElementsMap);
111
- !this._spec.zoomWhenEmpty && inBrushData.length > 0 && this._setAxisAndDataZoom(operateMask, region),
112
- this._emitEvent(ChartEvent.brushEnd, region);
134
+ if (null === (_a = this._spec) || void 0 === _a ? void 0 : _a.onBrushEnd) !0 === this._spec.onBrushEnd(e) ? (this.clearGraphic(),
135
+ this._initMarkBrushState(componentIndex, ""), this._needDisablePickable = !1, this._emitEvent(ChartEvent.brushClear, region)) : (this._spec.onBrushEnd(e),
136
+ this._emitEvent(ChartEvent.brushEnd, region)); else {
137
+ const inBrushData = this._extendDataInBrush(this._inBrushElementsMap);
138
+ !this._spec.zoomWhenEmpty && inBrushData.length > 0 && this._setAxisAndDataZoom(operateMask, region),
139
+ this._emitEvent(ChartEvent.brushEnd, region);
140
+ }
113
141
  })), brush.addEventListener(BrushEvent.moveEnd, (e => {
114
- const {operateMask: operateMask} = e.detail;
115
- this._handleBrushChange(ChartEvent.brushEnd, region, e);
116
- const inBrushData = this._extendDataInBrush(this._inBrushElementsMap);
142
+ const {operateMask: operateMask} = e.detail, inBrushData = this._extendDataInBrush(this._inBrushElementsMap);
117
143
  !this._spec.zoomWhenEmpty && inBrushData.length > 0 && this._setAxisAndDataZoom(operateMask, region),
118
144
  this._emitEvent(ChartEvent.brushEnd, region);
119
145
  }));
120
146
  }
121
- _handleBrushChange(eventType, region, e) {
147
+ _getBrushInteractiveAttr(region) {
148
+ const regionLayoutPosition = region.getLayoutStartPoint(), regionLayoutRect = region.getLayoutRect(), seriesRegionStartX = regionLayoutPosition.x, seriesRegionEndX = seriesRegionStartX + regionLayoutRect.width, seriesRegionStartY = regionLayoutPosition.y, seriesRegionEndY = seriesRegionStartY + regionLayoutRect.height;
149
+ return {
150
+ interactiveRange: {
151
+ minY: seriesRegionStartY,
152
+ maxY: seriesRegionEndY,
153
+ minX: seriesRegionStartX,
154
+ maxX: seriesRegionEndX
155
+ },
156
+ xRange: [ seriesRegionStartX, seriesRegionEndX ],
157
+ yRange: [ seriesRegionStartY, seriesRegionEndY ]
158
+ };
159
+ }
160
+ _transformBrushedMarkAttr(brushedStyle) {
161
+ const styleResult = {};
162
+ return (null == brushedStyle ? void 0 : brushedStyle.symbol) && (styleResult.symbolType = brushedStyle.symbol),
163
+ (null == brushedStyle ? void 0 : brushedStyle.symbolSize) && (styleResult.size = brushedStyle.symbolSize),
164
+ (null == brushedStyle ? void 0 : brushedStyle.color) && (styleResult.fill = brushedStyle.color),
165
+ (null == brushedStyle ? void 0 : brushedStyle.colorAlpha) && (styleResult.fillOpacity = brushedStyle.colorAlpha),
166
+ Object.assign(Object.assign({}, transformToGraphic(brushedStyle)), styleResult);
167
+ }
168
+ _handleBrushChange(region, e) {
122
169
  const {operateMask: operateMask} = e.detail;
123
170
  this._reconfigItem(operateMask, region), this._reconfigLinkedItem(operateMask, region);
124
171
  }
172
+ _extendDataInBrush(elementsMap) {
173
+ var _a, _b;
174
+ const data = [];
175
+ for (const brushName in elementsMap) for (const elementKey in elementsMap[brushName]) data.push(Object.assign({}, null === (_b = null === (_a = elementsMap[brushName][elementKey]) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b[0]));
176
+ return data;
177
+ }
178
+ _extendDatumOutOfBrush(elementsMap) {
179
+ var _a;
180
+ const data = [];
181
+ for (const elementKey in elementsMap) data.push(null === (_a = elementsMap[elementKey].data) || void 0 === _a ? void 0 : _a[0]);
182
+ return data;
183
+ }
125
184
  _emitEvent(eventType, region) {
185
+ var _a;
126
186
  this.event.emit(eventType, {
127
187
  model: this,
128
188
  value: {
@@ -137,102 +197,113 @@ export class Brush extends BaseComponent {
137
197
  linkedInBrushElementsMap: this._linkedInBrushElementsMap,
138
198
  linkedOutOfBrushElementsMap: this._linkedOutOfBrushElementsMap,
139
199
  zoomRecord: this._zoomRecord
140
- }
200
+ },
201
+ vchart: null === (_a = this._option) || void 0 === _a ? void 0 : _a.globalInstance
141
202
  });
142
203
  }
143
- _transformBrushedMarkAttr(brushedStyle) {
144
- const styleResult = {};
145
- return (null == brushedStyle ? void 0 : brushedStyle.symbol) && (styleResult.symbolType = brushedStyle.symbol),
146
- (null == brushedStyle ? void 0 : brushedStyle.symbolSize) && (styleResult.size = brushedStyle.symbolSize),
147
- (null == brushedStyle ? void 0 : brushedStyle.color) && (styleResult.fill = brushedStyle.color),
148
- (null == brushedStyle ? void 0 : brushedStyle.colorAlpha) && (styleResult.fillOpacity = brushedStyle.colorAlpha),
149
- Object.assign(Object.assign({}, transformToGraphic(brushedStyle)), styleResult);
150
- }
151
204
  _reconfigItem(operateMask, region) {
205
+ var _a, _b, _c;
206
+ if (!(null == operateMask ? void 0 : operateMask.globalTransMatrix) || !(null === (_a = null == operateMask ? void 0 : operateMask.attribute) || void 0 === _a ? void 0 : _a.points)) return;
207
+ const points = null !== (_c = null === (_b = null == operateMask ? void 0 : operateMask.attribute) || void 0 === _b ? void 0 : _b.points) && void 0 !== _c ? _c : [], {a: a, b: b, c: c, d: d, e: e, f: f} = operateMask.globalTransMatrix, pointsCoord = points.map((p => ({
208
+ x: a * p.x + c * p.y + e,
209
+ y: b * p.x + d * p.y + f
210
+ }))), {markTypeFilter: markTypeFilter = []} = this._spec;
152
211
  this._itemMap[region.id].forEach((mark => {
212
+ if (markTypeFilter.includes(mark.type)) return;
153
213
  const grammarMark = mark.getProduct();
154
214
  if (!grammarMark || !grammarMark.elements || !grammarMark.elements.length) return;
155
215
  grammarMark.elements.forEach((el => {
156
216
  var _a, _b, _c;
157
- const graphicItem = el.getGraphicItem(), elementKey = mark.id + "_" + el.key;
158
- (null === (_a = this._outOfBrushElementsMap) || void 0 === _a ? void 0 : _a[elementKey]) && this._isBrushContainItem(operateMask, graphicItem) ? (el.addState("inBrush"),
217
+ const graphicItem = el.getGraphicItem(), elementKey = mark.id + "_" + el.key, isBrushContainItem = this._isBrushContainItem(operateMask.globalAABBBounds, pointsCoord, graphicItem);
218
+ (null === (_a = this._outOfBrushElementsMap) || void 0 === _a ? void 0 : _a[elementKey]) && isBrushContainItem ? (el.addState("inBrush"),
159
219
  this._inBrushElementsMap[null == operateMask ? void 0 : operateMask.name] || (this._inBrushElementsMap[null == operateMask ? void 0 : operateMask.name] = {}),
160
220
  this._inBrushElementsMap[null == operateMask ? void 0 : operateMask.name][elementKey] = el,
161
- delete this._outOfBrushElementsMap[elementKey]) : (null === (_c = null === (_b = this._inBrushElementsMap) || void 0 === _b ? void 0 : _b[null == operateMask ? void 0 : operateMask.name]) || void 0 === _c ? void 0 : _c[elementKey]) && !this._isBrushContainItem(operateMask, graphicItem) && (el.removeState("inBrush"),
221
+ delete this._outOfBrushElementsMap[elementKey]) : (null === (_c = null === (_b = this._inBrushElementsMap) || void 0 === _b ? void 0 : _b[null == operateMask ? void 0 : operateMask.name]) || void 0 === _c ? void 0 : _c[elementKey]) && !isBrushContainItem && (el.removeState("inBrush"),
162
222
  el.addState("outOfBrush"), this._outOfBrushElementsMap[elementKey] = el, delete this._inBrushElementsMap[operateMask.name][elementKey]),
163
223
  graphicItem.setAttribute("pickable", !this._needDisablePickable);
164
224
  }));
165
225
  }));
166
226
  }
167
227
  _reconfigLinkedItem(operateMask, region) {
228
+ var _a;
229
+ if (!(null == operateMask ? void 0 : operateMask.globalTransMatrix) || !(null === (_a = null == operateMask ? void 0 : operateMask.attribute) || void 0 === _a ? void 0 : _a.points)) return;
168
230
  const regionLayoutPos = region.getLayoutStartPoint(), seriesId = region.getSeries().map((s => s.id));
169
231
  this._linkedSeries.forEach((s => {
232
+ var _a, _b;
170
233
  if (!seriesId.includes(s.id)) {
171
- const sRegionLayoutPos = s.getRegion().getLayoutStartPoint(), regionOffsetX = sRegionLayoutPos.x - regionLayoutPos.x, regionOffsetY = sRegionLayoutPos.y - regionLayoutPos.y;
234
+ const sRegionLayoutPos = s.getRegion().getLayoutStartPoint(), regionOffsetX = sRegionLayoutPos.x - regionLayoutPos.x, regionOffsetY = sRegionLayoutPos.y - regionLayoutPos.y, points = null !== (_b = null === (_a = null == operateMask ? void 0 : operateMask.attribute) || void 0 === _a ? void 0 : _a.points) && void 0 !== _b ? _b : [], {a: a, b: b, c: c, d: d, e: e, f: f} = operateMask.globalTransMatrix, dx = regionOffsetX || 0, dy = regionOffsetY || 0, pointsCoord = points.map((p => ({
235
+ x: a * p.x + c * p.y + e + dx,
236
+ y: b * p.x + d * p.y + f + dy
237
+ })));
238
+ operateMask.globalAABBBounds.clone().set(operateMask.globalAABBBounds.x1 + dx, operateMask.globalAABBBounds.y1 + dy, operateMask.globalAABBBounds.x2 + dx, operateMask.globalAABBBounds.y2 + dy);
239
+ const {markTypeFilter: markTypeFilter = []} = this._spec;
172
240
  this._linkedItemMap[s.id].forEach((mark => {
241
+ if (markTypeFilter.includes(mark.type)) return;
173
242
  const grammarMark = mark.getProduct();
174
243
  if (!grammarMark || !grammarMark.elements || !grammarMark.elements.length) return;
175
244
  grammarMark.elements.forEach((el => {
176
245
  var _a, _b, _c;
177
246
  const graphicItem = el.getGraphicItem(), elementKey = mark.id + "_" + el.key;
178
- (null === (_a = this._linkedOutOfBrushElementsMap) || void 0 === _a ? void 0 : _a[elementKey]) && this._isBrushContainItem(operateMask, graphicItem, {
179
- dx: regionOffsetX,
180
- dy: regionOffsetY
181
- }) ? (el.addState("inBrush"), this._linkedInBrushElementsMap[null == operateMask ? void 0 : operateMask.name] || (this._linkedInBrushElementsMap[null == operateMask ? void 0 : operateMask.name] = {}),
247
+ (null === (_a = this._linkedOutOfBrushElementsMap) || void 0 === _a ? void 0 : _a[elementKey]) && this._isBrushContainItem(operateMask.globalAABBBounds, pointsCoord, graphicItem) ? (el.addState("inBrush"),
248
+ this._linkedInBrushElementsMap[null == operateMask ? void 0 : operateMask.name] || (this._linkedInBrushElementsMap[null == operateMask ? void 0 : operateMask.name] = {}),
182
249
  this._linkedInBrushElementsMap[null == operateMask ? void 0 : operateMask.name][elementKey] = el,
183
- delete this._linkedOutOfBrushElementsMap[elementKey]) : (null === (_c = null === (_b = this._linkedInBrushElementsMap) || void 0 === _b ? void 0 : _b[null == operateMask ? void 0 : operateMask.name]) || void 0 === _c ? void 0 : _c[elementKey]) && !this._isBrushContainItem(operateMask, graphicItem, {
184
- dx: regionOffsetX,
185
- dy: regionOffsetY
186
- }) && (el.removeState("inBrush"), el.addState("outOfBrush"), this._linkedOutOfBrushElementsMap[elementKey] = el),
250
+ delete this._linkedOutOfBrushElementsMap[elementKey]) : (null === (_c = null === (_b = this._linkedInBrushElementsMap) || void 0 === _b ? void 0 : _b[null == operateMask ? void 0 : operateMask.name]) || void 0 === _c ? void 0 : _c[elementKey]) && !this._isBrushContainItem(operateMask.globalAABBBounds, pointsCoord, graphicItem) && (el.removeState("inBrush"),
251
+ el.addState("outOfBrush"), this._linkedOutOfBrushElementsMap[elementKey] = el),
187
252
  graphicItem.setAttribute("pickable", !this._needDisablePickable);
188
253
  }));
189
254
  }));
190
255
  }
191
256
  }));
192
257
  }
193
- _isBrushContainItem(brushMask, item, linkedOffset) {
194
- var _a, _b, _c;
195
- if (!(null == brushMask ? void 0 : brushMask.globalTransMatrix) || !(null === (_a = null == brushMask ? void 0 : brushMask.attribute) || void 0 === _a ? void 0 : _a.points)) return !1;
196
- const points = null !== (_c = null === (_b = null == brushMask ? void 0 : brushMask.attribute) || void 0 === _b ? void 0 : _b.points) && void 0 !== _c ? _c : [], {a: a, b: b, c: c, d: d, e: e, f: f} = brushMask.globalTransMatrix, dx = (null == linkedOffset ? void 0 : linkedOffset.dx) || 0, dy = (null == linkedOffset ? void 0 : linkedOffset.dy) || 0, pointsCoord = points.map((p => ({
197
- x: a * p.x + c * p.y + e + dx,
198
- y: b * p.x + d * p.y + f + dy
199
- })));
200
- brushMask.globalAABBBounds.clone().set(brushMask.globalAABBBounds.x1 + dx, brushMask.globalAABBBounds.y1 + dy, brushMask.globalAABBBounds.x2 + dx, brushMask.globalAABBBounds.y2 + dy);
201
- const x = item.globalTransMatrix.e, y = item.globalTransMatrix.f;
258
+ _isBrushContainItem(brushMaskAABBBounds, brushMaskPointsCoord, item) {
202
259
  let itemBounds = [];
203
- if ("symbol" === item.type) {
204
- const {size: itemSize = 0} = null == item ? void 0 : item.attribute, size = array(itemSize)[0] / 2;
260
+ if ([ "symbol", "rect" ].includes(item.type)) {
261
+ const {x1: x1, x2: x2, y1: y1, y2: y2} = null == item ? void 0 : item.globalAABBBounds;
205
262
  return itemBounds = [ {
206
- x: x - size,
207
- y: y - size
263
+ x: x1,
264
+ y: y1
208
265
  }, {
209
- x: x + size,
210
- y: y - size
266
+ x: x2,
267
+ y: y1
211
268
  }, {
212
- x: x + size,
213
- y: y + size
269
+ x: x2,
270
+ y: y2
214
271
  }, {
215
- x: x - size,
216
- y: y + size
217
- } ], polygonIntersectPolygon(pointsCoord, itemBounds);
272
+ x: x1,
273
+ y: y2
274
+ } ], polygonIntersectPolygon(brushMaskPointsCoord, itemBounds);
218
275
  }
219
- if ("rect" === item.type) {
220
- const {x1: x1, x2: x2, y1: y1, y2: y2} = null == item ? void 0 : item.AABBBounds, width = Math.abs(x1 - x2), height = Math.abs(y1 - y2);
221
- return itemBounds = [ {
222
- x: x,
223
- y: y
224
- }, {
225
- x: x + width,
226
- y: y
227
- }, {
228
- x: x + width,
229
- y: y + height
230
- }, {
231
- x: x,
232
- y: y + height
233
- } ], polygonIntersectPolygon(pointsCoord, itemBounds);
234
- }
235
- return brushMask.globalAABBBounds.intersects(item.globalAABBBounds);
276
+ return brushMaskAABBBounds.intersects(item.globalAABBBounds);
277
+ }
278
+ _initMarkBrushState(componentIndex, stateName) {
279
+ this._brushComponents.forEach(((brush, index) => {
280
+ index !== componentIndex && brush.children[0].removeAllChild();
281
+ })), this._inBrushElementsMap = {}, this._outOfBrushElementsMap = {}, this._linkedInBrushElementsMap = {},
282
+ this._linkedOutOfBrushElementsMap = {};
283
+ const {markTypeFilter: markTypeFilter = []} = this._spec;
284
+ Object.entries(this._itemMap).forEach((([regionId, marks]) => {
285
+ marks.forEach((mark => {
286
+ if (markTypeFilter.includes(mark.type)) return;
287
+ const grammarMark = mark.getProduct();
288
+ if (!grammarMark || !grammarMark.elements || !grammarMark.elements.length) return;
289
+ grammarMark.elements.forEach((el => {
290
+ const elementKey = mark.id + "_" + el.key;
291
+ el.removeState("inBrush"), el.removeState("outOfBrush"), el.addState(stateName),
292
+ this._outOfBrushElementsMap[elementKey] = el;
293
+ }));
294
+ }));
295
+ })), Object.entries(this._linkedItemMap).forEach((([seriesId, marks]) => {
296
+ marks.forEach((mark => {
297
+ if (markTypeFilter.includes(mark.type)) return;
298
+ const grammarMark = mark.getProduct();
299
+ if (!grammarMark || !grammarMark.elements || !grammarMark.elements.length) return;
300
+ grammarMark.elements.forEach((el => {
301
+ const elementKey = mark.id + "_" + el.key;
302
+ el.removeState("inBrush"), el.removeState("outOfBrush"), el.addState(stateName),
303
+ this._linkedOutOfBrushElementsMap[elementKey] = el;
304
+ }));
305
+ }));
306
+ }));
236
307
  }
237
308
  _stateClamp(state) {
238
309
  return Math.min(Math.max(0, state), 1);
@@ -267,79 +338,9 @@ export class Brush extends BaseComponent {
267
338
  }));
268
339
  }
269
340
  }
270
- _bindRegions() {
271
- isValid(this._spec.regionId) && isValid(this._spec.regionIndex) && (this._relativeRegions = this._option.getAllRegions()),
272
- this._relativeRegions = this._option.getRegionsInUserIdOrIndex(array(this._spec.regionId), array(this._spec.regionIndex));
273
- }
274
- _bindLinkedSeries() {
275
- isValid(this._spec.brushLinkSeriesId) && isValid(this._spec.brushLinkSeriesIndex) || (this._linkedSeries = this._option.getSeriesInUserIdOrIndex(array(this._spec.brushLinkSeriesId), array(this._spec.brushLinkSeriesIndex)));
276
- }
277
- _initRegionAxisMap() {
278
- isValid(this._spec.axisId) ? array(this._spec.axisId).forEach((axisId => {
279
- this._releatedAxes.push(this._option.getComponentByUserId(axisId));
280
- })) : isValid(this._spec.axisIndex) ? array(this._spec.axisIndex).forEach((axisIndex => {
281
- this._releatedAxes.push(this._option.getComponentByIndex("axes", axisIndex));
282
- })) : this._releatedAxes = this._option.getComponentsByKey("axes"), this._releatedAxes.forEach((axis => {
283
- null == axis || axis.getRegions().forEach((region => {
284
- this._regionAxisMap["region_" + region.id] ? this._regionAxisMap["region_" + region.id].push(axis) : this._regionAxisMap["region_" + region.id] = [ axis ];
285
- }));
286
- }));
287
- }
288
- _initAxisDataZoomMap() {
289
- this._option.getComponentsByKey("dataZoom").forEach((dz => {
290
- dz.relatedAxisComponent && (this._axisDataZoomMap[dz.relatedAxisComponent.id] = dz);
291
- }));
292
- }
293
- _initNeedOperatedItem() {
294
- const seriesUserId = this._spec.seriesId, seriesIndex = this._spec.seriesIndex;
295
- this._relativeRegions.forEach((r => {
296
- const allMarks = [];
297
- r.getSeries().forEach((s => {
298
- (seriesUserId && array(seriesUserId).includes(s.userId.toString()) || seriesIndex && array(seriesIndex).includes(s.getSpecIndex()) || !seriesIndex && !seriesUserId) && allMarks.push(...s.getMarksWithoutRoot()),
299
- this._itemMap[r.id] = allMarks;
300
- }));
301
- })), this._linkedSeries.forEach((s => {
302
- this._linkedItemMap[s.id] = s.getMarksWithoutRoot();
303
- }));
304
- }
305
- _initMarkBrushState(componentIndex, stateName) {
306
- this._brushComponents.forEach(((brush, index) => {
307
- index !== componentIndex && brush.children[0].removeAllChild();
308
- })), this._inBrushElementsMap = {}, this._outOfBrushElementsMap = {}, this._linkedInBrushElementsMap = {},
309
- this._linkedOutOfBrushElementsMap = {}, this._option.getAllSeries().forEach((s => {
310
- s.getMarksWithoutRoot().forEach((mark => {
311
- const grammarMark = mark.getProduct();
312
- if (!grammarMark || !grammarMark.elements || !grammarMark.elements.length) return;
313
- grammarMark.elements.forEach((el => {
314
- const elementKey = mark.id + "_" + el.key;
315
- el.removeState("inBrush"), el.removeState("outOfBrush"), el.addState(stateName),
316
- this._outOfBrushElementsMap[elementKey] = el, this._linkedOutOfBrushElementsMap[elementKey] = el;
317
- }));
318
- }));
319
- }));
320
- }
321
- initEvent() {}
322
- onRender(ctx) {}
323
- changeRegions(regions) {}
324
341
  _getNeedClearVRenderComponents() {
325
342
  return this._brushComponents;
326
343
  }
327
- _compareSpec(spec, prevSpec) {
328
- this._brushComponents && this._relativeRegions.forEach(((region, index) => {
329
- this._updateBrushComponent(region, index);
330
- }));
331
- const result = super._compareSpec(spec, prevSpec);
332
- return isEqual(prevSpec, spec) || (result.reRender = !0, result.reMake = !0), result;
333
- }
334
- onLayoutEnd(ctx) {
335
- var _a;
336
- if (super.onLayoutEnd(ctx), this._option.disableTriggerEvent) return;
337
- (null === (_a = this._spec.visible) || void 0 === _a || _a) && (this._brushComponents ? this._relativeRegions.forEach(((region, index) => {
338
- this._updateBrushComponent(region, index);
339
- })) : (this._brushComponents = [], this._relativeRegions.forEach(((region, index) => {
340
- this._createBrushComponent(region, index);
341
- }))));
342
- }
343
344
  clearGraphic() {
344
345
  this._brushComponents && this._brushComponents.forEach((brush => {
345
346
  brush._container.incrementalClearChild();
@@ -348,8 +349,9 @@ export class Brush extends BaseComponent {
348
349
  clear() {
349
350
  if (this._brushComponents) {
350
351
  const container = this.getContainer();
351
- this._brushComponents.forEach((brush => {
352
- brush.removeAllChild(), brush.releaseBrushEvents(), container && container.removeChild(brush);
352
+ this._brushComponents.forEach(((brush, index) => {
353
+ this._initMarkBrushState(index, ""), this._needDisablePickable = !1, brush.removeAllChild(),
354
+ brush.releaseBrushEvents(), container && container.removeChild(brush);
353
355
  })), this._brushComponents = null;
354
356
  }
355
357
  }