@visactor/vchart 1.8.5 → 1.8.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
@@ -8659,6 +8659,7 @@
8659
8659
  textureSize: 10,
8660
8660
  texturePadding: 2,
8661
8661
  backgroundMode: "no-repeat",
8662
+ backgroundFit: !0,
8662
8663
  blur: 0,
8663
8664
  cursor: null,
8664
8665
  html: null
@@ -14930,11 +14931,11 @@
14930
14931
  get cliped() {
14931
14932
  const textTheme = getTheme$1(this).text,
14932
14933
  attribute = this.attribute;
14933
- if (!this.isSimplify()) return;
14934
+ if (this.isMultiLine) return;
14934
14935
  const {
14935
14936
  maxLineWidth = textTheme.maxLineWidth
14936
14937
  } = attribute;
14937
- return !!Number.isFinite(maxLineWidth) && (this.tryUpdateAABBBounds(), null != this.clipedText && this.clipedText !== attribute.text.toString());
14938
+ return !!Number.isFinite(maxLineWidth) && (this.tryUpdateAABBBounds(), "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString());
14938
14939
  }
14939
14940
  get multilineLayout() {
14940
14941
  if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
@@ -18540,7 +18541,8 @@
18540
18541
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
18541
18542
  const {
18542
18543
  background: background,
18543
- backgroundMode = graphicAttribute.backgroundMode
18544
+ backgroundMode = graphicAttribute.backgroundMode,
18545
+ backgroundFit = graphicAttribute.backgroundFit
18544
18546
  } = graphic.attribute;
18545
18547
  if (background) if (graphic.backgroundImg && graphic.resources) {
18546
18548
  const res = graphic.resources.get(background);
@@ -18555,13 +18557,33 @@
18555
18557
  }
18556
18558
  context.clip();
18557
18559
  const b = graphic.AABBBounds;
18558
- context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, backgroundMode), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
18560
+ context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
18559
18561
  } else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.fillStyle = background, context.fill(), context.highPerformanceRestore();
18560
18562
  }
18561
- doDrawImage(context, data, b, backgroundMode) {
18563
+ doDrawImage(context, data, b, backgroundMode, backgroundFit) {
18562
18564
  if ("no-repeat" === backgroundMode) context.drawImage(data, b.x1, b.y1, b.width(), b.height());else {
18565
+ const targetW = b.width(),
18566
+ targetH = b.height();
18567
+ let w = targetW,
18568
+ h = targetH;
18569
+ if (backgroundFit && "repeat" !== backgroundMode && (data.width || data.height)) {
18570
+ const resW = data.width,
18571
+ resH = data.height;
18572
+ if ("repeat-x" === backgroundMode) {
18573
+ w = resW * (targetH / resH);
18574
+ } else if ("repeat-y" === backgroundMode) {
18575
+ h = resH * (targetW / resW);
18576
+ }
18577
+ const canvas = canvasAllocate.allocate({
18578
+ width: w,
18579
+ height: h,
18580
+ dpr: context.dpr
18581
+ }),
18582
+ ctx = canvas.getContext("2d");
18583
+ 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), document.body.appendChild(data), canvasAllocate.free(canvas);
18584
+ }
18563
18585
  const pattern = context.createPattern(data, backgroundMode);
18564
- context.fillStyle = pattern, context.translate(b.x1, b.y1), context.fillRect(0, 0, b.width(), b.height()), context.translate(-b.x1, -b.y1);
18586
+ context.fillStyle = pattern, context.translate(b.x1, b.y1), context.fillRect(0, 0, targetW, targetH), context.translate(-b.x1, -b.y1);
18565
18587
  }
18566
18588
  }
18567
18589
  }
@@ -18821,14 +18843,15 @@
18821
18843
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
18822
18844
  const {
18823
18845
  background: background,
18824
- backgroundMode = graphicAttribute.backgroundMode
18846
+ backgroundMode = graphicAttribute.backgroundMode,
18847
+ backgroundFit = graphicAttribute.backgroundFit
18825
18848
  } = graphic.attribute;
18826
18849
  if (background) if (graphic.backgroundImg && graphic.resources) {
18827
18850
  const res = graphic.resources.get(background);
18828
18851
  if ("success" !== res.state || !res.data) return;
18829
18852
  context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0);
18830
18853
  const b = graphic.AABBBounds;
