@visactor/vchart 1.9.6-alpha.1 → 1.9.6-alpha.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 (91) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +77 -236
  3. package/build/index.min.js +1 -1
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/chart/stack.js +2 -1
  6. package/cjs/compile/grammar-item.js +1 -2
  7. package/cjs/component/axis/base-axis.js +1 -1
  8. package/cjs/component/axis/base-axis.js.map +1 -1
  9. package/cjs/component/brush/brush.d.ts +0 -5
  10. package/cjs/component/brush/brush.js +14 -60
  11. package/cjs/component/brush/brush.js.map +1 -1
  12. package/cjs/component/brush/interface.d.ts +0 -3
  13. package/cjs/component/brush/interface.js.map +1 -1
  14. package/cjs/component/data-zoom/data-filter-base-component.d.ts +2 -11
  15. package/cjs/component/data-zoom/data-filter-base-component.js +12 -31
  16. package/cjs/component/data-zoom/data-filter-base-component.js.map +1 -1
  17. package/cjs/component/data-zoom/data-zoom/data-zoom.d.ts +0 -1
  18. package/cjs/component/data-zoom/data-zoom/data-zoom.js +8 -11
  19. package/cjs/component/data-zoom/data-zoom/data-zoom.js.map +1 -1
  20. package/cjs/component/data-zoom/data-zoom/interface.d.ts +0 -1
  21. package/cjs/component/data-zoom/data-zoom/interface.js.map +1 -1
  22. package/cjs/component/data-zoom/interface.d.ts +0 -2
  23. package/cjs/component/data-zoom/interface.js.map +1 -1
  24. package/cjs/component/data-zoom/scroll-bar/scroll-bar.js +1 -2
  25. package/cjs/component/data-zoom/scroll-bar/scroll-bar.js.map +1 -1
  26. package/cjs/component/data-zoom/util.js +1 -5
  27. package/cjs/component/data-zoom/util.js.map +1 -1
  28. package/cjs/component/label/base-label.d.ts +2 -1
  29. package/cjs/component/label/base-label.js +3 -0
  30. package/cjs/component/label/base-label.js.map +1 -1
  31. package/cjs/component/label/label.d.ts +1 -2
  32. package/cjs/component/label/label.js +7 -10
  33. package/cjs/component/label/label.js.map +1 -1
  34. package/cjs/component/label/total-label.d.ts +1 -0
  35. package/cjs/component/label/total-label.js +9 -1
  36. package/cjs/component/label/total-label.js.map +1 -1
  37. package/cjs/component/tooltip/tooltip.js +8 -5
  38. package/cjs/component/tooltip/tooltip.js.map +1 -1
  39. package/cjs/core/index.d.ts +1 -1
  40. package/cjs/core/index.js +1 -1
  41. package/cjs/core/index.js.map +1 -1
  42. package/cjs/event/interface.d.ts +1 -1
  43. package/cjs/event/interface.js.map +1 -1
  44. package/cjs/mark/base/base-mark.js +2 -2
  45. package/cjs/mark/base/base-mark.js.map +1 -1
  46. package/cjs/series/map/geo-source.d.ts +1 -1
  47. package/cjs/series/map/geo-source.js.map +1 -1
  48. package/esm/chart/stack.js +2 -1
  49. package/esm/compile/grammar-item.js +1 -2
  50. package/esm/component/axis/base-axis.js +1 -1
  51. package/esm/component/axis/base-axis.js.map +1 -1
  52. package/esm/component/brush/brush.d.ts +0 -5
  53. package/esm/component/brush/brush.js +13 -60
  54. package/esm/component/brush/brush.js.map +1 -1
  55. package/esm/component/brush/interface.d.ts +0 -3
  56. package/esm/component/brush/interface.js.map +1 -1
  57. package/esm/component/data-zoom/data-filter-base-component.d.ts +2 -11
  58. package/esm/component/data-zoom/data-filter-base-component.js +12 -31
  59. package/esm/component/data-zoom/data-filter-base-component.js.map +1 -1
  60. package/esm/component/data-zoom/data-zoom/data-zoom.d.ts +0 -1
  61. package/esm/component/data-zoom/data-zoom/data-zoom.js +9 -12
  62. package/esm/component/data-zoom/data-zoom/data-zoom.js.map +1 -1
  63. package/esm/component/data-zoom/data-zoom/interface.d.ts +0 -1
  64. package/esm/component/data-zoom/data-zoom/interface.js.map +1 -1
  65. package/esm/component/data-zoom/interface.d.ts +0 -2
  66. package/esm/component/data-zoom/interface.js.map +1 -1
  67. package/esm/component/data-zoom/scroll-bar/scroll-bar.js +2 -3
  68. package/esm/component/data-zoom/scroll-bar/scroll-bar.js.map +1 -1
  69. package/esm/component/data-zoom/util.js +1 -5
  70. package/esm/component/data-zoom/util.js.map +1 -1
  71. package/esm/component/label/base-label.d.ts +2 -1
  72. package/esm/component/label/base-label.js +3 -0
  73. package/esm/component/label/base-label.js.map +1 -1
  74. package/esm/component/label/label.d.ts +1 -2
  75. package/esm/component/label/label.js +8 -9
  76. package/esm/component/label/label.js.map +1 -1
  77. package/esm/component/label/total-label.d.ts +1 -0
  78. package/esm/component/label/total-label.js +10 -0
  79. package/esm/component/label/total-label.js.map +1 -1
  80. package/esm/component/tooltip/tooltip.js +8 -5
  81. package/esm/component/tooltip/tooltip.js.map +1 -1
  82. package/esm/core/index.d.ts +1 -1
  83. package/esm/core/index.js +1 -1
  84. package/esm/core/index.js.map +1 -1
  85. package/esm/event/interface.d.ts +1 -1
  86. package/esm/event/interface.js.map +1 -1
  87. package/esm/mark/base/base-mark.js +1 -1
  88. package/esm/mark/base/base-mark.js.map +1 -1
  89. package/esm/series/map/geo-source.d.ts +1 -1
  90. package/esm/series/map/geo-source.js.map +1 -1
  91. package/package.json +13 -13
