@visactor/react-vchart 2.0.20-alpha.4 → 2.0.20-alpha.5

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.
package/build/index.js CHANGED
@@ -38820,6 +38820,16 @@
38820
38820
  strokeBoundsBuffer: 0
38821
38821
  }
38822
38822
  };
38823
+ const LAYOUT_LEVEL = {
38824
+ background: 0,
38825
+ preview: 1,
38826
+ dragMask: 2,
38827
+ selectedBackground: 3,
38828
+ selectedPreview: 4,
38829
+ handler: 5,
38830
+ handlerText: 5,
38831
+ handlerMask: 999
38832
+ };
38823
38833
 
38824
38834
  const isTextOverflow = (componentBoundsLike, textBounds, layout, isHorizontal) => {
38825
38835
  if (!textBounds) return !1;
@@ -38950,12 +38960,14 @@
38950
38960
  x: position.x + start * width,
38951
38961
  y: position.y,
38952
38962
  width: (end - start) * width,
38953
- height: height
38963
+ height: height,
38964
+ zIndex: LAYOUT_LEVEL.dragMask
38954
38965
  }, dragMaskStyle), "rect") : this._dragMask = this._getContainer().createOrUpdateChild("dragMask", Object.assign({
38955
38966
  x: position.x,
38956
38967
  y: position.y + start * height,
38957
38968
  width: width,
38958
- height: (end - start) * height
38969
+ height: (end - start) * height,
38970
+ zIndex: LAYOUT_LEVEL.dragMask
38959
38971
  }, dragMaskStyle), "rect"), {
38960
38972
  start: start,
38961
38973
  end: end
@@ -38979,7 +38991,8 @@
38979
38991
  y: position.y,
38980
38992
  width: width,
38981
38993
  height: height,
38982
- cursor: brushSelect ? "crosshair" : "auto"
38994
+ cursor: brushSelect ? "crosshair" : "auto",
38995
+ zIndex: LAYOUT_LEVEL.background
38983
38996
  }, backgroundStyle), {
38984
38997
  pickable: !zoomLock && (null === (_a = backgroundStyle.pickable) || void 0 === _a || _a)
38985
38998
  }), "rect");
@@ -39012,7 +39025,8 @@
39012
39025
  x: position.x + start * width,
39013
39026
  y: position.y - middleHandlerBackgroundSize,
39014
39027
  width: (end - start) * width,
39015
- height: middleHandlerBackgroundSize
39028
+ height: middleHandlerBackgroundSize,
39029
+ zIndex: LAYOUT_LEVEL.handler
39016
39030
  }, null === (_d = middleHandlerStyle.background) || void 0 === _d ? void 0 : _d.style), {
39017
39031
  pickable: !zoomLock && (null === (_g = null === (_f = null === (_e = middleHandlerStyle.background) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.pickable) || void 0 === _g || _g)
39018
39032
  }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
@@ -39020,24 +39034,29 @@
39020
39034
  y: position.y - middleHandlerBackgroundSize / 2,
39021
39035
  strokeBoundsBuffer: 0,
39022
39036
  angle: 0,
39023
- symbolType: null !== (_j = null === (_h = middleHandlerStyle.icon) || void 0 === _h ? void 0 : _h.symbolType) && void 0 !== _j ? _j : "square"
39037
+ symbolType: null !== (_j = null === (_h = middleHandlerStyle.icon) || void 0 === _h ? void 0 : _h.symbolType) && void 0 !== _j ? _j : "square",
39038
+ zIndex: LAYOUT_LEVEL.handler
39024
39039
  }, middleHandlerStyle.icon), {
39025
39040
  pickable: !zoomLock && (null === (_k = middleHandlerStyle.icon.pickable) || void 0 === _k || _k)
39026
39041
  }), "symbol");
39027
39042
  }