18831
- this.doDrawImage(context, res.data, b, backgroundMode), context.highPerformanceRestore(), context.setTransformForCurrent();
18854
+ this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.highPerformanceRestore(), context.setTransformForCurrent();
18832
18855
  } else context.highPerformanceSave(), context.fillStyle = background, context.fill(), context.highPerformanceRestore();
18833
18856
  }
18834
18857
  }
@@ -18897,7 +18920,8 @@
18897
18920
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
18898
18921
  const {
18899
18922
  background: background,
18900
- backgroundMode = graphicAttribute.backgroundMode
18923
+ backgroundMode = graphicAttribute.backgroundMode,
18924
+ backgroundFit = graphicAttribute.backgroundFit
18901
18925
  } = graphic.attribute;
18902
18926
  if (background) if (graphic.backgroundImg) {
18903
18927
  const res = graphic.resources.get(background);
@@ -18911,7 +18935,7 @@
18911
18935
  context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.translate(scrollX, scrollY);
18912
18936
  }
18913
18937
  const b = graphic.AABBBounds;
18914
- this.doDrawImage(context, res.data, b, backgroundMode), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
18938
+ this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
18915
18939
  } else if (isObject$2(background)) {
18916
18940
  const {
18917
18941
  stroke: stroke,
@@ -20212,14 +20236,15 @@
20212
20236
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
20213
20237
  const {
20214
20238
  background: background,
20215
- backgroundMode = graphicAttribute.backgroundMode
20239
+ backgroundMode = graphicAttribute.backgroundMode,
20240
+ backgroundFit = graphicAttribute.backgroundFit
20216
20241
  } = graphic.attribute;
20217
20242
  if (!background) return;
20218
20243
  const b = graphic.AABBBounds;
20219
20244
  if (graphic.backgroundImg && graphic.resources) {
20220
20245
  const res = graphic.resources.get(background);
20221
20246
  if ("success" !== res.state || !res.data) return;
20222
- context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), this.doDrawImage(context, res.data, b, backgroundMode), context.highPerformanceRestore(), context.setTransformForCurrent();
20247
+ context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.highPerformanceRestore(), context.setTransformForCurrent();
20223
20248
  } else context.highPerformanceSave(), context.fillStyle = background, context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
20224
20249
  }
20225
20250
  }
@@ -22118,10 +22143,10 @@
22118
22143
  let left = 0,
22119
22144
  top = 0;
22120
22145
  if ("position" === anchorType) {
22121
- const matrix = graphic.transMatrix;
22146
+ const matrix = graphic.globalTransMatrix;
22122
22147
  left = matrix.e, top = matrix.f;
22123
22148
  } else {
22124
- const b = graphic.AABBBounds;
22149
+ const b = graphic.globalAABBBounds;
22125
22150
  left = b.x1, top = b.y1;
22126
22151
  }
22127
22152
  const containerTL = application.global.getElementTopLeft(nativeContainer, !1),
@@ -34498,11 +34523,28 @@
34498
34523
  }
34499
34524
  getGraphicBounds(graphic) {
34500
34525
  let point = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
34501
- return (null == graphic ? void 0 : graphic.AABBBounds) || {
34502
- x1: point.x,
34503
- x2: point.x,
34504
- y1: point.y,
34505
- y2: point.y
34526
+ if (graphic) {
34527
+ if (!1 !== graphic.attribute.visible) return graphic.AABBBounds;
34528
+ const {
34529
+ x: x,
34530
+ y: y
34531
+ } = graphic.attribute;
34532
+ return {
34533
+ x1: x,
34534
+ x2: x,
34535
+ y1: y,
34536
+ y2: y
34537
+ };
34538
+ }
34539
+ const {
34540
+ x: x,
34541
+ y: y
34542
+ } = point;
34543
+ return {
34544
+ x1: x,
34545
+ x2: x,
34546
+ y1: y,
34547
+ y2: y
34506
34548
  };
34507
34549
  }
34508
34550
  _renderLabels(labels) {
@@ -47693,9 +47735,10 @@
47693
47735
  return [];
47694
47736
  };
47695
47737
 
47738
+ const HIDE_KEY = "_mo_hide_";
47696
47739
  function reset(elements) {
47697
47740
  return elements.forEach(element => {
47698
- element.setGraphicAttribute("visible", !0);
47741
+ element.getGraphicAttribute("HIDE_KEY") && (element.setGraphicAttribute("visible", !0), element.setGraphicAttribute(HIDE_KEY, !1));
47699
47742
  }), elements;
47700
47743
  }
47701
47744
  function overlapX(elements, delta, deltaMul, useRadius) {
@@ -47705,9 +47748,10 @@
47705
47748
  const useDeltaMul = isNil$1(delta);
47706
47749
  let itemDelta = delta;
47707
47750
  elements.forEach(element => {
47751
+ if (!1 === element.getGraphicAttribute("visible")) return;
47708
47752
  const r = element.getGraphicAttribute("size") / 2,
47709
47753
  currentX = element.getGraphicAttribute("x");
47710
- useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentX - lastX) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || element.setGraphicAttribute("visible", !1) : lastX = currentX, lastR = r;
47754
+ useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentX - lastX) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || (element.setGraphicAttribute(HIDE_KEY, !0), element.setGraphicAttribute("visible", !1)) : lastX = currentX, lastR = r;
47711
47755
  });
