@visactor/react-vchart 2.0.20-alpha.7 → 2.0.21

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
@@ -9950,6 +9950,7 @@
9950
9950
  backgroundScale: 1,
9951
9951
  backgroundOffsetX: 0,
9952
9952
  backgroundOffsetY: 0,
9953
+ backgroundPosition: "top-left",
9953
9954
  blur: 0,
9954
9955
  filter: "",
9955
9956
  cursor: null,
@@ -10122,11 +10123,16 @@
10122
10123
  const DefaultImageAttribute = Object.assign(Object.assign({
10123
10124
  repeatX: "no-repeat",
10124
10125
  repeatY: "no-repeat",
10126
+ imageMode: void 0,
10125
10127
  image: "",
10126
10128
  width: 0,
10127
10129
  height: 0,
10128
10130
  maxWidth: 500,
10129
- maxHeight: 500
10131
+ maxHeight: 500,
10132
+ imagePosition: "top-left",
10133
+ imageScale: 1,
10134
+ imageOffsetX: 0,
10135
+ imageOffsetY: 0
10130
10136
  }, DefaultAttribute), {
10131
10137
  fill: !0,
10132
10138
  cornerRadius: 0,
@@ -15177,7 +15183,8 @@
15177
15183
  return isString$1(path, !0) ? this.pathProxy = new CustomPath2D().fromString(path) : this.pathProxy = new CustomPath2D(), this.pathProxy;
15178
15184
  }
15179
15185
  loadImage(image, background = !1) {
15180
- if (!image || background && backgroundNotImage(image)) return;
15186
+ if (background && (null == image ? void 0 : image.background) && (image = image.background), background && (!image || backgroundNotImage(image))) return void (this.backgroundImg = !1);
15187
+ if (!image) return;
15181
15188
  const url = image;
15182
15189
  this.resources || (this.resources = new Map());
15183
15190
  const cache = {
@@ -15232,7 +15239,7 @@
15232
15239
  }
15233
15240
  }
15234
15241
  function backgroundNotImage(image) {
15235
- return !(!image.fill && !image.stroke);
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));
15236
15243
  }
15237
15244
  Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
15238
15245
 
@@ -17365,7 +17372,7 @@
17365
17372
  return [new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode), new Paragraph(text2, !0, paragraph.character, paragraph.ascentDescentMode)];
17366
17373
  }
17367
17374
 
17368
- const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", ...GRAPHIC_UPDATE_TAG_KEY];
17375
+ const IMAGE_UPDATE_TAG_KEY = ["width", "height", "image", "imageMode", "imagePosition", "imageScale", "imageOffsetX", "imageOffsetY", ...GRAPHIC_UPDATE_TAG_KEY];
17369
17376
  class Image extends Graphic {
17370
17377
  constructor(params) {
17371
17378
  super(params), this.type = "image", this.numberType = IMAGE_NUMBER_TYPE, this.loadImage(this.attribute.image);
@@ -17470,6 +17477,7 @@
17470
17477
  }
17471
17478
  Image.NOWORK_ANIMATE_ATTR = Object.assign({
17472
17479
  image: 1,
17480
+ imageMode: 1,
17473
17481
  repeatX: 1,
17474
17482
  repeatY: 1
17475
17483
  }, NOWORK_ANIMATE_ATTR);
@@ -18663,11 +18671,12 @@
18663
18671
  backgroundScale = graphicAttribute.backgroundScale,
18664
18672
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
18665
18673
  backgroundOffsetY = graphicAttribute.backgroundOffsetY,
18666
- backgroundClip = graphicAttribute.backgroundClip
18674
+ backgroundClip = graphicAttribute.backgroundClip,
18675
+ backgroundPosition = graphicAttribute.backgroundPosition
18667
18676
  } = graphic.attribute;
18668
18677
  if (background) if (graphic.backgroundImg && graphic.resources) {
18669
- const res = graphic.resources.get(background);
18670
- if ("success" !== res.state || !res.data) return;
18678
+ const res = graphic.resources.get(getBackgroundImage(background));
18679
+ if (!res || "success" !== res.state || !res.data) return;
18671
18680
  if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
18672
18681
  const groupAttribute = getTheme$1(graphic.parent).group,
18673
18682
  {
@@ -18684,59 +18693,160 @@
18684
18693
  backgroundKeepAspectRatio: backgroundKeepAspectRatio,
18685
18694
  backgroundScale: backgroundScale,
18686
18695
  backgroundOffsetX: backgroundOffsetX,
18687
- backgroundOffsetY: backgroundOffsetY
18696
+ backgroundOffsetY: backgroundOffsetY,
18697
+ backgroundPosition: backgroundPosition
18688
18698
  }), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
18689
18699
  } else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
18690
18700
  }
