@visactor/react-vchart 2.0.22-alpha.1 → 2.0.22-alpha.2

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
@@ -19011,13 +19011,14 @@
19011
19011
  texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
19012
19012
  }
19013
19013
  drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
19014
- var _a, _b, _c, _d, _e;
19014
+ var _a, _b, _c, _d, _e, _f;
19015
19015
  const {
19016
19016
  textureRatio = graphicAttribute.textureRatio,
19017
19017
  textureOptions = null
19018
19018
  } = graphic.attribute;
19019
19019
  let pattern = null;
19020
- const patternKey = this.getPatternCacheKey(texture, textureSize, texturePadding, textureColor, context.dpr);
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);
19021
19022
  if (null !== patternKey && (pattern = this.textureMap.get(patternKey)), !pattern) {
19022
19023
  if ("string" == typeof texture) switch (texture) {
19023
19024
  case "circle":
@@ -19044,7 +19045,7 @@
19044
19045
  case "grid":
19045
19046
  pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
19046
19047
  }
19047
- pattern || (pattern = this.createResourcePattern(texture, graphic, context)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
19048
+ pattern || (pattern = this.createResourcePattern(texture, graphic, context, texturePadding, textureRadius)), pattern && null !== patternKey && this.textureMap.set(patternKey, pattern);
19048
19049
  }
19049
19050
  if ("string" == typeof texture && textureOptions && textureOptions.dynamicTexture) {
19050
19051
  const {
@@ -19091,19 +19092,19 @@
19091
19092
  for (let i = 0; i < gridRows; i++) for (let j = 0; j < gridColumns; j++) {
19092
19093
  const _x = x + cellSize / 2 + j * cellSize,
19093
19094
  _y = y + cellSize / 2 + i * cellSize;
19094
- 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());
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());
19095
19096
  }
19096
19097
  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();
19097
19098
  } else if (pattern) {
19098
19099
  if (pattern.setTransform) {
19099
19100
  const alignToGraphic = !!(null == textureOptions ? void 0 : textureOptions.alignToGraphic),
19100
- alignOffsetX = null !== (_b = null == textureOptions ? void 0 : textureOptions.alignOffsetX) && void 0 !== _b ? _b : 0,
19101
- alignOffsetY = null !== (_c = null == textureOptions ? void 0 : textureOptions.alignOffsetY) && void 0 !== _c ? _c : 0;
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;
19102
19103
  let translateX = 0,
19103
19104
  translateY = 0;
19104
19105
  if (alignToGraphic) {
19105
19106
  const m = context.currentMatrix;
19106
- translateX = (null !== (_d = null == m ? void 0 : m.e) && void 0 !== _d ? _d : 0) + x + alignOffsetX, translateY = (null !== (_e = null == m ? void 0 : m.f) && void 0 !== _e ? _e : 0) + y + alignOffsetY;
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;
19107
19108
  } else (alignOffsetX || alignOffsetY) && (translateX = alignOffsetX, translateY = alignOffsetY);
19108
19109
  pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, translateX, translateY]));
19109
19110
  }
@@ -19116,14 +19117,42 @@
19116
19117
  }), x + b.x1 - x, y + b.y1 - y), context.restore();
19117
19118
  }
19118
19119
  }
19119
- getPatternCacheKey(texture, textureSize, texturePadding, textureColor, dpr) {
19120
- return "string" != typeof texture ? texture : "wave" === texture ? null : `${texture}-${textureSize}-${texturePadding}-${textureColor}-${dpr}`;
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}`;
19121
19122
  }
19122
- createResourcePattern(texture, graphic, context) {
19123
+ createResourcePattern(texture, graphic, context, texturePadding, textureRadius) {
19123
19124
  var _a;
19124
19125
  const resource = null === (_a = graphic.resources) || void 0 === _a ? void 0 : _a.get(texture),
19125
19126
  data = "success" === (null == resource ? void 0 : resource.state) ? resource.data : "object" == typeof texture ? texture : null;
19126
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
+ }
19127
19156
  const pattern = context.createPattern(data, "repeat");
19128
19157
  return (null == pattern ? void 0 : pattern.setTransform) && pattern.setTransform(new DOMMatrix([1 / context.dpr, 0, 0, 1 / context.dpr, 0, 0])), pattern;
19129
19158
  }