@visactor/vrender-components 0.14.6-alpha.4 → 0.14.6-alpha.8

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 (87) hide show
  1. package/cjs/axis/line.js +50 -1
  2. package/cjs/axis/line.js.map +1 -1
  3. package/cjs/axis/overlap/auto-rotate.js +2 -2
  4. package/cjs/axis/overlap/auto-rotate.js.map +1 -1
  5. package/cjs/axis/type.d.ts +1 -0
  6. package/cjs/axis/type.js.map +1 -1
  7. package/cjs/brush/brush.d.ts +1 -0
  8. package/cjs/brush/brush.js +5 -0
  9. package/cjs/brush/brush.js.map +1 -1
  10. package/cjs/index.d.ts +1 -2
  11. package/cjs/index.js +2 -2
  12. package/cjs/index.js.map +1 -1
  13. package/cjs/label/arc.d.ts +6 -3
  14. package/cjs/label/arc.js +31 -1
  15. package/cjs/label/arc.js.map +1 -1
  16. package/cjs/label/base.d.ts +12 -9
  17. package/cjs/label/base.js +117 -134
  18. package/cjs/label/base.js.map +1 -1
  19. package/cjs/label/dataLabel.js +4 -4
  20. package/cjs/label/dataLabel.js.map +1 -1
  21. package/cjs/label/overlap/place.d.ts +2 -2
  22. package/cjs/label/overlap/place.js +15 -8
  23. package/cjs/label/overlap/place.js.map +1 -1
  24. package/cjs/label/polygon.d.ts +12 -0
  25. package/cjs/label/polygon.js +35 -0
  26. package/cjs/label/polygon.js.map +1 -0
  27. package/cjs/label/rect.js.map +1 -1
  28. package/cjs/label/symbol.js.map +1 -1
  29. package/cjs/label/type.d.ts +5 -2
  30. package/cjs/label/type.js.map +1 -1
  31. package/cjs/link-path/index.js +2 -1
  32. package/cjs/link-path/link-path.js +1 -2
  33. package/cjs/marker/point.js +1 -1
  34. package/cjs/util/labelSmartInvert.d.ts +1 -0
  35. package/cjs/util/labelSmartInvert.js +20 -2
  36. package/cjs/util/labelSmartInvert.js.map +1 -1
  37. package/dist/index.js +297 -177
  38. package/dist/index.min.js +1 -1
  39. package/es/axis/line.js +50 -2
  40. package/es/axis/line.js.map +1 -1
  41. package/es/axis/overlap/auto-rotate.js +2 -2
  42. package/es/axis/overlap/auto-rotate.js.map +1 -1
  43. package/es/axis/type.d.ts +1 -0
  44. package/es/axis/type.js.map +1 -1
  45. package/es/brush/brush.d.ts +1 -0
  46. package/es/brush/brush.js +5 -0
  47. package/es/brush/brush.js.map +1 -1
  48. package/es/index.d.ts +1 -2
  49. package/es/index.js +1 -3
  50. package/es/index.js.map +1 -1
  51. package/es/label/arc.d.ts +6 -3
  52. package/es/label/arc.js +31 -0
  53. package/es/label/arc.js.map +1 -1
  54. package/es/label/base.d.ts +12 -9
  55. package/es/label/base.js +118 -132
  56. package/es/label/base.js.map +1 -1
  57. package/es/label/dataLabel.js +5 -3
  58. package/es/label/dataLabel.js.map +1 -1
  59. package/es/label/overlap/place.d.ts +2 -2
  60. package/es/label/overlap/place.js +15 -8
  61. package/es/label/overlap/place.js.map +1 -1
  62. package/es/label/polygon.d.ts +12 -0
  63. package/es/label/polygon.js +31 -0
  64. package/es/label/polygon.js.map +1 -0
  65. package/es/label/rect.js.map +1 -1
  66. package/es/label/symbol.js.map +1 -1
  67. package/es/label/type.d.ts +5 -2
  68. package/es/label/type.js.map +1 -1
  69. package/es/link-path/index.js +2 -1
  70. package/es/link-path/link-path.js +1 -2
  71. package/es/marker/point.js +1 -1
  72. package/es/util/labelSmartInvert.d.ts +1 -0
  73. package/es/util/labelSmartInvert.js +17 -0
  74. package/es/util/labelSmartInvert.js.map +1 -1
  75. package/package.json +4 -4
  76. package/cjs/jsx/component-type.d.ts +0 -4
  77. package/cjs/jsx/component-type.js +0 -14
  78. package/cjs/jsx/component-type.js.map +0 -1
  79. package/cjs/jsx/index.d.ts +0 -1
  80. package/cjs/jsx/index.js +0 -21
  81. package/cjs/jsx/index.js.map +0 -1
  82. package/es/jsx/component-type.d.ts +0 -4
  83. package/es/jsx/component-type.js +0 -6
  84. package/es/jsx/component-type.js.map +0 -1
  85. package/es/jsx/index.d.ts +0 -1
  86. package/es/jsx/index.js +0 -2
  87. package/es/jsx/index.js.map +0 -1