18691
18701
  doDrawImage(context, data, b, params) {
18692
- const {
18693
- backgroundMode: backgroundMode,
18694
- backgroundFit: backgroundFit,
18695
- backgroundKeepAspectRatio: backgroundKeepAspectRatio,
18696
- backgroundScale = 1,
18697
- backgroundOffsetX = 0,
18698
- backgroundOffsetY = 0
18699
- } = params,
18700
- targetW = b.width(),
18701
- targetH = b.height();
18702
- let w = targetW,
18703
- h = targetH;
18704
- if ("no-repeat" === backgroundMode) {
18705
- if (backgroundFit) {
18706
- if (backgroundKeepAspectRatio) {
18707
- const maxScale = Math.max(targetW / data.width, targetH / data.height);
18708
- context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
18709
- } else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
18710
- } else {
18711
- const resW = data.width * backgroundScale,
18712
- resH = data.height * backgroundScale;
18713
- context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
18714
- }
18715
- } else {
18716
- if (backgroundFit && "repeat" !== backgroundMode && (data.width || data.height)) {
18717
- const resW = data.width,
18718
- resH = data.height;
18719
- if ("repeat-x" === backgroundMode) {
18720
- w = resW * (targetH / resH), h = targetH;
18721
- } else if ("repeat-y" === backgroundMode) {
18722
- h = resH * (targetW / resW), w = targetW;
18723
- }
18724
- const dpr = context.dpr,
18725
- canvas = canvasAllocate.allocate({
18726
- width: w,
18727
- height: h,
18728
- dpr: dpr
18729
- }),
18730
- ctx = canvas.getContext("2d");
18731
- ctx && (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, w, h), ctx.drawImage(data, 0, 0, w, h), data = canvas.nativeCanvas), canvasAllocate.free(canvas);
18732
- }
18733
- const dpr = context.dpr,
18734
- pattern = context.createPattern(data, backgroundMode);
18735
- pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0])), context.fillStyle = pattern, context.translate(b.x1, b.y1), context.fillRect(0, 0, targetW, targetH), context.translate(-b.x1, -b.y1);
18736
- }
18702
+ drawBackgroundImage(context, data, b, params);
18737
18703
  }
18738
18704
  }
18739
18705
  const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();
