@visactor/vchart 1.13.9-alpha.5 → 1.13.9

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