@visactor/react-vchart 2.0.22-alpha.2 → 2.0.22-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.
package/build/index.js CHANGED
@@ -9936,9 +9936,7 @@
9936
9936
  background: null,
9937
9937
  autoAnimateTexture: !1,
9938
9938
  textureRatio: 1,
9939
- textureOptions: {
9940
- alignToGraphic: !0
9941
- },
9939
+ textureOptions: null,
9942
9940
  backgroundOpacity: 1,
9943
9941
  backgroundCornerRadius: 0,
9944
9942
  texture: null,
@@ -14573,7 +14571,6 @@
14573
14571
  const tempConstantXYKey = ["x", "y"],
14574
14572
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
14575
14573
  tempConstantAngleKey = ["angle"],
14576
- builtinTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave"]),
14577
14574
  point = new Point();
14578
14575
  const NOWORK_ANIMATE_ATTR = {
14579
14576
  strokeSeg: 1,
@@ -14630,7 +14627,7 @@
14630
14627
  }
14631
14628
  constructor(params = {}) {
14632
14629
  var _a;
14633
- super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0), isExternalTexture(params.texture) ? this.loadImage(params.texture, !1) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
14630
+ super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
14634
14631
  }
14635
14632
  getGraphicService() {
14636
14633
  var _a, _b;
@@ -14819,7 +14816,7 @@
14819
14816
  });
14820
14817
  }
14821
14818
  setAttributes(params, forceUpdateTag = !1, context) {
14822
- params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0), isExternalTexture(params.texture) ? this.loadImage(params.texture, !1) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
14819
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
14823
14820
  }
14824
14821
  _setAttributes(params, forceUpdateTag = !1, context) {
14825
14822
  const keys = Object.keys(params);
@@ -14834,7 +14831,7 @@
14834
14831
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
14835
14832
  [key]: value
14836
14833
  }, this.attribute, key, context);
14837
- params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
14834
+ params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "shadowGraphic" === key && this.setShadowGraphic(value);
14838
14835
  }
14839
14836
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
14840
14837
  for (let i = 0; i < k.length; i++) {
@@ -14853,7 +14850,7 @@
14853
14850
  const context = {
14854
14851
  type: AttributeUpdateType.INIT
14855
14852
  };
14856
- params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background && this.loadImage(params.background, !0), isExternalTexture(params.texture) ? this.loadImage(params.texture, !1) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
14853
+ params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
14857
14854
  }
14858
14855
  translate(x, y) {
14859
14856
  var _a, _b;
@@ -15244,9 +15241,6 @@
15244
15241
  function backgroundNotImage(image) {
15245
15242
  return "string" == typeof image ? !(image.startsWith("<svg") || isValidUrl$1(image) || image.includes("/") || isBase64$1(image)) : !(!image.fill && !image.stroke) || !("string" != typeof image.gradient || !Array.isArray(image.stops));
15246
15243
  }
15247
- function isExternalTexture(texture) {
15248
- return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$2(texture));
15249
- }
15250
15244
  Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
15251
15245
 
15252
15246
  var GroupUpdateAABBBoundsMode;
@@ -19011,43 +19005,38 @@
19011
19005
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
19012
19006
  }
19013
19007
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
19014
- var _a, _b, _c, _d, _e, _f;
19008
+ var _a;
19015
19009
  const {
19016
19010
  textureRatio = graphicAttribute.textureRatio,
19017
19011
  textureOptions = null
19018
19012
  } = graphic.attribute;