package/dist/index.js CHANGED
@@ -310,14 +310,14 @@
310
310
  scrollRange: [0, 1]
311
311
  };
312
312
 
313
- function _typeof(obj) {
313
+ function _typeof(o) {
314
314
  "@babel/helpers - typeof";
315
315
 
316
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
317
- return typeof obj;
318
- } : function (obj) {
319
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
320
- }, _typeof(obj);
316
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
317
+ return typeof o;
318
+ } : function (o) {
319
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
320
+ }, _typeof(o);
321
321
  }
322
322
 
323
323
  function __rest(s, e) {
@@ -495,6 +495,20 @@
495
495
  const { r, g, b } = c.color;
496
496
  return '#' + vutils.ColorUtil.rgbToHex(r, g, b);
497
497
  }
498
+ function smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor) {
499
+ let result;
500
+ switch (fillStrategy) {
501
+ case 'base':
502
+ result = baseColor;
503
+ break;
504
+ case 'invertBase':
505
+ result = invertColor;
506
+ break;
507
+ case 'similarBase':
508
+ result = similarColor;
509
+ }
510
+ return result;
511
+ }
498
512
 
499
513
  function scale(vector, scale) {
500
514
  return [vector[0] * scale, vector[1] * scale];
@@ -1395,26 +1409,29 @@
1395
1409
  };
1396
1410
  }
1397
1411
 
1398
- function canPlace($, bitmap, bound, checkBound = true) {
1399
- const range = boundToRange($, bound);
1412
+ function canPlace($, bitmap, bound, checkBound = true, pad = 0) {
1413
+ let range = bound;
1414
+ if (pad > 0) {
1415
+ range = {
1416
+ x1: bound.x1 - pad,
1417
+ x2: bound.x2 + pad,
1418
+ y1: bound.y1 - pad,
1419
+ y2: bound.y2 + pad
1420
+ };
1421
+ }
1422
+ range = boundToRange($, range);
1400
1423
  const outOfBounds = checkBound && bitmap.outOfBounds(range);
1401
1424
  if (outOfBounds) {
1402
1425
  return false;
1403
1426
  }
1404
1427
  return !bitmap.getRange(range);
1405
1428
  }
1406
- function canPlaceInside(textBound, shapeBound) {
1407
- if (!textBound || !shapeBound) {
1408
- return false;
1409
- }
1410
- return shapeBound.encloses(textBound);
1411
- }
1412
- function placeToCandidates($, bitmap, text, candidates = [], clampForce = true) {
1429
+ function placeToCandidates($, bitmap, text, candidates = [], clampForce = true, pad = 0) {
1413
1430
  for (let i = 0; i < candidates.length; i++) {
1414
1431
  const tempText = text.clone();
1415
1432
  tempText.setAttributes(candidates[i]);
1416
1433
  tempText.update();
1417
- if (canPlace($, bitmap, boundToRange($, tempText.AABBBounds), clampForce)) {
1434
+ if (canPlace($, bitmap, boundToRange($, tempText.AABBBounds), clampForce, pad)) {
1418
1435
  bitmap.setRange(boundToRange($, tempText.AABBBounds, true));
1419
1436
  return candidates[i];
1420
1437
  }
@@ -1422,13 +1439,15 @@
1422
1439
  return false;
1423
1440
  }
1424
1441
  function place($, bitmap, s, attrs, text, bounds, labeling) {
1425
- var _a, _b, _c;
1442
+ var _a, _b;
1443
+ const clampForce = (_a = attrs.overlap) === null || _a === void 0 ? void 0 : _a.clampForce;
1444
+ const overlapPadding = (_b = attrs.overlap) === null || _b === void 0 ? void 0 : _b.overlapPadding;
1426
1445
  if (s.type === 'bound' || s.type === 'position') {
1427
1446
  if (vutils.isFunction(labeling)) {
1428
1447
  const userPosition = vutils.isFunction(s.position) ? s.position(text.attribute) : s.position;
1429
1448
  const positions = (userPosition || defaultLabelPosition(attrs.type));
1430
1449
  const candidates = positions.map(p => labeling(text.AABBBounds, bounds, p, attrs.offset));
1431
- return placeToCandidates($, bitmap, text, candidates, (_a = attrs.overlap) === null || _a === void 0 ? void 0 : _a.clampForce);
1450
+ return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);
1432
1451
  }
1433
1452
  return false;
1434
1453
  }
@@ -1437,14 +1456,14 @@
1437
1456
  const candidates = offset.map(dy => {
1438
1457
  return { x: text.attribute.x, y: text.attribute.y + dy };
1439
1458
  });
1440
- return placeToCandidates($, bitmap, text, candidates, (_b = attrs.overlap) === null || _b === void 0 ? void 0 : _b.clampForce);
1459
+ return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);
1441
1460
  }
1442
1461
  if (s.type === 'moveX') {
1443
1462
  const offset = s.offset ? (vutils.isFunction(s.offset) ? s.offset(text.attribute) : s.offset) : [];
1444
1463
  const candidates = offset.map(dx => {
1445
1464
  return { x: text.attribute.x + dx, y: text.attribute.y };
1446
1465
  });
1447
- return placeToCandidates($, bitmap, text, candidates, (_c = attrs.overlap) === null || _c === void 0 ? void 0 : _c.clampForce);
1466
+ return placeToCandidates($, bitmap, text, candidates, clampForce, overlapPadding);
1448
1467
  }
1449
1468
  return false;
1450
1469
  }
@@ -1532,8 +1551,14 @@
1532
1551
  };
