@visactor/vchart 1.2.3 → 1.2.4

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
@@ -30034,7 +30034,8 @@
30034
30034
  getBoundingClientRect: () => ({
30035
30035
  height: domref.height,
30036
30036
  width: domref.width
30037
- })
30037
+ }),
30038
+ nativeCanvas: _canvas
30038
30039
  };
30039
30040
  canvasMap.set(id, canvas), i >= freeCanvasIdx && freeCanvasList.push(canvas);
30040
30041
  });
@@ -31277,7 +31278,10 @@
31277
31278
  applyPosition() {}
31278
31279
  hide() {}
31279
31280
  show() {}
31280
- resize(width, height) {}
31281
+ resize(width, height) {
31282
+ this._pixelWidth = width * this._dpr, this._pixelHeight = height * this._dpr, this._displayWidth = width, this._displayHeight = height, this._nativeCanvas.width = this._pixelWidth, this._nativeCanvas.height = this._pixelHeight, this._nativeCanvas.nativeCanvas && (this._nativeCanvas.nativeCanvas.width = this._pixelWidth, this._nativeCanvas.nativeCanvas.height = this._pixelHeight);
31283
+ this._context.dpr = this._dpr;
31284
+ }
31281
31285
  toDataURL(mimeType, quality) {
31282
31286
  return "";
31283
31287
  }
@@ -31389,7 +31393,9 @@
31389
31393
  });
31390
31394
  }
31391
31395
  releaseWindow() {}
31392
- resizeWindow(width, height) {}
31396
+ resizeWindow(width, height) {
31397
+ this.canvas.resize(width, height);
31398
+ }
31393
31399
  setDpr(dpr) {
31394
31400
  this.canvas.dpr = dpr;
31395
31401
  }
@@ -40735,29 +40741,34 @@
40735
40741
  }
40736
40742
  return t;
40737
40743
  };