package/build/index.js CHANGED
@@ -23968,38 +23968,6 @@
23968
23968
  };
23969
23969
  DefaultPickService = __decorate$Z([injectable(), __param$u(0, inject(ContributionProvider)), __param$u(0, named(PickItemInterceptor)), __metadata$J("design:paramtypes", [Object])], DefaultPickService);
23970
23970
 
23971
- function simplifyRadialDist(points, sqTolerance) {
23972
- let deltaX,
23973
- deltaY,
23974
- lastX = points[0].x,
23975
- lastY = points[0].y;
23976
- const newPoints = [points[0]];
23977
- for (let i = 1, len = points.length; i < len; i++) deltaX = points[i].x - lastX, deltaY = points[i].y - lastY, deltaX * deltaX + deltaY * deltaY > sqTolerance && (lastX = points[i].x, lastY = points[i].y, newPoints.push(points[i]));
23978
- return points[points.length - 1].x === lastX && points[points.length - 1].y === lastY || newPoints.push(points[points.length - 1]), newPoints;
23979
- }
23980
- function simplifyDPStep(points, startIdx, endIdx, sqTolerance, simplified) {
23981
- let maxSqDist = sqTolerance,
23982
- nextIdx = startIdx;
23983
- const startX = points[startIdx].x,
23984
- startY = points[startIdx].y,
23985
- vecX2 = points[endIdx].x - startX,
23986
- vecY2 = points[endIdx].y - startY,
23987
- sqLength = vecX2 * vecX2 + vecY2 * vecY2;
23988
- let area, sqArea, sqDistance, vecX1, vecY1;
23989
- for (let i = startIdx + 1, len = endIdx - 1; i < len; i++) vecX1 = points[i].x - startX, vecY1 = points[i].y - startY, area = vecX1 * vecY2 - vecX2 * vecY1, sqArea = area * area, sqDistance = sqArea / sqLength, sqDistance > maxSqDist && (maxSqDist = sqDistance, nextIdx = i);
23990
- maxSqDist > sqTolerance && (nextIdx - startIdx > 2 && simplifyDPStep(points, startIdx, nextIdx, sqTolerance, simplified), simplified.push(points[nextIdx], points[nextIdx + 1]), endIdx - nextIdx > 2 && simplifyDPStep(points, nextIdx, endIdx, sqTolerance, simplified));
23991
- }
23992
- function simplifyDouglasPeucker(points, sqTolerance) {
23993
- const lastIdx = points.length - 1,
23994
- simplified = [points[0]];
23995
- return simplifyDPStep(points, 0, lastIdx, sqTolerance, simplified), simplified.push(points[lastIdx]), simplified;
23996
- }
23997
- function flatten_simplify(points, tolerance, highestQuality) {
23998
- if (points.length <= 10) return points;
23999
- const sqTolerance = void 0 !== tolerance ? tolerance * tolerance : 1;
24000
- return points = simplifyDouglasPeucker(points = highestQuality ? points : simplifyRadialDist(points, sqTolerance), sqTolerance);
24001
- }
24002
-
24003
23971
  let loadArcModule = !1;