1533
1552
 
1534
1553
  class LabelBase extends AbstractComponent {
1535
- constructor() {
1536
- super(...arguments);
1554
+ setBitmap(bitmap) {
1555
+ this._bitmap = bitmap;
1556
+ }
1557
+ setBitmapTool(bmpTool) {
1558
+ this._bmpTool = bmpTool;
1559
+ }
1560
+ constructor(attributes) {
1561
+ super(vutils.merge({}, LabelBase.defaultAttributes, attributes));
1537
1562
  this.name = 'label';
1538
1563
  this._onHover = (e) => {
1539
1564
  const target = e.target;
@@ -1581,15 +1606,11 @@
1581
1606
  }
1582
1607
  };
1583
1608
  }
1584
- setBitmap(bitmap) {
1585
- this._bitmap = bitmap;
1586
- }
1587
- setBitmapTool(bmpTool) {
1588
- this._bmpTool = bmpTool;
1609
+ labeling(textBounds, graphicBounds, position, offset) {
1610
+ return;
1589
1611
  }
1590
- layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray, ellipsisWidth) {
1591
- const arcs = [];
1592
- return arcs;
1612
+ _labelLine(text) {
1613
+ return;
1593
1614
  }
1594
1615
  render() {
1595
1616
  this._prepare();
@@ -1603,14 +1624,14 @@
1603
1624
  labels = customLayoutFunc(data, (d) => this._idToGraphic.get(d.id));
1604
1625
  }
1605
1626
  else {
1606
- labels = this.layout(data);
1607
- if (vutils.isFunction(customOverlapFunc)) {
1608
- labels = customOverlapFunc(labels, (d) => this._idToGraphic.get(d.id));
1609
- }
1610
- else {
1611
- if (overlap !== false) {
1612
- labels = this._overlapping(labels);
1613
- }
1627
+ labels = this._layout(data);
1628
+ }
1629
+ if (vutils.isFunction(customOverlapFunc)) {
1630
+ labels = customOverlapFunc(labels, (d) => this._idToGraphic.get(d.id));
1631
+ }
1632
+ else {
1633
+ if (overlap !== false) {
1634
+ labels = this._overlapping(labels);
1614
1635
  }
1615
1636
  }
1616
1637
  if (smartInvert !== false) {
@@ -1679,49 +1700,24 @@
1679
1700
  }
1680
1701
  }
1681
1702
  }
1682
- layout(data = []) {
1703
+ _layout(data = []) {
1683
1704
  const { textStyle = {}, position, offset } = this.attribute;
1684
1705
  const labels = [];
1685
- const textBoundsArray = [];
1686
1706
  for (let i = 0; i < data.length; i++) {
1687
1707
  const textData = data[i];
1688
1708
  const baseMark = this._idToGraphic.get(textData.id);
1689
1709
  const labelAttribute = Object.assign(Object.assign({ fill: baseMark.attribute.fill }, textStyle), textData);
1690
1710
  const text = this._createLabelText(labelAttribute);
1691
1711
  const textBounds = this.getGraphicBounds(text);
1692
- textBoundsArray.push(textBounds);
1693
1712
  const graphicBounds = this.getGraphicBounds(baseMark, { x: textData.x, y: textData.y });
1694
1713
  const textLocation = this.labeling(textBounds, graphicBounds, vutils.isFunction(position) ? position(textData) : position, offset);
1695
- if (!textLocation) {
1696
- continue;
1714
+ if (textLocation) {
1715
+ labelAttribute.x = textLocation.x;
1716
+ labelAttribute.y = textLocation.y;
1717
+ text.setAttributes(textLocation);
1697
1718
  }
1698
- labelAttribute.x = textLocation.x;
1699
- labelAttribute.y = textLocation.y;
1700
- text.setAttributes(textLocation);
1701
1719
  labels.push(text);
1702
1720
  }
1703
- if (this.attribute.type === 'arc') {
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);
1709
- for (let i = 0; i < data.length; i++) {
1710
- const textData = data[i];
1711
- const basedArc = arcs.find(arc => arc.refDatum.id === textData.id);
1712
- const labelAttribute = {
1713
- visible: basedArc.labelVisible,
1714
- x: basedArc.labelPosition.x,
1715
- y: basedArc.labelPosition.y,
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
1721
- };
1722
- labels[i].setAttributes(labelAttribute);
1723
- }
1724
- }
1725
1721
  return labels;
1726
1722
  }
1727
1723
  _overlapping(labels) {
@@ -1739,7 +1735,7 @@
1739
1735
  if (size.width === 0 || size.height === 0) {
1740
1736
  return labels;
1741
1737
  }
1742
- const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [] } = option;
1738
+ const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [], overlapPadding } = option;
1743
1739
  const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);