18706
+ const verticalPositionKeywords = new Set(["top", "center", "bottom"]);
18707
+ function getBackgroundImage(background) {
18708
+ var _a;
18709
+ return null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
18710
+ }
18711
+ function resolveBackgroundSizing({
18712
+ backgroundFit: backgroundFit,
18713
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
18714
+ }) {
18715
+ return backgroundFit ? backgroundKeepAspectRatio ? "cover" : "fill" : "auto";
18716
+ }
18717
+ const NO_REPEAT_SIZING_MAP = {
18718
+ "no-repeat-cover": "cover",
18719
+ "no-repeat-contain": "contain",
18720
+ "no-repeat-fill": "fill",
18721
+ "no-repeat-auto": "auto"
18722
+ };
18723
+ function resolveBackgroundDrawMode({
18724
+ backgroundMode: backgroundMode,
18725
+ backgroundFit: backgroundFit,
18726
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
18727
+ }) {
18728
+ const sizing = NO_REPEAT_SIZING_MAP[backgroundMode];
18729
+ return sizing ? {
18730
+ backgroundRepeatMode: "no-repeat",
18731
+ backgroundSizing: sizing
18732
+ } : {
18733
+ backgroundRepeatMode: backgroundMode,
18734
+ backgroundSizing: resolveBackgroundSizing({
18735
+ backgroundFit: backgroundFit,
18736
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
18737
+ })
18738
+ };
18739
+ }
18740
+ function isPercentageValue(value) {
18741
+ return /^-?\d+(\.\d+)?%$/.test(value);
18742
+ }
18743
+ function parsePositionToken(value, remainSpace, startKeyword, centerKeyword, endKeyword) {
18744
+ if ("number" == typeof value && Number.isFinite(value)) return value;
18745
+ const normalizedValue = `${null != value ? value : ""}`.trim().toLowerCase();
18746
+ if (!normalizedValue || normalizedValue === startKeyword) return 0;
18747
+ if (normalizedValue === centerKeyword) return remainSpace / 2;
18748
+ if (normalizedValue === endKeyword) return remainSpace;
18749
+ if (isPercentageValue(normalizedValue)) return remainSpace * parseFloat(normalizedValue) / 100;
18750
+ const parsedValue = Number(normalizedValue);
18751
+ return Number.isFinite(parsedValue) ? parsedValue : 0;
18752
+ }
18753
+ function normalizeBackgroundPosition(position) {
18754
+ var _a, _b;
18755
+ if (Array.isArray(position)) return [null !== (_a = position[0]) && void 0 !== _a ? _a : "left", null !== (_b = position[1]) && void 0 !== _b ? _b : "top"];
18756
+ const tokens = `${null != position ? position : "top-left"}`.trim().toLowerCase().replace(/-/g, " ").split(/\s+/).filter(Boolean);
18757
+ if (0 === tokens.length) return ["left", "top"];
18758
+ if (1 === tokens.length) {
18759
+ const token = tokens[0];
18760
+ return "center" === token ? ["center", "center"] : verticalPositionKeywords.has(token) ? ["center", token] : [token, "center"];
18761
+ }
18762
+ let horizontal, vertical;
18763
+ const genericTokens = [];
18764
+ for (let i = 0; i < 2; i++) {
18765
+ const token = tokens[i];
18766
+ "left" !== token && "right" !== token ? "top" !== token && "bottom" !== token ? genericTokens.push(token) : vertical = token : horizontal = token;
18767
+ }
18768
+ return null == horizontal && genericTokens.length && (horizontal = genericTokens.shift()), null == vertical && genericTokens.length && (vertical = genericTokens.shift()), [null != horizontal ? horizontal : "left", null != vertical ? vertical : "top"];
18769
+ }
18770
+ function resolveBackgroundPosition(position, remainWidth, remainHeight) {
18771
+ const [horizontalPosition, verticalPosition] = normalizeBackgroundPosition(position);
18772
+ return {
18773
+ x: parsePositionToken(horizontalPosition, remainWidth, "left", "center", "right"),
18774
+ y: parsePositionToken(verticalPosition, remainHeight, "top", "center", "bottom")
18775
+ };
18776
+ }
18777
+ function pickRenderableDimension(...values) {
18778
+ for (const value of values) if ("number" == typeof value && Number.isFinite(value) && value > 0) return value;
18779
+ return null;
18780
+ }
18781
+ function resolveRenderableImageSize(data) {
18782
+ if (!data) return null;
18783
+ const width = pickRenderableDimension(data.naturalWidth, data.videoWidth, data.width),
18784
+ height = pickRenderableDimension(data.naturalHeight, data.videoHeight, data.height);
18785
+ return null == width || null == height ? null : {
18786
+ width: width,
18787
+ height: height
18788
+ };
18789
+ }
18790
+ function drawBackgroundImage(context, data, b, params) {
18791
+ var _a, _b;
18792
+ const {
18793
+ backgroundMode: backgroundMode,
18794
+ backgroundFit: backgroundFit,
18795
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
18796
+ backgroundScale = 1,
18797
+ backgroundOffsetX = 0,
18798
+ backgroundOffsetY = 0,
18799
+ backgroundPosition = "top-left"
18800
+ } = params,
18801
+ targetW = b.width(),
18802
+ targetH = b.height(),
18803
+ sourceSize = resolveRenderableImageSize(data),
18804
+ {
18805
+ backgroundRepeatMode: backgroundRepeatMode,
18806
+ backgroundSizing: resolvedBackgroundSizing
18807
+ } = resolveBackgroundDrawMode({
18808
+ backgroundMode: backgroundMode,
18809
+ backgroundFit: backgroundFit,
18810
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
18811
+ });
18812
+ let w = targetW,
18813
+ h = targetH;
18814
+ if (targetW <= 0 || targetH <= 0) return;
18815
+ if ("no-repeat" === backgroundRepeatMode) {
18816
+ let drawWidth = null !== (_a = null == sourceSize ? void 0 : sourceSize.width) && void 0 !== _a ? _a : targetW,
18817
+ drawHeight = null !== (_b = null == sourceSize ? void 0 : sourceSize.height) && void 0 !== _b ? _b : targetH;
18818
+ if ("cover" !== resolvedBackgroundSizing && "contain" !== resolvedBackgroundSizing || !sourceSize) "fill" === resolvedBackgroundSizing && (drawWidth = targetW, drawHeight = targetH);else {
18819
+ const scale = "cover" === resolvedBackgroundSizing ? Math.max(targetW / sourceSize.width, targetH / sourceSize.height) : Math.min(targetW / sourceSize.width, targetH / sourceSize.height);
18820
+ drawWidth = sourceSize.width * scale, drawHeight = sourceSize.height * scale;
18821
+ }
18822
+ drawWidth *= backgroundScale, drawHeight *= backgroundScale;
18823
+ const {
18824
+ x: x,
18825
+ y: y
18826
+ } = resolveBackgroundPosition(backgroundPosition, targetW - drawWidth, targetH - drawHeight);
18827
+ return void context.drawImage(data, b.x1 + x + backgroundOffsetX, b.y1 + y + backgroundOffsetY, drawWidth, drawHeight);
18828
+ }
18829
+ if (backgroundFit && "repeat" !== backgroundRepeatMode && sourceSize) {
18830
+ const resW = sourceSize.width,
18831
+ resH = sourceSize.height;
18832
+ if ("repeat-x" === backgroundRepeatMode) {
18833
+ w = resW * (targetH / resH), h = targetH;
18834
+ } else if ("repeat-y" === backgroundRepeatMode) {
18835
+ h = resH * (targetW / resW), w = targetW;
18836
+ }
18837
+ const dpr = context.dpr,
18838
+ canvas = canvasAllocate.allocate({
18839
+ width: w,
18840
+ height: h,
18841
+ dpr: dpr
18842
+ }),
18843
+ ctx = canvas.getContext("2d");
18844
+ ctx && (ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, w, h), ctx.drawImage(data, 0, 0, w, h), data = canvas.nativeCanvas), canvasAllocate.free(canvas);
18845
+ }
18846
+ const dpr = context.dpr,
18847
+ pattern = context.createPattern(data, backgroundRepeatMode);
18848
+ pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0])), context.fillStyle = pattern, context.translate(b.x1, b.y1), context.fillRect(0, 0, targetW, targetH), context.translate(-b.x1, -b.y1);
18849
+ }
18740
18850
  let DefaultBaseInteractiveRenderContribution = class {
18741
18851
  constructor(subRenderContribitions) {
18742
18852
  this.subRenderContribitions = subRenderContribitions, this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
@@ -19093,27 +19203,32 @@
19093
19203
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
19094
19204
  const {
19095
19205
  background: background,
19206
+ backgroundOpacity = graphicAttribute.backgroundOpacity,
19207
+ opacity = graphicAttribute.opacity,
19096
19208
  backgroundMode = graphicAttribute.backgroundMode,
19097
19209
  backgroundFit = graphicAttribute.backgroundFit,
19098
19210
  backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
19099
19211
  backgroundScale = graphicAttribute.backgroundScale,
19100
19212
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
19101
- backgroundOffsetY = graphicAttribute.backgroundOffsetY
19213
+ backgroundOffsetY = graphicAttribute.backgroundOffsetY,
19214
+ backgroundClip = graphicAttribute.backgroundClip,
19215
+ backgroundPosition = graphicAttribute.backgroundPosition
19102
19216
  } = graphic.attribute;
19103
19217
  if (background) if (graphic.backgroundImg && graphic.resources) {
19104
- const res = graphic.resources.get(background);
19105
- if ("success" !== res.state || !res.data) return;
19218
+ const res = graphic.resources.get(getBackgroundImage(background));
19219
+ if (!res || "success" !== res.state || !res.data) return;
19106
19220
  context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0);
19107
19221
  const b = graphic.AABBBounds;
19108
- this.doDrawImage(context, res.data, b, {
19222
+ context.globalAlpha = backgroundOpacity * opacity, backgroundClip && context.clip(), this.doDrawImage(context, res.data, b, {
19109
19223
  backgroundMode: backgroundMode,
19110
19224
  backgroundFit: backgroundFit,
19111
19225
  backgroundKeepAspectRatio: backgroundKeepAspectRatio,
19112
19226
  backgroundScale: backgroundScale,
19113
19227
  backgroundOffsetX: backgroundOffsetX,
19114
- backgroundOffsetY: backgroundOffsetY
19228
+ backgroundOffsetY: backgroundOffsetY,
19229
+ backgroundPosition: backgroundPosition
19115
19230
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
19116
- } else context.highPerformanceSave(), context.fillStyle = background, context.fill(), context.highPerformanceRestore();
19231
+ } else context.highPerformanceSave(), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, context.fill(), context.highPerformanceRestore();
19117
19232
  }
19118
19233
  }
19119
19234
  const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();
@@ -20595,9 +20710,17 @@
20595
20710
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
20596
20711
  var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
20597
20712
  const {
20713
+ backgroundOpacity = graphicAttribute.backgroundOpacity,
20714
+ opacity = graphicAttribute.opacity,
20598
20715
  backgroundMode = graphicAttribute.backgroundMode,
20599
20716
  backgroundFit = graphicAttribute.backgroundFit,
20600
- backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
20717
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
20718
+ backgroundScale = graphicAttribute.backgroundScale,
20719
+ backgroundOffsetX = graphicAttribute.backgroundOffsetX,
20720
+ backgroundOffsetY = graphicAttribute.backgroundOffsetY,
20721
+ backgroundPosition = graphicAttribute.backgroundPosition,
20722
+ backgroundClip = graphicAttribute.backgroundClip,
20723
+ backgroundCornerRadius = graphicAttribute.backgroundCornerRadius
20601
20724
  } = graphic.attribute;
20602
20725
  let matrix,
20603
20726
  {
@@ -20609,18 +20732,18 @@
20609
20732
  };
20610
20733
  let b;
20611
20734
  "richtext" === graphic.type && (matrix = context.currentMatrix.clone(), context.restore(), context.save(), context.setTransformForCurrent());
20612
- const shouldReCalBounds = isObject$2(background) && background.background,
20735
+ const backgroundConfig = isObject$2(background) && background.background ? background : null,
20613
20736
  onlyTranslate = graphic.transMatrix.onlyTranslate();
20614
- if (shouldReCalBounds) {
20737
+ if (backgroundConfig) {
20615
20738
  const _b = graphic.AABBBounds,
20616
- x = (null !== (_a = background.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = background.dx) && void 0 !== _c ? _c : 0),
20617
- y = (null !== (_d = background.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = background.dy) && void 0 !== _e ? _e : 0),
20618
- w = null !== (_f = background.width) && void 0 !== _f ? _f : _b.width(),
20619
- h = null !== (_g = background.height) && void 0 !== _g ? _g : _b.height();
20620
- if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = background.background, !onlyTranslate) {
20739
+ x = (null !== (_a = backgroundConfig.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = backgroundConfig.dx) && void 0 !== _c ? _c : 0),
20740
+ y = (null !== (_d = backgroundConfig.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = backgroundConfig.dy) && void 0 !== _e ? _e : 0),
20741
+ w = null !== (_f = backgroundConfig.width) && void 0 !== _f ? _f : _b.width(),
20742
+ h = null !== (_g = backgroundConfig.height) && void 0 !== _g ? _g : _b.height();
20743
+ if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = backgroundConfig.background, !onlyTranslate) {
20621
20744
  const w = b.width(),
20622
20745
  h = b.height();
20623
- b.set((null !== (_h = background.x) && void 0 !== _h ? _h : 0) + (null !== (_j = background.dx) && void 0 !== _j ? _j : 0), (null !== (_k = background.y) && void 0 !== _k ? _k : 0) + (null !== (_l = background.dy) && void 0 !== _l ? _l : 0), w, h);
20746
+ b.set((null !== (_h = backgroundConfig.x) && void 0 !== _h ? _h : 0) + (null !== (_j = backgroundConfig.dx) && void 0 !== _j ? _j : 0), (null !== (_k = backgroundConfig.y) && void 0 !== _k ? _k : 0) + (null !== (_l = backgroundConfig.dy) && void 0 !== _l ? _l : 0), w, h);
20624
20747
  }
20625
20748
  } else b = graphic.AABBBounds, onlyTranslate || (b = getTextBounds(Object.assign(Object.assign({}, graphic.attribute), {
20626
20749
  angle: 0,
@@ -20633,20 +20756,18 @@
20633
20756
  })).clone());
20634
20757
  if (graphic.backgroundImg && graphic.resources) {
20635
20758
  const res = graphic.resources.get(background);
20636
- if ("success" !== res.state || !res.data) return void restore();
20637
- context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, {
20759
+ if (!res || "success" !== res.state || !res.data) return void restore();
20760
+ context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.globalAlpha = backgroundOpacity * opacity, backgroundClip && (context.beginPath(), backgroundCornerRadius ? createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0) : context.rect(b.x1, b.y1, b.width(), b.height()), context.clip()), this.doDrawImage(context, res.data, b, {
20638
20761
  backgroundMode: backgroundMode,
20639
20762
  backgroundFit: backgroundFit,
20640
- backgroundKeepAspectRatio: backgroundKeepAspectRatio
20763
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
20764
+ backgroundScale: backgroundScale,
20765
+ backgroundOffsetX: backgroundOffsetX,
20766
+ backgroundOffsetY: backgroundOffsetY,
20767
+ backgroundPosition: backgroundPosition
20641
20768
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
20642
- } else {
20643
- const {
20644
- backgroundCornerRadius: backgroundCornerRadius,
20645
- backgroundOpacity = 1
20646
- } = graphic.attribute;
20647
- context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity, context.fillStyle = background, backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0), context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
20648
- }
20649
- shouldReCalBounds && boundsAllocate.free(b), restore();
20769
+ } else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background, backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0), context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
20770
+ backgroundConfig && boundsAllocate.free(b), restore();
20650
20771
  }
