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

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,16 +38820,6 @@
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
- };
38833
38823
 
38834
38824
  const isTextOverflow = (componentBoundsLike, textBounds, layout, isHorizontal) => {
38835
38825
  if (!textBounds) return !1;
@@ -38960,14 +38950,12 @@
38960
38950
  x: position.x + start * width,
38961
38951
  y: position.y,
38962
38952
  width: (end - start) * width,
38963
- height: height,
38964
- zIndex: LAYOUT_LEVEL.dragMask
38953
+ height: height
38965
38954
  }, dragMaskStyle), "rect") : this._dragMask = this._getContainer().createOrUpdateChild("dragMask", Object.assign({
38966
38955
  x: position.x,
38967
38956
  y: position.y + start * height,
38968
38957
  width: width,
38969
- height: (end - start) * height,
38970
- zIndex: LAYOUT_LEVEL.dragMask
38958
+ height: (end - start) * height
38971
38959
  }, dragMaskStyle), "rect"), {
38972
38960
  start: start,
38973
38961
  end: end
@@ -38991,8 +38979,7 @@
38991
38979
  y: position.y,
38992
38980
  width: width,
38993
38981
  height: height,
38994
- cursor: brushSelect ? "crosshair" : "auto",
38995
- zIndex: LAYOUT_LEVEL.background
38982
+ cursor: brushSelect ? "crosshair" : "auto"
38996
38983
  }, backgroundStyle), {
38997
38984
  pickable: !zoomLock && (null === (_a = backgroundStyle.pickable) || void 0 === _a || _a)
38998
38985
  }), "rect");
@@ -39025,8 +39012,7 @@
39025
39012
  x: position.x + start * width,
39026
39013
  y: position.y - middleHandlerBackgroundSize,
39027
39014
  width: (end - start) * width,
39028
- height: middleHandlerBackgroundSize,
39029
- zIndex: LAYOUT_LEVEL.handler
39015
+ height: middleHandlerBackgroundSize
39030
39016
  }, null === (_d = middleHandlerStyle.background) || void 0 === _d ? void 0 : _d.style), {
39031
39017
  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)
39032
39018
  }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
@@ -39034,29 +39020,24 @@
39034
39020
  y: position.y - middleHandlerBackgroundSize / 2,
39035
39021
  strokeBoundsBuffer: 0,
39036
39022
  angle: 0,
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
39023
+ symbolType: null !== (_j = null === (_h = middleHandlerStyle.icon) || void 0 === _h ? void 0 : _h.symbolType) && void 0 !== _j ? _j : "square"
39039
39024
  }, middleHandlerStyle.icon), {
39040
39025
  pickable: !zoomLock && (null === (_k = middleHandlerStyle.icon.pickable) || void 0 === _k || _k)
39041
39026
  }), "symbol");
39042
39027
  }
39043
- this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign(Object.assign({
39028
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
39044
39029
  x: position.x + start * width,
39045
39030
  y: position.y + height / 2,
39046
39031
  size: height,
39047
39032
  symbolType: null !== (_l = startHandlerStyle.symbolType) && void 0 !== _l ? _l : "square"
39048
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
39049
- zIndex: LAYOUT_LEVEL.handler
39050
- }), startHandlerStyle), {
39033
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), startHandlerStyle), {
39051
39034
  pickable: !zoomLock && (null === (_m = startHandlerStyle.pickable) || void 0 === _m || _m)
39052
- }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign(Object.assign({
39035
+ }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
39053
39036
  x: position.x + end * width,
39054
39037
  y: position.y + height / 2,
39055
39038
  size: height,
39056
39039
  symbolType: null !== (_o = endHandlerStyle.symbolType) && void 0 !== _o ? _o : "square"
39057
- }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
39058
- zIndex: LAYOUT_LEVEL.handler
39059
- }), endHandlerStyle), {
39040
+ }, DEFAULT_HANDLER_ATTR_MAP.horizontal), endHandlerStyle), {
39060
39041
  pickable: !zoomLock && (null === (_p = endHandlerStyle.pickable) || void 0 === _p || _p)
39061
39042
  }), "symbol");
