@visactor/vchart 1.12.14 → 1.12.15

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
@@ -31743,10 +31743,11 @@
31743
31743
  let candidates = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
31744
31744
  let clampForce = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : !0;
31745
31745
  let pad = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
31746
+ let changePosition = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : !1;
31746
31747
  const validCandidates = candidates.filter(candidate => isValid$1(candidate));
31747
31748
  for (let i = 0; i < validCandidates.length; i++) {
31748
- const tempText = text.clone();
31749
- if (tempText.setAttributes(validCandidates[i]), tempText.update(), canPlace($, bitmap, tempText.AABBBounds, clampForce, pad)) return bitmap.setRange(boundToRange($, tempText.AABBBounds, !0)), validCandidates[i];
31749
+ let measureText;
31750
+ if (measureText = changePosition ? text : text.clone(), measureText.setAttributes(validCandidates[i]), canPlace($, bitmap, measureText.AABBBounds, clampForce, pad)) return bitmap.setRange(boundToRange($, measureText.AABBBounds, !0)), validCandidates[i];
31750
31751
  }
31751
31752
  return !1;
31752
31753
  }
@@ -31756,8 +31757,9 @@
31756
31757
  overlapPadding = null === (_b = attrs.overlap) || void 0 === _b ? void 0 : _b.overlapPadding;
31757
31758
  if ("bound" === s.type || "position" === s.type) {
31758
31759
  if (isFunction$1(labeling)) {
31759
- const candidates = ((isFunction$1(s.position) ? s.position(text.attribute) : s.position) || defaultLabelPosition(attrs.type)).map(p => labeling(text.AABBBounds, bounds, p, attrs.offset));
31760
- return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);
31760
+ const candidates = ((isFunction$1(s.position) ? s.position(text.attribute) : s.position) || defaultLabelPosition(attrs.type)).map(p => labeling(text.AABBBounds, bounds, p, attrs.offset)),
31761
+ shouldClone = !1 === s.restorePosition;
31762
+ return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding, shouldClone);
31761
31763
  }
31762
31764
  return !1;
31763
31765
  }
@@ -32141,18 +32143,18 @@
32141
32143
  textInformation.get(text).attempts = attempts;
32142
32144
  };
32143
32145
  function adjustPositionInOneGroup(texts) {
32144
- var text;
32145
- if (1 !== texts.length) for (let i = texts.length - 1; i > 0; i--) {
32146
+ for (let i = texts.length - 1; i >= 0; i--) {
32146
32147
  const curText = texts[i],
32147
32148
  upperText = texts[i - 1],
32148
32149
  lowerText = texts[i + 1];
32149
- if (isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText))) {
32150
+ if (upperText && isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText)) || 0 === getY1(curText) && curText._isClamped) {
32150
32151
  const {
32151
32152
  y: y
32152
32153
  } = labelling(curText);
32153
32154
  lowerText && isIntersect(y + getHeight(curText) / 2, getY1(lowerText)) || y + getHeight(curText) / 2 <= maxY && setY1(curText, getY1(curText) + y - (text = curText, textInformation.get(text).y));
32154
32155
  }
32155
32156
  }
32157
+ var text;
32156
32158
  }
32157
32159
  texts.sort((a, b) => a.attribute.x - b.attribute.x);
32158
32160
  for (const text of texts) {
@@ -32516,12 +32518,35 @@
32516
32518
  const text = result[i],
32517
32519
  bounds = text.AABBBounds,
32518
32520
  range = boundToRange(bmpTool, bounds, !0);
32519
- canPlace(bmpTool, bitmap, bounds, clampForce, text._isClamped ? 0 : overlapPadding) ? bitmap.setRange(range) : hideOnHit ? text.setAttributes({
32520
- visible: !1
32521
- }) : bitmap.setRange(range);
32521
+ if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) bitmap.setRange(range);else {
32522
+ if (clampForce) {
32523
+ if (this._processClampForce(text, bmpTool, bitmap)) continue;
32524
+ }
32525
+ hideOnHit ? text.setAttributes({
32526
+ visible: !1
32527
+ }) : bitmap.setRange(range);
32528
+ }
32522
32529
  }
32523
32530
  return result;
32524
32531
  }
32532
+ _processClampForce(text, bmpTool, bitmap) {
32533
+ const {
32534
+ dy = 0,
32535
+ dx = 0
32536
+ } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
32537
+ if (0 === dx && 0 === dy) {
32538
+ if (canPlace(bmpTool, bitmap, text.AABBBounds)) return bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), !0;
32539
+ } else if (canPlace(bmpTool, bitmap, {
32540
+ x1: text.AABBBounds.x1 + dx,
32541
+ x2: text.AABBBounds.x2 + dx,
32542
+ y1: text.AABBBounds.y1 + dy,
32543
+ y2: text.AABBBounds.y2 + dy
32544
+ })) return text.setAttributes({
32545
+ x: text.attribute.x + dx,
32546
+ y: text.attribute.y + dy
32547
+ }), bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), !0;
32548
+ return !1;
32549
+ }
32525
32550
  _overlapByStrategy(labels, option, bmpTool, bitmap) {
32526
32551
  var _a;
32527
32552
  const {
@@ -32570,25 +32595,8 @@
32570
32595
  break;
32571
32596
  }
32572
32597
  if (!hasPlace && clampForce) {
32573
- const {
32574
- dx = 0,
32575
- dy = 0
32576
- } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
32577
- if (0 === dx && 0 === dy) {
32578
- if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
32579
- bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
32580
- continue;
32581
- }
32582
- } else if (canPlace(bmpTool, bitmap, {
32583
- x1: text.AABBBounds.x1 + dx,
32584
- x2: text.AABBBounds.x2 + dx,
32585
- y1: text.AABBBounds.y1 + dy,
32586
- y2: text.AABBBounds.y2 + dy
32587
- })) {
32588
- text.setAttributes({
32589
- x: text.attribute.x + dx,
32590
- y: text.attribute.y + dy
32591
- }), bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, !0)), result.push(text);
32598
+ if (this._processClampForce(text, bmpTool, bitmap)) {
32599
+ result.push(text);
32592
32600
  continue;
32593
32601
  }
32594
32602
  }
@@ -61926,7 +61934,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
61926
61934
  };
61927
61935
  registerVChartCore();
61928
61936
 
61929
- const version = "1.12.14";
61937
+ const version = "1.12.15";
61930
61938
 
61931
61939
  const addVChartProperty = (data, op) => {
61932
61940
  const context = op.beforeCall();