@visactor/vrender-components 0.14.2 → 0.14.3-alpha.1

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.
Files changed (69) hide show
  1. package/cjs/axis/base.d.ts +4 -0
  2. package/cjs/axis/base.js +3 -5
  3. package/cjs/axis/base.js.map +1 -1
  4. package/cjs/axis/circle.d.ts +5 -1
  5. package/cjs/axis/circle.js +6 -0
  6. package/cjs/axis/circle.js.map +1 -1
  7. package/cjs/axis/line.d.ts +5 -0
  8. package/cjs/axis/line.js +10 -3
  9. package/cjs/axis/line.js.map +1 -1
  10. package/cjs/axis/overlap/auto-rotate.d.ts +9 -1
  11. package/cjs/axis/overlap/auto-rotate.js +41 -30
  12. package/cjs/axis/overlap/auto-rotate.js.map +1 -1
  13. package/cjs/index.d.ts +1 -1
  14. package/cjs/index.js +1 -1
  15. package/cjs/index.js.map +1 -1
  16. package/cjs/label/arc.d.ts +4 -9
  17. package/cjs/label/arc.js +56 -48
  18. package/cjs/label/arc.js.map +1 -1
  19. package/cjs/label/base.d.ts +3 -3
  20. package/cjs/label/base.js +18 -30
  21. package/cjs/label/base.js.map +1 -1
  22. package/cjs/label/type.d.ts +3 -1
  23. package/cjs/label/type.js.map +1 -1
  24. package/cjs/legend/constant.d.ts +2 -1
  25. package/cjs/legend/constant.js +1 -1
  26. package/cjs/legend/constant.js.map +1 -1
  27. package/cjs/legend/discrete/discrete.js +26 -13
  28. package/cjs/legend/discrete/discrete.js.map +1 -1
  29. package/cjs/marker/base.d.ts +3 -0
  30. package/cjs/marker/base.js +25 -6
  31. package/cjs/marker/base.js.map +1 -1
  32. package/cjs/marker/type.d.ts +6 -0
  33. package/cjs/marker/type.js.map +1 -1
  34. package/dist/index.js +213 -134
  35. package/dist/index.min.js +1 -1
  36. package/es/axis/base.d.ts +4 -0
  37. package/es/axis/base.js +3 -5
  38. package/es/axis/base.js.map +1 -1
  39. package/es/axis/circle.d.ts +5 -1
  40. package/es/axis/circle.js +6 -0
  41. package/es/axis/circle.js.map +1 -1
  42. package/es/axis/line.d.ts +5 -0
  43. package/es/axis/line.js +11 -3
  44. package/es/axis/line.js.map +1 -1
  45. package/es/axis/overlap/auto-rotate.d.ts +9 -1
  46. package/es/axis/overlap/auto-rotate.js +38 -28
  47. package/es/axis/overlap/auto-rotate.js.map +1 -1
  48. package/es/index.d.ts +1 -1
  49. package/es/index.js +1 -1
  50. package/es/index.js.map +1 -1
  51. package/es/label/arc.d.ts +4 -9
  52. package/es/label/arc.js +37 -32
  53. package/es/label/arc.js.map +1 -1
  54. package/es/label/base.d.ts +3 -3
  55. package/es/label/base.js +17 -31
  56. package/es/label/base.js.map +1 -1
  57. package/es/label/type.d.ts +3 -1
  58. package/es/label/type.js.map +1 -1
  59. package/es/legend/constant.d.ts +2 -1
  60. package/es/legend/constant.js +1 -1
  61. package/es/legend/constant.js.map +1 -1
  62. package/es/legend/discrete/discrete.js +26 -13
  63. package/es/legend/discrete/discrete.js.map +1 -1
  64. package/es/marker/base.d.ts +3 -0
  65. package/es/marker/base.js +26 -5
  66. package/es/marker/base.js.map +1 -1
  67. package/es/marker/type.d.ts +6 -0
  68. package/es/marker/type.js.map +1 -1
  69. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1587,7 +1587,7 @@
1587
1587
  setBitmapTool(bmpTool) {
1588
1588
  this._bmpTool = bmpTool;
1589
1589
  }
1590
- layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray) {
1590
+ layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray, ellipsisWidth) {
1591
1591
  const arcs = [];
1592
1592
  return arcs;
1593
1593
  }
@@ -1680,7 +1680,6 @@
1680
1680
  }
1681
1681
  }
1682
1682
  layout(data = []) {
1683
- var _a;
1684
1683
  const { textStyle = {}, position, offset } = this.attribute;
1685
1684
  const labels = [];
1686
1685
  const textBoundsArray = [];
@@ -1702,15 +1701,23 @@
1702
1701
  labels.push(text);
1703
1702
  }