19019
- let pattern = null;
19020
- const textureRadius = null !== (_a = null == textureOptions ? void 0 : textureOptions.radius) && void 0 !== _a ? _a : 0,
19021
- patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr, textureRadius);
19022
- if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
19023
- if ("string" == typeof texture) switch (texture) {
19024
- case "circle":
19025
- pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
19026
- break;
19027
- case "diamond":
19028
- pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
19029
- break;
19030
- case "rect":
19031
- pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
19032
- break;
19033
- case "vertical-line":
19034
- pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
19035
- break;
19036
- case "horizontal-line":
19037
- pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
19038
- break;
19039
- case "bias-lr":
19040
- pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
19041
- break;
19042
- case "bias-rl":
19043
- pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
19044
- break;
19045
- case "grid":
19046
- pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
19047
- }
19048
- pattern || (pattern = this.createResourcePattern(texture, graphic, context, texturePadding, textureRadius)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
19013
+ let pattern = this.textureMap.get(texture);
19014
+ if (!pattern) switch (texture) {
19015
+ case "circle":
19016
+ pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
19017
+ break;
19018
+ case "diamond":
19019
+ pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
19020
+ break;
19021
+ case "rect":
19022
+ pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
19023
+ break;
19024
+ case "vertical-line":
19025
+ pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
19026
+ break;
19027
+ case "horizontal-line":
19028
+ pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
19029
+ break;
19030
+ case "bias-lr":
19031
+ pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
19032
+ break;
19033
+ case "bias-rl":
19034
+ pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
19035
+ break;
19036
+ case "grid":
19037
+ pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
19049
19038
  }
19050
- if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
19039
+ if (textureOptions && textureOptions.dynamicTexture) {
19051
19040
  const {
19052
19041
  gridConfig = {},
19053
19042
  useNewCanvas: useNewCanvas
@@ -19092,24 +19081,10 @@
19092
19081
  for (let i = 0; i < gridRows; i++) for (let j = 0; j < gridColumns; j++) {
19093
19082
  const _x = x + cellSize / 2 + j * cellSize,
19094
19083
  _y = y + cellSize / 2 + i * cellSize;
19095
- null === (_b = textureOptions.beforeDynamicTexture) || void 0 === _b || _b.call(textureOptions, context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height()), context.beginPath(), !1 === parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) && context.closePath(), context.fillStyle = textureColor, textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height());
19084
+ null === (_a = textureOptions.beforeDynamicTexture) || void 0 === _a || _a.call(textureOptions, context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height()), context.beginPath(), !1 === parsedPath.draw(context, Math.min(sizeW - gutterColumn, sizeH - gutterRow), _x, _y, 0) && context.closePath(), context.fillStyle = textureColor, textureOptions.dynamicTexture(context, i, j, gridRows, gridColumns, textureRatio, graphic, b.width(), b.height());
19096
19085
  }
19097
19086
  useNewCanvas && (originalContext.globalAlpha = 1, originalContext.drawImage(newCanvas.nativeCanvas, 0, 0, newCanvas.nativeCanvas.width, newCanvas.nativeCanvas.height, b.x1, b.y1, b.width() * originalContext.dpr, b.height() * originalContext.dpr)), originalContext.restore();
19098
- } else if (pattern) {
19099
- if (pattern.setTransform) {
19100
- const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
19101
- alignOffsetX = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _c ? _c : 0,
19102
- alignOffsetY = null !== (_d = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _d ? _d : 0;
19103
- let translateX = 0,
19104
- translateY = 0;
19105
- if (alignToGraphic) {
19106
- const m = context.currentMatrix;
19107
- translateX = (null !== (_e = null == m ? void 0 : m.e) && void 0 !== _e ? _e : 0) + x + alignOffsetX, translateY = (null !== (_f = null == m ? void 0 : m.f) && void 0 !== _f ? _f : 0) + y + alignOffsetY;
19108
- } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
19109
- pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
19110
- }
19111
- context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
19112
- } else if ("wave" === texture) {
19087
+ } else if (pattern) context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();else if ("wave" === texture) {
19113
19088
  context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.clip();
19114
19089
  const b = graphic.AABBBounds;
19115
19090
  drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
@@ -19117,45 +19092,6 @@
19117
19092
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
19118
19093
  }
19119
19094
  }
19120
- getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr, textureRadius) {
19121
- return "string" != typeof texture ? texturePadding > 0 || textureRadius > 0 ? null : texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
19122
- }
19123
- createResourcePattern(texture, graphic, context, texturePadding, textureRadius) {
19124
- var _a;
19125
- const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
19126
- data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
19127
- if (!data) return null;
19128
- if (texturePadding > 0 || textureRadius > 0) {
19129
- const w = data.naturalWidth || data.width,
19130
- h = data.naturalHeight || data.height;
19131
- if (w > 0 && h > 0) {
19132
- const tileW = w + 2 * texturePadding,
19133
- tileH = h + 2 * texturePadding,
19134
- canvas = canvasAllocate.allocate({
19135
- width: tileW,
19136
- height: tileH,
19137
- dpr: context.dpr
19138
- }),
19139
- ctx = canvas.getContext("2d");
19140
- if (ctx) {
19141
- if (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, tileW, tileH), textureRadius > 0) {
19142
- const r = Math.max(0, Math.min(textureRadius, Math.min(w, h) / 2)),
19143
- x0 = texturePadding,
19144
- y0 = texturePadding,
19145
- x1 = x0 + w,
19146
- y1 = y0 + h;
19147
- ctx.beginPath(), ctx.moveTo(x0 + r, y0), ctx.lineTo(x1 - r, y0), ctx.quadraticCurveTo(x1, y0, x1, y0 + r), ctx.lineTo(x1, y1 - r), ctx.quadraticCurveTo(x1, y1, x1 - r, y1), ctx.lineTo(x0 + r, y1), ctx.quadraticCurveTo(x0, y1, x0, y1 - r), ctx.lineTo(x0, y0 + r), ctx.quadraticCurveTo(x0, y0, x0 + r, y0), ctx.closePath(), ctx.clip();
19148
- }
19149
- ctx.drawImage(data, texturePadding, texturePadding, w, h);
19150
- const pattern = context.createPattern(canvas.nativeCanvas, "repeat");
19151
- return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), canvasAllocate.free(canvas), pattern;
19152
- }
19153
- canvasAllocate.free(canvas);
19154
- }
19155
- }
19156
- const pattern = context.createPattern(data, "repeat");
19157
- return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
19158
- }
19159
19095
  }
