@visactor/react-vchart 2.0.23-alpha.6 → 2.0.23-alpha.8

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
@@ -47559,11 +47559,24 @@
47559
47559
  updateLayoutTag() {
47560
47560
  this._layoutState = LayoutState.before;
47561
47561
  }
47562
+ _isGeoRegionRoamDragEnabled() {
47563
+ var _a, _b;
47564
+ const chartSpec = null === (_b = null === (_a = this._compileChart) || void 0 === _a ? void 0 : _a.getSpec) || void 0 === _b ? void 0 : _b.call(_a),
47565
+ regions = null == chartSpec ? void 0 : chartSpec.region;
47566
+ return !!isArray$1(regions) && regions.some(region => {
47567
+ var _a;
47568
+ return !("geo" !== (null == region ? void 0 : region.coordinate) || !region.roam) && (!0 === region.roam || null === (_a = region.roam.drag) || void 0 === _a || _a);
47569
+ });
47570
+ }
47571
+ _shouldDisableCanvasTouchAction() {
47572
+ if (!isTrueBrowser(this._option.mode)) return !1;
47573
+ return !1 === (isValid$1(this._option.supportsTouchEvents) ? this._option.supportsTouchEvents : vglobal.supportsTouchEvents) && this._isGeoRegionRoamDragEnabled();
47574
+ }
47562
47575
  _setCanvasStyle() {
47563
47576
  if (this._stage && this._container.dom && !isString$1(this._container.dom)) {
47564
47577
  this._container.dom.style.display = "block", this._container.dom.style.position = "relative";
47565
47578
  const canvas = this.getCanvas();
47566
- canvas && (canvas.style.display = "block");
47579
+ canvas && (canvas.style.display = "block", canvas.style.touchAction = this._shouldDisableCanvasTouchAction() ? "none" : "");
47567
47580
  }
47568
47581
  }
47569
47582
  compile(ctx, option) {
@@ -47571,7 +47584,7 @@
47571
47584
  const {
47572
47585
  chart: chart
47573
47586
  } = ctx;
47574
- this._compileChart = chart, this.initView(), this._stage && ("render" !== (null == option ? void 0 : option.actionSource) && this._cachedMarks && (this.reuseOrMorphing(option.morphConfig), this._cachedMarks = null), chart.compile(), chart.afterCompile());
47587
+ this._compileChart = chart, this.initView(), this._stage && ("render" !== (null == option ? void 0 : option.actionSource) && this._cachedMarks && (this.reuseOrMorphing(option.morphConfig), this._cachedMarks = null), chart.compile(), this._setCanvasStyle(), chart.afterCompile());
47575
47588
  }
47576
47589
  clearNextRender() {
47577
47590
  return !!this._nextRafId && (vglobal.getSpecifiedCancelAnimationFrame(10)(this._nextRafId), this._nextRafId = null, !0);
@@ -54397,7 +54410,7 @@
54397
54410
  }), res), []) : null;
54398
54411
  }
54399
54412
  _runPointsEncoder(newStyles, g, attrs = {}) {
54400
- var _a, _b, _c;
54413
+ var _a, _b;
54401
54414
  const data = g.context.data,
54402
54415
  lineAttrs = [],
54403
54416
  points = [],
@@ -54410,7 +54423,7 @@
54410
54423
  this._isValidPointChannel(attrName) ? points[index][attrName] = newStyles[attrName](datum) : this._segmentStyleKeys.includes(attrName) && !progressive ? lineAttrs[index][attrName] = newStyles[attrName](datum) : 0 !== index || progressive && !isFirstFrame || (commonAttrs[attrName] = newStyles[attrName](datum));
54411
54424
  }), points[index].context = null !== (_a = this._keyGetter(datum)) && void 0 !== _a ? _a : index;
54412
54425
  }), progressive) {
54413
- const segments = null !== (_c = null === (_b = g.attribute) || void 0 === _b ? void 0 : _b.segments) && void 0 !== _c ? _c : [];
54426
+ const segments = (null === (_b = g.attribute) || void 0 === _b ? void 0 : _b.segments) ? [...g.attribute.segments] : [];
54414
54427
  return segments.push({
54415
54428
  points: points
54416
54429
  }), isFirstFrame ? Object.assign(Object.assign({}, commonAttrs), {
@@ -62504,6 +62517,14 @@
62504
62517
  bandPosition: this._bandPosition
62505
62518
  }));
62506
62519
  }