1704
1703
  if (this.attribute.type === 'arc') {
1705
- const arcs = this.layoutArcLabels(position, this.attribute, Array.from(this._idToGraphic.values()), data, textBoundsArray);
1704
+ const ellipsisLabelAttribute = Object.assign(Object.assign({}, this.attribute.textStyle), { text: '...' });
1705
+ const ellipsisText = this._createLabelText(ellipsisLabelAttribute);
1706
+ const ellipsisTextBounds = this.getGraphicBounds(ellipsisText);
1707
+ const ellipsisWidth = ellipsisTextBounds.x2 - ellipsisTextBounds.x1;
1708
+ const arcs = this.layoutArcLabels(position, this.attribute, Array.from(this._idToGraphic.values()), data, textBoundsArray, ellipsisWidth);
1706
1709
  for (let i = 0; i < data.length; i++) {
1707
1710
  const textData = data[i];
1708
- const basedArc = arcs.find(arc => arc.labelText === textData.text);
1711
+ const basedArc = arcs.find(arc => arc.refDatum.id === textData.id);
1709
1712
  const labelAttribute = {
1713
+ visible: basedArc.labelVisible,
1710
1714
  x: basedArc.labelPosition.x,
1711
1715
  y: basedArc.labelPosition.y,
1712
- angle: (_a = this.attribute.angle) !== null && _a !== void 0 ? _a : basedArc.angle,
1713
- labelLinePath: basedArc.labelLinePath
1716
+ angle: basedArc.angle,
1717
+ maxLineWidth: basedArc.labelLimit,
1718
+ points: (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointA) && (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointB) && (basedArc === null || basedArc === void 0 ? void 0 : basedArc.pointC)
1719
+ ? [basedArc.pointA, basedArc.pointB, basedArc.pointC]
1720
+ : undefined
1714
1721
  };
1715
1722
  labels[i].setAttributes(labelAttribute);
1716
1723
  }
@@ -1772,20 +1779,6 @@
1772
1779
  continue;
1773
1780
  }
1774
1781
  }
1775
- if (clampForce) {
1776
- const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
1777
- if (!(dx === 0 && dy === 0) &&
1778
- canPlace(bmpTool, bitmap, {
1779
- x1: text.AABBBounds.x1 + dx,
1780
- x2: text.AABBBounds.x2 + dx,
1781
- y1: text.AABBBounds.y1 + dy,
1782
- y2: text.AABBBounds.y2 + dy
1783
- })) {
1784
- text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
1785
- result.push(text);
1786
- continue;
1787
- }
1788
- }
1789
1782
  let hasPlace = false;