24004
23972
  const arcModule = new ContainerModule(bind => {
24005
23973
  loadArcModule || (loadArcModule = !0, bind(DefaultCanvasArcRender).toSelf().inSingletonScope(), bind(ArcRender).to(DefaultCanvasArcRender).inSingletonScope(), bind(GraphicRender).toService(ArcRender), bind(ArcRenderContribution).toService(DefaultBaseInteractiveRenderContribution), bindContributionProvider(bind, ArcRenderContribution));
@@ -37445,11 +37413,11 @@
37445
37413
  start: start,
37446
37414
  end: end
37447
37415
  } = this.state;
37448
- this._activeState && (this._activeTag === DataZoomActiveTag.middleHandler ? this.moveZoomWithMiddle((this.state.start + this.state.end) / 2 + dis) : this._activeTag === DataZoomActiveTag.startHandler ? start + dis > end ? (start = end, end = start + dis, this._activeTag = DataZoomActiveTag.endHandler) : start += dis : this._activeTag === DataZoomActiveTag.endHandler && (end + dis < start ? (end = start, start = end + dis, this._activeTag = DataZoomActiveTag.startHandler) : end += dis), this._activeCache.lastPos = pos, brushSelect && this.renderDragMask()), start = Math.min(Math.max(start, 0), 1), end = Math.min(Math.max(end, 0), 1), startAttr === start && endAttr === end || this.setStateAttr(start, end, !0), realTime && this._dispatchEvent("change", {
37416
+ this._activeState && (this._activeTag === DataZoomActiveTag.middleHandler ? this.moveZoomWithMiddle((this.state.start + this.state.end) / 2 + dis) : this._activeTag === DataZoomActiveTag.startHandler ? start + dis > end ? (start = end, end = start + dis, this._activeTag = DataZoomActiveTag.endHandler) : start += dis : this._activeTag === DataZoomActiveTag.endHandler && (end + dis < start ? (end = start, start = end + dis, this._activeTag = DataZoomActiveTag.startHandler) : end += dis), this._activeCache.lastPos = pos, brushSelect && this.renderDragMask()), start = Math.min(Math.max(start, 0), 1), end = Math.min(Math.max(end, 0), 1), !realTime || startAttr === start && endAttr === end || (this.setStateAttr(start, end, !0), this._dispatchEvent("change", {
37449
37417
  start: start,
37450
37418
  end: end,
37451
37419
  tag: this._activeTag
37452
- });
37420
+ }));
37453
37421
  }, this._onHandlerPointerMove = 0 === this.attribute.delayTime ? this._pointerMove : delayMap$2[this.attribute.delayType](this._pointerMove, this.attribute.delayTime), this._onHandlerPointerUp = e => {
37454
37422
  e.preventDefault();
37455
37423
  const {
@@ -37462,11 +37430,11 @@
37462
37430
  const pos = this.eventPosToStagePos(e);
37463
37431
  this.backgroundDragZoom(this._activeCache.startPos, pos);
37464
37432
  }
37465
- this._activeState = !1, brushSelect && this.renderDragMask(), start === this.state.start && end === this.state.end || this.setStateAttr(this.state.start, this.state.end, !0), this._dispatchEvent("change", {
37433
+ this._activeState = !1, brushSelect && this.renderDragMask(), realTime && start === this.state.start && end === this.state.end || (this.setStateAttr(this.state.start, this.state.end, !0), this._dispatchEvent("change", {
37466
37434
  start: this.state.start,
37467
37435
  end: this.state.end,
37468
37436
  tag: this._activeTag
37469
- }), "browser" === vglobal.env && (vglobal.removeEventListener("pointermove", this._onHandlerPointerMove, {
37437
+ })), "browser" === vglobal.env && (vglobal.removeEventListener("pointermove", this._onHandlerPointerMove, {
37470
37438
  capture: !0
37471
37439
  }), vglobal.removeEventListener("pointerup", this._onHandlerPointerUp)), this.removeEventListener("pointermove", this._onHandlerPointerMove, {
37472
37440
  capture: !0
@@ -37674,7 +37642,7 @@
37674
37642
  } else this._isHorizontal ? this._startText.setAttribute("dy", startTextDy) : this._startText.setAttribute("dx", startTextDx);
37675
37643
  }
37676
37644
  getLayoutAttrFromConfig() {
37677
- var _a, _b, _c, _d, _e, _f;
37645
+ var _a, _b, _c, _d;
37678
37646
  if (this._layoutAttrFromConfig) return this._layoutAttrFromConfig;
37679
37647
  const {
37680
37648
  position: positionConfig,
@@ -37682,8 +37650,7 @@
37682
37650
  orient: orient,
37683
37651
  middleHandlerStyle = {},
37684
37652
  startHandlerStyle = {},
37685
- endHandlerStyle = {},
37686
- backgroundStyle = {}
37653
+ endHandlerStyle = {}
37687
37654
  } = this.attribute,
37688
37655
  {
37689
37656
  width: widthConfig,
@@ -37705,8 +37672,8 @@
37705
37672
  y: position.y
37706
37673
  }) : (height -= (startHandlerSize + endHandlerSize) / 2, position = {
37707
37674
  x: position.x,
37708
- y: position.y + startHandlerSize / 2
37709
- })), height += null !== (_e = backgroundStyle.lineWidth / 2) && void 0 !== _e ? _e : 1, width += null !== (_f = backgroundStyle.lineWidth / 2) && void 0 !== _f ? _f : 1, this._layoutAttrFromConfig = {
37675
+ y: position.y + startHandlerSize
37676
+ })), this._layoutAttrFromConfig = {
37710
37677
  position: position,
37711
37678
  width: width,
37712
37679
  height: height
@@ -37920,14 +37887,11 @@
37920
37887
  };
37921
37888
  }