39028
- this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
39043
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign(Object.assign({
39029
39044
  x: position.x + start * width,
39030
39045
  y: position.y + height / 2,
39031
39046
  size: height,
39032
39047
  symbolType: null !== (_l = startHandlerStyle.symbolType) && void 0 !== _l ? _l : "square"
39033
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), startHandlerStyle), {
39048
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
39049
+ zIndex: LAYOUT_LEVEL.handler
39050
+ }), startHandlerStyle), {
39034
39051
  pickable: !zoomLock && (null === (_m = startHandlerStyle.pickable) || void 0 === _m || _m)
39035
- }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
39052
+ }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign(Object.assign({
39036
39053
  x: position.x + end * width,
39037
39054
  y: position.y + height / 2,
39038
39055
  size: height,
39039
39056
  symbolType: null !== (_o = endHandlerStyle.symbolType) && void 0 !== _o ? _o : "square"
39040
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), endHandlerStyle), {
39057
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
39058
+ zIndex: LAYOUT_LEVEL.handler
39059
+ }), endHandlerStyle), {
39041
39060
  pickable: !zoomLock && (null === (_p = endHandlerStyle.pickable) || void 0 === _p || _p)
39042
39061
  }), "symbol");
39043
39062
  const startHandlerWidth = Math.max(this._startHandler.AABBBounds.width(), startHandlerMinSize),
@@ -39051,7 +39070,7 @@
39051
39070
  height: startHandlerHeight,
39052
39071
  fill: "white",
39053
39072
  fillOpacity: 0,
39054
- zIndex: 999
39073
+ zIndex: LAYOUT_LEVEL.handlerMask
39055
39074
  }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
39056
39075
  pickable: !zoomLock
39057
39076
  }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
@@ -39061,7 +39080,7 @@
39061
39080
  height: endHandlerHeight,
39062
39081
  fill: "white",
39063
39082
  fillOpacity: 0,
39064
- zIndex: 999
39083
+ zIndex: LAYOUT_LEVEL.handlerMask
39065
39084
  }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
39066
39085
  pickable: !zoomLock
39067
39086
  }), "rect");
@@ -39072,7 +39091,8 @@
39072
39091
  x: "left" === orient ? position.x - middleHandlerBackgroundSize : position.x + width,
39073
39092
  y: position.y + start * height,
39074
39093
  width: middleHandlerBackgroundSize,
39075
- height: (end - start) * height
39094
+ height: (end - start) * height,
39095
+ zIndex: LAYOUT_LEVEL.handler
39076
39096
  }, null === (_r = middleHandlerStyle.background) || void 0 === _r ? void 0 : _r.style), {
39077
39097
  pickable: !zoomLock && (null === (_u = null === (_t = null === (_s = middleHandlerStyle.background) || void 0 === _s ? void 0 : _s.style) || void 0 === _t ? void 0 : _t.pickable) || void 0 === _u || _u)
39078
39098
  }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
@@ -39080,23 +39100,27 @@
39080
39100
  y: position.y + (start + end) / 2 * height,
39081
39101
  angle: Math.PI / 180 * 90,
39082
39102
  symbolType: null !== (_w = null === (_v = middleHandlerStyle.icon) || void 0 === _v ? void 0 : _v.symbolType) && void 0 !== _w ? _w : "square",
39083
- strokeBoundsBuffer: 0
39103
+ strokeBoundsBuffer: 0,
39104
+ zIndex: LAYOUT_LEVEL.handler
39084
39105
  }, middleHandlerStyle.icon), {
39085
39106
  pickable: !zoomLock && (null === (_y = null === (_x = middleHandlerStyle.icon) || void 0 === _x ? void 0 : _x.pickable) || void 0 === _y || _y)
39086
39107
  }), "symbol");
39087
39108
  }
39088
- this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
39109
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign(Object.assign({
39089
39110
  x: position.x + width / 2,
39090
39111
  y: position.y + start * height,
39091
39112
  size: width,
39092
39113
  symbolType: null !== (_z = startHandlerStyle.symbolType) && void 0 !== _z ? _z : "square"
39093
- }, DEFAULT_HANDLER_ATTR_MAP.vertical), startHandlerStyle), {
39114
+ }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
39115
+ zIndex: LAYOUT_LEVEL.handler
39116
+ }), startHandlerStyle), {
39094
39117
  pickable: !zoomLock && (null === (_0 = startHandlerStyle.pickable) || void 0 === _0 || _0)
39095
39118
  }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