47712
47756
  }
47713
47757
  }
@@ -47718,9 +47762,10 @@
47718
47762
  const useDeltaMul = isNil$1(delta);
47719
47763
  let itemDelta = delta;
47720
47764
  elements.forEach(element => {
47765
+ if (!1 === element.getGraphicAttribute("visible")) return;
47721
47766
  const r = element.getGraphicAttribute("size") / 2,
47722
47767
  currentY = element.getGraphicAttribute("y");
47723
- useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentY - lastY) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || element.setGraphicAttribute("visible", !1) : lastY = currentY, lastR = r;
47768
+ useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentY - lastY) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || (element.setGraphicAttribute(HIDE_KEY, !0), element.setGraphicAttribute("visible", !1)) : lastY = currentY, lastR = r;
47724
47769
  });
47725
47770
  }
47726
47771
  }
@@ -47733,10 +47778,11 @@
47733
47778
  const useDeltaMul = isNil$1(delta);
47734
47779
  let itemDelta = delta;
47735
47780
  elements.forEach(element => {
47781
+ if (!1 === element.getGraphicAttribute("visible")) return;
47736
47782
  const r = element.getGraphicAttribute("size") / 2,
47737
47783
  currentX = element.getGraphicAttribute("x"),
47738
47784
  currentY = element.getGraphicAttribute("y");
47739
- useDeltaMul && (itemDelta = (r + lastR) * deltaMul), dis = (lastX - currentX) ** 2 + (lastY - currentY) ** 2, dis < (itemDelta + lastR + r) ** 2 ? element.getGraphicAttribute("forceShow") || element.setGraphicAttribute("visible", !1) : lastY = currentY, lastR = r;
47785
+ useDeltaMul && (itemDelta = (r + lastR) * deltaMul), dis = (lastX - currentX) ** 2 + (lastY - currentY) ** 2, dis < (itemDelta + lastR + r) ** 2 ? element.getGraphicAttribute("forceShow") || (element.setGraphicAttribute(HIDE_KEY, !0), element.setGraphicAttribute("visible", !1)) : lastY = currentY, lastR = r;
47740
47786
  });
47741
47787
  }
47742
47788
  }
@@ -48346,7 +48392,7 @@
48346
48392
  };
48347
48393
  return points.forEach(point => {
48348
48394
  center.x += point.x, center.y += point.y;
48349
- }), center.x /= points.length, center.y /= points.length, options && options.center && (isValidNumber$1(options.center.x) && (center.x = options.center.x), isValidNumber$1(options.center.y) && (center.y = options.center.y)), points.map(() => Object.assign(center));
48395
+ }), center.x /= points.length, center.y /= points.length, options && options.center && (isValidNumber$1(options.center.x) && (center.x = options.center.x), isValidNumber$1(options.center.y) && (center.y = options.center.y)), "area" === element.mark.markType && (center.x1 = center.x, center.y1 = center.y), points.map(() => Object.assign(center));
48350
48396
  };