1744
1740
  const bitmap = this._bitmap || bmpTool.bitmap();
1745
1741
  const checkBounds = strategy.some(s => s.type === 'bound');
@@ -1767,13 +1763,16 @@
1767
1763
  const text = labels[i];
1768
1764
  const baseMark = this._idToGraphic.get(text.attribute.id);
1769
1765
  text.update();
1770
- if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce)) {
1766
+ if (!vutils.isRectIntersect(baseMark.AABBBounds, { x1: 0, x2: bmpTool.width, y1: 0, y2: bmpTool.height }, true)) {
1767
+ continue;
1768
+ }
1769
+ if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce, overlapPadding)) {
1771
1770
  if (!checkBounds) {
1772
1771
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
1773
1772
  result.push(text);
1774
1773
  continue;
1775
1774
  }
1776
- if (checkBounds && (baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds) && canPlaceInside(text.AABBBounds, baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds)) {
1775
+ if (checkBounds && (baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds) && this._canPlaceInside(text.AABBBounds, baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds)) {
1777
1776
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
1778
1777
  result.push(text);
1779
1778
  continue;
@@ -1796,7 +1795,7 @@
1796
1795
  x2: text.AABBBounds.x2 + dx,
1797
1796
  y1: text.AABBBounds.y1 + dy,
1798
1797
  y2: text.AABBBounds.y2 + dy
1799
- })) {
1798
+ }, undefined, overlapPadding)) {
1800
1799
  text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
1801
1800
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
1802
1801
  result.push(text);
@@ -1827,9 +1826,17 @@
1827
1826
  });
1828
1827
  }