39096
39119
  x: position.x + width / 2,
39097
39120
  y: position.y + end * height,
39098
39121
  size: width,
39099
- symbolType: null !== (_1 = endHandlerStyle.symbolType) && void 0 !== _1 ? _1 : "square"
39122
+ symbolType: null !== (_1 = endHandlerStyle.symbolType) && void 0 !== _1 ? _1 : "square",
39123
+ zIndex: LAYOUT_LEVEL.handler
39100
39124
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), endHandlerStyle), {
39101
39125
  pickable: !zoomLock && (null === (_2 = endHandlerStyle.pickable) || void 0 === _2 || _2)
39102
39126
  }), "symbol");
@@ -39111,7 +39135,7 @@
39111
39135
  height: endHandlerWidth,
39112
39136
  fill: "white",
39113
39137
  fillOpacity: 0,
39114
- zIndex: 999
39138
+ zIndex: LAYOUT_LEVEL.handlerMask
39115
39139
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
39116
39140
  pickable: !zoomLock
39117
39141
  }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
@@ -39121,7 +39145,7 @@
39121
39145
  height: endHandlerWidth,
39122
39146
  fill: "white",
39123
39147
  fillOpacity: 0,
39124
- zIndex: 999
39148
+ zIndex: LAYOUT_LEVEL.handlerMask
39125
39149
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
39126
39150
  pickable: !zoomLock
39127
39151
  }), "rect");
@@ -39150,7 +39174,8 @@
39150
39174
  y: position.y,
39151
39175
  width: (end - start) * width,
39152
39176
  height: height,
39153
- cursor: brushSelect ? "crosshair" : "move"
39177
+ cursor: brushSelect ? "crosshair" : "move",
39178
+ zIndex: LAYOUT_LEVEL.selectedBackground
39154
39179
  }, selectedBackgroundStyle), {
39155
39180
  pickable: !zoomLock && (null === (_a = selectedBackgroundChartStyle.pickable) || void 0 === _a || _a)
39156
39181
  }), "rect") : this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
@@ -39158,14 +39183,16 @@
39158
39183
  y: position.y + start * height,
39159
39184
  width: width,
39160
39185
  height: (end - start) * height,
39161
- cursor: brushSelect ? "crosshair" : "move"
39186
+ cursor: brushSelect ? "crosshair" : "move",
39187
+ zIndex: LAYOUT_LEVEL.selectedBackground
39162
39188
  }, selectedBackgroundStyle), {
39163
39189
  pickable: !zoomLock && (null === (_b = selectedBackgroundStyle.pickable) || void 0 === _b || _b)
39164
39190
  }), "rect");
39165
39191
  }
39166
39192
  _setPreviewAttributes(type, group) {
39167
39193
  this._previewGroup || (this._previewGroup = group.createOrUpdateChild("previewGroup", {
39168
- pickable: !1
39194
+ pickable: !1,
39195
+ zIndex: LAYOUT_LEVEL.preview
39169
39196
  }, "group")), "line" === type ? this._previewLine = this._previewGroup.createOrUpdateChild("previewLine", {}, "line") : this._previewArea = this._previewGroup.createOrUpdateChild("previewArea", {
39170
39197
  curveType: "basis"
39171
39198
  }, "area");
@@ -39184,7 +39211,8 @@
39184
39211
  }
39185
39212
  _setSelectedPreviewClipAttributes(type, group) {
39186
39213
  this._selectedPreviewGroupClip || (this._selectedPreviewGroupClip = group.createOrUpdateChild("selectedPreviewGroupClip", {
39187
- pickable: !1
39214
+ pickable: !1,
39215
+ zIndex: LAYOUT_LEVEL.selectedPreview
39188
39216
  }, "group"), this._selectedPreviewGroup = this._selectedPreviewGroupClip.createOrUpdateChild("selectedPreviewGroup", {}, "group"));
39189
39217
  const {
39190
39218
  start: start,
@@ -80147,7 +80175,7 @@
80147
80175
  }
80148
80176
  }