48351
48397
  const growPointsIn = (element, options, animationParameters) => ({
48352
48398
  from: {
@@ -57849,7 +57895,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
57849
57895
  registerChartPlugin(MediaQuery);
57850
57896
  };
57851
57897
 
57852
- const version = "1.8.5";
57898
+ const version = "1.8.6";
57853
57899
 
57854
57900
  var ChartTypeEnum;
57855
57901
  (function (ChartTypeEnum) {
@@ -63223,7 +63269,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
63223
63269
  (_a = this._option) === null || _a === void 0 ? void 0 : _a.onError(`${key}Field is required.`);
63224
63270
  return spec;
63225
63271
  }
63226
- if (spec.length > 2) {
63272
+ if (defaultScaleType !== 'ordinal' && spec.length > 2) {
63227
63273
  (_b = this._option) === null || _b === void 0 ? void 0 : _b.onError(`${key} length is invalid, specify up to 2 ${key}s.`);
63228
63274
  return spec;
63229
63275
  }
@@ -72483,7 +72529,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
72483
72529
  themeSpec: (_a = this._theme) === null || _a === void 0 ? void 0 : _a.funnel,
72484
72530
  morph: shouldMarkDoMorph(this._spec, this._funnelMarkName),
72485
72531
  defaultMorphElementKey: this._seriesField,
72486
- key: this._seriesField,
72487
72532
  groupKey: this._seriesField,
72488
72533
  isSeriesMark: true,
72489
72534
  customShape: (_b = this._spec.funnel) === null || _b === void 0 ? void 0 : _b.customShape
@@ -72491,7 +72536,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
72491
72536
  if (this._spec.isTransform) {
72492
72537
  this._funnelTransformMark = this._createMark(Object.assign(Object.assign({}, FunnelSeries.mark.transform), { name: this._transformMarkName, type: this._transformMarkType }), {
72493
72538
  themeSpec: (_c = this._theme) === null || _c === void 0 ? void 0 : _c.transform,
72494
- key: this._seriesField,
72495
72539
  skipBeforeLayouted: false,
72496
72540
  dataView: this._viewDataTransform.getDataView(),
72497
72541
  dataProductId: this._viewDataTransform.getProductId(),
@@ -72503,13 +72547,11 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
72503
72547
  const { line: lineTheme } = (_j = (_h = this._theme) === null || _h === void 0 ? void 0 : _h.outerLabel) !== null && _j !== void 0 ? _j : {};
72504
72548
  this._funnelOuterLabelMark.label = this._createMark(FunnelSeries.mark.outerLabel, {
72505
72549
  themeSpec: (_k = this._theme) === null || _k === void 0 ? void 0 : _k.outerLabel,
72506
- key: this._seriesField,
72507
72550
  markSpec: this._spec.outerLabel,
72508
72551
  skipBeforeLayouted: true
72509
72552
  });
72510
72553
  this._funnelOuterLabelMark.line = this._createMark(FunnelSeries.mark.outerLabelLine, {
72511
72554
  themeSpec: lineTheme,
72512
- key: this._seriesField,
72513
72555
  markSpec: line,
72514
72556
  depend: [this._funnelOuterLabelMark.label]
72515
72557
  });
@@ -72715,7 +72757,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
72715
72757
  }
72716
72758
  _getMainAxisLength(isTransform = false) {
72717
72759
  var _a;
72718
- const funnelCount = this.getViewDataStatistics().latestData[this.getCategoryField()].values.length;
72760
+ const funnelCount = this.getViewData().latestData.length;
72719
72761
  const viewHeight = this._isHorizontal() ? this.getLayoutRect().width : this.getLayoutRect().height;
72720
72762
  const hasTransform = !!this._spec.isTransform;
72721
72763
  const gap = hasTransform ? 0 : (_a = this._spec.gap) !== null && _a !== void 0 ? _a : 0;
@@ -72734,7 +72776,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
72734
72776
  }
72735
72777
  _getPositionByData(datum) {
72736
72778
  var _a;
72737
- const index = (_a = this.getViewData().latestData) === null || _a === void 0 ? void 0 : _a.findIndex((d) => d[this._seriesField] === datum[this._seriesField]);
72779
+ const index = (_a = this.getViewData().latestData) === null || _a === void 0 ? void 0 : _a.findIndex((d) => d[this._categoryField] === datum[this._categoryField] && d[DEFAULT_DATA_KEY] === datum[DEFAULT_DATA_KEY]);
72738
72780
  if (!isValid$1(index) || index < 0) {
72739
72781
  return {};
72740
72782
  }