20651
20772
  }
20652
20773
  const defaultTextBackgroundRenderContribution = new DefaultTextBackgroundRenderContribution();
@@ -21073,6 +21194,92 @@
21073
21194
  };
21074
21195
  };
21075
21196
  const repeatStr = ["", "repeat-x", "repeat-y", "repeat"];
21197
+ function resolveImageMode({
21198
+ repeatX = "no-repeat",
21199
+ repeatY = "no-repeat",
21200
+ imageMode: imageMode
21201
+ }) {
21202
+ const repeatMode = resolveImageRepeatMode(repeatX, repeatY);
21203
+ return {
21204
+ repeatMode: repeatMode,
21205
+ sizingMode: "no-repeat" === repeatMode && null != imageMode ? imageMode : "fill"
21206
+ };
21207
+ }
21208
+ const IMAGE_MODE_TO_BACKGROUND_MODE = {
21209
+ cover: "no-repeat-cover",
21210
+ contain: "no-repeat-contain",
21211
+ fill: "no-repeat-fill",
21212
+ auto: "no-repeat-auto"
21213
+ };
21214
+ function resolveBackgroundParamsByImageSizing(sizingMode) {
21215
+ return {
21216
+ backgroundMode: IMAGE_MODE_TO_BACKGROUND_MODE[sizingMode],
21217
+ backgroundFit: !1,
21218
+ backgroundKeepAspectRatio: !1
21219
+ };
21220
+ }
21221
+ function resolveImageRepeatMode(repeatX, repeatY) {
21222
+ let repeat = 0;
21223
+ return "repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat ? repeatStr[repeat] : "no-repeat";
21224
+ }
21225
+ function shouldClipImageByLayout({
21226
+ repeatX = "no-repeat",
21227
+ repeatY = "no-repeat",
21228
+ imageMode: imageMode,
21229
+ imageScale = 1,
21230
+ imageOffsetX = 0,
21231
+ imageOffsetY = 0,
21232
+ imagePosition = "top-left"
21233
+ }) {
21234
+ const {
21235
+ repeatMode: repeatMode,
21236
+ sizingMode: sizingMode
21237
+ } = resolveImageMode({
21238
+ repeatX: repeatX,
21239
+ repeatY: repeatY,
21240
+ imageMode: imageMode
21241
+ });
21242
+ return "no-repeat" === repeatMode && ("cover" === sizingMode || "auto" === sizingMode || 1 !== imageScale || 0 !== imageOffsetX || 0 !== imageOffsetY);
21243
+ }
21244
+ function drawImageWithLayout(context, data, x, y, width, height, {
21245
+ repeatX = "no-repeat",
21246
+ repeatY = "no-repeat",
21247
+ imageMode: imageMode,
21248
+ imageScale = 1,
21249
+ imageOffsetX = 0,
21250
+ imageOffsetY = 0,
21251
+ imagePosition = "top-left"
21252
+ }) {
21253
+ const {
21254
+ repeatMode: repeatMode,
21255
+ sizingMode: sizingMode
21256
+ } = resolveImageMode({
21257
+ repeatX: repeatX,
21258
+ repeatY: repeatY,
21259
+ imageMode: imageMode
21260
+ }),
21261
+ imageBackgroundParams = "no-repeat" === repeatMode ? resolveBackgroundParamsByImageSizing(sizingMode) : {
21262
+ backgroundMode: repeatMode,
21263
+ backgroundFit: !1,
21264
+ backgroundKeepAspectRatio: !1
21265
+ };
21266
+ drawBackgroundImage(context, data, {
21267
+ x1: x,
21268
+ y1: y,
21269
+ x2: x + width,
21270
+ y2: y + height,
21271
+ width: () => width,
21272
+ height: () => height
21273
+ }, {
21274
+ backgroundMode: imageBackgroundParams.backgroundMode,
21275
+ backgroundFit: imageBackgroundParams.backgroundFit,
21276
+ backgroundKeepAspectRatio: imageBackgroundParams.backgroundKeepAspectRatio,
21277
+ backgroundScale: imageScale,
21278
+ backgroundOffsetX: imageOffsetX,
21279
+ backgroundOffsetY: imageOffsetY,
21280
+ backgroundPosition: imagePosition
21281
+ });
21282
+ }
21076
21283
  let DefaultCanvasImageRender = class extends BaseRender {
21077
21284
  constructor(graphicRenderContributions) {
21078
21285
  super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution], this.init(graphicRenderContributions);
@@ -21087,6 +21294,11 @@
21087
21294
  cornerRadius = imageAttribute.cornerRadius,
21088
21295
  fillStrokeOrder = imageAttribute.fillStrokeOrder,
21089
21296
  cornerType = imageAttribute.cornerType,
21297
+ imageMode = imageAttribute.imageMode,
21298
+ imageScale = imageAttribute.imageScale,
21299
+ imageOffsetX = imageAttribute.imageOffsetX,
21300
+ imageOffsetY = imageAttribute.imageOffsetY,
21301
+ imagePosition = imageAttribute.imagePosition,
21090
21302
  image: url
21091
21303
  } = image.attribute,