37922
37889
  getPreviewLinePoints() {
37923
- var _a;
37924
- let previewPoints = this._previewData.map(d => ({
37890
+ const previewPoints = this._previewData.map(d => ({
37925
37891
  x: this._previewPointsX && this._previewPointsX(d),
37926
37892
  y: this._previewPointsY && this._previewPointsY(d)
37927
37893
  }));
37928
37894
  if (0 === previewPoints.length) return previewPoints;
37929
- const tolerance = null !== (_a = this.attribute.tolerance) && void 0 !== _a ? _a : this._previewData.length > 1e4 ? this._previewData.length / 1e4 : this._previewData.length;
37930
- previewPoints = flatten_simplify(previewPoints, tolerance, !1);
37931
37895
  const {
37932
37896
  basePointStart: basePointStart,
37933
37897
  basePointEnd: basePointEnd
@@ -37935,16 +37899,13 @@
37935
37899
  return basePointStart.concat(previewPoints).concat(basePointEnd);
37936
37900
  }
37937
37901
  getPreviewAreaPoints() {
37938
- var _a;
37939
- let previewPoints = this._previewData.map(d => ({
37902
+ const previewPoints = this._previewData.map(d => ({
37940
37903
  x: this._previewPointsX && this._previewPointsX(d),
37941
37904
  y: this._previewPointsY && this._previewPointsY(d),
37942
37905
  x1: this._previewPointsX1 && this._previewPointsX1(d),
37943
37906
  y1: this._previewPointsY1 && this._previewPointsY1(d)
37944
37907
  }));
37945
37908
  if (0 === previewPoints.length) return previewPoints;
37946
- const tolerance = null !== (_a = this.attribute.tolerance) && void 0 !== _a ? _a : this._previewData.length > 1e4 ? this._previewData.length / 1e4 : this._previewData.length;
37947
- previewPoints = flatten_simplify(previewPoints, tolerance, !1);
37948
37909
  const {
37949
37910
  basePointStart: basePointStart,
37950
37911
  basePointEnd: basePointEnd
@@ -57933,6 +57894,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
57933
57894
  if (stateStyle.referer) {
57934
57895
  return stateStyle.referer._computeAttribute(key, state);
57935
57896
  }
57897
+ if (!stateStyle.style) {
57898
+ return (datum, opt) => stateStyle.style;
57899
+ }
57936
57900
  if (typeof stateStyle.style === 'function') {
57937
57901
  return (datum, opt) => stateStyle.style(datum, this._attributeContext, opt, this.getDataView());
57938
57902
  }
@@ -59952,7 +59916,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
59952
59916
  registerChartPlugin(MediaQuery);
59953
59917
  };
59954
59918
 
59955
- const version = "1.9.6-alpha.1";
59919
+ const version = "1.9.6-alpha.3";
59956
59920
 
59957
59921
  const addVChartProperty = (data, op) => {
59958
59922
  const context = op.beforeCall();
@@ -66357,19 +66321,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
66357
66321
  if (newDomain.length === 0) {
66358
66322
  return [];
66359
66323
  }
66360
- const domainMap = {};
66361
- newDomain.forEach(d => {
66362
- if (!domainMap[d]) {
66363
- domainMap[d] = 1;
66364
- }
66365
- });
66366
66324
  let filter = null;
66367
66325
  if (isContinuous()) {
66368
66326
  filter = (d) => d[datumField] >= newDomain[0] && d[datumField] <= newDomain[1];
66369
66327
  }
66370
66328
  else {
66371
66329
  filter = (d) => {
66372
- return domainMap[d[datumField] + ''] || domainMap[d[datumField]];
66330
+ return newDomain.indexOf(d[datumField] + '') >= 0 || newDomain.indexOf(d[datumField]) >= 0;
66373
66331
  };
66374
66332
  }
66375
66333
  return data.filter(filter);
@@ -82404,7 +82362,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
82404
82362
  : null;
82405
82363
  }
82406
82364
  _delegateAxisContainerEvent(component) {
82407
- component.addEventListener('*', ((event, type) => this._delegateEvent(component, event, type)));
82365
+ if (component.listenerCount('*') === 0) {
82366
+ component.addEventListener('*', ((event, type) => this._delegateEvent(component, event, type)));
82367
+ }
82408
82368
  }
82409
82369
  _getAxisAttributes() {
82410
82370
  const spec = this._spec;
@@ -85945,14 +85905,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
85945
85905
  });
85946
85906
  };
85947
85907
  this._getMouseOutHandler = (needPointerDetection) => (params) => {
85948
- var _a, _b;
85908
+ var _a, _b, _c;
85949
85909
  if (this._alwaysShow) {
85950
85910
  return;
85951
85911
  }
85952
85912
  if (!this._isTooltipShown && !((_b = (_a = this.tooltipHandler) === null || _a === void 0 ? void 0 : _a.isTooltipShown) === null || _b === void 0 ? void 0 : _b.call(_a))) {
85953
85913
  return;
85954
85914
  }
85955
- const browserEnv = isTrueBrowser(this._option.mode);
85915
+ const browserEnv = isTrueBrowser((_c = this._option) === null || _c === void 0 ? void 0 : _c.mode);
85956
85916
  const { clientX, clientY } = params.event;
85957
85917
  if (browserEnv && this._isPointerOnTooltip(params)) {
85958
85918
  return;
@@ -86009,6 +85969,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
86009
85969
  }
86010
85970
  };
86011
85971
  this._showTooltipByMouseEvent = (activeType, mouseEventData, params, useCache) => {
85972
+ var _a;
86012
85973
  const processor = this._processor[activeType];
86013
85974
  if (!processor.shouldHandleTooltip(params, {
86014
85975
  tooltipInfo: mouseEventData.tooltipInfo[activeType],
@@ -86032,8 +85993,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
86032
85993
  if (success) {
86033
85994
  this._isTooltipShown = true;
86034
85995
  }
86035
- const vchart = this._option.globalInstance;
86036
- if (success && VChart.globalConfig.uniqueTooltip) {
85996
+ const vchart = (_a = this._option) === null || _a === void 0 ? void 0 : _a.globalInstance;
85997
+ if (success && VChart.globalConfig.uniqueTooltip && vchart) {
86037
85998
  VChart.hideTooltip(vchart.id);
86038
85999
  }
86039
86000
  return success;
@@ -86287,7 +86248,11 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
86287
86248
  prevParams.datum === nextParams.datum);
86288
86249
  }
86289
86250
  _isPointerInChart(point) {
86290
- const globalInstance = this._option.globalInstance;
86251
+ var _a;
86252
+ const globalInstance = (_a = this._option) === null || _a === void 0 ? void 0 : _a.globalInstance;
86253
+ if (!globalInstance) {
86254
+ return false;
86255
+ }
86291
86256
  const chart = globalInstance.getChart();
86292
86257
  if (!chart) {
86293
86258
  return false;
@@ -87650,27 +87615,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87650
87615
  get orient() {
87651
87616
  return this._orient;
87652
87617
  }
87653
- get isHorizontal() {
87654
- return this._isHorizontal;
87655
- }
87656
- get stateScale() {
87657
- return this._stateScale;
87658
- }
87659
- get relatedAxisComponent() {
87660
- return this._relatedAxisComponent;
87661
- }
87662
- get state() {
87663
- return {
87664
- start: this._start,
87665
- end: this._end,
87666
- startValue: this._startValue,
87667
- endValue: this._endValue
87668
- };
87669
- }
87670
87618
  setStartAndEnd(start, end, rangeMode = ['percent', 'percent']) {
87671
87619
  const [startMode = 'percent', endMode = 'percent'] = rangeMode;
87672
- const startPercent = (startMode === 'percent' ? start : this.dataToStatePoint(start));
87673
- const endPercent = (endMode === 'percent' ? end : this.dataToStatePoint(end));
87620
+ const startPercent = (startMode === 'percent' ? start : this._dataToStatePoint(start));
87621
+ const endPercent = (endMode === 'percent' ? end : this._dataToStatePoint(end));
87674
87622
  this._handleChange(startPercent, endPercent, true);
87675
87623
  }
87676
87624
  enableInteraction() {
@@ -87696,7 +87644,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87696
87644
  _handleChange(start, end, updateComponent) {
87697
87645
  var _a, _b;
87698
87646
  const zoomLock = (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.zoomLock) !== null && _b !== void 0 ? _b : false;
87699
- if (zoomLock) {
87647
+ if (zoomLock || end - start < this._minSpan || end - start > this._maxSpan) {
87700
87648
  this._shouldChange = false;
87701
87649
  }
87702
87650
  }
@@ -87970,9 +87918,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
87970
87918
  this._handleChange(this._start, this._end, true);
87971
87919
  }
87972
87920
  _computeDomainOfStateScale(isContinuous) {
87973
- if (this._spec.customDomain) {
87974
- return this._spec.customDomain;
87975
- }
87976
87921
  const domain = this._data.getLatestData().map((d) => d[this._stateField]);
87977
87922
  if (isContinuous) {
87978
87923
  const domainNum = domain.map((n) => n * 1);
@@ -88095,23 +88040,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
88095
88040
  }
88096
88041
  _statePointToData(state) {
88097
88042
  const scale = this._stateScale;
88098
- const domain = scale.domain();
88099
- if (isContinuous(scale.type)) {
88100
- if (this._isReverse()) {
88101
- return domain[0] + (domain[1] - domain[0]) * (1 - state);
88102
- }
88103
- return domain[0] + (domain[1] - domain[0]) * state;
88104
- }
88105
88043
  let range = scale.range();
88106
88044
  if (this._isReverse()) {
88107
88045
  range = range.slice().reverse();
88108
88046
  }
88109
88047
  const posInRange = range[0] + (range[1] - range[0]) * state;
88110
- const bandSize = scale.bandwidth();
88111
- const domainIndex = Math.min(Math.max(0, Math.floor(posInRange / bandSize)), domain.length - 1);
88112
- return domain[domainIndex];
88048
+ return scale.invert(posInRange);
88113
88049
  }
88114
- dataToStatePoint(data) {
88050
+ _dataToStatePoint(data) {
88115
88051
  const scale = this._stateScale;
88116
88052
  const pos = scale.scale(data);
88117
88053
  let range = scale.range();
@@ -88134,17 +88070,17 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
88134
88070
  if (this._spec.rangeMode) {
88135
88071
  const [startMode, endMode] = this._spec.rangeMode;
88136
88072
  if (this._modeCheck('start', startMode) && this._modeCheck('end', endMode)) {
88137
- start = startMode === 'percent' ? this._spec.start : this.dataToStatePoint(this._spec.startValue);
88138
- end = endMode === 'percent' ? this._spec.end : this.dataToStatePoint(this._spec.endValue);
88073
+ start = startMode === 'percent' ? this._spec.start : this._dataToStatePoint(this._spec.startValue);
88074
+ end = endMode === 'percent' ? this._spec.end : this._dataToStatePoint(this._spec.endValue);
88139
88075
  }
88140
88076
  }
88141
88077
  else {
88142
88078
  start = this._spec.start
88143
88079
  ? this._spec.start
88144
88080
  : this._spec.startValue
88145
- ? this.dataToStatePoint(this._spec.startValue)
88081
+ ? this._dataToStatePoint(this._spec.startValue)
88146
88082
  : 0;
88147
- end = this._spec.end ? this._spec.end : this._spec.endValue ? this.dataToStatePoint(this._spec.endValue) : 1;
88083
+ end = this._spec.end ? this._spec.end : this._spec.endValue ? this._dataToStatePoint(this._spec.endValue) : 1;
88148
88084
  }
88149
88085
  this._startValue = this._statePointToData(start);
88150
88086
  this._endValue = this._statePointToData(end);
@@ -88185,11 +88121,11 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
88185
88121
  .range(defaultRange);
88186
88122
  }
88187
88123
  else {
88188
- this._stateScale.domain(domain, true).range(defaultRange).padding(0);
88124
+ this._stateScale.domain(domain, true).range(defaultRange);
88189
88125
  }
88190
88126
  }
88191
88127
  else {
88192
- this._stateScale = new BandScale().padding(0);
88128
+ this._stateScale = new BandScale();
88193
88129
  this._stateScale.domain(this._computeDomainOfStateScale(), true).range(defaultRange);
88194
88130
  }
88195
88131
  }
@@ -88448,7 +88384,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
88448
88384
  this.layoutZIndex = exports.LayoutZIndex.DataZoom;
88449
88385
  this.layoutLevel = exports.LayoutLevel.DataZoom;
88450
88386
  this.layoutType = 'region-relative';
88451
- this._isReverseCache = false;
88452
88387
  this._dataToPositionX = (datum) => {
88453
88388
  const offsetLeft = this._orient === 'left' ? this._middleHandlerSize : 0;
88454
88389
  const offsetHandler = this._isHorizontal ? this._startHandlerSize / 2 : 0;
@@ -88516,10 +88451,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
88516
88451
  }
88517
88452
  onLayoutEnd(ctx) {
88518
88453
  this._updateScaleRange();
88519
- if (this._isReverse() && !this._isReverseCache) {
88520
- this._isReverseCache = this._isReverse();
88521
- this.effect.onZoomChange();
88522
- }
88523
88454
  if (this._cacheVisibility !== false) {
88524
88455
  super.onLayoutEnd(ctx);
88525
88456
  }
@@ -88542,28 +88473,19 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
88542
88473
  const defaultSize = this._isHorizontal
88543
88474
  ? this.getLayoutRect().width - handlerSize
88544
88475
  : this.getLayoutRect().height - handlerSize;
88545
- const defaultRange = (_b = (_a = this._relatedAxisComponent) === null || _a === void 0 ? void 0 : _a.getScale().range()) !== null && _b !== void 0 ? _b : [
88546
- this._startHandlerSize / 2,
88547
- defaultSize - this._endHandlerSize / 2
88548
- ];
88476
+ const defaultRange = (_b = (_a = this._relatedAxisComponent) === null || _a === void 0 ? void 0 : _a.getScale().range()) !== null && _b !== void 0 ? _b : [0, defaultSize];
88549
88477
  if (this._isHorizontal) {
88550
- stateScaleRange = this._visible
88551
- ? [this._startHandlerSize / 2, this._computeWidth() - this._endHandlerSize / 2]
88552
- : defaultRange;
88478
+ stateScaleRange = this._visible ? [0, this._computeWidth() - handlerSize] : defaultRange;
88553
88479
  this._stateScale.range(stateScaleRange);
88554
88480
  this._valueScale.range([this._computeHeight() - this._middleHandlerSize, 0]);
88555
88481
  }
88556
88482
  else if (this.layoutOrient === 'left') {
88557
- stateScaleRange = this._visible
88558
- ? [this._startHandlerSize / 2, this._computeHeight() - this._endHandlerSize / 2]
88559
- : defaultRange;
88483
+ stateScaleRange = this._visible ? [0, this._computeHeight() - handlerSize] : defaultRange;
88560
88484
  this._stateScale.range(stateScaleRange);
88561
88485
  this._valueScale.range([this._computeWidth() - this._middleHandlerSize, 0]);
88562
88486
  }
88563
88487
  else {
88564
- stateScaleRange = this._visible
88565
- ? [this._startHandlerSize / 2, this._computeHeight() - this._endHandlerSize / 2]
88566
- : defaultRange;
88488
+ stateScaleRange = this._visible ? [0, this._computeHeight() - handlerSize] : defaultRange;
88567
88489
  this._stateScale.range(stateScaleRange);
88568
88490
  this._valueScale.range([0, this._computeWidth() - this._middleHandlerSize]);
88569
88491
  }
@@ -88641,7 +88563,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
88641
88563
  }, orient: this._orient, size: {
88642
88564
  width: this.getLayoutRect().width,
88643
88565
  height: this.getLayoutRect().height
88644
- }, showDetail: spec.showDetail, brushSelect: (_b = spec.brushSelect) !== null && _b !== void 0 ? _b : false, zoomLock: (_c = spec.zoomLock) !== null && _c !== void 0 ? _c : false, minSpan: this._minSpan, maxSpan: this._maxSpan, delayType: spec.delayType, delayTime: isValid$3(spec.delayType) ? (_d = spec.delayTime) !== null && _d !== void 0 ? _d : 30 : 0, realTime: (_e = spec.realTime) !== null && _e !== void 0 ? _e : true, previewData: isNeedPreview && this._data.getLatestData(), previewPointsX: isNeedPreview && this._dataToPositionX, previewPointsY: isNeedPreview && this._dataToPositionY, tolerance: this._spec.tolerance }, this._getComponentAttrs());
88566
+ }, showDetail: spec.showDetail, brushSelect: (_b = spec.brushSelect) !== null && _b !== void 0 ? _b : false, zoomLock: (_c = spec.zoomLock) !== null && _c !== void 0 ? _c : false, minSpan: this._minSpan, maxSpan: this._maxSpan, delayType: spec.delayType, delayTime: isValid$3(spec.delayType) ? (_d = spec.delayTime) !== null && _d !== void 0 ? _d : 30 : 0, realTime: (_e = spec.realTime) !== null && _e !== void 0 ? _e : true, previewData: isNeedPreview && this._data.getLatestData(), previewPointsX: isNeedPreview && this._dataToPositionX, previewPointsY: isNeedPreview && this._dataToPositionY }, this._getComponentAttrs());
88645
88567
  }
88646
88568
  _createOrUpdateComponent() {
88647
88569
  if (this._visible) {
@@ -88679,11 +88601,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
88679
88601
  }
88680
88602
  this._start = start;
88681
88603
  this._end = end;
88682
- const startValue = this._statePointToData(start);
88683
- const endValue = this._statePointToData(end);
88684
- const hasChange = isFunction$1(this._spec.updateDataAfterChange)
88685
- ? this._spec.updateDataAfterChange(start, end, startValue, endValue)
88686
- : this._handleStateChange(startValue, endValue, tag);
88604
+ const hasChange = this._handleStateChange(this._statePointToData(start), this._statePointToData(end), tag);
88687
88605
  if (hasChange) {
88688
88606
  this.event.emit(exports.ChartEvent.dataZoomChange, {
88689
88607
  model: this,
@@ -88872,11 +88790,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
88872
88790
  }
88873
88791
  this._start = start;
88874
88792
  this._end = end;
88875
- const startValue = this._statePointToData(start);
88876
- const endValue = this._statePointToData(end);
88877
- const hasChange = isFunction$1(this._spec.updateDataAfterChange)
88878
- ? this._spec.updateDataAfterChange(start, end, startValue, endValue)
88879
- : this._handleStateChange(this._statePointToData(start), this._statePointToData(end));
88793
+ const hasChange = this._handleStateChange(this._statePointToData(start), this._statePointToData(end));
88880
88794
  if (hasChange) {
88881
88795
  this.event.emit(exports.ChartEvent.scrollBarChange, {
88882
88796
  model: this,
@@ -90957,6 +90871,11 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
90957
90871
  _getNeedClearVRenderComponents() {
90958
90872
  return [];
90959
90873
  }
90874
+ _delegateLabelEvent(component) {
90875
+ if (component.listenerCount('*') === 0) {
90876
+ component.addEventListener('*', ((event, type) => this._delegateEvent(component, event, type)));
90877
+ }
90878
+ }
90960
90879
  }
90961
90880
  BaseLabelComponent.type = ComponentTypeEnum.label;
90962
90881
 
@@ -91066,23 +90985,19 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91066
90985
  });
91067
90986
  this.event.off(exports.VGRAMMAR_HOOK_EVENT.AFTER_MARK_RENDER_END, enableAnimation);
91068
90987
  };
91069
- this.event.on('afterElementEncode', eventParams => {
91070
- var _a;
91071
- const mark = eventParams.item;
91072
- if (this._option.getChart().getLayoutTag() === false && ((_a = mark.getContext()) === null || _a === void 0 ? void 0 : _a.model) === this) {
91073
- this._delegateLabelEvent(mark.getGroupGraphicItem());
90988
+ }
90989
+ afterCompile() {
90990
+ this._labelComponentMap.forEach((info, component) => {
90991
+ const product = component.getProduct();
90992
+ if (product) {
90993
+ product.addEventListener(exports.VGRAMMAR_HOOK_EVENT.AFTER_ELEMENT_ENCODE, () => {
90994
+ if (this._isLayout === false) {
90995
+ this._delegateLabelEvent(product.getGroupGraphicItem());
90996
+ }
90997
+ });
91074
90998
  }
91075
90999
  });
91076
91000
  }
91077
- _delegateLabelEvent(component) {
91078
- const textNodes = component === null || component === void 0 ? void 0 : component.findAll(node => node.type === 'text', true).filter(text => !text.__vchart_event);
91079
- if (textNodes && textNodes.length > 0) {
91080
- textNodes.forEach(text => {
91081
- text.__vchart_event = true;
91082
- text.addEventListener('*', ((event, type) => this._delegateEvent(component, event, type, text, text.attribute.data)));
91083
- });
91084
- }
91085
- }
91086
91001
  _initTextMark() {
91087
91002
  if (!this._labelInfoMap) {
91088
91003
  this._labelInfoMap = new Map();
@@ -91335,6 +91250,18 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91335
91250
  this._marks.addMark(component);
91336
91251
  }
91337
91252
  }
91253
+ afterCompile() {
91254
+ this._marks.forEach((componentMark, index) => {
91255
+ const product = componentMark.getProduct();
91256
+ if (product) {
91257
+ product.addEventListener(exports.VGRAMMAR_HOOK_EVENT.AFTER_ELEMENT_ENCODE, () => {
91258
+ if (this._isLayout === false) {
91259
+ this._delegateLabelEvent(product.getGroupGraphicItem());
91260
+ }
91261
+ });
91262
+ }
91263
+ });
91264
+ }
91338
91265
  updateLayoutAttribute() {
91339
91266
  super.updateLayoutAttribute();
91340
91267
  const series = this._getSeries();
@@ -91593,7 +91520,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91593
91520
  this._needInitOutState = true;
91594
91521
  this._cacheInteractiveRangeAttrs = [];
91595
91522
  this._needDisablePickable = false;
91596
- this._relatedDataZooms = [];
91597
91523
  }
91598
91524
  init() {
91599
91525
  const inBrushMarkAttr = this._transformBrushedMarkAttr(this._spec.inBrush);
@@ -91626,14 +91552,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91626
91552
  this.initEvent();
91627
91553
  this._bindRegions();
91628
91554
  this._bindLinkedSeries();
91629
- this._bindDataZoom();
91630
91555
  this._initNeedOperatedItem();
91631
91556
  }
91632
91557
  _extendDataInBrush(elementsMap) {
91633
91558
  const data = [];
91634
91559
  for (const brushName in elementsMap) {
91635
91560
  for (const elementKey in elementsMap[brushName]) {
91636
- data.push(Object.assign(Object.assign({}, elementsMap[brushName][elementKey].data[0]), { getSeries: elementsMap[brushName][elementKey].getSeries }));
91561
+ data.push(elementsMap[brushName][elementKey].data[0]);
91637
91562
  }
91638
91563
  }
91639
91564
  return data;
@@ -91693,11 +91618,9 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91693
91618
  this._needInitOutState = false;
91694
91619
  this._needDisablePickable = true;
91695
91620
  this._handleBrushChange(exports.ChartEvent.brushChange, region, e);
91696
- this._emitEvent(exports.ChartEvent.brushChange, region);
91697
91621
  });
91698
91622
  brush.addEventListener(IOperateType.moving, (e) => {
91699
91623
  this._handleBrushChange(exports.ChartEvent.brushChange, region, e);
91700
- this._emitEvent(exports.ChartEvent.brushChange, region);
91701
91624
  });
91702
91625
  brush.addEventListener(IOperateType.brushClear, (e) => {
91703
91626
  this._initMarkBrushState(componentIndex, '');
@@ -91705,31 +91628,23 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91705
91628
  this._needDisablePickable = false;
91706
91629
  this._handleBrushChange(exports.ChartEvent.brushChange, region, e);
91707
91630
  this._handleBrushChange(exports.ChartEvent.brushClear, region, e);
91708
- this._emitEvent(exports.ChartEvent.brushChange, region);
91709
- this._emitEvent(exports.ChartEvent.brushClear, region);
91710
91631
  });
91711
91632
  brush.addEventListener(IOperateType.drawEnd, (e) => {
91712
91633
  this._needInitOutState = true;
91713
91634
  this._needDisablePickable = false;
91714
- const { operateMask } = e.detail;
91715
91635
  this._handleBrushChange(exports.ChartEvent.brushEnd, region, e);
91716
- this._setDataZoomState(operateMask, region);
91717
- this._emitEvent(exports.ChartEvent.brushEnd, region);
91718
91636
  });
91719
91637
  brush.addEventListener(IOperateType.moveEnd, (e) => {
91720
- const { operateMask } = e.detail;
91721
91638
  this._handleBrushChange(exports.ChartEvent.brushEnd, region, e);
91722
- this._setDataZoomState(operateMask, region);
91723
- this._emitEvent(exports.ChartEvent.brushEnd, region);
91724
91639
  });
91725
91640
  }
91726
91641
  _handleBrushChange(eventType, region, e) {
91727
91642
  const { operateMask } = e.detail;
91728
91643
  this._reconfigItem(operateMask, region);
91729
91644
  this._reconfigLinkedItem(operateMask, region);
91645
+ this._emitEvent(eventType, region);
91730
91646
  }
91731
91647
  _emitEvent(eventType, region) {
91732
- var _a;
91733
91648
  this.event.emit(eventType, {
91734
91649
  model: this,
91735
91650
  value: {
@@ -91742,8 +91657,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91742
91657
  inBrushElementsMap: this._inBrushElementsMap,
91743
91658
  outOfBrushElementsMap: this._outOfBrushElementsMap,
91744
91659
  linkedInBrushElementsMap: this._linkedInBrushElementsMap,
91745
- linkedOutOfBrushElementsMap: this._linkedOutOfBrushElementsMap,
91746
- releatedDataZoom: (_a = this._relatedDataZooms) !== null && _a !== void 0 ? _a : []
91660
+ linkedOutOfBrushElementsMap: this._linkedOutOfBrushElementsMap
91747
91661
  }
91748
91662
  });
91749
91663
  }
@@ -91772,7 +91686,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91772
91686
  const elements = grammarMark.elements;
91773
91687
  elements.forEach((el) => {
91774
91688
  var _a, _b, _c;
91775
- el.getSeries = mark.getSeries;
91776
91689
  const graphicItem = el.getGraphicItem();
91777
91690
  const elementKey = mark.id + '_' + el.key;
91778
91691
  if (((_a = this._outOfBrushElementsMap) === null || _a === void 0 ? void 0 : _a[elementKey]) && this._isBrushContainItem(operateMask, graphicItem)) {
@@ -91903,63 +91816,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91903
91816
  }
91904
91817
  return brushMask.globalAABBBounds.intersects(item.globalAABBBounds);
91905
91818
  }
91906
- _findValueInDataZoom(dataZoom, dataValue, type) {
91907
- const stateScale = dataZoom.stateScale;
91908
- if (isContinuous(stateScale.type)) {
91909
- return Math[type](...dataValue);
91910
- }
91911
- const domain = stateScale.domain();
91912
- const dataIndex = dataValue.map(d => d.indexOf(domain));
91913
- return domain[Math[type](...dataIndex)];
91914
- }
91915
- _setDataZoomComponent(dataZooms, region, operateMaskBounds, inBrushDataValue, isHorizontal) {
91916
- var _a;
91917
- const range = (_a = this._spec.dataZoomRangeExpand) !== null && _a !== void 0 ? _a : 0;
91918
- const { x1, x2, y1, y2 } = operateMaskBounds;
91919
- const regionStartAttr = isHorizontal ? 'x' : 'y';
91920
- const boundsStart = isHorizontal ? x1 : y1;
91921
- const boundsEnd = isHorizontal ? x2 : y2;
91922
- dataZooms.forEach((dz) => {
91923
- const startValue = dz.relatedAxisComponent && inBrushDataValue.length > 0
91924
- ? dz.relatedAxisComponent
91925
- .getScale()
91926
- .invert(boundsStart - region.getLayoutStartPoint()[regionStartAttr])
91927
- : this._findValueInDataZoom(dz, inBrushDataValue, 'min');
91928
- const endValue = dz.relatedAxisComponent && inBrushDataValue.length > 0
91929
- ? dz.relatedAxisComponent
91930
- .getScale()
91931
- .invert(boundsEnd - region.getLayoutStartPoint()[regionStartAttr])
91932
- : this._findValueInDataZoom(dz, inBrushDataValue, 'max');
91933
- const startPercent = dz.dataToStatePoint(startValue);
91934
- const endPercent = dz.dataToStatePoint(endValue);
91935
- dz.setStartAndEnd(Math.min(Math.max(0, startPercent - range), 1), Math.min(Math.max(0, endPercent + range), 1), [
91936
- 'percent',
91937
- 'percent'
91938
- ]);
91939
- });
91940
- }
91941
- _setDataZoomState(operateMask, region) {
91942
- const hDataZooms = [];
91943
- const vDataZooms = [];
91944
- this._relatedDataZooms.forEach(dz => {
91945
- if (dz.isHorizontal) {
91946
- hDataZooms.push(dz);
91947
- }
91948
- else {
91949
- vDataZooms.push(dz);
91950
- }
91951
- });
91952
- const operateMaskBounds = operateMask.AABBBounds;
91953
- const inBrushDataXValue = [];
91954
- const inBrushDataYValue = [];
91955
- this._extendDataInBrush(this._inBrushElementsMap).forEach(item => {
91956
- const spec = item.getSeries().getSpec();
91957
- inBrushDataXValue.push(item[array(spec.xField)[0]]);
91958
- inBrushDataYValue.push(item[array(spec.yField)[0]]);
91959
- });
91960
- this._setDataZoomComponent(hDataZooms, region, operateMaskBounds, inBrushDataXValue, true);
91961
- this._setDataZoomComponent(vDataZooms, region, operateMaskBounds, inBrushDataYValue, false);
91962
- }
91963
91819
  _bindRegions() {
91964
91820
  if (isValid$3(this._spec.regionId) && isValid$3(this._spec.regionIndex)) {
91965
91821
  this._relativeRegions = this._option.getAllRegions();
@@ -91972,18 +91828,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91972
91828
  }
91973
91829
  this._linkedSeries = this._option.getSeriesInUserIdOrIndex(array(this._spec.brushLinkSeriesId), array(this._spec.brushLinkSeriesIndex));
91974
91830
  }
91975
- _bindDataZoom() {
91976
- if (this._spec.dataZoomId) {
91977
- array(this._spec.dataZoomId).forEach((dataZoomId) => {
91978
- this._relatedDataZooms.push(this._option.getComponentByUserId(dataZoomId));
91979
- });
91980
- }
91981
- if (this._spec.dataZoomIndex) {
91982
- array(this._spec.dataZoomIndex).forEach((dataZoomIndex) => {
91983
- this._relatedDataZooms.push(this._option.getComponentByIndex('dataZoom', dataZoomIndex));
91984
- });
91985
- }
91986
- }
91987
91831
  _initNeedOperatedItem() {
91988
91832
  const seriesUserId = this._spec.seriesId;
91989
91833
  const seriesIndex = this._spec.seriesIndex;
@@ -91993,10 +91837,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
91993
91837
  if ((seriesUserId && array(seriesUserId).includes(s.userId.toString())) ||
91994
91838
  (seriesIndex && array(seriesIndex).includes(s.getSpecIndex())) ||
91995
91839
  (!seriesIndex && !seriesUserId)) {
91996
- allMarks.push(...s.getMarksWithoutRoot().map(mark => {
91997
- mark.getSeries = () => s;
91998
- return mark;
91999
- }));
91840
+ allMarks.push(...s.getMarksWithoutRoot());
92000
91841
  }
92001
91842
  this._itemMap[r.id] = allMarks;
92002
91843
  });