1829
1828
  _renderLabels(labels) {
1829
+ const disableAnimation = this._enableAnimation === false || this.attribute.animation === false;
1830
+ if (disableAnimation) {
1831
+ this._renderWithOutAnimation(labels);
1832
+ }
1833
+ else {
1834
+ this._renderWithAnimation(labels);
1835
+ }
1836
+ }
1837
+ _renderWithAnimation(labels) {
1830
1838
  var _a, _b, _c, _d, _e;
1831
1839
  const animationConfig = ((_a = this.attribute.animation) !== null && _a !== void 0 ? _a : {});
1832
- const disableAnimation = this._enableAnimation === false || animationConfig === false;
1833
1840
  const mode = (_b = animationConfig.mode) !== null && _b !== void 0 ? _b : DefaultLabelAnimation.mode;
1834
1841
  const duration = (_c = animationConfig.duration) !== null && _c !== void 0 ? _c : DefaultLabelAnimation.duration;
1835
1842
  const easing = (_d = animationConfig.easing) !== null && _d !== void 0 ? _d : DefaultLabelAnimation.easing;
@@ -1838,27 +1845,18 @@
1838
1845
  const prevTextMap = this._graphicToText || new Map();
1839
1846
  const texts = [];
1840
1847
  labels.forEach((text, index) => {
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({
1844
- visible: (_c = (_b = text.attribute) === null || _b === void 0 ? void 0 : _b.visible) !== null && _c !== void 0 ? _c : true,
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,
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
1848
- })
1849
- : undefined;
1848
+ var _a;
1849
+ const labelLine = this._labelLine(text);
1850
1850
  const relatedGraphic = this._idToGraphic.get(text.attribute.id);
1851
1851
  const state = (prevTextMap === null || prevTextMap === void 0 ? void 0 : prevTextMap.get(relatedGraphic)) ? 'update' : 'enter';
1852
1852
  if (state === 'enter') {
1853
1853
  texts.push(text);
1854
1854
  currentTextMap.set(relatedGraphic, labelLine ? { text, labelLine } : { text });
1855
- if (!disableAnimation && relatedGraphic) {
1855
+ if (relatedGraphic) {
1856
1856
  const { from, to } = getAnimationAttributes(text.attribute, 'fadeIn');
1857
1857
  this.add(text);
1858
- if (labelLine) {
1859
- this.add(labelLine);
1860
- }
1861
- relatedGraphic.onAnimateBind = () => {
1858
+ labelLine && this.add(labelLine);
1859
+ relatedGraphic.once('animate-bind', () => {
1862
1860
  text.setAttributes(from);
1863
1861
  const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, {
1864
1862
  mode,
@@ -1868,58 +1866,69 @@
1868
1866
  delay
1869
1867
  });
1870
1868
  relatedGraphic.on('afterAttributeUpdate', listener);
1871
- };
1872
- }
1873
- else {
1874
- this.add(text);
1875
- if (labelLine) {
1876
- this.add(labelLine);
1877
- }
1869
+ });
1878
1870
  }
1879
1871
  }
1880
- if (state === 'update') {
1872
+ else if (state === 'update') {
1881
1873
  const prevLabel = prevTextMap.get(relatedGraphic);
1882
1874
  prevTextMap.delete(relatedGraphic);
1883
1875
  currentTextMap.set(relatedGraphic, prevLabel);
1884
- if (!disableAnimation) {
1885
- const prevText = prevLabel.text;
1886
- prevText.animate().to(text.attribute, duration, easing);
1887
- if (prevLabel.labelLine) {
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);
1891
- }
1892
- if (animationConfig.increaseEffect !== false &&
1893
- prevText.attribute.text !== text.attribute.text &&
1894
- vutils.isValidNumber(Number(prevText.attribute.text) * Number(text.attribute.text))) {
1895
- prevText
1896
- .animate()
1897
- .play(new vrender.IncreaseCount({ text: prevText.attribute.text }, { text: text.attribute.text }, duration, easing));
1898
- }
1876
+ const prevText = prevLabel.text;
1877
+ prevText.animate().to(text.attribute, duration, easing);
1878
+ if (prevLabel.labelLine) {
1879
+ prevLabel.labelLine.animate().to(vutils.merge({}, prevLabel.labelLine.attribute, {
1880
+ points: (_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points
1881
+ }), duration, easing);
1899
1882
  }
1900
- else {
1901
- prevLabel.text.setAttributes(text.attribute);
1902
- if (prevLabel === null || prevLabel === void 0 ? void 0 : prevLabel.labelLine) {
1903
- prevLabel.labelLine.setAttributes({ points: (_o = text.attribute) === null || _o === void 0 ? void 0 : _o.points });
1904
- }
1883
+ if (animationConfig.increaseEffect !== false &&
1884
+ prevText.attribute.text !== text.attribute.text &&
1885
+ vutils.isValidNumber(Number(prevText.attribute.text) * Number(text.attribute.text))) {
1886
+ prevText
1887
+ .animate()
1888
+ .play(new vrender.IncreaseCount({ text: prevText.attribute.text }, { text: text.attribute.text }, duration, easing));
1905
1889
  }
1906
1890
  }
1907
1891
  });
1908
1892
  prevTextMap.forEach(label => {
1909
1893
  var _a;
1910
- if (disableAnimation) {
1894
+ (_a = label.text) === null || _a === void 0 ? void 0 : _a.animate().to(getAnimationAttributes(label.text.attribute, 'fadeOut').to, duration, easing).onEnd(() => {
1911
1895
  this.removeChild(label.text);
1912
1896
  if (label === null || label === void 0 ? void 0 : label.labelLine) {
1913
1897
  this.removeChild(label.labelLine);
1914
1898
  }
1899
+ });
1900
+ });
1901
+ this._graphicToText = currentTextMap;
1902
+ }
1903
+ _renderWithOutAnimation(labels) {
1904
+ const currentTextMap = new Map();
1905
+ const prevTextMap = this._graphicToText || new Map();
1906
+ labels.forEach(text => {
1907
+ var _a;
1908
+ const labelLine = this._labelLine(text);
1909
+ const relatedGraphic = this._idToGraphic.get(text.attribute.id);
1910
+ const state = (prevTextMap === null || prevTextMap === void 0 ? void 0 : prevTextMap.get(relatedGraphic)) ? 'update' : 'enter';
1911
+ if (state === 'enter') {
1912
+ currentTextMap.set(relatedGraphic, labelLine ? { text, labelLine } : { text });
1913
+ this.add(text);
1914
+ if (labelLine) {
1915
+ this.add(labelLine);
1916
+ }
1915
1917
  }
1916
- else {
1917
- (_a = label.text) === null || _a === void 0 ? void 0 : _a.animate().to(getAnimationAttributes(label.text.attribute, 'fadeOut').to, duration, easing).onEnd(() => {
1918
- this.removeChild(label.text);
1919
- if (label === null || label === void 0 ? void 0 : label.labelLine) {
1920
- this.removeChild(label.labelLine);
1921
- }
1922
- });
1918
+ else if (state === 'update') {
1919
+ const prevLabel = prevTextMap.get(relatedGraphic);
1920
+ prevTextMap.delete(relatedGraphic);
1921
+ currentTextMap.set(relatedGraphic, prevLabel);
1922
+ prevLabel.text.setAttributes(text.attribute);
1923
+ if (prevLabel === null || prevLabel === void 0 ? void 0 : prevLabel.labelLine) {
1924
+ prevLabel.labelLine.setAttributes({ points: (_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points });
1925
+ }
1926
+ }
1927
+ });
1928
+ prevTextMap.forEach(label => {
1929
+ this.removeChild(label.text);
1930
+ if (label === null || label === void 0 ? void 0 : label.labelLine) {
1931
+ this.removeChild(label.labelLine);
1923
1932
  }
1924
1933
  });
1925
1934
  this._graphicToText = currentTextMap;
@@ -1990,21 +1999,20 @@
1990
1999
  continue;
1991
2000
  }
1992
2001
  const baseMark = this._idToGraphic.get(label.attribute.id);
1993
- let isInside = canPlaceInside(label.AABBBounds, baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds);
1994
- if (this.attribute.type === 'arc') {
1995
- isInside = this.attribute.position === 'inside';
1996
- }
2002
+ const isInside = this._canPlaceInside(label.AABBBounds, baseMark === null || baseMark === void 0 ? void 0 : baseMark.AABBBounds);
1997
2003
  const backgroundColor = baseMark.attribute.fill;
1998
2004
  const foregroundColor = label.attribute.fill;
1999
2005
  const baseColor = backgroundColor;
2000
2006
  const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors);
2001
- const simialrColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
2007
+ const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
2002
2008
  if (isInside) {
2003
- this.setFillStrategy(fillStrategy, label, baseColor, invertColor, simialrColor);
2009
+ const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
2010
+ fill && label.setAttributes({ fill });
2004
2011
  if (label.attribute.lineWidth === 0) {
2005
2012
  continue;
2006
2013
  }
2007
- this.setStrokeStrategy(strokeStrategy, label, baseColor, invertColor, simialrColor);
2014
+ const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
2015
+ stroke && label.setAttributes({ stroke });
2008
2016
  }
2009
2017
  else {
2010
2018
  if (label.attribute.lineWidth === 0) {
@@ -2016,47 +2024,18 @@
2016
2024
  });
2017
2025
  continue;
2018
2026
  }
2019
- this.setFillStrategy(fillStrategy, label, baseColor, invertColor, simialrColor);
2020
- this.setStrokeStrategy(strokeStrategy, label, baseColor, invertColor, simialrColor);
2027
+ const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
2028
+ fill && label.setAttributes({ fill });
2029
+ const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
2030
+ stroke && label.setAttributes({ stroke });
2021
2031
  }
2022
2032
  }
2023
2033
  }
2024
- setFillStrategy(fillStrategy, label, baseColor, invertColor, simialrColor) {
2025
- switch (fillStrategy) {
2026
- case 'base':
2027
- label.setAttributes({
2028
- fill: baseColor
2029
- });
2030
- break;
2031
- case 'invertBase':
2032
- label.setAttributes({
2033
- fill: invertColor
2034
- });
2035
- break;
2036
- case 'similarBase':
2037
- label.setAttributes({
2038
- fill: simialrColor
2039
- });
2040
- }
2041
- }
2042
- setStrokeStrategy(strokeStrategy, label, baseColor, invertColor, simialrColor) {
2043
- switch (strokeStrategy) {
2044
- case 'base':
2045
- label.setAttributes({
2046
- stroke: baseColor
2047
- });
2048
- break;
2049
- case 'invertBase':
2050
- label.setAttributes({
2051
- stroke: invertColor
2052
- });
2053
- break;
2054
- case 'similarBase':
2055
- label.setAttributes({
2056
- stroke: simialrColor
2057
- });
2058
- break;
2034
+ _canPlaceInside(textBound, shapeBound) {
2035
+ if (!textBound || !shapeBound) {
2036
+ return false;
2059
2037
  }
2038
+ return shapeBound.encloses(textBound);
2060
2039
  }
2061
2040
  setLocation(point) {
2062
2041
  this.translateTo(point.x, point.y);
@@ -2068,6 +2047,16 @@
2068
2047
  this._enableAnimation = true;
2069
2048
  }
2070
2049
  }
2050
+ LabelBase.defaultAttributes = {
2051
+ textStyle: {
2052
+ fontSize: 12,
2053
+ textAlign: 'center',
2054
+ textBaseline: 'middle',
2055
+ boundsPadding: [-1, 0, -1, 0]
2056
+ },
2057
+ offset: 0,
2058
+ pickable: false
2059
+ };
2071
2060
 
2072
2061
  class SymbolLabel extends LabelBase {
2073
2062
  constructor(attributes) {
@@ -2422,6 +2411,31 @@
2422
2411
  }
2423
2412
  return { x: 0, y: 0 };
2424
2413
  }
2414
+ _layout(data = []) {
2415
+ const labels = super._layout(data);
2416
+ const textBoundsArray = labels.map(label => this.getGraphicBounds(label));
2417
+ const ellipsisLabelAttribute = Object.assign(Object.assign({}, this.attribute.textStyle), { text: '...' });
2418
+ const ellipsisText = this._createLabelText(ellipsisLabelAttribute);
2419
+ const ellipsisTextBounds = this.getGraphicBounds(ellipsisText);
2420
+ const ellipsisWidth = ellipsisTextBounds.x2 - ellipsisTextBounds.x1;
2421
+ const arcs = this.layoutArcLabels(this.attribute.position, this.attribute, Array.from(this._idToGraphic.values()), data, textBoundsArray, ellipsisWidth);
2422
+ for (let i = 0; i < data.length; i++) {
2423
+ const textData = data[i];
2424
+ const basedArc = arcs.find(arc => arc.refDatum.id === textData.id);
2425
+ const labelAttribute = {
2426
+ visible: basedArc.labelVisible,
2427
+ x: basedArc.labelPosition.x,
2428
+ y: basedArc.labelPosition.y,
2429
+ angle: basedArc.angle,
2430
+ maxLineWidth: basedArc.labelLimit,
2431
+ 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)
2432
+ ? [basedArc.pointA, basedArc.pointB, basedArc.pointC]
2433
+ : undefined
2434
+ };
2435
+ labels[i].setAttributes(labelAttribute);
2436
+ }
2437
+ return labels;
2438
+ }
2425
2439
  layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray, ellipsisWidth) {
2426
2440
  var _a;
2427
2441
  this._arcLeft.clear();
@@ -2988,6 +3002,18 @@
2988
3002
  }