21092
21304
  data = this.valid(image, imageAttribute, fillCb);
@@ -21103,22 +21315,33 @@
21103
21315
  const width = image.width,
21104
21316
  height = image.height;
21105
21317
  context.beginPath();
21106
- let needRestore = !1;
21107
- 0 === cornerRadius || isArray$1(cornerRadius) && cornerRadius.every(num => 0 === num) ? context.rect(x, y, width, height) : (createRectPath(context, x, y, width, height, cornerRadius, "bevel" !== cornerType), needRestore = !0), context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);
21318
+ let needCornerClip = !1;
21319
+ 0 === cornerRadius || isArray$1(cornerRadius) && cornerRadius.every(num => 0 === num) ? context.rect(x, y, width, height) : (createRectPath(context, x, y, width, height, cornerRadius, "bevel" !== cornerType), needCornerClip = !0), context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);
21108
21320
  const _runFill = () => {
21109
- if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
21110
- context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
21111
- let repeat = 0;
21112
- if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
21113
- const pattern = context.createPattern(res.data, repeatStr[repeat]);
21114
- context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
21115
- } else context.drawImage(res.data, x, y, width, height);
21116
- }
21321
+ doFill && (fillCb ? fillCb(context, image.attribute, imageAttribute) : fVisible && (context.setCommonStyle(image, image.attribute, x, y, imageAttribute), drawImageWithLayout(context, res.data, x, y, width, height, {
21322
+ repeatX: repeatX,
21323
+ repeatY: repeatY,
21324
+ imageMode: imageMode,
21325
+ imageScale: imageScale,
21326
+ imageOffsetX: imageOffsetX,
21327
+ imageOffsetY: imageOffsetY,
21328
+ imagePosition: imagePosition
21329
+ })));
21117
21330
  },