1790
1783
  for (let j = 0; j < strategy.length; j++) {
1791
1784
  hasPlace = place(bmpTool, bitmap, strategy[j], this.attribute, text, this.getGraphicBounds(baseMark, labels[i]), this.labeling);
@@ -1845,13 +1838,13 @@
1845
1838
  const prevTextMap = this._graphicToText || new Map();
1846
1839
  const texts = [];
1847
1840
  labels.forEach((text, index) => {
1848
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1849
- const labelLine = ((_a = text.attribute) === null || _a === void 0 ? void 0 : _a.labelLinePath)
1850
- ? vrender.createPath({
1841
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
1842
+ const labelLine = ((_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points)
1843
+ ? vrender.createLine({
1851
1844
  visible: (_c = (_b = text.attribute) === null || _b === void 0 ? void 0 : _b.visible) !== null && _c !== void 0 ? _c : true,
1852
1845
  stroke: (_f = (_e = (_d = text.attribute) === null || _d === void 0 ? void 0 : _d.line) === null || _e === void 0 ? void 0 : _e.stroke) !== null && _f !== void 0 ? _f : (_g = text.attribute) === null || _g === void 0 ? void 0 : _g.fill,
1853
- lineWidth: 1,
1854
- path: (_h = text.attribute) === null || _h === void 0 ? void 0 : _h.labelLinePath
1846
+ lineWidth: (_k = (_j = (_h = text.attribute) === null || _h === void 0 ? void 0 : _h.line) === null || _j === void 0 ? void 0 : _j.lineWidth) !== null && _k !== void 0 ? _k : 1,
1847
+ points: (_l = text.attribute) === null || _l === void 0 ? void 0 : _l.points
1855
1848
  })
1856
1849
  : undefined;
1857
1850
  const relatedGraphic = this._idToGraphic.get(text.attribute.id);
@@ -1892,9 +1885,9 @@
1892
1885
  const prevText = prevLabel.text;
1893
1886
  prevText.animate().to(text.attribute, duration, easing);
1894
1887
  if (prevLabel.labelLine) {
1895
- prevLabel.labelLine
1896
- .animate()
1897
- .to(vutils.merge({}, prevLabel.labelLine.attribute, { path: (_j = text.attribute) === null || _j === void 0 ? void 0 : _j.labelLinePath }), duration, easing);
1888
+ prevLabel.labelLine.animate().to(vutils.merge({}, prevLabel.labelLine.attribute, {
1889
+ points: (_m = text.attribute) === null || _m === void 0 ? void 0 : _m.points
1890
+ }), duration, easing);
1898
1891
  }
1899
1892
  if (animationConfig.increaseEffect !== false &&
1900
1893
  prevText.attribute.text !== text.attribute.text &&
@@ -1907,7 +1900,7 @@
1907
1900
  else {
1908
1901
  prevLabel.text.setAttributes(text.attribute);
1909
1902
  if (prevLabel === null || prevLabel === void 0 ? void 0 : prevLabel.labelLine) {
1910
- prevLabel.labelLine.setAttributes({ path: (_k = text.attribute) === null || _k === void 0 ? void 0 : _k.labelLinePath });
1903
+ prevLabel.labelLine.setAttributes({ points: (_o = text.attribute) === null || _o === void 0 ? void 0 : _o.points });
1911
1904
  }
1912
1905
  }
1913
1906
  }
@@ -2384,15 +2377,18 @@
2384
2377
  }
2385
2378
  return { x: 0, y: 0 };
2386
2379
  }
2387
- layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray) {
2380
+ layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray, ellipsisWidth) {
2381
+ var _a;
2388
2382
  this._arcLeft.clear();
2389
2383
  this._arcRight.clear();
2384
+ this._ellipsisWidth = ellipsisWidth;
2390
2385
  const { width, height } = attribute;
2386
+ const centerOffset = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _a !== void 0 ? _a : 0;
2391
2387
  currentMarks.forEach((currentMark, index) => {
2392
2388
  var _a, _b;
2393
2389
  const graphicAttribute = currentMark.attribute;
2394
2390
  const radiusRatio = this.computeLayoutOuterRadius(graphicAttribute.outerRadius, width, height);
2395
- const radius = this.computeRadius(radiusRatio, width, height);
2391
+ const radius = this.computeRadius(radiusRatio, width, height, centerOffset);
2396
2392
  const center = { x: (_a = graphicAttribute === null || graphicAttribute === void 0 ? void 0 : graphicAttribute.x) !== null && _a !== void 0 ? _a : 0, y: (_b = graphicAttribute === null || graphicAttribute === void 0 ? void 0 : graphicAttribute.y) !== null && _b !== void 0 ? _b : 0 };
2397
2393
  const item = data[index];
2398
2394
  const textBounds = textBoundsArray[index];
@@ -2402,7 +2398,7 @@
2402
2398
  const arcMiddle = circlePoint(center.x, center.y, graphicAttribute.outerRadius, arcMiddleAngle);
2403
2399
  const outerArcMiddle = circlePoint(center.x, center.y, radius + attribute.line.line1MinLength, arcMiddleAngle);
2404
2400
  const arc = new ArcInfo(item, arcMiddle, outerArcMiddle, arcQuadrant, intervalAngle, arcMiddleAngle);
2405
- arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius), arc.middleAngle);
2401
+ arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(center.x * 2, center.y * 2, graphicAttribute.outerRadius, centerOffset), arc.middleAngle);
2406
2402
  arc.labelSize = {
2407
2403
  width: textBounds.x2 - textBounds.x1,
2408
2404
  height: textBounds.y2 - textBounds.y1
@@ -2428,16 +2424,18 @@
2428
2424
  return arcs;
2429
2425
  }
2430
2426
  _layoutInsideLabels(arcs, attribute, currentMarks) {
2431
- var _a, _b, _c, _d;
2427
+ var _a, _b, _c, _d, _e;
2432
2428
  const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
2429
+ const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
2433
2430
  const innerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.innerRadius, attribute.width, attribute.height);
2434
2431
  const outerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
2435
2432
  const labelConfig = attribute;
2436
2433
  const spaceWidth = labelConfig.spaceWidth;
2437
2434
  arcs.forEach((arc) => {
2435
+ var _a, _b;
2438
2436
  const { labelSize, radian } = arc;
2439
- const innerRadius = this.computeRadius(innerRadiusRatio, attribute.width, attribute.height, 1);
2440
- const outerRadius = this.computeRadius(outerRadiusRatio, attribute.width, attribute.height, 1);
2437
+ const innerRadius = this.computeRadius(innerRadiusRatio, attribute.width, attribute.height, centerOffset, 1);
2438
+ const outerRadius = this.computeRadius(outerRadiusRatio, attribute.width, attribute.height, centerOffset, 1);
2441
2439
  const minRadian = connectLineRadian(outerRadius, labelSize.height);
2442
2440
  let limit;
2443
2441
  if (radian < minRadian) {
@@ -2467,7 +2465,7 @@
2467
2465
  if (!vutils.isGreater(labelWidth, 0)) {
2468
2466
  arc.labelVisible = false;
2469
2467
  }
2470
- arc.angle = arc.middleAngle;
2468
+ arc.angle = (_b = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.textStyle) === null || _a === void 0 ? void 0 : _a.angle) !== null && _b !== void 0 ? _b : arc.middleAngle;
2471
2469
  });
2472
2470
  return arcs;
2473
2471
  }
@@ -2525,36 +2523,33 @@
2525
2523
  }
2526
2524
  const width = center.x * 2;
2527
2525
  arcs.forEach(arc => {
2526
+ var _a, _b;
2528
2527
  if (arc.labelVisible &&
2529
2528
  (vutils.isLess(arc.pointB.x, line2MinLength + spaceWidth) ||
2530
2529
  vutils.isGreater(arc.pointB.x, width - line2MinLength - spaceWidth))) {
2531
2530
  arc.labelVisible = false;
2532
2531
  }
2533
- arc.angle = 0;
2534
- arc.labelLinePath =
2535
- `M${Math.round(arc.pointA.x)},${Math.round(arc.pointA.y)}` +
2536
- ` L${Math.round(arc.pointB.x)},${Math.round(arc.pointB.y)}` +
2537
- ` L${Math.round(arc.pointC.x)},${Math.round(arc.pointC.y)}`;
2532
+ arc.angle = (_b = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.textStyle) === null || _a === void 0 ? void 0 : _a.angle) !== null && _b !== void 0 ? _b : 0;
2538
2533
  });