40744
+ const _tBounds = new AABBBounds();
40738
40745
  class PopTip extends AbstractComponent {
40739
40746
  constructor(attributes) {
40740
40747
  super(merge$2({}, PopTip.defaultAttributes, attributes)), this.name = "poptip", this.positionList = ["top", "tl", "tr", "bottom", "bl", "br", "left", "lt", "lb", "right", "rt", "rb"];
40741
40748
  }
40742
40749
  render() {
40743
- var _a, _b, _c, _d, _e;
40750
+ var _a, _b, _c, _d, _e, _f, _g, _h;
40744
40751
  const {
40745
- title = "",
40746
- titleStyle = {},
40747
- position: position,
40748
- content = "",
40749
- contentStyle = {},
40750
- panel = {},
40751
- space = 4,
40752
- minWidth = 0,
40753
- maxWidth = 1 / 0,
40754
- padding = 4,
40755
- visible: visible,
40756
- state: state,
40757
- dx = 0,
40758
- dy = 0
40759
- } = this.attribute,
40760
- parsedPadding = normalizePadding$1(padding),
40752
+ titleStyle = {},
40753
+ position: position,
40754
+ contentStyle = {},
40755
+ panel = {},
40756
+ space = 4,
40757
+ minWidth = 0,
40758
+ maxWidth = 1 / 0,
40759
+ padding = 4,
40760
+ maxWidthPercent: maxWidthPercent,
40761
+ visible: visible,
40762
+ state: state,
40763
+ dx = 0,
40764
+ dy = 0
40765
+ } = this.attribute;
40766
+ let {
40767
+ title = "",
40768
+ content = ""
40769
+ } = this.attribute;
40770
+ title = this.attribute.titleFormatMethod ? this.attribute.titleFormatMethod(title) : title, content = this.attribute.contentFormatMethod ? this.attribute.contentFormatMethod(content) : content;
40771
+ const parsedPadding = normalizePadding$1(padding),
40761
40772
  group = this.createOrUpdateChild("poptip-content", {
40762
40773
  x: 0,
40763
40774
  y: 0,
@@ -40766,7 +40777,7 @@
40766
40777
  maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3],
40767
40778
  titleVisible = isValid(title) && !1 !== visible,
40768
40779
  titleAttrs = Object.assign(Object.assign({
40769
- text: title,
40780
+ text: isArray$3(title) ? title : [title],
40770
40781
  visible: titleVisible
40771
40782
  }, titleStyle), {
40772
40783
  x: parsedPadding[3],
@@ -40775,7 +40786,7 @@
40775
40786
  textAlign: "left",
40776
40787
  textBaseline: "top"
40777
40788
  }),
40778
- titleShape = group.createOrUpdateChild("poptip-title", titleAttrs, "text");
40789
+ titleShape = group.createOrUpdateChild("poptip-title", titleAttrs, "wrapText");
40779
40790
  isEmpty(null == state ? void 0 : state.title) || (titleShape.states = state.title);
40780
40791
  const titleBounds = titleShape.AABBBounds,
40781
40792
  titleHeight = titleBounds.height(),
@@ -40784,7 +40795,7 @@
40784
40795
  titleVisible || (height = 0);
40785
40796
  const contentVisible = isValid(content) && !1 !== visible,
40786
40797
  contentAttrs = Object.assign(Object.assign({
40787
- text: content,
40798
+ text: isArray$3(content) ? content : [content],
40788
40799
  visible: contentVisible
40789
40800
  }, contentStyle), {
40790
40801
  x: parsedPadding[3],
@@ -40793,7 +40804,7 @@
40793
40804
  textAlign: "left",
40794
40805
  textBaseline: "top"
40795
40806
  }),
40796
- contentShape = group.createOrUpdateChild("poptip-content", contentAttrs, "text");
40807
+ contentShape = group.createOrUpdateChild("poptip-content", contentAttrs, "wrapText");
40797
40808
  isEmpty(null == state ? void 0 : state.content) || (contentShape.states = state.content);
40798
40809
  const contentBounds = contentShape.AABBBounds,
40799
40810
  contentHeight = contentBounds.height(),
@@ -40801,20 +40812,32 @@
40801
40812
  contentVisible && (height += contentHeight);
40802
40813
  let popTipWidth = max$3(titleWidth + parsedPadding[1] + parsedPadding[3], contentWidth + parsedPadding[1] + parsedPadding[3]);
40803
40814
  popTipWidth > maxWidth ? popTipWidth = maxWidth : popTipWidth < minWidth && (popTipWidth = minWidth);
40804
- const poptipHeight = parsedPadding[0] + parsedPadding[2] + height,
40805
- {
40815
+ let poptipHeight = parsedPadding[0] + parsedPadding[2] + height;
40816
+ const {
40806
40817
  visible: bgVisible
40807
40818
  } = panel,
40808
40819
  backgroundStyle = __rest$5(panel, ["visible"]),
40809
40820
  symbolSize = null !== (_a = backgroundStyle.size) && void 0 !== _a ? _a : 12,
40810
40821
  spaceSize = isArray$3(symbolSize) ? [symbolSize[0] + (null !== (_b = backgroundStyle.space) && void 0 !== _b ? _b : 0), symbolSize[1] + (null !== (_c = backgroundStyle.space) && void 0 !== _c ? _c : 0)] : symbolSize + (null !== (_d = backgroundStyle.space) && void 0 !== _d ? _d : 0),
40811
40822
  lineWidth = null !== (_e = backgroundStyle.lineWidth) && void 0 !== _e ? _e : 1,
40812
- range = this.stage ? [this.stage.width, this.stage.height] : void 0,
40813
- layout = "auto" === position;
40814
- let minifyBBoxI,
40815
- minifyBBoxSize = 1 / 0;
40823
+ range = this.stage ? [null !== (_f = this.stage.viewWidth) && void 0 !== _f ? _f : this.stage.width, null !== (_g = this.stage.viewHeight) && void 0 !== _g ? _g : this.stage.height] : void 0;
40824
+ if (range) {
40825
+ const b = this.AABBBounds,
40826
+ leftWidth = null !== (_h = this.attribute.x) && void 0 !== _h ? _h : b.x1,
40827
+ rightWidth = range[0] - b.x1;
40828
+ let maxSpace = Math.max(leftWidth, rightWidth);
40829
+ const buf = (isArray$3(symbolSize) ? symbolSize[0] : 12) + 3;
40830
+ if (maxSpace = Math.min(maxSpace - buf, maxSpace * maxWidthPercent), maxSpace < popTipWidth) {
40831
+ popTipWidth = maxSpace;
40832
+ const buf = parsedPadding[1] + parsedPadding[3];
40833
+ titleShape.setAttribute("maxLineWidth", maxSpace - buf), contentShape.setAttribute("maxLineWidth", maxSpace - buf), poptipHeight = parsedPadding[0] + parsedPadding[2], titleVisible && (poptipHeight += titleShape.AABBBounds.height() + space), poptipHeight += contentShape.AABBBounds.height();
40834
+ }
40835
+ }
40836
+ const layout = "auto" === position;
40837
+ let maxBBoxI,
40838
+ maxBBoxSize = -1 / 0;
40816
40839
  for (let i = 0; i < this.positionList.length + 1; i++) {
40817
- const p = layout ? this.positionList[i === this.positionList.length ? minifyBBoxI : i] : position,
40840
+ const p = layout ? this.positionList[i === this.positionList.length ? maxBBoxI : i] : position,
40818
40841
  {
40819
40842
  angle: angle,
40820
40843
  offset: offset,
@@ -40852,13 +40875,14 @@
40852
40875
  y: -offset[1] + dy
40853
40876
  }), !layout || !range) break;
40854
40877
  {
40855
- const b = this.AABBBounds,
40878
+ _tBounds.setValue(0, 0, popTipWidth, poptipHeight).transformWithMatrix(group.globalTransMatrix);
40879
+ const b = _tBounds,
40856
40880
  stageBounds = new Bounds().setValue(0, 0, range[0], range[1]);
40857
40881
  if (rectInsideAnotherRect(b, stageBounds, !1)) break;
40858
40882
  {
40859
40883
  const bbox = getRectIntersect(b, stageBounds, !1),
40860
40884
  size = (bbox.x2 - bbox.x1) * (bbox.y2 - bbox.y1);
40861
- size < minifyBBoxSize && (minifyBBoxSize = size, minifyBBoxI = i);
40885
+ size > maxBBoxSize && (maxBBoxSize = size, maxBBoxI = i);
40862
40886
  }
40863
40887
  }
40864
40888
  }
@@ -40958,6 +40982,7 @@
40958
40982
  textAlign: "left",
40959
40983
  textBaseline: "top"
40960
40984
  },