80149
80177
  _handleDataCollectionChange() {
80150
- this._data.getDataView().reRunAllTransform();
80178
+ this._data.getDataView().reRunAllTransform(), this._initAfterLayout();
80151
80179
  const domain = this._computeDomainOfValueScale();
80152
80180
  domain && (this._valueScale || (this._valueScale = new LinearScale()), this._valueScale.domain(domain), this._updateValueScaleRange(), this._component && this._createOrUpdateComponent(!0));
80153
80181
  }
@@ -80298,9 +80326,7 @@
80298
80326
  }
80299
80327
  _createOrUpdateComponent(changeData) {
80300
80328
  if (this._visible) {
80301
- const xScale = this._isHorizontal ? this._stateScale : this._valueScale,
80302
- yScale = this._isHorizontal ? this._valueScale : this._stateScale,
80303
- isNeedPreview = this._isScaleValid(xScale) && this._isScaleValid(yScale) && !1 !== this._spec.showBackgroundChart,
80329
+ const isNeedPreview = !1 !== this._spec.showBackgroundChart,
80304
80330
  attrs = this._getAttrs(isNeedPreview),
80305
80331
  axis = this._relatedAxisComponent;
80306
80332
  if (this._component) this._component.setAttributes(attrs), changeData && (this._component.setPreviewData(this._data.getDataView().latestData), isNeedPreview && (this._isHorizontal ? this._component.setPreviewPointsY1(this._dataToPositionY2) : this._component.setPreviewPointsX1(this._dataToPositionX2), this._component.setStatePointToData(state => statePointToData(state, this._stateScale, isReverse(axis, this._isHorizontal)))));else {
@@ -80450,10 +80476,8 @@
80450
80476
  const isSameScrollValue = isClose(this._start, start) && isClose(this._end, end);
80451
80477
  if (this._shouldChange && (!isSameScrollValue || !1 === this._spec.realTime)) {
80452
80478
  updateComponent && this._component && this._component.setAttribute("range", [start, end]), this._start = start, this._end = end;
80453
- const axis = this._relatedAxisComponent,
80454
- reverse = isReverse(axis, this._isHorizontal),
80455
- startValue = statePointToData(start, this._stateScale, reverse),
80456
- endValue = statePointToData(end, this._stateScale, reverse);
80479
+ const startValue = statePointToData(start, this._stateScale, !1),
80480
+ endValue = statePointToData(end, this._stateScale, !1);
80457
80481
  (isFunction$1(this._spec.updateDataAfterChange) ? this._spec.updateDataAfterChange(start, end, startValue, endValue) : this._handleStateChange(startValue, endValue)) && this.event.emit(ChartEvent.scrollBarChange, {
80458
80482
  model: this,
80459
80483
  value: {
@@ -84091,15 +84115,23 @@
84091
84115
  y2: y2
84092
84116
  } = operateMaskBounds,
84093
84117
  regionStartAttr = isHorizontal ? "x" : "y",
84094
- regionSizeAttr = isHorizontal ? "width" : "height",
84095
84118
  boundsStart = isHorizontal ? x1 : y1,
84096
- boundsEnd = isHorizontal ? x2 : y2;
84119
+ boundsEnd = isHorizontal ? x2 : y2,
84120
+ range = axis.getScale().range(),
84121
+ rangeFactor = null !== (_b = axis.scaleRangeFactor()) && void 0 !== _b ? _b : [0, 1],
84122
+ isAxisReverse = last(range) < range[0],
84123
+ startPosTemp = boundsStart - region.getLayoutStartPoint()[regionStartAttr],
84124
+ endPosTemp = boundsEnd - region.getLayoutStartPoint()[regionStartAttr],
84125
+ endPos = isAxisReverse ? Math.min(startPosTemp, endPosTemp) : Math.max(startPosTemp, endPosTemp),
84126
+ startPos = isAxisReverse ? Math.max(startPosTemp, endPosTemp) : Math.min(startPosTemp, endPosTemp),
84127
+ start = (startPos - range[0]) / (last(range) - range[0]) * (rangeFactor[1] - rangeFactor[0]) + rangeFactor[0],
84128
+ end = (endPos - range[0]) / (last(range) - range[0]) * (rangeFactor[1] - rangeFactor[0]) + rangeFactor[0],
84129
+ newStart = this._stateClamp(start - axisRangeExpand),
84130
+ newEnd = this._stateClamp(end + axisRangeExpand);
84097
84131
  if (this._axisDataZoomMap[axis.id]) {
84098
84132
  const dataZoom = this._axisDataZoomMap[axis.id],
84099
- startPercent = (boundsStart - region.getLayoutStartPoint()[regionStartAttr]) / region.getLayoutRect()[regionSizeAttr],
84100
- endPercent = (boundsEnd - region.getLayoutStartPoint()[regionStartAttr]) / region.getLayoutRect()[regionSizeAttr],
84101
- newStartPercent = this._stateClamp(startPercent - axisRangeExpand),
84102
- newEndPercent = this._stateClamp(endPercent + axisRangeExpand);
84133
+ newStartPercent = isAxisReverse ? 1 - newStart : newStart,
84134
+ newEndPercent = isAxisReverse ? 1 - newEnd : newEnd;
84103
84135
  dataZoom.setStartAndEnd(Math.min(newStartPercent, newEndPercent), Math.max(newStartPercent, newEndPercent), ["percent", "percent"]), this._zoomRecord.push({
84104
84136
  operateComponent: dataZoom,
84105
84137
  start: newStartPercent,
@@ -84107,26 +84139,13 @@
84107
84139
  startValue: statePointToData(newStartPercent, dataZoom.stateScale, isReverse(dataZoom.relatedAxisComponent, dataZoom.isHorizontal)),
84108
84140
  endValue: statePointToData(newEndPercent, dataZoom.stateScale, isReverse(dataZoom.relatedAxisComponent, dataZoom.isHorizontal))
84109
84141
  });
84110
- } else {
84111
- const range = axis.getScale().range(),
84112
- rangeFactor = null !== (_b = axis.scaleRangeFactor()) && void 0 !== _b ? _b : [0, 1],
84113
- isAxisReverse = last(range) < range[0],
84114
- startPosTemp = boundsStart - region.getLayoutStartPoint()[regionStartAttr],
84115
- endPosTemp = boundsEnd - region.getLayoutStartPoint()[regionStartAttr],
84116
- endPos = isAxisReverse ? Math.min(startPosTemp, endPosTemp) : Math.max(startPosTemp, endPosTemp),
84117
- startPos = isAxisReverse ? Math.max(startPosTemp, endPosTemp) : Math.min(startPosTemp, endPosTemp),
84118
- start = (startPos - range[0]) / (last(range) - range[0]) * (rangeFactor[1] - rangeFactor[0]) + rangeFactor[0],
84119
- end = (endPos - range[0]) / (last(range) - range[0]) * (rangeFactor[1] - rangeFactor[0]) + rangeFactor[0],
84120
- newStart = this._stateClamp(start - axisRangeExpand),
84121
- newEnd = this._stateClamp(end + axisRangeExpand);
84122
- axis.scaleRangeFactor([newStart, newEnd]), axis.effect.scaleUpdate(), this._zoomRecord.push({
84123
- operateComponent: axis,
84124
- start: newStart,
84125
- end: newEnd,
84126
- startValue: axis.getScale().invert(startPos),
84127
- endValue: axis.getScale().invert(endPos)
84128
- });
84129
- }
84142
+ } else axis.scaleRangeFactor([newStart, newEnd]), axis.effect.scaleUpdate(), this._zoomRecord.push({
84143
+ operateComponent: axis,
84144
+ start: newStart,
84145
+ end: newEnd,
84146
+ startValue: axis.getScale().invert(startPos),
84147
+ endValue: axis.getScale().invert(endPos)
84148
+ });
84130
84149
  });
84131
84150
  }
84132
84151
  }