2539
2534
  return arcs;
2540
2535
  }
2541
2536
  _computeX(arc, attribute, currentMarks) {
2542
- var _a, _b, _c, _d, _e;
2537
+ var _a, _b, _c, _d, _e, _f;
2543
2538
  const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
2539
+ const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
2544
2540
  const plotLayout = { width: center.x * 2, height: center.y * 2 };
2545
2541
  const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
2546
2542
  const line1MinLength = attribute.line.line1MinLength;
2547
2543
  const line2MinLength = attribute.line.line2MinLength;
2548
- const labelLayoutAlign = (_e = attribute.layout) === null || _e === void 0 ? void 0 : _e.align;
2544
+ const labelLayoutAlign = (_f = attribute.layout) === null || _f === void 0 ? void 0 : _f.align;
2549
2545
  const spaceWidth = attribute.spaceWidth;
2550
- this._computeAlign(arc, attribute);
2551
2546
  const { labelPosition, quadrant, pointB } = arc;
2552
2547
  if (!vutils.isValidNumber(pointB.x * pointB.y)) {
2553
2548
  arc.pointC = { x: NaN, y: NaN };
2554
2549
  labelPosition.x = NaN;
2555
2550
  arc.labelLimit = 0;
2556
2551
  }
2557
- const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
2552
+ const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
2558
2553
  const flag = isQuadrantLeft(quadrant) ? -1 : 1;
2559
2554
  let cx = 0;
2560
2555
  const restWidth = flag > 0 ? plotLayout.width - pointB.x : pointB.x;
@@ -2578,16 +2573,17 @@
2578
2573
  break;
2579
2574
  }
2580
2575
  labelWidth = Math.max(this._ellipsisWidth, labelWidth);
2576
+ arc.labelLimit = labelWidth;
2581
2577
  arc.pointC = { x: cx, y: labelPosition.y };
2578
+ const targetCenterOffset = 0.5 * (arc.labelLimit < arc.labelSize.width ? arc.labelLimit : arc.labelSize.width);
2582
2579
  if (labelLayoutAlign === 'edge') {
2583
2580
  const alignOffset = 0;
2584
- labelPosition.x = flag > 0 ? plotLayout.width + alignOffset : alignOffset;
2581
+ labelPosition.x = (flag > 0 ? plotLayout.width + alignOffset : alignOffset) - flag * targetCenterOffset;
2585
2582
  }
2586
2583
  else {
2587
2584
  const alignOffset = 0;
2588
- labelPosition.x = cx + alignOffset + flag * (spaceWidth + 0.5 * arc.labelSize.width);
2585
+ labelPosition.x = cx + alignOffset + flag * (spaceWidth + 0.5 * targetCenterOffset);
2589
2586
  }
2590
- arc.labelLimit = labelWidth;
2591
2587
  }
2592
2588
  _computeAlignOffset(align, labelWidth, alignFlag) {
2593
2589
  switch (align) {
@@ -2771,7 +2767,7 @@
2771
2767
  return -1;
2772
2768
  }
2773
2769
  _computePointB(arc, r, attribute, currentMarks) {
2774
- var _a, _b, _c, _d;
2770
+ var _a, _b, _c, _d, _e;
2775
2771
  const labelConfig = attribute;
2776
2772
  const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
2777
2773
  const line1MinLength = labelConfig.line.line1MinLength;
@@ -2784,7 +2780,8 @@
2784
2780
  }
2785
2781
  else {
2786
2782
  const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
2787
- const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
2783
+ const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
2784
+ const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
2788
2785
  const { labelPosition, quadrant } = arc;
2789
2786
  const outerR = Math.max(radius + line1MinLength, currentMarks[0].attribute.outerRadius);
2790
2787
  const rd = r - outerR;
@@ -2808,13 +2805,14 @@
2808
2805
  }
2809
2806
  }