39062
39043
  const startHandlerWidth = Math.max(this._startHandler.AABBBounds.width(), startHandlerMinSize),
@@ -39070,7 +39051,7 @@
39070
39051
  height: startHandlerHeight,
39071
39052
  fill: "white",
39072
39053
  fillOpacity: 0,
39073
- zIndex: LAYOUT_LEVEL.handlerMask
39054
+ zIndex: 999
39074
39055
  }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
39075
39056
  pickable: !zoomLock
39076
39057
  }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
@@ -39080,7 +39061,7 @@
39080
39061
  height: endHandlerHeight,
39081
39062
  fill: "white",
39082
39063
  fillOpacity: 0,
39083
- zIndex: LAYOUT_LEVEL.handlerMask
39064
+ zIndex: 999
39084
39065
  }, DEFAULT_HANDLER_ATTR_MAP.horizontal), {
39085
39066
  pickable: !zoomLock
39086
39067
  }), "rect");
@@ -39091,8 +39072,7 @@
39091
39072
  x: "left" === orient ? position.x - middleHandlerBackgroundSize : position.x + width,
39092
39073
  y: position.y + start * height,
39093
39074
  width: middleHandlerBackgroundSize,
39094
- height: (end - start) * height,
39095
- zIndex: LAYOUT_LEVEL.handler
39075
+ height: (end - start) * height
39096
39076
  }, null === (_r = middleHandlerStyle.background) || void 0 === _r ? void 0 : _r.style), {
39097
39077
  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)
39098
39078
  }), "rect"), this._middleHandlerSymbol = group.createOrUpdateChild("middleHandlerSymbol", Object.assign(Object.assign({
@@ -39100,27 +39080,23 @@
39100
39080
  y: position.y + (start + end) / 2 * height,
39101
39081
  angle: Math.PI / 180 * 90,
39102
39082
  symbolType: null !== (_w = null === (_v = middleHandlerStyle.icon) || void 0 === _v ? void 0 : _v.symbolType) && void 0 !== _w ? _w : "square",
39103
- strokeBoundsBuffer: 0,
39104
- zIndex: LAYOUT_LEVEL.handler
39083
+ strokeBoundsBuffer: 0
39105
39084
  }, middleHandlerStyle.icon), {
39106
39085
  pickable: !zoomLock && (null === (_y = null === (_x = middleHandlerStyle.icon) || void 0 === _x ? void 0 : _x.pickable) || void 0 === _y || _y)
39107
39086
  }), "symbol");
39108
39087
  }
39109
- this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign(Object.assign({
39088
+ this._startHandler = group.createOrUpdateChild("startHandler", Object.assign(Object.assign(Object.assign({
39110
39089
  x: position.x + width / 2,
39111
39090
  y: position.y + start * height,
39112
39091
  size: width,
39113
39092
  symbolType: null !== (_z = startHandlerStyle.symbolType) && void 0 !== _z ? _z : "square"
39114
- }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
39115
- zIndex: LAYOUT_LEVEL.handler
39116
- }), startHandlerStyle), {
39093
+ }, DEFAULT_HANDLER_ATTR_MAP.vertical), startHandlerStyle), {
39117
39094
  pickable: !zoomLock && (null === (_0 = startHandlerStyle.pickable) || void 0 === _0 || _0)
39118
39095
  }), "symbol"), this._endHandler = group.createOrUpdateChild("endHandler", Object.assign(Object.assign(Object.assign({
39119
39096
  x: position.x + width / 2,
39120
39097
  y: position.y + end * height,
39121
39098
  size: width,
39122
- symbolType: null !== (_1 = endHandlerStyle.symbolType) && void 0 !== _1 ? _1 : "square",
39123
- zIndex: LAYOUT_LEVEL.handler
39099
+ symbolType: null !== (_1 = endHandlerStyle.symbolType) && void 0 !== _1 ? _1 : "square"
39124
39100
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), endHandlerStyle), {
39125
39101
  pickable: !zoomLock && (null === (_2 = endHandlerStyle.pickable) || void 0 === _2 || _2)
39126
39102
  }), "symbol");
@@ -39135,7 +39111,7 @@
39135
39111
  height: endHandlerWidth,
39136
39112
  fill: "white",
39137
39113
  fillOpacity: 0,
39138
- zIndex: LAYOUT_LEVEL.handlerMask
39114
+ zIndex: 999
39139
39115
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
39140
39116
  pickable: !zoomLock
39141
39117
  }), "rect"), this._endHandlerMask = group.createOrUpdateChild("endHandlerMask", Object.assign(Object.assign({
@@ -39145,7 +39121,7 @@
39145
39121
  height: endHandlerWidth,
39146
39122
  fill: "white",
39147
39123
  fillOpacity: 0,
39148
- zIndex: LAYOUT_LEVEL.handlerMask
39124
+ zIndex: 999
39149
39125
  }, DEFAULT_HANDLER_ATTR_MAP.vertical), {
39150
39126
  pickable: !zoomLock
39151
39127
  }), "rect");