40985
+ maxWidthPercent: .8,
40961
40986
  space: 8,
40962
40987
  padding: 10
40963
40988
  };
@@ -41006,7 +41031,8 @@
41006
41031
  visibleCb: visibleCb
41007
41032
  } = graphic.attribute.poptip || {};
41008
41033
  if (!1 === visible || visibleCb && !1 === visibleCb(graphic)) return;
41009
- this.poptipComponent || (this.poptipComponent = new PopTip(graphic.attribute.poptip));
41034
+ const attribute = {};
41035
+ graphic.attribute.poptip && merge$2(attribute, PopTip.defaultAttributes, graphic.attribute.poptip), this.poptipComponent ? this.poptipComponent.initAttributes(attribute) : this.poptipComponent = new PopTip(attribute);
41010
41036
  let poptip = graphic.attribute.poptip || {};
41011
41037
  if ("text" === graphic.type && null == poptip.title && null == poptip.content) {
41012
41038
  const out = {};
@@ -58440,7 +58466,7 @@
58440
58466
  VChart.useMark([ComponentMark, GroupMark, ImageMark]);
58441
58467
  Factory.registerRegion('region', Region);
58442
58468
  Factory.registerLayout('base', Layout);
58443
- const version = "1.2.3";
58469
+ const version = "1.2.4";
58444
58470
  Logger.getInstance(LoggerLevel.Error);
58445
58471
 
58446
58472
  var SeriesMarkNameEnum;