62520
+ _isCategoryAxisInverse() {
62521
+ var _a, _b, _c, _e;
62522
+ return "horizontal" === this._direction ? null === (_b = null === (_a = this._yAxisHelper) || void 0 === _a ? void 0 : _a.isInverse) || void 0 === _b ? void 0 : _b.call(_a) : null === (_e = null === (_c = this._xAxisHelper) || void 0 === _c ? void 0 : _c.isInverse) || void 0 === _e ? void 0 : _e.call(_c);
62523
+ }
62524
+ _getLeaderLineCategoryPos(isStart, isDecrease) {
62525
+ const normalPos = isStart ? isDecrease ? 0 : 1 : isDecrease ? 1 : 0;
62526
+ return !!this._isCategoryAxisInverse() ? 1 - normalPos : normalPos;
62527
+ }
62507
62528
  initMarkStyle() {
62508
62529
  super.initMarkStyle();
62509
62530
  const isDecrease = "decrease" === this._spec.calculationMode;
@@ -62511,12 +62532,12 @@
62511
62532
  visible: datum => this.isVisibleLeaderLine(datum),
62512
62533
  x: datum => this.totalPositionX(datum, "lastEnd", 0),
62513
62534
  x1: datum => this.totalPositionX(datum, datum.isTotal ? "end" : "start", 0),
62514
- y: datum => datum.lastIndex ? this.totalPositionY(datum, "lastIndex", isDecrease ? 0 : 1) : 0,
62515
- y1: datum => this.totalPositionY(datum, "index", isDecrease ? 1 : 0)
62535
+ y: datum => datum.lastIndex ? this.totalPositionY(datum, "lastIndex", this._getLeaderLineCategoryPos(!0, isDecrease)) : 0,
62536
+ y1: datum => this.totalPositionY(datum, "index", this._getLeaderLineCategoryPos(!1, isDecrease))
62516
62537
  }, "normal", AttributeLevel.Series) : this.setMarkStyle(this._leaderLineMark, {
62517
62538
  visible: datum => this.isVisibleLeaderLine(datum),
62518
- x: datum => datum.lastIndex ? this.totalPositionX(datum, "lastIndex", isDecrease ? 0 : 1) : 0,
62519
- x1: datum => this.totalPositionX(datum, "index", isDecrease ? 1 : 0),
62539
+ x: datum => datum.lastIndex ? this.totalPositionX(datum, "lastIndex", this._getLeaderLineCategoryPos(!0, isDecrease)) : 0,
62540
+ x1: datum => this.totalPositionX(datum, "index", this._getLeaderLineCategoryPos(!1, isDecrease)),
62520
62541
  y: datum => this.totalPositionY(datum, "lastEnd", 0),
62521
62542
  y1: datum => this.totalPositionY(datum, datum.isTotal ? "end" : "start", 0)
62522
62543
  }, "normal", AttributeLevel.Series));
@@ -65081,10 +65102,9 @@
65081
65102
  fill: this.getColorAttribute(),
65082
65103
  outerRadius: datum => valueInScaleRange(this.radiusAxisHelper.dataToPosition([datum[this._radiusField[0]]]), this.radiusAxisHelper.getScale(0)),
65083
65104
  innerRadius: datum => {
65084
- var _a;
65085
- if (!this.getStack()) return 0;
65105
+ if (!this.getStack()) return this._computeLayoutRadius() * this._innerRadius;
65086
65106
  const stackStart = valueInScaleRange(this.radiusAxisHelper.dataToPosition([datum[this._innerRadiusField[0]]]), this.radiusAxisHelper.getScale(0));
65087
- return stackStart <= Number.MIN_VALUE ? this._computeLayoutRadius() * (null !== (_a = this._spec.innerRadius) && void 0 !== _a ? _a : 0) : stackStart;
65107
+ return stackStart <= Number.MIN_VALUE ? this._computeLayoutRadius() * this._innerRadius : stackStart;
65088
65108
  }
65089
65109
  });
65090
65110
  }
@@ -65103,10 +65123,7 @@
65103
65123
  const appearPreset = null === (_b = null === (_a = this._spec) || void 0 === _a ? void 0 : _a.animationAppear) || void 0 === _b ? void 0 : _b.preset;
65104
65124
  if (this._roseMark) {
65105
65125
  const animationParams = {
65106
- innerRadius: () => {
65107
- var _a;
65108
- return this._computeLayoutRadius() * (null !== (_a = this._spec.innerRadius) && void 0 !== _a ? _a : 0);
65109
- }
65126
+ innerRadius: () => this._computeLayoutRadius() * this._innerRadius
65110
65127
  };
65111
65128
  this._roseMark.setAnimationConfig(animationConfig(null === (_c = Factory.getAnimationInKey("rose")) || void 0 === _c ? void 0 : _c(animationParams, appearPreset), userAnimationConfig("rose", this._spec, this._markAttributeContext)));
65112
65129
  }
@@ -77175,7 +77192,7 @@
77175
77192
  return [this._legendComponent];
77176
77193
  }
77177
77194
  clear() {
77178
- super.clear(), this._cacheAttrs = null, this._preSelectedData = null;
77195
+ super.clear(), this._legendComponent = null, this._cacheAttrs = null, this._preSelectedData = null;
77179
77196
  }
77180
77197
  }
77181
77198
  BaseLegend.specKey = "legends";