21118
21331
  _runStroke = () => {
21119
21332
  doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
21120
- };
21121
- fillStrokeOrder ? (_runStroke(), needRestore && (context.save(), context.clip()), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), _runFill(), needRestore && context.restore()) : (needRestore && (context.save(), context.clip()), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), _runFill(), needRestore && context.restore(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
21333
+ },
21334
+ needLayoutClip = shouldClipImageByLayout({
21335
+ repeatX: repeatX,
21336
+ repeatY: repeatY,
21337
+ imageMode: imageMode,
21338
+ imageScale: imageScale,
21339
+ imageOffsetX: imageOffsetX,
21340
+ imageOffsetY: imageOffsetY,
21341
+ imagePosition: imagePosition
21342
+ }),
21343
+ needClip = needCornerClip || needLayoutClip;
21344
+ fillStrokeOrder ? (_runStroke(), needClip && (context.save(), context.clip()), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), _runFill(), needClip && context.restore()) : (needClip && (context.save(), context.clip()), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), _runFill(), needClip && context.restore(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
21122
21345
  }
21123
21346
  draw(image, renderService, drawContext) {
21124
21347
  const {
@@ -21977,7 +22200,7 @@
21977
22200
  return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);
21978
22201
  }
21979
22202
  clearScreen(renderService, context, drawContext) {
21980
- var _a, _b, _c;
22203
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
21981
22204
  const {
21982
22205
  clear: clear,
21983
22206
  viewBox: viewBox
@@ -21987,9 +22210,20 @@
21987
22210
  if (clear) {
21988
22211
  context.clearRect(0, 0, width, height), (null === (_a = renderService.drawParams) || void 0 === _a ? void 0 : _a.stage) && renderService.drawParams.stage.hooks.afterClearRect.call(renderService.drawParams);
21989
22212
  const stage = null === (_b = renderService.drawParams) || void 0 === _b ? void 0 : _b.stage;
21990
- if (stage && (context.globalAlpha = null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1), stage && stage.backgroundImg && stage.resources) {
21991
- const res = stage.resources.get(clear);
21992
- res && "success" === res.state && res.data && context.drawImage(res.data, 0, 0, width, height);
22213
+ if (stage && (context.globalAlpha = (null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1) * (null !== (_d = stage.attribute.backgroundOpacity) && void 0 !== _d ? _d : 1)), stage && stage.backgroundImg && stage.resources) {
22214
+ const res = stage.resources.get(getBackgroundImage(clear));
22215
+ if (res && "success" === res.state && res.data) {
22216
+ const backgroundBounds = boundsAllocate.allocate(0, 0, 0 + width, 0 + height);
22217
+ drawBackgroundImage(context, res.data, backgroundBounds, {
22218
+ backgroundMode: null !== (_e = stage.attribute.backgroundMode) && void 0 !== _e ? _e : DefaultAttribute.backgroundMode,
22219
+ backgroundFit: null !== (_f = stage.attribute.backgroundFit) && void 0 !== _f ? _f : DefaultAttribute.backgroundFit,
22220
+ backgroundKeepAspectRatio: null !== (_g = stage.attribute.backgroundKeepAspectRatio) && void 0 !== _g ? _g : DefaultAttribute.backgroundKeepAspectRatio,
22221
+ backgroundScale: null !== (_h = stage.attribute.backgroundScale) && void 0 !== _h ? _h : DefaultAttribute.backgroundScale,
22222
+ backgroundOffsetX: null !== (_j = stage.attribute.backgroundOffsetX) && void 0 !== _j ? _j : DefaultAttribute.backgroundOffsetX,
22223
+ backgroundOffsetY: null !== (_k = stage.attribute.backgroundOffsetY) && void 0 !== _k ? _k : DefaultAttribute.backgroundOffsetY,
22224
+ backgroundPosition: null !== (_l = stage.attribute.backgroundPosition) && void 0 !== _l ? _l : DefaultAttribute.backgroundPosition
22225
+ }), boundsAllocate.free(backgroundBounds);
22226
+ }
21993
22227
  } else context.fillStyle = createColor(context, clear, {
21994
22228
  AABBBounds: {
21995
22229
  x1: 0,
@@ -22487,7 +22721,7 @@
22487
22721
  return null !== (_a = this._background) && void 0 !== _a ? _a : DefaultConfig.BACKGROUND;
22488
22722
  }
22489
22723
  set background(b) {
22490
- this._background = b;
22724
+ this._background = b, this.syncBackgroundImage(b);
22491
22725
  }
22492
22726
  get defaultLayer() {
22493
22727
  return this.at(0);
@@ -22501,6 +22735,18 @@
22501
22735
  set ticker(ticker) {
22502
22736
  ticker.bindStage(this), this._ticker && this._ticker.removeListener("tick", this.afterTickCb), ticker.addTimeline(this.timeline), this._ticker = ticker, this._ticker.on("tick", this.afterTickCb);
22503
22737
  }
22738
+ syncBackgroundImage(background) {
22739
+ var _a;
22740
+ const source = null !== (_a = null == background ? void 0 : background.background) && void 0 !== _a ? _a : background;
22741
+ this.backgroundImg = !1, this.isImageBackgroundSource(source) && this.loadImage(source, !0);
22742
+ }
22743
+ isImageBackgroundSource(source) {
22744
+ if (!source) return !1;
22745
+ if ("string" == typeof source) return source.startsWith("<svg") || isValidUrl$1(source) || source.includes("/") || isBase64$1(source);
22746
+ if (!isObject$2(source)) return !1;
22747
+ const gradientSource = source;
22748
+ return "string" != typeof gradientSource.gradient || !Array.isArray(gradientSource.stops);
22749
+ }
22504
22750
  constructor(params = {}) {
22505
22751
  var _a, _b;
22506
22752
  super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
@@ -22539,9 +22785,7 @@
22539
22785
  main: !0
22540
22786
  })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), params.beforeRender && this._beforeRenderList.push(params.beforeRender), params.afterRender && this._afterRenderList.push(params.afterRender), this.hooks.afterClearScreen.tap("constructor", this.afterClearScreen), this.hooks.afterClearRect.tap("constructor", this.afterClearRect), this._afterClearScreen = params.afterClearScreen, this._afterClearRect = params.afterClearRect, this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
22541
22787
  tickRenderMode: "effect"
22542
- }), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
22543
- background: this._background
22544
- }), this.initAnimate(params), this.rafId = null !== (_b = params.rafId) && void 0 !== _b ? _b : Math.floor(6 * Math.random());
22788
+ }), this.optmize(params.optimize), params.background && this.syncBackgroundImage(this._background), this.initAnimate(params), this.rafId = null !== (_b = params.rafId) && void 0 !== _b ? _b : Math.floor(6 * Math.random());
22545
22789
  }