@@ -39174,8 +39150,7 @@
39174
39150
  y: position.y,
39175
39151
  width: (end - start) * width,
39176
39152
  height: height,
39177
- cursor: brushSelect ? "crosshair" : "move",
39178
- zIndex: LAYOUT_LEVEL.selectedBackground
39153
+ cursor: brushSelect ? "crosshair" : "move"
39179
39154
  }, selectedBackgroundStyle), {
39180
39155
  pickable: !zoomLock && (null === (_a = selectedBackgroundChartStyle.pickable) || void 0 === _a || _a)
39181
39156
  }), "rect") : this._selectedBackground = group.createOrUpdateChild("selectedBackground", Object.assign(Object.assign({
@@ -39183,16 +39158,14 @@
39183
39158
  y: position.y + start * height,
39184
39159
  width: width,
39185
39160
  height: (end - start) * height,
39186
- cursor: brushSelect ? "crosshair" : "move",
39187
- zIndex: LAYOUT_LEVEL.selectedBackground
39161
+ cursor: brushSelect ? "crosshair" : "move"
39188
39162
  }, selectedBackgroundStyle), {
39189
39163
  pickable: !zoomLock && (null === (_b = selectedBackgroundStyle.pickable) || void 0 === _b || _b)
39190
39164
  }), "rect");
39191
39165
  }
39192
39166
  _setPreviewAttributes(type, group) {
39193
39167
  this._previewGroup || (this._previewGroup = group.createOrUpdateChild("previewGroup", {
39194
- pickable: !1,
39195
- zIndex: LAYOUT_LEVEL.preview
39168
+ pickable: !1
39196
39169
  }, "group")), "line" === type ? this._previewLine = this._previewGroup.createOrUpdateChild("previewLine", {}, "line") : this._previewArea = this._previewGroup.createOrUpdateChild("previewArea", {
39197
39170
  curveType: "basis"
39198
39171
  }, "area");
@@ -39211,8 +39184,7 @@
39211
39184
  }
39212
39185
  _setSelectedPreviewClipAttributes(type, group) {
39213
39186
  this._selectedPreviewGroupClip || (this._selectedPreviewGroupClip = group.createOrUpdateChild("selectedPreviewGroupClip", {
39214
- pickable: !1,
39215
- zIndex: LAYOUT_LEVEL.selectedPreview
39187
+ pickable: !1
39216
39188
  }, "group"), this._selectedPreviewGroup = this._selectedPreviewGroupClip.createOrUpdateChild("selectedPreviewGroup", {}, "group"));
39217
39189
  const {
39218
39190
  start: start,
@@ -49918,11 +49890,11 @@
49918
49890
  this._lastMark = mark;
49919
49891
  }
49920
49892
  reuse(mark) {
49921
- this.type === mark.type && (this._product = mark.getProduct(), this._product.clearStates(), this._graphics = mark.getGraphics(), this._graphics.forEach(g => {
49893
+ this.type === mark.type && (this._product = mark.getProduct(), this._product && (this._product.clearStates(), this._graphics = mark.getGraphics(), this._graphics.forEach(g => {
49922
49894
  g.clearStates();
49923
49895
  }), this._graphicMap = mark._graphicMap, this._graphicMap.forEach(g => {
49924
49896
  g.context = Object.assign(Object.assign({}, g.context), this._getCommonContext());
49925
- }), this._dataByKey = mark._dataByKey, this._prevDataByKey = mark._prevDataByKey, this.needClear = mark.needClear);
49897
+ }), this._dataByKey = mark._dataByKey, this._prevDataByKey = mark._prevDataByKey, this.needClear = mark.needClear));
49926
49898
  }
49927
49899
  _parseProgressiveContext(data) {
49928
49900
  const enableProgressive = this._markConfig.progressiveStep > 0 && this._markConfig.progressiveThreshold > 0 && this._markConfig.progressiveStep < this._markConfig.progressiveThreshold,
@@ -80175,7 +80147,7 @@
80175
80147
  }
80176
80148
  }