@@ -82123,7 +82140,7 @@
82123
82140
  };
82124
82141
  }
82125
82142
  _markerLayout() {
82126
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
82143
+ var _a, _b, _c, _d, _e;
82127
82144
  const updateAttrs = this._getUpdateMarkerAttrs();
82128
82145
  if ("type-step" === this._spec.type) {
82129
82146
  const startRelativeSeries = this._startRelativeSeries,
@@ -82133,26 +82150,9 @@
82133
82150
  mainSegmentIndex: mainSegmentIndex
82134
82151
  } = this._spec.line || {},
82135
82152
  {
82136
- connectDirection: connectDirection
82153
+ connectDirection: connectDirection,
82154
+ expandDistance = 0
82137
82155
  } = this._spec;
82138
- let {
82139
- expandDistance = 0
82140
- } = this._spec;
82141
- const {
82142
- points: points,
82143
- limitRect: limitRect
82144
- } = updateAttrs,
82145
- coordinatePoints = array(points).filter(Boolean);
82146
- if (isFunction$1(expandDistance)) {
82147
- const startRegion = null === (_a = null == startRelativeSeries ? void 0 : startRelativeSeries.getRegion) || void 0 === _a ? void 0 : _a.call(startRelativeSeries),
82148
- endRegion = null === (_b = null == endRelativeSeries ? void 0 : endRelativeSeries.getRegion) || void 0 === _b ? void 0 : _b.call(endRelativeSeries);
82149
- expandDistance = expandDistance(this._markerData, Object.assign(Object.assign({}, this.getMarkAttributeContext()), {
82150
- region: null === (_d = null === (_c = this._relativeSeries) || void 0 === _c ? void 0 : _c.getRegion) || void 0 === _d ? void 0 : _d.call(_c),
82151
- startRegion: startRegion,
82152
- endRegion: endRegion,
82153
- coordinatePoints: coordinatePoints
82154
- }));
82155
- }
82156
82156
  let expandDistanceValue;
82157
82157
  if (isPercent(expandDistance)) {
82158
82158
  const regionStart = startRelativeSeries.getRegion(),
@@ -82167,7 +82167,11 @@
82167
82167
  expandDistanceValue = Number(expandDistance.substring(0, expandDistance.length - 1)) * regionWidth / 100;
82168
82168
  }
82169
82169
  } else expandDistanceValue = expandDistance;
82170
- if (!points || points.length < 2) return void (null === (_e = this._markerComponent) || void 0 === _e || _e.setAttributes(updateAttrs));
82170
+ const {
82171
+ points: points,
82172
+ limitRect: limitRect
82173
+ } = updateAttrs;
82174
+ if (!points || points.length < 2) return void (null === (_a = this._markerComponent) || void 0 === _a || _a.setAttributes(updateAttrs));
82171
82175
  const joinPoints = getInsertPoints(points[0], points[1], connectDirection, expandDistanceValue);
82172
82176
  let labelPositionAttrs;
82173
82177
  labelPositionAttrs = multiSegment && isValid$1(mainSegmentIndex) ? {
@@ -82177,11 +82181,11 @@
82177
82181
  position: "start",
82178
82182
  autoRotate: !1
82179
82183
  }, getTextOffset(points[0], points[1], connectDirection, expandDistanceValue));
82180
- const markerComponentAttr = null !== (_g = null === (_f = this._markerComponent) || void 0 === _f ? void 0 : _f.attribute) && void 0 !== _g ? _g : {},
82184
+ const markerComponentAttr = null !== (_c = null === (_b = this._markerComponent) || void 0 === _b ? void 0 : _b.attribute) && void 0 !== _c ? _c : {},
82181
82185
  prevLabelAttrs = array(markerComponentAttr.label),
82182
82186
  updateLabels = array(updateAttrs.label),
82183
82187
  labelsInSpec = array(this._spec.label);
82184
- null === (_h = this._markerComponent) || void 0 === _h || _h.setAttributes({
82188
+ null === (_d = this._markerComponent) || void 0 === _d || _d.setAttributes({
82185
82189
  points: multiSegment ? [[joinPoints[0], joinPoints[1]], [joinPoints[1], joinPoints[2]], [joinPoints[2], joinPoints[3]]] : joinPoints,
82186
82190
  label: updateLabels.map((labelItem, index) => {
82187
82191
  var _a, _b, _c, _d;
@@ -82207,7 +82211,7 @@
82207
82211
  dx: this._layoutOffsetX,
82208
82212
  dy: this._layoutOffsetY
82209
82213
  });
82210
- } else null === (_j = this._markerComponent) || void 0 === _j || _j.setAttributes(updateAttrs);
82214
+ } else null === (_e = this._markerComponent) || void 0 === _e || _e.setAttributes(updateAttrs);
82211
82215
  }
82212
82216
  _computeOptions() {
82213
82217
  let options,