2989
3003
  }
2990
3004
  }
3005
+ _labelLine(text) {
3006
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
3007
+ const labelLine = ((_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points)
3008
+ ? vrender.createLine({
3009
+ visible: (_c = (_b = text.attribute) === null || _b === void 0 ? void 0 : _b.visible) !== null && _c !== void 0 ? _c : true,
3010
+ 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,
3011
+ 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,
3012
+ points: (_l = text.attribute) === null || _l === void 0 ? void 0 : _l.points
3013
+ })
3014
+ : undefined;
3015
+ return labelLine;
3016
+ }
2991
3017
  computeRadius(r, width, height, centerOffset, k) {
2992
3018
  var _a;
2993
3019
  return ((_a = this.computeLayoutRadius(width ? width : 0, height ? height : 0) * r * (vutils.isNil(k) ? 1 : k) + centerOffset) !== null && _a !== void 0 ? _a : 0);
@@ -2995,6 +3021,9 @@
2995
3021
  computeLayoutRadius(width, height) {
2996
3022
  return Math.min(width / 2, height / 2);
2997
3023
  }
3024
+ _canPlaceInside(textBound, shapeBound) {
3025
+ return this.attribute.position === 'inside';
3026
+ }
2998
3027
  computeLayoutOuterRadius(r, width, height) {
2999
3028
  return r / (Math.min(width, height) / 2);
3000
3029
  }
@@ -3059,7 +3088,8 @@
3059
3088
  const prevComponentMap = this._componentMap;
3060
3089
  for (let i = 0; i < dataLabels.length; i++) {
3061
3090
  const dataLabel = dataLabels[i];
3062
- if (labelComponentMap[dataLabel.type]) {
3091
+ const labelComponent = labelComponentMap[dataLabel.type] || LabelBase;
3092
+ if (labelComponent) {
3063
3093
  const { baseMarkGroupName } = dataLabel;
3064
3094
  let component = this._componentMap.get(baseMarkGroupName);
3065
3095
  if (component) {
@@ -3069,7 +3099,7 @@
3069
3099
  currentComponentMap.set(baseMarkGroupName, component);
3070
3100
  }
3071
3101
  else {
3072
- component = new labelComponentMap[dataLabel.type](dataLabel);
3102
+ component = new labelComponent(dataLabel);
3073
3103
  component.setBitmap(bitmap);
3074
3104
  component.setBitmapTool(tool);
3075
3105
  this.add(component);
@@ -4069,12 +4099,14 @@
4069
4099
  }
4070
4100
  function rotateYAxis(orient, items) {
4071
4101
  items.forEach((item, i) => {
4072
- item.setAttributes(Object.assign(Object.assign({}, getYAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
4102
+ item.attribute.angle &&
4103
+ item.setAttributes(Object.assign(Object.assign({}, getYAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
4073
4104
  });
4074
4105
  }
4075
4106
  function rotateXAxis(orient, items) {
4076
4107
  items.forEach(item => {
4077
- item.setAttributes(Object.assign(Object.assign({}, getXAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
4108
+ item.attribute.angle &&
4109
+ item.setAttributes(Object.assign(Object.assign({}, getXAxisLabelAlign(orient, item.attribute.angle)), { angle: clampAngle(item.attribute.angle) }));
4078
4110
  });
4079
4111
  }
4080
4112
  function getXAxisLabelAlign(orient, angle = 0) {
@@ -4540,6 +4572,92 @@
4540
4572
  };
4541
4573
  }
4542
4574
  beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4575
+ const { flush = false } = this.attribute.label || {};
4576
+ if (flush) {
4577
+ const { orient, start, end } = this.attribute;
4578
+ const isX = orient === 'bottom' || orient === 'top';
4579
+ const first = labelShapes[0];
4580
+ const last = vutils.last(labelShapes);
4581
+ const isInverse = isX ? first.attribute.x > last.attribute.x : first.attribute.y < last.attribute.y;
4582
+ if (isX) {
4583
+ const width = Math.abs(start.x - end.x);
4584
+ if (isInverse) {
4585
+ const start = width;
4586
+ const end = 0;
4587
+ const startBound = first.AABBBounds.x2;
4588
+ const endBound = last.AABBBounds.x1;
4589
+ if (startBound > start) {
4590
+ first.setAttributes({
4591
+ x: start,
4592
+ textAlign: 'right'
4593
+ });
4594
+ }
4595
+ if (endBound < end) {
4596
+ last.setAttributes({
4597
+ x: end,
4598
+ textAlign: 'left'
4599
+ });
4600
+ }
4601
+ }
4602
+ else {
4603
+ const start = 0;
4604
+ const end = width;
4605
+ const startBound = first.AABBBounds.x1;
4606
+ const endBound = last.AABBBounds.x2;
4607
+ if (startBound < start) {
4608
+ first.setAttributes({
4609
+ x: start,
4610
+ textAlign: 'left'
4611
+ });
4612
+ }
4613
+ if (endBound > end) {
4614
+ last.setAttributes({
4615
+ x: end,
4616
+ textAlign: 'right'
4617
+ });
4618
+ }
4619
+ }
4620
+ }
4621
+ else {
4622
+ const height = Math.abs(start.y - end.y);
4623
+ if (isInverse) {
4624
+ const startBound = first.AABBBounds.y1;
4625
+ const endBound = last.AABBBounds.y2;
4626
+ const start = 0;
4627
+ const end = height;
4628
+ if (startBound < start) {
4629
+ first.setAttributes({
4630
+ y: start,
4631
+ textBaseline: 'top'
4632
+ });
4633
+ }
4634
+ if (endBound > end) {
4635
+ last.setAttributes({
4636
+ y: end,
4637
+ textBaseline: 'bottom'
4638
+ });
4639
+ }
4640
+ }
4641
+ else {
4642
+ const start = height;
4643
+ const end = 0;
4644
+ const startBound = first.AABBBounds.y2;
4645
+ const endBound = last.AABBBounds.y1;
4646
+ if (startBound > start) {
4647
+ first.setAttributes({
4648
+ y: start,
4649
+ textBaseline: 'bottom'
4650
+ });
4651
+ }
4652
+ if (endBound < end) {
4653
+ last.setAttributes({
4654
+ y: end,
4655
+ textBaseline: 'top'
4656
+ });
4657
+ }
4658
+ }
4659
+ }
4660
+ }
4543
4661
  return;
4544
4662
  }
4545
4663
  handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
@@ -9734,6 +9852,13 @@
9734
9852
  setUpdateDragMaskCallback(callback) {
9735
9853
  vutils.isFunction(callback) && (this._updateDragMaskCallback = callback);
9736
9854
  }
9855
+ releaseBrushEvents() {
9856
+ const { delayType = 'throttle', delayTime = 0 } = this.attribute;
9857
+ this.stage.removeEventListener('pointerdown', this._onBrushStart);
9858
+ this.stage.removeEventListener('pointermove', delayMap[delayType](this._onBrushing, delayTime));
9859
+ this.stage.removeEventListener('pointerup', this._onBrushEnd);
9860
+ this.stage.removeEventListener('pointerupoutside', this._onBrushEnd);
9861
+ }
9737
9862
  }
9738
9863
  Brush.defaultAttributes = DEFAULT_BRUSH_ATTRIBUTES;
9739
9864
 
@@ -10119,11 +10244,7 @@
10119
10244
  }
10120
10245
  Tooltip.defaultAttributes = defaultAttributes;
10121
10246
 
10122
- function VTag(params) {
10123
- return new Tag(params ? params.attribute : {});
10124
- }
10125
-
10126
- const version = "0.14.6-alpha.4";
10247
+ const version = "0.14.6-alpha.8";
10127
10248
 
10128
10249
  exports.AbstractComponent = AbstractComponent;
10129
10250
  exports.ArcInfo = ArcInfo;
@@ -10174,7 +10295,6 @@
10174
10295
  exports.Tag = Tag;
10175
10296
  exports.Title = Title;
10176
10297
  exports.Tooltip = Tooltip;
10177
- exports.VTag = VTag;
10178
10298
  exports.getHorizontalPath = getHorizontalPath;
10179
10299
  exports.getSizeHandlerPath = getSizeHandlerPath;
10180
10300
  exports.getVerticalPath = getVerticalPath;