80177
80149
  _handleDataCollectionChange() {
80178
- this._data.getDataView().reRunAllTransform(), this._initAfterLayout();
80150
+ this._data.getDataView().reRunAllTransform();
80179
80151
  const domain = this._computeDomainOfValueScale();
80180
80152
  domain && (this._valueScale || (this._valueScale = new LinearScale()), this._valueScale.domain(domain), this._updateValueScaleRange(), this._component && this._createOrUpdateComponent(!0));
80181
80153
  }
@@ -80326,7 +80298,9 @@
80326
80298
  }
80327
80299
  _createOrUpdateComponent(changeData) {
80328
80300
  if (this._visible) {
80329
- const isNeedPreview = !1 !== this._spec.showBackgroundChart,
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,
80330
80304
  attrs = this._getAttrs(isNeedPreview),
80331
80305
  axis = this._relatedAxisComponent;
80332
80306
  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 {
@@ -80476,8 +80450,10 @@
80476
80450
  const isSameScrollValue = isClose(this._start, start) && isClose(this._end, end);
80477
80451
  if (this._shouldChange && (!isSameScrollValue || !1 === this._spec.realTime)) {
80478
80452
  updateComponent && this._component && this._component.setAttribute("range", [start, end]), this._start = start, this._end = end;
80479
- const startValue = statePointToData(start, this._stateScale, !1),
80480
- endValue = statePointToData(end, this._stateScale, !1);
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);
80481
80457
  (isFunction$1(this._spec.updateDataAfterChange) ? this._spec.updateDataAfterChange(start, end, startValue, endValue) : this._handleStateChange(startValue, endValue)) && this.event.emit(ChartEvent.scrollBarChange, {
80482
80458
  model: this,
80483
80459
  value: {
@@ -84115,23 +84091,15 @@
84115
84091
  y2: y2
84116
84092
  } = operateMaskBounds,
84117
84093
  regionStartAttr = isHorizontal ? "x" : "y",
84094
+ regionSizeAttr = isHorizontal ? "width" : "height",
84118
84095
  boundsStart = isHorizontal ? x1 : y1,
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);
84096
+ boundsEnd = isHorizontal ? x2 : y2;
84131
84097
  if (this._axisDataZoomMap[axis.id]) {
84132
84098
  const dataZoom = this._axisDataZoomMap[axis.id],
84133
- newStartPercent = isAxisReverse ? 1 - newStart : newStart,
84134
- newEndPercent = isAxisReverse ? 1 - newEnd : newEnd;
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);
84135
84103
  dataZoom.setStartAndEnd(Math.min(newStartPercent, newEndPercent), Math.max(newStartPercent, newEndPercent), ["percent", "percent"]), this._zoomRecord.push({
84136
84104
  operateComponent: dataZoom,
84137
84105
  start: newStartPercent,
@@ -84139,13 +84107,26 @@
84139
84107
  startValue: statePointToData(newStartPercent, dataZoom.stateScale, isReverse(dataZoom.relatedAxisComponent, dataZoom.isHorizontal)),
84140
84108
  endValue: statePointToData(newEndPercent, dataZoom.stateScale, isReverse(dataZoom.relatedAxisComponent, dataZoom.isHorizontal))
84141
84109
  });
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
- });
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
+ }
84149
84130
  });
84150
84131
  }
84151
84132
  }