2810
2807
  _computeYRange(arc, attribute, currentMarks) {
2811
- var _a, _b, _c, _d;
2808
+ var _a, _b, _c, _d, _e;
2812
2809
  const center = { x: (_b = (_a = currentMarks[0].attribute) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0, y: (_d = (_c = currentMarks[0].attribute) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0 };
2813
2810
  const plotRect = { width: center.x * 2, height: center.y * 2 };
2814
2811
  const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
2815
2812
  const line1MinLength = attribute.line.line1MinLength;
2816
2813
  const { width, height } = plotRect;
2817
- const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
2814
+ const centerOffset = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _e !== void 0 ? _e : 0;
2815
+ const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
2818
2816
  const r = this._computeLayoutRadius(height / 2, attribute, currentMarks);
2819
2817
  const cx = Math.abs(arc.center.x - width / 2);
2820
2818
  const cy = arc.center.y - height / 2;
@@ -2873,11 +2871,13 @@
2873
2871
  arc.labelYRange = [min, max];
2874
2872
  }
2875
2873
  _computeLayoutRadius(halfYLength, attribute, currentMarks) {
2874
+ var _a;
2876
2875
  const labelConfig = attribute;
2877
2876
  const layoutArcGap = labelConfig.layoutArcGap;
2878
2877
  const line1MinLength = labelConfig.line.line1MinLength;
2879
2878
  const radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height);
2880
- const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height);
2879
+ const centerOffset = (_a = attribute === null || attribute === void 0 ? void 0 : attribute.centerOffset) !== null && _a !== void 0 ? _a : 0;
2880
+ const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset);
2881
2881
  const outerR = radius + line1MinLength;
2882
2882
  const a = outerR - layoutArcGap;
2883
2883
  return Math.max((a ** 2 + halfYLength ** 2) / (2 * a), outerR);
@@ -2943,8 +2943,9 @@
2943
2943
  }
2944
2944
  }
2945
2945
  }