22546
22790
  initAnimate(params) {
22547
22791
  var _a;
@@ -31215,6 +31459,7 @@
31215
31459
  if (custom.prototype.constructor === custom) {
31216
31460
  const descriptor = Object.getOwnPropertyDescriptor(custom, "prototype");
31217
31461
  if (descriptor && !descriptor.writable) return 1;
31462
+ if (Object.getOwnPropertyNames(custom.prototype).length > 1) return 1;
31218
31463
  }
31219
31464
  return 2;
31220
31465
  }
@@ -49920,11 +50165,11 @@
49920
50165
  this._lastMark = mark;
49921
50166
  }
49922
50167
  reuse(mark) {
49923
- this.type === mark.type && (this._product = mark.getProduct(), this._product.clearStates(), this._graphics = mark.getGraphics(), this._graphics.forEach(g => {
50168
+ this.type === mark.type && (this._product = mark.getProduct(), this._product && (this._product.clearStates(), this._graphics = mark.getGraphics(), this._graphics.forEach(g => {
49924
50169
  g.clearStates();
49925
50170
  }), this._graphicMap = mark._graphicMap, this._graphicMap.forEach(g => {
49926
50171
  g.context = Object.assign(Object.assign({}, g.context), this._getCommonContext());
49927
- }), this._dataByKey = mark._dataByKey, this._prevDataByKey = mark._prevDataByKey, this.needClear = mark.needClear);
50172
+ }), this._dataByKey = mark._dataByKey, this._prevDataByKey = mark._prevDataByKey, this.needClear = mark.needClear));
49928
50173
  }