19160
19096
  const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();
19161
19097
 
@@ -63384,21 +63320,21 @@
63384
63320
  super.init(option), this.initBoxPlotMarkStyle();
63385
63321
  }
63386
63322
  _getMarkWidth() {
63387
- var _a;
63323
+ var _a, _b;
63388
63324
  if (this._autoBoxWidth) return this._autoBoxWidth;
63389
63325
  const bandAxisHelper = "horizontal" === this._direction ? this._yAxisHelper : this._xAxisHelper,
63390
63326
  depthFromSpec = this._groups ? this._groups.fields.length : 1,
63391
- bandWidth = null === (_a = bandAxisHelper.getBandwidth) || void 0 === _a ? void 0 : _a.call(bandAxisHelper, depthFromSpec - 1);
63327
+ bandWidth = null !== (_b = null === (_a = bandAxisHelper.getBandwidth) || void 0 === _a ? void 0 : _a.call(bandAxisHelper, depthFromSpec - 1)) && void 0 !== _b ? _b : Math.max(this._boxWidth, this._shaftWidth);
63392
63328
  let width = bandWidth;
63393
63329
  return isValid$1(this._spec.boxWidth) && (width = getActualNumValue(this._spec.boxWidth, bandWidth)), isValid$1(this._spec.boxMinWidth) && (width = Math.max(width, getActualNumValue(this._spec.boxMinWidth, bandWidth))), isValid$1(this._spec.boxMaxWidth) && (width = Math.min(width, getActualNumValue(this._spec.boxMaxWidth, bandWidth))), this._autoBoxWidth = width, this._autoBoxWidth;
63394
63330
  }
63395
63331
  _getPosition(direction, datum) {
63396
- var _a, _b, _c, _d;
63332
+ var _a, _b, _c, _d, _e, _f;
63397
63333
  let axisHelper, sizeAttribute, dataToPosition;
63398
63334
  "horizontal" === direction ? (axisHelper = this.getYAxisHelper(), sizeAttribute = "boxHeight", dataToPosition = this.dataToPositionY.bind(this)) : (axisHelper = this.getXAxisHelper(), sizeAttribute = "boxWidth", dataToPosition = this.dataToPositionX.bind(this));
63399
63335
  const scale = axisHelper.getScale(0),
63400
63336
  depth = this._groups ? this._groups.fields.length : 1,
63401
- bandWidth = null === (_a = axisHelper.getBandwidth) || void 0 === _a ? void 0 : _a.call(axisHelper, depth - 1),
63337
+ bandWidth = null !== (_b = null === (_a = axisHelper.getBandwidth) || void 0 === _a ? void 0 : _a.call(axisHelper, depth - 1)) && void 0 !== _b ? _b : Math.max(this._boxWidth, this._shaftWidth),
63402
63338
  size = this._boxPlotMark.getAttribute(sizeAttribute, datum);
63403
63339
  if (depth > 1 && isValid$1(this._spec.boxGapInGroup)) {
63404
63340
  const groupFields = this._groups.fields,
@@ -63407,13 +63343,13 @@
63407
63343
  offSet = 0;
63408
63344
  for (let index = groupFields.length - 1; index >= 1; index--) {
63409
63345
  const groupField = groupFields[index],
63410
- groupValues = null !== (_c = null === (_b = axisHelper.getScale(index)) || void 0 === _b ? void 0 : _b.domain()) && void 0 !== _c ? _c : [],
63346
+ groupValues = null !== (_d = null === (_c = axisHelper.getScale(index)) || void 0 === _c ? void 0 : _c.domain()) && void 0 !== _d ? _d : [],
63411
63347
  groupCount = groupValues.length,
63412
- gap = getActualNumValue(null !== (_d = boxGapInGroup[index - 1]) && void 0 !== _d ? _d : last(boxGapInGroup), bandWidth),
63348
+ gap = getActualNumValue(null !== (_e = boxGapInGroup[index - 1]) && void 0 !== _e ? _e : last(boxGapInGroup), bandWidth),
63413
63349
  i = groupValues.indexOf(datum[groupField]);
63414
63350
  index === groupFields.length - 1 ? (totalWidth += groupCount * size + (groupCount - 1) * gap, offSet += i * (size + gap)) : (offSet += i * (totalWidth + gap), totalWidth += totalWidth + (groupCount - 1) * gap);
63415
63351
  }
63416
- return scale.scale(datum[groupFields[0]]) + axisHelper.getBandwidth(0) / 2 - totalWidth / 2 + offSet + size / 2;
63352
+ return scale.scale(datum[groupFields[0]]) + (null !== (_f = axisHelper.getBandwidth(0)) && void 0 !== _f ? _f : Math.max(this._boxWidth, this._shaftWidth)) / 2 - totalWidth / 2 + offSet + size / 2;
63417
63353
  }
63418
63354
  const continuous = isContinuous(scale.type || "band");
63419
63355
  return dataToPosition(datum) + .5 * bandWidth + (continuous ? -bandWidth / 2 : 0);