2946
- computeRadius(r, width, height, k) {
2947
- return this.computeLayoutRadius(width ? width : 0, height ? height : 0) * r * (vutils.isNil(k) ? 1 : k);
2946
+ computeRadius(r, width, height, centerOffset, k) {
2947
+ var _a;
2948
+ return ((_a = this.computeLayoutRadius(width ? width : 0, height ? height : 0) * r * (vutils.isNil(k) ? 1 : k) + centerOffset) !== null && _a !== void 0 ? _a : 0);
2948
2949
  }
2949
2950
  computeLayoutRadius(width, height) {
2950
2951
  return Math.min(width / 2, height / 2);
@@ -2952,9 +2953,10 @@
2952
2953
  computeLayoutOuterRadius(r, width, height) {
2953
2954
  return r / (Math.min(width, height) / 2);
2954
2955
  }
2955
- computeDatumRadius(width, height, outerRadius) {
2956
+ computeDatumRadius(width, height, outerRadius, centerOffset) {
2957
+ var _a;
2956
2958
  const outerRadiusRatio = this.computeLayoutOuterRadius(outerRadius, width, height);
2957
- return this.computeLayoutRadius(width ? width : 0, height ? height : 0) * outerRadiusRatio;
2959
+ return (_a = this.computeLayoutRadius(width ? width : 0, height ? height : 0) * outerRadiusRatio + centerOffset) !== null && _a !== void 0 ? _a : 0;
2958
2960
  }
2959
2961
  }
2960
2962
  ArcLabel.defaultAttributes = {
@@ -3839,10 +3841,8 @@
3839
3841
  textStyle = vutils.isFunction(textStyle)
3840
3842
  ? vutils.merge({}, DEFAULT_AXIS_THEME.label.style, textStyle(tickDatum, index, tickData, layer))
3841
3843
  : textStyle;
3842
- textStyle = vutils.merge({
3843
- textAlign: this.getTextAlign(vector),
3844
- textBaseline: this.getTextBaseline(vector, inside)
3845
- }, textStyle);
3844
+ const labelAlign = this.getLabelAlign(vector, inside, textStyle.angle);
3845
+ textStyle = vutils.merge(labelAlign, textStyle);
3846
3846
  if (vutils.isFunction(textStyle.text)) {
3847
3847
  textStyle.text = textStyle.text({
3848
3848
  label: tickDatum.label,
@@ -4008,73 +4008,70 @@
4008
4008
  item.rotatedBounds = bounds;
4009
4009
  });
4010
4010
  }
4011
- function rotateYAxis(orient, items) {
4012
- let align = ['right', 'right', 'center', 'left', 'center', 'left', 'center', 'right', 'right'];
4013
- let baseline = ['middle', 'middle', 'top', 'top', 'middle', 'middle', 'bottom', 'bottom', 'middle'];
4014
- if (orient === 'right') {
4015
- align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];
4016
- baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
4017
- }
4018
- items.forEach((item, i) => {
4019
- let angle = item.attribute.angle || 0;
4020
- if (angle < 0) {
4021
- while (angle < 0) {
4022
- angle += Math.PI * 2;
4023
- }
4024
- }
4025
- if (angle > 0) {
4026
- while (angle >= Math.PI * 2) {
4027
- angle -= Math.PI * 2;
4028
- }
4029
- }
4030
- const step = angle / (Math.PI * 0.5);
4031
- let index;
4032
- if (step === Math.floor(step)) {
4033
- index = Math.floor(step) * 2;
4011
+ function clampAngle(angle = 0) {
4012
+ if (angle < 0) {
4013
+ while (angle < 0) {
4014
+ angle += Math.PI * 2;
4034
4015
  }
4035
- else {
4036
- index = Math.floor(step) * 2 + 1;
4016
+ }
4017
+ if (angle > 0) {
4018
+ while (angle >= Math.PI * 2) {
4019
+ angle -= Math.PI * 2;
4037
4020
  }
4038
- item.setAttributes({
4039
- textAlign: align[index],
4040
- textBaseline: baseline[index],
4041
- angle: angle
4042
- });
4021
+ }
4022
+ return angle;
4023
+ }
4024
+ function rotateYAxis(orient, items) {
4025
+ items.forEach((item, i) => {
4026
+ item.setAttributes(Object.assign(Object.assign({}, getYAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
4043
4027
  });
4044
4028
  }
4045
4029
  function rotateXAxis(orient, items) {
4030
+ items.forEach(item => {
4031
+ item.setAttributes(Object.assign(Object.assign({}, getXAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
4032
+ });
4033
+ }
4034
+ function getXAxisLabelAlign(orient, angle = 0) {
4046
4035
  let align = ['center', 'left', 'left', 'left', 'center', 'right', 'right', 'right', 'left'];
4047
4036
  let baseline = ['top', 'top', 'middle', 'bottom', 'bottom', 'bottom', 'middle', 'top', 'top'];
4048
4037
  if (orient === 'top') {
4049
4038
  align = ['center', 'right', 'right', 'right', 'center', 'left', 'left', 'left', 'right'];
4050
4039
  baseline = ['bottom', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
4051
4040
  }
4052
- items.forEach(item => {
4053
- let angle = item.attribute.angle || 0;
4054
- if (angle < 0) {
4055
- while (angle < 0) {
4056
- angle += Math.PI * 2;
4057
- }
4058
- }
4059
- if (angle > 0) {
4060
- while (angle >= Math.PI * 2) {
4061
- angle -= Math.PI * 2;
4062
- }
4063
- }
4064
- const step = angle / (Math.PI * 0.5);
4065
- let index;
4066
- if (step === Math.floor(step)) {
4067
- index = Math.floor(step) * 2;
4068
- }
4069
- else {
4070
- index = Math.floor(step) * 2 + 1;
4071
- }
4072
- item.setAttributes({
4073
- textAlign: align[index],
4074
- textBaseline: baseline[index],
4075
- angle
4076
- });
4077
- });
4041
+ angle = clampAngle(angle);
4042
+ const step = angle / (Math.PI * 0.5);
4043
+ let index;
4044
+ if (step === Math.floor(step)) {
4045
+ index = Math.floor(step) * 2;
4046
+ }
4047
+ else {
4048
+ index = Math.floor(step) * 2 + 1;
4049
+ }
4050
+ return {
4051
+ textAlign: align[index],
4052
+ textBaseline: baseline[index]
4053
+ };
4054
+ }
4055
+ function getYAxisLabelAlign(orient, angle = 0) {
4056
+ let align = ['right', 'right', 'center', 'left', 'center', 'left', 'center', 'right', 'right'];
4057
+ let baseline = ['middle', 'middle', 'top', 'top', 'middle', 'middle', 'bottom', 'bottom', 'middle'];
4058
+ if (orient === 'right') {
4059
+ align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];
4060
+ baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];
4061
+ }
4062
+ angle = clampAngle(angle);
4063
+ const step = angle / (Math.PI * 0.5);
4064
+ let index;
4065
+ if (step === Math.floor(step)) {
4066
+ index = Math.floor(step) * 2;
4067
+ }
4068
+ else {
4069
+ index = Math.floor(step) * 2 + 1;
4070
+ }
4071
+ return {
4072
+ textAlign: align[index],
4073
+ textBaseline: baseline[index]
4074
+ };
4078
4075
  }
4079
4076
 
4080
4077
  function autoLimit(labels, config) {
@@ -4481,14 +4478,23 @@
4481
4478
  }
4482
4479
  return base;
4483
4480
  }
4484
- beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4481
+ getLabelAlign(vector, inside, angle) {
4485
4482
  const orient = this.attribute.orient;
4486
- if (orient === 'left' || orient === 'right') {
4487
- rotateYAxis(orient, labelShapes);
4488
- }
4489
- else if (orient === 'bottom' || orient === 'top') {
4490
- rotateXAxis(orient, labelShapes);
4483
+ if (vutils.isValidNumber(angle)) {
4484
+ if (orient === 'top' || orient === 'bottom') {
4485
+ return getXAxisLabelAlign(orient, angle);
4486
+ }
4487
+ if (orient === 'left' || orient === 'right') {
4488
+ return getYAxisLabelAlign(orient, angle);
4489
+ }
4491
4490
  }
4491
+ return {
4492
+ textAlign: this.getTextAlign(vector),
4493
+ textBaseline: this.getTextBaseline(vector, inside)
4494
+ };
4495
+ }
4496
+ beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4497
+ return;
4492
4498
  }
4493
4499
  handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4494
4500
  if (vutils.isEmpty(labelShapes)) {
@@ -4836,6 +4842,12 @@
4836
4842
  afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4837
4843
  return;
4838
4844
  }
4845
+ getLabelAlign(vector, inside, angle) {
4846
+ return {
4847
+ textAlign: this.getTextAlign(vector),
4848
+ textBaseline: this.getTextBaseline(vector)
4849
+ };
4850
+ }
4839
4851
  }
4840
4852
  CircleAxis.defaultAttributes = DEFAULT_AXIS_THEME;
4841
4853
 
@@ -5726,6 +5738,27 @@
5726
5738
  })(exports.IMarkPointItemPosition || (exports.IMarkPointItemPosition = {}));
5727
5739
 
5728
5740
  class Marker extends AbstractComponent {
5741
+ _initContainer() {
5742
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
5743
+ const groupClip = vrender.createGroup(Object.assign(Object.assign({}, (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.clipRange), { clip: (_c = vutils.isValid((_b = this.attribute) === null || _b === void 0 ? void 0 : _b.clipRange)) !== null && _c !== void 0 ? _c : false }));
5744
+ groupClip.name = 'marker-container';
5745
+ const group = vrender.createGroup({
5746
+ x: -((_f = (_e = (_d = this.attribute) === null || _d === void 0 ? void 0 : _d.clipRange) === null || _e === void 0 ? void 0 : _e.x) !== null && _f !== void 0 ? _f : 0),
5747
+ y: -((_j = (_h = (_g = this.attribute) === null || _g === void 0 ? void 0 : _g.clipRange) === null || _h === void 0 ? void 0 : _h.y) !== null && _j !== void 0 ? _j : 0)
5748
+ });
5749
+ groupClip.add(group);
5750
+ this._containerClip = groupClip;
5751
+ this.add(groupClip);
5752
+ this._container = group;
5753
+ }
5754
+ _updateContainer() {
5755
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
5756
+ this._containerClip.setAttributes(Object.assign(Object.assign({}, (_a = this.attribute) === null || _a === void 0 ? void 0 : _a.clipRange), { clip: (_c = vutils.isValid((_b = this.attribute) === null || _b === void 0 ? void 0 : _b.clipRange)) !== null && _c !== void 0 ? _c : false }));
5757
+ this._container.setAttributes({
5758
+ x: -((_f = (_e = (_d = this.attribute) === null || _d === void 0 ? void 0 : _d.clipRange) === null || _e === void 0 ? void 0 : _e.x) !== null && _f !== void 0 ? _f : 0),
5759
+ y: -((_j = (_h = (_g = this.attribute) === null || _g === void 0 ? void 0 : _g.clipRange) === null || _h === void 0 ? void 0 : _h.y) !== null && _j !== void 0 ? _j : 0)
5760
+ });
5761
+ }
5729
5762
  render() {
5730
5763
  var _a, _b;
5731
5764
  const markerVisible = (_a = this.attribute.visible) !== null && _a !== void 0 ? _a : true;
@@ -5735,14 +5768,12 @@
5735
5768
  this.setAttribute('childrenPickable', false);
5736
5769
  }
5737
5770
  if (markerVisible) {
5738
- if (!this._container) {
5739
- const group = vrender.createGroup({});
5740
- group.name = 'marker-container';
5741
- this.add(group);
5742
- this._container = group;
5743
- this.initMarker(group);
5771
+ if (!this._containerClip) {
5772
+ this._initContainer();
5773
+ this.initMarker(this._container);
5744
5774
  }
5745
5775
  else {
5776
+ this._updateContainer();
5746
5777
  this.updateMarker();
5747
5778
  }
5748
5779
  }
@@ -6503,6 +6534,7 @@
6503
6534
  LegendEvent["legendItemHover"] = "legendItemHover";
6504
6535
  LegendEvent["legendItemUnHover"] = "legendItemUnHover";
6505
6536
  LegendEvent["legendItemClick"] = "legendItemClick";
6537
+ LegendEvent["legendItemAttributeUpdate"] = "legendItemAttributeUpdate";
6506
6538
  })(exports.LegendEvent || (exports.LegendEvent = {}));
6507
6539
  exports.LEGEND_ELEMENT_NAME = void 0;
6508
6540
  (function (LEGEND_ELEMENT_NAME) {
@@ -6626,12 +6658,21 @@
6626
6658
  const target = e.target;
6627
6659
  if ((_a = target === null || target === void 0 ? void 0 : target.name) === null || _a === void 0 ? void 0 : _a.startsWith(exports.LEGEND_ELEMENT_NAME.item)) {
6628
6660
  const legendItem = target.delegate;
6661
+ let attributeUpdate = false;
6662
+ if (legendItem.hasState(exports.LegendStateValue.unSelectedHover) ||
6663
+ legendItem.hasState(exports.LegendStateValue.selectedHover)) {
6664
+ attributeUpdate = true;
6665
+ }
6629
6666
  legendItem.removeState(exports.LegendStateValue.unSelectedHover);
6630
6667
  legendItem.removeState(exports.LegendStateValue.selectedHover);
6631
6668
  legendItem
6632
6669
  .getChildren()[0]
6633
6670
  .getChildren()
6634
6671
  .forEach((child) => {
6672
+ if (!attributeUpdate &&
6673
+ (child.hasState(exports.LegendStateValue.unSelectedHover) || child.hasState(exports.LegendStateValue.selectedHover))) {
6674
+ attributeUpdate = true;
6675
+ }
6635
6676
  child.removeState(exports.LegendStateValue.unSelectedHover);
6636
6677
  child.removeState(exports.LegendStateValue.selectedHover);
6637
6678
  });
@@ -6639,6 +6680,9 @@
6639
6680
  if (focusButton) {
6640
6681
  focusButton.setAttribute('visible', false);
6641
6682
  }
6683
+ if (attributeUpdate) {
6684
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
6685
+ }
6642
6686
  this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem);
6643
6687
  }
6644
6688
  };
@@ -6909,15 +6953,30 @@
6909
6953
  this._appendDataToShape(valueShape, exports.LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueAttr === null || valueAttr === void 0 ? void 0 : valueAttr.state);
6910
6954
  valueShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
6911
6955
  if (this._itemWidthByUser) {
6912
- valueShape.setAttribute('maxLineWidth', this._itemWidthByUser -
6956
+ const layoutWidth = this._itemWidthByUser -
6913
6957
  parsedPadding[1] -
6914
6958
  parsedPadding[3] -
6915
6959
  shapeSize -
6916
6960
  shapeSpace -
6917
- labelShape.AABBBounds.width() -
6918
6961
  labelSpace -
6919
6962
  focusSpace -
6920
- valueSpace);
6963
+ valueSpace;
6964
+ const valueBounds = valueShape.AABBBounds;
6965
+ const labelBounds = labelShape.AABBBounds;
6966
+ const valueWidth = valueBounds.width();
6967
+ const labelWidth = labelBounds.width();
6968
+ if (valueWidth + labelWidth > layoutWidth) {
6969
+ if ((layoutWidth - valueWidth) / labelWidth > 0.4) {
6970
+ labelShape.setAttribute('maxLineWidth', layoutWidth - valueWidth);
6971
+ }
6972
+ else {
6973
+ valueShape.setAttribute('maxLineWidth', layoutWidth * 0.5);
6974
+ labelShape.setAttribute('maxLineWidth', layoutWidth * 0.5);
6975
+ }
6976
+ }
6977
+ else {
6978
+ valueShape.setAttribute('maxLineWidth', layoutWidth - labelWidth);
6979
+ }
6921
6980
  if (valueAttr.alignRight) {
6922
6981
  valueShape.setAttributes({
6923
6982
  textAlign: 'right',
@@ -7067,18 +7126,32 @@
7067
7126
  return true;
7068
7127
  }
7069
7128
  _setLegendItemState(legendItem, stateName, keepCurrentStates = true) {
7129
+ let attributeUpdate = false;
7130
+ if (!legendItem.hasState(stateName)) {
7131
+ attributeUpdate = true;
7132
+ }
7070
7133
  legendItem.addState(stateName, keepCurrentStates);
7071
7134
  legendItem
7072
7135
  .getChildren()[0]
7073
7136
  .getChildren()
7074
- .forEach(child => {
7137
+ .forEach((child) => {
7075
7138
  if (child.name !== exports.LEGEND_ELEMENT_NAME.focus) {
7139
+ if (!attributeUpdate && !child.hasState(stateName)) {
7140
+ attributeUpdate = true;
7141
+ }
7076
7142
  child.addState(stateName, keepCurrentStates);
7077
7143
  }
7078
7144
  });
7145
+ if (attributeUpdate) {
7146
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7147
+ }
7079
7148
  }
7080
7149
  _removeLegendItemState(legendItem, stateNames) {
7150
+ let attributeUpdate = false;
7081
7151
  stateNames.forEach(name => {
7152
+ if (!attributeUpdate && legendItem.hasState(name)) {
7153
+ attributeUpdate = true;
7154
+ }
7082
7155
  legendItem.removeState(name);
7083
7156
  });
7084
7157
  legendItem
@@ -7087,10 +7160,16 @@
7087
7160
  .forEach(child => {
7088
7161
  if (child.name !== exports.LEGEND_ELEMENT_NAME.focus) {
7089
7162
  stateNames.forEach(name => {
7163
+ if (!attributeUpdate && child.hasState(name)) {
7164
+ attributeUpdate = true;
7165
+ }
7090
7166
  child.removeState(name);
7091
7167
  });
7092
7168
  }
7093
7169
  });
7170
+ if (attributeUpdate) {
7171
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7172
+ }
7094
7173
  }
7095
7174
  _getSelectedLegends() {
7096
7175
  var _a;
@@ -9964,7 +10043,7 @@
9964
10043
  }
9965
10044
  Tooltip.defaultAttributes = defaultAttributes;
9966
10045
 
9967
- const version = "0.14.2";
10046
+ const version = "0.14.3-alpha.1";
9968
10047
 
9969
10048
  exports.AbstractComponent = AbstractComponent;
9970
10049
  exports.ArcInfo = ArcInfo;