49929
50174
  _parseProgressiveContext(data) {
49930
50175
  const enableProgressive = this._markConfig.progressiveStep > 0 && this._markConfig.progressiveThreshold > 0 && this._markConfig.progressiveStep < this._markConfig.progressiveThreshold,
@@ -80478,8 +80723,10 @@
80478
80723
  const isSameScrollValue = isClose(this._start, start) && isClose(this._end, end);
80479
80724
  if (this._shouldChange && (!isSameScrollValue || !1 === this._spec.realTime)) {
80480
80725
  updateComponent && this._component && this._component.setAttribute("range", [start, end]), this._start = start, this._end = end;
80481
- const startValue = statePointToData(start, this._stateScale, !1),
80482
- endValue = statePointToData(end, this._stateScale, !1);
80726
+ const axis = this._relatedAxisComponent,
80727
+ reverse = isReverse(axis, this._isHorizontal),
80728
+ startValue = statePointToData(start, this._stateScale, reverse),
80729
+ endValue = statePointToData(end, this._stateScale, reverse);
80483
80730
  (isFunction$1(this._spec.updateDataAfterChange) ? this._spec.updateDataAfterChange(start, end, startValue, endValue) : this._handleStateChange(startValue, endValue)) && this.event.emit(ChartEvent.scrollBarChange, {
80484
80731
  model: this,
80485
80732
  value: {
@@ -88971,7 +89218,7 @@
88971
89218
 
88972
89219
  const VChartSimple = createChart('VChartSimple');
88973
89220
 
88974
- const version = "2.0.19";
89221
+ const version = "2.0.21";
88975
89222
 
88976
89223
  exports.Area = Area;
88977
89224
  exports.AreaChart = AreaChart;