@visactor/vrender-components 0.14.0-alpha.0 → 0.14.0-alpha.2

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 (147) hide show
  1. package/cjs/axis/base.d.ts +3 -1
  2. package/cjs/axis/base.js +4 -2
  3. package/cjs/axis/base.js.map +1 -1
  4. package/cjs/axis/circle.d.ts +3 -1
  5. package/cjs/axis/circle.js +3 -1
  6. package/cjs/axis/circle.js.map +1 -1
  7. package/cjs/axis/constant.d.ts +2 -1
  8. package/cjs/axis/constant.js +1 -1
  9. package/cjs/axis/constant.js.map +1 -1
  10. package/cjs/axis/line.d.ts +5 -2
  11. package/cjs/axis/line.js +41 -9
  12. package/cjs/axis/line.js.map +1 -1
  13. package/cjs/axis/overlap/auto-limit.js +1 -1
  14. package/cjs/axis/overlap/auto-limit.js.map +1 -1
  15. package/cjs/axis/type.d.ts +6 -2
  16. package/cjs/axis/type.js.map +1 -1
  17. package/cjs/brush/brush.d.ts +3 -3
  18. package/cjs/brush/brush.js.map +1 -1
  19. package/cjs/data-zoom/config.d.ts +2 -0
  20. package/cjs/data-zoom/config.js +3 -1
  21. package/cjs/data-zoom/config.js.map +1 -1
  22. package/cjs/data-zoom/data-zoom.d.ts +2 -0
  23. package/cjs/data-zoom/data-zoom.js +21 -11
  24. package/cjs/data-zoom/data-zoom.js.map +1 -1
  25. package/cjs/data-zoom/type.d.ts +4 -3
  26. package/cjs/data-zoom/type.js.map +1 -1
  27. package/cjs/index.d.ts +1 -1
  28. package/cjs/index.js +1 -1
  29. package/cjs/index.js.map +1 -1
  30. package/cjs/label/base.d.ts +12 -11
  31. package/cjs/label/base.js +83 -62
  32. package/cjs/label/base.js.map +1 -1
  33. package/cjs/label/overlap/place.d.ts +8 -4
  34. package/cjs/label/overlap/place.js +14 -2
  35. package/cjs/label/overlap/place.js.map +1 -1
  36. package/cjs/label/rect.d.ts +5 -3
  37. package/cjs/label/rect.js.map +1 -1
  38. package/cjs/label/symbol.d.ts +5 -3
  39. package/cjs/label/symbol.js.map +1 -1
  40. package/cjs/label/type.d.ts +12 -7
  41. package/cjs/label/type.js.map +1 -1
  42. package/cjs/legend/discrete/discrete.js +2 -1
  43. package/cjs/legend/discrete/discrete.js.map +1 -1
  44. package/cjs/marker/type.d.ts +4 -5
  45. package/cjs/marker/type.js.map +1 -1
  46. package/cjs/player/continuous-player.d.ts +1 -2
  47. package/cjs/player/continuous-player.js +5 -5
  48. package/cjs/player/continuous-player.js.map +1 -1
  49. package/cjs/player/discrete-player.d.ts +1 -2
  50. package/cjs/player/discrete-player.js +4 -4
  51. package/cjs/player/discrete-player.js.map +1 -1
  52. package/cjs/poptip/contribution.js +1 -1
  53. package/cjs/poptip/contribution.js.map +1 -1
  54. package/cjs/poptip/poptip.js +10 -3
  55. package/cjs/poptip/poptip.js.map +1 -1
  56. package/cjs/scrollbar/scrollbar.js +4 -4
  57. package/cjs/scrollbar/scrollbar.js.map +1 -1
  58. package/cjs/segment/segment.js +4 -1
  59. package/cjs/segment/segment.js.map +1 -1
  60. package/cjs/segment/type.d.ts +1 -0
  61. package/cjs/segment/type.js.map +1 -1
  62. package/cjs/slider/slider.d.ts +1 -1
  63. package/cjs/slider/slider.js +8 -8
  64. package/cjs/slider/slider.js.map +1 -1
  65. package/cjs/tag/type.d.ts +3 -3
  66. package/cjs/tag/type.js.map +1 -1
  67. package/cjs/util/align.d.ts +2 -0
  68. package/cjs/util/align.js +60 -0
  69. package/cjs/util/align.js.map +1 -0
  70. package/cjs/util/common.d.ts +3 -1
  71. package/cjs/util/common.js +14 -2
  72. package/cjs/util/common.js.map +1 -1
  73. package/dist/index.js +396 -143
  74. package/dist/index.min.js +1 -1
  75. package/es/axis/base.d.ts +3 -1
  76. package/es/axis/base.js +4 -2
  77. package/es/axis/base.js.map +1 -1
  78. package/es/axis/circle.d.ts +3 -1
  79. package/es/axis/circle.js +3 -1
  80. package/es/axis/circle.js.map +1 -1
  81. package/es/axis/constant.d.ts +2 -1
  82. package/es/axis/constant.js +1 -1
  83. package/es/axis/constant.js.map +1 -1
  84. package/es/axis/line.d.ts +5 -2
  85. package/es/axis/line.js +45 -9
  86. package/es/axis/line.js.map +1 -1
  87. package/es/axis/overlap/auto-limit.js +1 -1
  88. package/es/axis/overlap/auto-limit.js.map +1 -1
  89. package/es/axis/type.d.ts +6 -2
  90. package/es/axis/type.js.map +1 -1
  91. package/es/brush/brush.d.ts +3 -3
  92. package/es/brush/brush.js.map +1 -1
  93. package/es/data-zoom/config.d.ts +2 -0
  94. package/es/data-zoom/config.js +3 -1
  95. package/es/data-zoom/config.js.map +1 -1
  96. package/es/data-zoom/data-zoom.d.ts +2 -0
  97. package/es/data-zoom/data-zoom.js +22 -12
  98. package/es/data-zoom/data-zoom.js.map +1 -1
  99. package/es/data-zoom/type.d.ts +4 -3
  100. package/es/data-zoom/type.js.map +1 -1
  101. package/es/index.d.ts +1 -1
  102. package/es/index.js +1 -1
  103. package/es/index.js.map +1 -1
  104. package/es/label/base.d.ts +12 -11
  105. package/es/label/base.js +85 -65
  106. package/es/label/base.js.map +1 -1
  107. package/es/label/overlap/place.d.ts +8 -4
  108. package/es/label/overlap/place.js +11 -0
  109. package/es/label/overlap/place.js.map +1 -1
  110. package/es/label/rect.d.ts +5 -3
  111. package/es/label/rect.js.map +1 -1
  112. package/es/label/symbol.d.ts +5 -3
  113. package/es/label/symbol.js.map +1 -1
  114. package/es/label/type.d.ts +12 -7
  115. package/es/label/type.js.map +1 -1
  116. package/es/legend/discrete/discrete.js +1 -1
  117. package/es/legend/discrete/discrete.js.map +1 -1
  118. package/es/marker/type.d.ts +4 -5
  119. package/es/marker/type.js.map +1 -1
  120. package/es/player/continuous-player.d.ts +1 -2
  121. package/es/player/continuous-player.js +5 -5
  122. package/es/player/continuous-player.js.map +1 -1
  123. package/es/player/discrete-player.d.ts +1 -2
  124. package/es/player/discrete-player.js +5 -5
  125. package/es/player/discrete-player.js.map +1 -1
  126. package/es/poptip/contribution.js +1 -1
  127. package/es/poptip/contribution.js.map +1 -1
  128. package/es/poptip/poptip.js +11 -4
  129. package/es/poptip/poptip.js.map +1 -1
  130. package/es/scrollbar/scrollbar.js +5 -5
  131. package/es/scrollbar/scrollbar.js.map +1 -1
  132. package/es/segment/segment.js +4 -1
  133. package/es/segment/segment.js.map +1 -1
  134. package/es/segment/type.d.ts +1 -0
  135. package/es/segment/type.js.map +1 -1
  136. package/es/slider/slider.d.ts +1 -1
  137. package/es/slider/slider.js +9 -9
  138. package/es/slider/slider.js.map +1 -1
  139. package/es/tag/type.d.ts +3 -3
  140. package/es/tag/type.js.map +1 -1
  141. package/es/util/align.d.ts +2 -0
  142. package/es/util/align.js +54 -0
  143. package/es/util/align.js.map +1 -0
  144. package/es/util/common.d.ts +3 -1
  145. package/es/util/common.js +12 -0
  146. package/es/util/common.js.map +1 -1
  147. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -273,9 +273,9 @@
273
273
  e.stopPropagation();
274
274
  const { direction } = this.attribute;
275
275
  this._prePos = direction === 'horizontal' ? e.clientX : e.clientY;
276
- if (vrender.vglobal.env === 'browser') {
277
- vrender.vglobal.addEventListener('pointermove', this._onSliderPointerMove);
278
- vrender.vglobal.addEventListener('pointerup', this._onSliderPointerUp);
276
+ if (vrender.global.env === 'browser') {
277
+ vrender.global.addEventListener('pointermove', this._onSliderPointerMove);
278
+ vrender.global.addEventListener('pointerup', this._onSliderPointerUp);
279
279
  }
280
280
  else {
281
281
  this._slider.addEventListener('pointermove', this._onSliderPointerMove);
@@ -306,9 +306,9 @@
306
306
  };
307
307
  _onSliderPointerUp = (e) => {
308
308
  e.preventDefault();
309
- if (vrender.vglobal.env === 'browser') {
310
- vrender.vglobal.removeEventListener('pointermove', this._onSliderPointerMove);
311
- vrender.vglobal.removeEventListener('pointerup', this._onSliderPointerUp);
309
+ if (vrender.global.env === 'browser') {
310
+ vrender.global.removeEventListener('pointermove', this._onSliderPointerMove);
311
+ vrender.global.removeEventListener('pointerup', this._onSliderPointerUp);
312
312
  }
313
313
  else {
314
314
  this._slider.removeEventListener('pointermove', this._onSliderPointerMove);
@@ -341,6 +341,26 @@
341
341
  }
342
342
  return obj.visible !== false;
343
343
  };
344
+ function getMarksByName(root, name) {
345
+ if (!name) {
346
+ return [];
347
+ }
348
+ const group = root.find(node => node.name === name, true);
349
+ if (!group) {
350
+ return [];
351
+ }
352
+ return group.getChildren();
353
+ }
354
+ function getNoneGroupMarksByName(root, name) {
355
+ if (!name) {
356
+ return [];
357
+ }
358
+ const group = root.find(node => node.name === name, true);
359
+ if (!group) {
360
+ return [];
361
+ }
362
+ return group.findAll(node => node.type !== 'group', true);
363
+ }
344
364
 
345
365
  const defaultAlternativeColors = ['#ffffff', '#000000'];
346
366
  function labelSmartInvert(foregroundColorOrigin, backgroundColorOrogin, textType, contrastRatiosThreshold, alternativeColors) {
@@ -751,8 +771,10 @@
751
771
  ? [this.stage.width, this.stage.height]
752
772
  : undefined;
753
773
  const layout = position === 'auto';
754
- for (let i = 0; i < this.positionList.length; i++) {
755
- const p = layout ? this.positionList[i] : position;
774
+ let minifyBBoxI;
775
+ let minifyBBoxSize = Infinity;
776
+ for (let i = 0; i < this.positionList.length + 1; i++) {
777
+ const p = layout ? this.positionList[i === this.positionList.length ? minifyBBoxI : i] : position;
756
778
  const { angle, offset, rectOffset } = this.getAngleAndOffset(p, popTipWidth, poptipHeight, vutils.isArray(spaceSize) ? spaceSize : [spaceSize, spaceSize - lineWidth]);
757
779
  if (vutils.isBoolean(bgVisible)) {
758
780
  const offsetX = (vutils.isArray(symbolSize) ? symbolSize[0] : symbolSize) / 4;
@@ -761,6 +783,8 @@
761
783
  visible: bgVisible && (contentVisible || titleVisible),
762
784
  x: offsetX,
763
785
  y: 0,
786
+ strokeBoundsBuffer: -1,
787
+ boundsPadding: -2,
764
788
  anchor: [0, 0],
765
789
  symbolType: 'arrow2Left',
766
790
  angle: angle,
@@ -779,7 +803,7 @@
779
803
  y: 0,
780
804
  width: popTipWidth,
781
805
  height: poptipHeight,
782
- zIndex: -10
806
+ zIndex: -8
783
807
  }, 'rect');
784
808
  if (!vutils.isEmpty(state?.panel)) {
785
809
  bgRect.states = state.panel;
@@ -795,6 +819,14 @@
795
819
  if (vutils.rectInsideAnotherRect(b, stageBounds, false)) {
796
820
  break;
797
821
  }
822
+ else {
823
+ const bbox = vutils.getRectIntersect(b, stageBounds, false);
824
+ const size = (bbox.x2 - bbox.x1) * (bbox.y2 - bbox.y1);
825
+ if (size < minifyBBoxSize) {
826
+ minifyBBoxSize = size;
827
+ minifyBBoxI = i;
828
+ }
829
+ }
798
830
  }
799
831
  else {
800
832
  break;
@@ -951,6 +983,7 @@
951
983
  x: matrix.e,
952
984
  y: matrix.f
953
985
  });
986
+ drawContext.stage.tryInitInteractiveLayer();
954
987
  const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');
955
988
  if (interactiveLayer) {
956
989
  interactiveLayer.add(this.poptipComponent);
@@ -1501,6 +1534,28 @@
1501
1534
  return DefaultPositions;
1502
1535
  }
1503
1536
  }
1537
+ function clampText(text, width, height) {
1538
+ const { x1, x2, y1, y2 } = text.AABBBounds;
1539
+ const minX = Math.min(x1, x2);
1540
+ const maxX = Math.max(x1, x2);
1541
+ const minY = Math.min(y1, y2);
1542
+ const maxY = Math.max(y1, y2);
1543
+ let dx = 0;
1544
+ let dy = 0;
1545
+ if (minX < 0 && maxX - minX <= width) {
1546
+ dx = -minX;
1547
+ }
1548
+ else if (maxX > width && minX - (maxX - width) >= 0) {
1549
+ dx = width - maxX;
1550
+ }
1551
+ if (minY < 0 && maxY - minY <= height) {
1552
+ dy = -minY;
1553
+ }
1554
+ else if (maxY > height && minY - (maxY - height) >= 0) {
1555
+ dy = height - maxY;
1556
+ }
1557
+ return { dx, dy };
1558
+ }
1504
1559
 
1505
1560
  const fadeIn = (textAttribute = {}) => {
1506
1561
  return {
@@ -1551,17 +1606,37 @@
1551
1606
  setBitmapTool(bmpTool) {
1552
1607
  this._bmpTool = bmpTool;
1553
1608
  }
1554
- _relationMap;
1555
- _prevRelationMap;
1556
- _textMap;
1609
+ _graphicToText;
1610
+ _idToGraphic;
1557
1611
  onAfterLabelOverlap;
1558
1612
  _lastHover;
1559
1613
  _lastSelect;
1560
1614
  _enableAnimation;
1561
1615
  render() {
1562
- const currentBaseMarks = this._checkMarks();
1563
- const labels = this.layout(currentBaseMarks);
1564
- this._smartInvert(labels);
1616
+ this._prepare();
1617
+ const { overlap, smartInvert, dataFilter, customLayoutFunc, customOverlapFunc } = this.attribute;
1618
+ let data = this.attribute.data;
1619
+ if (vutils.isFunction(dataFilter)) {
1620
+ data = dataFilter(data);
1621
+ }
1622
+ let labels;
1623
+ if (vutils.isFunction(customLayoutFunc)) {
1624
+ labels = customLayoutFunc(data, (d) => this._idToGraphic.get(d.id));
1625
+ }
1626
+ else {
1627
+ labels = this.layout(data);
1628
+ if (vutils.isFunction(customOverlapFunc)) {
1629
+ labels = customOverlapFunc(labels, (d) => this._idToGraphic.get(d.id));
1630
+ }
1631
+ else {
1632
+ if (overlap !== false) {
1633
+ labels = this._overlapping(labels);
1634
+ }
1635
+ }
1636
+ }
1637
+ if (smartInvert !== false) {
1638
+ this._smartInvert(labels);
1639
+ }
1565
1640
  this._renderLabels(labels);
1566
1641
  }
1567
1642
  _bindEvent(target) {
@@ -1638,67 +1713,66 @@
1638
1713
  this._setStates(text);
1639
1714
  return text;
1640
1715
  }
1641
- _checkMarks() {
1642
- const baseMarks = this.getBaseMarks();
1716
+ _prepare() {
1717
+ const baseMarks = getMarksByName(this.getRootNode(), this.attribute.baseMarkGroupName);
1643
1718
  const currentBaseMarks = [];
1644
1719
  baseMarks.forEach(mark => {
1645
1720
  if (mark.releaseStatus !== 'willRelease') {
1646
1721
  currentBaseMarks.push(mark);
1647
1722
  }
1648
1723
  });
1649
- this._prevRelationMap = new Map(this._relationMap);
1650
- this._relationMap?.clear();
1651
- return currentBaseMarks;
1652
- }
1653
- layout(currentMarks) {
1654
- const { textStyle, position, offset } = this.attribute;
1655
- let { data } = this.attribute;
1656
- if (vutils.isFunction(data)) {
1657
- data = data({});
1724
+ this._idToGraphic?.clear();
1725
+ this._baseMarks = currentBaseMarks;
1726
+ if (!currentBaseMarks || currentBaseMarks.length === 0) {
1727
+ return;
1658
1728
  }
1729
+ const { data } = this.attribute;
1659
1730
  if (!data || data.length === 0) {
1660
- return [];
1731
+ return;
1661
1732
  }
1662
- let labels = [];
1663
- if (vutils.isFunction(this.attribute.sort) && currentMarks && currentMarks.length) {
1664
- currentMarks = currentMarks.sort(this.attribute.sort);
1733
+ if (!this._idToGraphic) {
1734
+ this._idToGraphic = new Map();
1665
1735
  }
1666
- if (!this._relationMap) {
1667
- this._relationMap = new Map();
1736
+ for (let i = 0; i < currentBaseMarks.length; i++) {
1737
+ const textData = data[i];
1738
+ const baseMark = currentBaseMarks[i];
1739
+ if (textData && baseMark) {
1740
+ if (!vutils.isValid(textData.id)) {
1741
+ textData.id = `vrender-component-${this.name}-${i}`;
1742
+ }
1743
+ this._idToGraphic.set(textData.id, baseMark);
1744
+ }
1668
1745
  }
1746
+ }
1747
+ layout(data = []) {
1748
+ const { textStyle = {}, position, offset } = this.attribute;
1749
+ const labels = [];
1669
1750
  for (let i = 0; i < data.length; i++) {
1670
1751
  const textData = data[i];
1671
- const baseMark = currentMarks?.[i];
1752
+ const baseMark = this._idToGraphic.get(textData.id);
1672
1753
  const labelAttribute = {
1673
1754
  ...textStyle,
1674
- ...textData,
1675
- _relatedIndex: i
1755
+ ...textData
1676
1756
  };
1677
- this._relationMap.set(i, baseMark);
1678
- if (textData) {
1679
- const text = vrender.createText(labelAttribute);
1680
- text.update();
1681
- const textBounds = this.getGraphicBounds(text);
1682
- const graphicBounds = this.getGraphicBounds(baseMark, { x: textData.x, y: textData.y });
1683
- const textAttributes = this.labeling(textBounds, graphicBounds, vutils.isFunction(position) ? position(textData) : position, offset);
1684
- if (!textAttributes) {
1685
- continue;
1686
- }
1687
- labelAttribute.x = textAttributes.x;
1688
- labelAttribute.y = textAttributes.y;
1689
- labels.push(labelAttribute);
1757
+ const text = this._createLabelText(labelAttribute);
1758
+ const textBounds = this.getGraphicBounds(text);
1759
+ const graphicBounds = this.getGraphicBounds(baseMark, { x: textData.x, y: textData.y });
1760
+ const textLocation = this.labeling(textBounds, graphicBounds, vutils.isFunction(position) ? position(textData) : position, offset);
1761
+ if (!textLocation) {
1762
+ continue;
1690
1763
  }
1691
- }
1692
- this._baseMarks = currentMarks;
1693
- if (this.attribute.overlap !== false) {
1694
- labels = this.overlapping(labels, this.attribute.overlap);
1764
+ labelAttribute.x = textLocation.x;
1765
+ labelAttribute.y = textLocation.y;
1766
+ text.setAttributes(textLocation);
1767
+ labels.push(text);
1695
1768
  }
1696
1769
  return labels;
1697
1770
  }
1698
- overlapping(labels, option = {}) {
1771
+ _overlapping(labels) {
1699
1772
  if (labels.length === 0) {
1700
1773
  return [];
1701
1774
  }
1775
+ const option = this.attribute.overlap;
1702
1776
  const result = [];
1703
1777
  const baseMarkGroup = this.getBaseMarkGroup();
1704
1778
  const size = option.size ?? {
@@ -1708,7 +1782,7 @@
1708
1782
  if (size.width === 0 || size.height === 0) {
1709
1783
  return labels;
1710
1784
  }
1711
- const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true } = option;
1785
+ const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [] } = option;
1712
1786
  const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);
1713
1787
  const bitmap = this._bitmap || bmpTool.bitmap();
1714
1788
  const checkBounds = strategy.some(s => s.type === 'bound');
@@ -1717,22 +1791,34 @@
1717
1791
  mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, true));
1718
1792
  });
1719
1793
  }
1794
+ if (avoidMarks.length > 0) {
1795
+ avoidMarks.forEach(avoid => {
1796
+ if (vutils.isString(avoid)) {
1797
+ getNoneGroupMarksByName(this.getRootNode(), avoid).forEach(avoidMark => {
1798
+ avoidMark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, avoidMark.AABBBounds, true));
1799
+ });
1800
+ }
1801
+ else if (avoid.AABBBounds) {
1802
+ bitmap.setRange(boundToRange(bmpTool, avoid.AABBBounds, true));
1803
+ }
1804
+ });
1805
+ }
1720
1806
  for (let i = 0; i < labels.length; i++) {
1721
1807
  if (labels[i].visible === false) {
1722
1808
  continue;
1723
1809
  }
1724
- const text = vrender.createText(labels[i]);
1725
- const baseMark = this._baseMarks?.[i];
1810
+ const text = labels[i];
1811
+ const baseMark = this._idToGraphic.get(text.attribute.id);
1726
1812
  text.update();
1727
1813
  if (canPlace(bmpTool, bitmap, text.AABBBounds, clampForce)) {
1728
1814
  if (!checkBounds) {
1729
1815
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
1730
- result.push({ ...text.attribute });
1816
+ result.push(text);
1731
1817
  continue;
1732
1818
  }
1733
1819
  if (checkBounds && baseMark?.AABBBounds && canPlaceInside(text.AABBBounds, baseMark?.AABBBounds)) {
1734
1820
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
1735
- result.push({ ...text.attribute });
1821
+ result.push(text);
1736
1822
  continue;
1737
1823
  }
1738
1824
  }
@@ -1740,28 +1826,33 @@
1740
1826
  for (let j = 0; j < strategy.length; j++) {
1741
1827
  hasPlace = place(bmpTool, bitmap, strategy[j], this.attribute, text, this.getGraphicBounds(baseMark, labels[i]), this.labeling);
1742
1828
  if (hasPlace !== false) {
1743
- result.push({
1744
- ...text.attribute,
1745
- x: hasPlace.x,
1746
- y: hasPlace.y
1747
- });
1829
+ text.setAttributes({ x: hasPlace.x, y: hasPlace.y });
1830
+ result.push(text);
1748
1831
  break;
1749
1832
  }
1750
1833
  }
1751
- !hasPlace && !hideOnHit && result.push({ ...text.attribute });
1834
+ if (!hasPlace && clampForce) {
1835
+ const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
1836
+ if (!(dx === 0 && dy === 0) &&
1837
+ canPlace(bmpTool, bitmap, {
1838
+ x1: text.AABBBounds.x1 + dx,
1839
+ x2: text.AABBBounds.x2 + dx,
1840
+ y1: text.AABBBounds.y1 + dy,
1841
+ y2: text.AABBBounds.y2 + dy
1842
+ })) {
1843
+ text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
1844
+ bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
1845
+ result.push(text);
1846
+ continue;
1847
+ }
1848
+ }
1849
+ !hasPlace && !hideOnHit && result.push(text);
1752
1850
  }
1753
1851
  if (vutils.isFunction(this.onAfterLabelOverlap)) {
1754
1852
  this.onAfterLabelOverlap(bitmap);
1755
1853
  }
1756
1854
  return result;
1757
1855
  }
1758
- getBaseMarks() {
1759
- const baseMarkGroup = this.getBaseMarkGroup();
1760
- if (!baseMarkGroup) {
1761
- return;
1762
- }
1763
- return baseMarkGroup.getChildren();
1764
- }
1765
1856
  getBaseMarkGroup() {
1766
1857
  const { baseMarkGroupName } = this.attribute;
1767
1858
  if (!baseMarkGroupName) {
@@ -1786,17 +1877,16 @@
1786
1877
  const easing = animationConfig.easing ?? DefaultLabelAnimation.easing;
1787
1878
  const delay = animationConfig.delay ?? 0;
1788
1879
  const currentTextMap = new Map();
1789
- const prevTextMap = this._textMap || new Map();
1880
+ const prevTextMap = this._graphicToText || new Map();
1790
1881
  const texts = [];
1791
- labels.forEach((label, index) => {
1792
- const text = this._createLabelText(label);
1793
- const relatedGraphic = this._relationMap.get(label._relatedIndex);
1882
+ labels.forEach((text, index) => {
1883
+ const relatedGraphic = this._idToGraphic.get(text.attribute.id);
1794
1884
  const state = prevTextMap?.get(relatedGraphic) ? 'update' : 'enter';
1795
1885
  if (state === 'enter') {
1796
1886
  texts.push(text);
1797
1887
  currentTextMap.set(relatedGraphic, text);
1798
1888
  if (!disableAnimation && relatedGraphic) {
1799
- const { from, to } = getAnimationAttributes(label, 'fadeIn');
1889
+ const { from, to } = getAnimationAttributes(text.attribute, 'fadeIn');
1800
1890
  this.add(text);
1801
1891
  relatedGraphic.onAnimateBind = () => {
1802
1892
  text.setAttributes(from);
@@ -1846,7 +1936,7 @@
1846
1936
  });
1847
1937
  }
1848
1938
  });
1849
- this._textMap = currentTextMap;
1939
+ this._graphicToText = currentTextMap;
1850
1940
  }
1851
1941
  _afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, { mode, duration, easing, to, delay }) {
1852
1942
  const listener = (event) => {
@@ -1897,30 +1987,34 @@
1897
1987
  return listener;
1898
1988
  }
1899
1989
  _smartInvert(labels) {
1900
- if (this.attribute.smartInvert === false) {
1901
- return;
1902
- }
1990
+ const option = (this.attribute.smartInvert || {});
1991
+ const { textType, contrastRatiosThreshold, alternativeColors } = option;
1903
1992
  for (let i = 0; i < labels.length; i++) {
1904
- const label = labels?.[i];
1993
+ const label = labels[i];
1905
1994
  if (!label) {
1906
1995
  continue;
1907
1996
  }
1908
- const isInside = canPlaceInside(vrender.createText(label).AABBBounds, this._relationMap.get(label._relatedIndex)?.AABBBounds);
1909
- if (label.stroke && label.lineWidth > 0) {
1910
- label.fill = labelSmartInvert(label.fill, label.stroke, this.attribute.smartInvert?.textType, this.attribute.smartInvert?.contrastRatiosThreshold, this.attribute.smartInvert?.alternativeColors);
1997
+ const baseMark = this._idToGraphic.get(label.attribute.id);
1998
+ const isInside = canPlaceInside(label.AABBBounds, baseMark?.AABBBounds);
1999
+ if (label.attribute.stroke && label.attribute.lineWidth > 0) {
2000
+ label.setAttributes({
2001
+ fill: labelSmartInvert(label.attribute.fill, label.attribute.stroke, textType, contrastRatiosThreshold, alternativeColors)
2002
+ });
1911
2003
  }
1912
2004
  else if (isInside) {
1913
- const baseMark = this._relationMap.get(label._relatedIndex);
1914
2005
  const backgroundColor = baseMark.attribute.fill;
1915
- const foregroundColor = label.fill;
1916
- label.fill = labelSmartInvert(foregroundColor, backgroundColor, this.attribute.smartInvert?.textType, this.attribute.smartInvert?.contrastRatiosThreshold, this.attribute.smartInvert?.alternativeColors);
2006
+ const foregroundColor = label.attribute.fill;
2007
+ label.setAttributes({
2008
+ fill: labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors)
2009
+ });
1917
2010
  }
1918
- else if (label.lineWidth > 0) {
1919
- const baseMark = this._relationMap.get(label._relatedIndex);
1920
- label.stroke = baseMark.attribute.fill;
1921
- const backgroundColor = label.stroke;
1922
- const foregroundColor = label.fill;
1923
- label.fill = labelSmartInvert(foregroundColor, backgroundColor, this.attribute.smartInvert?.textType, this.attribute.smartInvert?.contrastRatiosThreshold, this.attribute.smartInvert?.alternativeColors);
2011
+ else if (label.attribute.lineWidth > 0) {
2012
+ const backgroundColor = label.attribute.stroke;
2013
+ const foregroundColor = label.attribute.fill;
2014
+ label.setAttributes({
2015
+ stroke: baseMark.attribute.fill,
2016
+ fill: labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors)
2017
+ });
1924
2018
  }
1925
2019
  }
1926
2020
  }
@@ -2375,6 +2469,7 @@
2375
2469
  },
2376
2470
  startSymbol: {
2377
2471
  visible: false,
2472
+ autoRotate: true,
2378
2473
  symbolType: 'triangle',
2379
2474
  size: 12,
2380
2475
  refX: 0,
@@ -2387,6 +2482,7 @@
2387
2482
  },
2388
2483
  endSymbol: {
2389
2484
  visible: false,
2485
+ autoRotate: true,
2390
2486
  symbolType: 'triangle',
2391
2487
  size: 12,
2392
2488
  refX: 0,
@@ -2458,6 +2554,7 @@
2458
2554
  this.add(line);
2459
2555
  }
2460
2556
  renderSymbol(attribute, dim) {
2557
+ const { autoRotate = true } = attribute;
2461
2558
  let symbol;
2462
2559
  if (attribute?.visible) {
2463
2560
  const startAngle = this._startAngle;
@@ -2486,7 +2583,7 @@
2486
2583
  ...position,
2487
2584
  symbolType: symbolType,
2488
2585
  size,
2489
- angle: rotate + refAngle,
2586
+ angle: autoRotate ? rotate + refAngle : 0,
2490
2587
  strokeBoundsBuffer: 0,
2491
2588
  ...style
2492
2589
  });
@@ -2522,6 +2619,7 @@
2522
2619
  AXIS_ELEMENT_NAME["gridRegion"] = "axis-grid-region";
2523
2620
  AXIS_ELEMENT_NAME["line"] = "axis-line";
2524
2621
  AXIS_ELEMENT_NAME["background"] = "axis-background";
2622
+ AXIS_ELEMENT_NAME["axisLabelBackground"] = "axis-label-background";
2525
2623
  })(exports.AXIS_ELEMENT_NAME || (exports.AXIS_ELEMENT_NAME = {}));
2526
2624
  exports.AxisStateValue = void 0;
2527
2625
  (function (AxisStateValue) {
@@ -2728,7 +2826,9 @@
2728
2826
  items.forEach((axisItems, layer) => {
2729
2827
  const layerLabelGroup = this.renderLabels(labelGroup, axisItems, layer);
2730
2828
  const labels = layerLabelGroup.getChildren();
2731
- this.handleLabelsOverlap(labels, axisItems, layer, items.length);
2829
+ this.beforeLabelsOverlap(labels, axisItems, layerLabelGroup, layer, items.length);
2830
+ this.handleLabelsOverlap(labels, axisItems, layerLabelGroup, layer, items.length);
2831
+ this.afterLabelsOverlap(labels, axisItems, layerLabelGroup, layer, items.length);
2732
2832
  });
2733
2833
  }
2734
2834
  if (grid?.visible) {
@@ -3280,7 +3380,7 @@
3280
3380
  ? orient === 'top' || orient === 'bottom'
3281
3381
  ? null
3282
3382
  : limitLength
3283
- : limitLength / Math.sin(label.attribute.angle);
3383
+ : Math.abs(limitLength / Math.sin(label.attribute.angle));
3284
3384
  label.setAttributes({
3285
3385
  maxLineWidth: limitLabelLength,
3286
3386
  ellipsis
@@ -3288,6 +3388,67 @@
3288
3388
  });
3289
3389
  }
3290
3390
 
3391
+ function alignAxisLabels(labels, start, containerSize, orient, align) {
3392
+ if (orient === 'right' || orient === 'left') {
3393
+ if (align === 'left') {
3394
+ const flag = orient === 'right' ? 0 : -1;
3395
+ labels.forEach(label => {
3396
+ label.setAttributes({
3397
+ x: start + containerSize * flag,
3398
+ textAlign: 'left'
3399
+ });
3400
+ });
3401
+ }
3402
+ else if (align === 'right') {
3403
+ const flag = orient === 'right' ? 1 : 0;
3404
+ labels.forEach(label => {
3405
+ label.setAttributes({
3406
+ x: start + containerSize * flag,
3407
+ textAlign: 'right'
3408
+ });
3409
+ });
3410
+ }
3411
+ else if (align === 'center') {
3412
+ const flag = orient === 'right' ? 1 : -1;
3413
+ labels.forEach(label => {
3414
+ label.setAttributes({
3415
+ x: start + containerSize * 0.5 * flag,
3416
+ textAlign: 'center'
3417
+ });
3418
+ });
3419
+ }
3420
+ }
3421
+ else if (orient === 'bottom' || orient === 'top') {
3422
+ if (align === 'top') {
3423
+ const flag = orient === 'bottom' ? 0 : -1;
3424
+ labels.forEach(label => {
3425
+ label.setAttributes({
3426
+ y: start + containerSize * flag,
3427
+ textBaseline: 'top'
3428
+ });
3429
+ });
3430
+ }
3431
+ else if (align === 'bottom') {
3432
+ const flag = orient === 'bottom' ? 1 : 0;
3433
+ labels.forEach(label => {
3434
+ label.setAttributes({
3435
+ y: start + containerSize * flag,
3436
+ textBaseline: 'bottom'
3437
+ });
3438
+ });
3439
+ }
3440
+ else if (align === 'middle') {
3441
+ const flag = orient === 'bottom' ? 1 : -1;
3442
+ labels.forEach(label => {
3443
+ label.setAttributes({
3444
+ y: start + containerSize * 0.5 * flag,
3445
+ textBaseline: 'middle'
3446
+ });
3447
+ });
3448
+ }
3449
+ }
3450
+ }
3451
+
3291
3452
  function getCirclePoints(center, count, radius, startAngle, endAngle) {
3292
3453
  const points = [];
3293
3454
  const range = endAngle - startAngle;
@@ -3612,24 +3773,15 @@
3612
3773
  }
3613
3774
  return base;
3614
3775
  }
3615
- handleLabelsOverlap(labelShapes, labelData, layer, layerCount) {
3776
+ beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
3777
+ return;
3778
+ }
3779
+ handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
3616
3780
  if (vutils.isEmpty(labelShapes)) {
3617
3781
  return;
3618
3782
  }
3619
- const { verticalLimitSize, label, title, line, tick, orient } = this.attribute;
3620
- const labelSpace = label.space ?? 4;
3621
- let limitLength = verticalLimitSize;
3622
- let titleHeight = 0;
3623
- let titleSpacing = 0;
3624
- const axisLineWidth = line?.visible ? line.style.lineWidth ?? 1 : 0;
3625
- const tickLength = tick?.visible ? tick.length ?? 4 : 0;
3626
- if (title?.visible) {
3627
- titleHeight = measureTextSize(title.text, title.textStyle).height;
3628
- titleSpacing = title.space;
3629
- }
3630
- if (limitLength) {
3631
- limitLength = (limitLength - labelSpace - titleSpacing - titleHeight - axisLineWidth - tickLength) / layerCount;
3632
- }
3783
+ const { verticalLimitSize, label, orient } = this.attribute;
3784
+ const limitLength = this._getAxisLabelLimitLength(verticalLimitSize, layerCount);
3633
3785
  const { layoutFunc, autoRotate: autoRotate$1, autoRotateAngle, autoLimit: autoLimit$1, limitEllipsis, autoHide: autoHide$1, autoHideMethod, autoHideSeparation } = label;
3634
3786
  if (vutils.isFunction(layoutFunc)) {
3635
3787
  layoutFunc(labelShapes, labelData, layer, this);
@@ -3657,6 +3809,78 @@
3657
3809
  }
3658
3810
  }
3659
3811
  }
3812
+ afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
3813
+ const { verticalLimitSize, orient } = this.attribute;
3814
+ const isHorizontal = orient === 'bottom' || orient === 'top';
3815
+ const axisLabelContainerBounds = labelContainer.AABBBounds;
3816
+ let axisLabelContainerSize = isHorizontal ? axisLabelContainerBounds.height() : axisLabelContainerBounds.width();
3817
+ const { verticalMinSize } = this.attribute;
3818
+ if (vutils.isValidNumber(verticalMinSize) && (!vutils.isValidNumber(verticalLimitSize) || verticalMinSize <= verticalLimitSize)) {
3819
+ const minSize = this._getAxisLabelLimitLength(verticalMinSize, layerCount);
3820
+ axisLabelContainerSize = Math.max(axisLabelContainerSize, minSize);
3821
+ let x;
3822
+ let y;
3823
+ if (orient === 'left') {
3824
+ x = axisLabelContainerBounds.x2 - axisLabelContainerSize;
3825
+ y = axisLabelContainerBounds.y1;
3826
+ }
3827
+ else if (orient === 'right') {
3828
+ x = axisLabelContainerBounds.x1;
3829
+ y = axisLabelContainerBounds.y1;
3830
+ }
3831
+ else if (orient === 'top') {
3832
+ x = axisLabelContainerBounds.x1;
3833
+ y = axisLabelContainerBounds.y2 - axisLabelContainerSize;
3834
+ }
3835
+ else if (orient === 'bottom') {
3836
+ x = axisLabelContainerBounds.x1;
3837
+ y = axisLabelContainerBounds.y1;
3838
+ }
3839
+ const bgRect = vrender.createRect({
3840
+ x,
3841
+ y,
3842
+ width: isHorizontal ? axisLabelContainerBounds.width() : axisLabelContainerSize,
3843
+ height: isHorizontal ? axisLabelContainerSize : axisLabelContainerBounds.height(),
3844
+ pickable: false
3845
+ });
3846
+ bgRect.name = exports.AXIS_ELEMENT_NAME.axisLabelBackground;
3847
+ bgRect.id = this._getNodeId('axis-label-background');
3848
+ labelContainer.insertBefore(bgRect, labelContainer.firstChild);
3849
+ }
3850
+ if (vutils.isValid(this.attribute.label.containerAlign)) {
3851
+ let start;
3852
+ if (orient === 'left') {
3853
+ start = axisLabelContainerBounds.x2;
3854
+ }
3855
+ else if (orient === 'right') {
3856
+ start = axisLabelContainerBounds.x1;
3857
+ }
3858
+ else if (orient === 'top') {
3859
+ start = axisLabelContainerBounds.y2;
3860
+ }
3861
+ else if (orient === 'bottom') {
3862
+ start = axisLabelContainerBounds.y1;
3863
+ }
3864
+ alignAxisLabels(labelShapes, start, axisLabelContainerSize, orient, this.attribute.label.containerAlign);
3865
+ }
3866
+ }
3867
+ _getAxisLabelLimitLength(limitSize, layerCount) {
3868
+ const { label, title, line, tick } = this.attribute;
3869
+ const labelSpace = label.space ?? 4;
3870
+ let limitLength = limitSize;
3871
+ let titleHeight = 0;
3872
+ let titleSpacing = 0;
3873
+ const axisLineWidth = line?.visible ? line.style.lineWidth ?? 1 : 0;
3874
+ const tickLength = tick?.visible ? tick.length ?? 4 : 0;
3875
+ if (title?.visible) {
3876
+ titleHeight = measureTextSize(title.text, title.textStyle).height;
3877
+ titleSpacing = title.space;
3878
+ }
3879
+ if (limitLength) {
3880
+ limitLength = (limitLength - labelSpace - titleSpacing - titleHeight - axisLineWidth - tickLength) / layerCount;
3881
+ }
3882
+ return limitLength;
3883
+ }
3660
3884
  }
3661
3885
 
3662
3886
  class CircleAxis extends AxisBase {
@@ -3911,7 +4135,13 @@
3911
4135
  }
3912
4136
  return base;
3913
4137
  }
3914
- handleLabelsOverlap(labelShapes, labelData, layer, layerCount) {
4138
+ beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4139
+ return;
4140
+ }
4141
+ handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
4142
+ return;
4143
+ }
4144
+ afterLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
3915
4145
  return;
3916
4146
  }
3917
4147
  }
@@ -4124,7 +4354,7 @@
4124
4354
  }
4125
4355
  },
4126
4356
  middleHandlerStyle: {
4127
- visible: false,
4357
+ visible: true,
4128
4358
  background: {
4129
4359
  size: 8,
4130
4360
  style: {
@@ -4142,12 +4372,14 @@
4142
4372
  }
4143
4373
  },
4144
4374
  startHandlerStyle: {
4375
+ visible: true,
4145
4376
  symbolType: 'M -0.0544 0.25 C -0.0742 0.25 -0.0901 0.234 -0.0901 0.2143 L -0.0901 -0.1786 C -0.0901 -0.1983 -0.0742 -0.2143 -0.0544 -0.2143 L -0.0187 -0.2143 L -0.0187 -0.5 L 0.017 -0.5 L 0.017 -0.2143 L 0.0527 -0.2143 C 0.0724 -0.2143 0.0884 -0.1983 0.0884 -0.1786 L 0.0884 0.2143 C 0.0884 0.234 0.0724 0.25 0.0527 0.25 L 0.017 0.25 L 0.017 0.5 L -0.0187 0.5 L -0.0187 0.25 L -0.0544 0.25 Z M -0.0187 -0.1429 L -0.0544 -0.1429 L -0.0544 0.1786 L -0.0187 0.1786 L -0.0187 -0.1429 Z M 0.0527 -0.1429 L 0.017 -0.1429 L 0.017 0.1786 L 0.0527 0.1786 L 0.0527 -0.1429 Z',
4146
4377
  fill: 'white',
4147
4378
  stroke: '#B0C8F9',
4148
4379
  lineWidth: 0.5
4149
4380
  },
4150
4381
  endHandlerStyle: {
4382
+ visible: true,
4151
4383
  symbolType: 'M -0.0544 0.25 C -0.0742 0.25 -0.0901 0.234 -0.0901 0.2143 L -0.0901 -0.1786 C -0.0901 -0.1983 -0.0742 -0.2143 -0.0544 -0.2143 L -0.0187 -0.2143 L -0.0187 -0.5 L 0.017 -0.5 L 0.017 -0.2143 L 0.0527 -0.2143 C 0.0724 -0.2143 0.0884 -0.1983 0.0884 -0.1786 L 0.0884 0.2143 C 0.0884 0.234 0.0724 0.25 0.0527 0.25 L 0.017 0.25 L 0.017 0.5 L -0.0187 0.5 L -0.0187 0.25 L -0.0544 0.25 Z M -0.0187 -0.1429 L -0.0544 -0.1429 L -0.0544 0.1786 L -0.0187 0.1786 L -0.0187 -0.1429 Z M 0.0527 -0.1429 L 0.017 -0.1429 L 0.017 0.1786 L 0.0527 0.1786 L 0.0527 -0.1429 Z',
4152
4384
  fill: 'white',
4153
4385
  stroke: '#B0C8F9',
@@ -4219,7 +4451,7 @@
4219
4451
  _layoutAttrFromConfig;
4220
4452
  constructor(attributes) {
4221
4453
  super(vutils.merge({}, DataZoom.defaultAttributes, attributes));
4222
- const { start, end, size, orient, showDetail, position, previewData, previewCallbackX, previewCallbackY, previewCallbackX1, previewCallbackY1 } = this.attribute;
4454
+ const { start, end, size, orient, showDetail, position, previewData, previewCallbackX, previewCallbackY, previewCallbackX1, previewCallbackY1, updateStateCallback } = this.attribute;
4223
4455
  const { width, height } = size;
4224
4456
  start && (this.state.start = start);
4225
4457
  end && (this.state.end = end);
@@ -4240,6 +4472,7 @@
4240
4472
  vutils.isFunction(previewCallbackY) && (this._previewCallbackY = previewCallbackY);
4241
4473
  vutils.isFunction(previewCallbackX1) && (this._previewCallbackX1 = previewCallbackX1);
4242
4474
  vutils.isFunction(previewCallbackY1) && (this._previewCallbackY1 = previewCallbackY1);
4475
+ vutils.isFunction(updateStateCallback) && (this._updateStateCallback = updateStateCallback);
4243
4476
  }
4244
4477
  bindEvents() {
4245
4478
  const { showDetail, brushSelect } = this.attribute;
@@ -4268,9 +4501,9 @@
4268
4501
  if (this._selectedPreviewGroup) {
4269
4502
  this._selectedPreviewGroup.addEventListener('pointerdown', (e) => this._onHandlerPointerDown(e, selectedTag));
4270
4503
  }
4271
- if (vrender.vglobal.env === 'browser') {
4272
- vrender.vglobal.addEventListener('pointermove', this._onHandlerPointerMove.bind(this));
4273
- vrender.vglobal.addEventListener('pointerup', this._onHandlerPointerUp.bind(this));
4504
+ if (vrender.global.env === 'browser') {
4505
+ vrender.global.addEventListener('pointermove', this._onHandlerPointerMove.bind(this));
4506
+ vrender.global.addEventListener('pointerup', this._onHandlerPointerUp.bind(this));
4274
4507
  }
4275
4508
  this.addEventListener('pointermove', this._onHandlerPointerMove);
4276
4509
  this.addEventListener('pointerup', this._onHandlerPointerUp);
@@ -4514,7 +4747,7 @@
4514
4747
  if (this._layoutAttrFromConfig) {
4515
4748
  return this._layoutAttrFromConfig;
4516
4749
  }
4517
- const { position: positionConfig, size, orient, middleHandlerStyle } = this.attribute;
4750
+ const { position: positionConfig, size, orient, middleHandlerStyle, startHandlerStyle, endHandlerStyle } = this.attribute;
4518
4751
  const { width: widthConfig, height: heightConfig } = size;
4519
4752
  const middleHandlerSize = middleHandlerStyle?.background?.size ?? 10;
4520
4753
  let width;
@@ -4543,6 +4776,24 @@
4543
4776
  height = heightConfig;
4544
4777
  position = positionConfig;
4545
4778
  }
4779
+ const startHandlerSize = startHandlerStyle?.size ?? (this._isHorizontal ? height : width);
4780
+ const endHandlerSize = endHandlerStyle?.size ?? (this._isHorizontal ? height : width);
4781
+ if (startHandlerStyle?.visible) {
4782
+ if (this._isHorizontal) {
4783
+ width -= (startHandlerSize + endHandlerSize) / 2;
4784
+ position = {
4785
+ x: position.x + startHandlerSize / 2,
4786
+ y: position.y
4787
+ };
4788
+ }
4789
+ else {
4790
+ height -= (startHandlerSize + endHandlerSize) / 2;
4791
+ position = {
4792
+ x: position.x,
4793
+ y: position.y + startHandlerSize
4794
+ };
4795
+ }
4796
+ }
4546
4797
  this._layoutAttrFromConfig = {
4547
4798
  position,
4548
4799
  width,
@@ -4797,10 +5048,9 @@
4797
5048
  else {
4798
5049
  this._selectedPreviewArea = this._selectedPreviewGroup.createOrUpdateChild('selectedPreviewArea', { curveType: 'basis' }, 'area');
4799
5050
  }
4800
- const { position, size, selectedBackgroundChartStyle } = this.attribute;
4801
- const { width, height } = size;
5051
+ const { selectedBackgroundChartStyle } = this.attribute;
4802
5052
  const { start, end } = this.state;
4803
- this.computeBasePoints();
5053
+ const { position, width, height } = this.getLayoutAttrFromConfig();
4804
5054
  this._selectedPreviewGroupClip.setAttributes({
4805
5055
  x: this._isHorizontal ? position.x + start * width : position.x,
4806
5056
  y: this._isHorizontal ? position.y : position.y + start * height,
@@ -4850,6 +5100,7 @@
4850
5100
  this.state.end = end;
4851
5101
  if (startAttr !== this.state.start || endAttr !== this.state.end) {
4852
5102
  this.setAttributes({ start, end });
5103
+ this._updateStateCallback && this._updateStateCallback(start, end);
4853
5104
  }
4854
5105
  }
4855
5106
  }
@@ -6233,7 +6484,9 @@
6233
6484
  const innerGroupBounds = innerGroup.AABBBounds;
6234
6485
  const innerGroupWidth = innerGroupBounds.width();
6235
6486
  const innerGroupHeight = innerGroupBounds.height();
6236
- const itemGroupWidth = this._itemWidthByUser || innerGroupWidth + parsedPadding[1] + parsedPadding[3];
6487
+ const itemGroupWidth = vutils.isValid(this.attribute.item.width)
6488
+ ? this.attribute.item.width
6489
+ : innerGroupWidth + parsedPadding[1] + parsedPadding[3];
6237
6490
  const itemGroupHeight = this._itemHeightByUser || innerGroupHeight + parsedPadding[0] + parsedPadding[2];
6238
6491
  itemGroup.attribute.width = itemGroupWidth;
6239
6492
  itemGroup.attribute.height = itemGroupHeight;
@@ -6925,9 +7178,9 @@
6925
7178
  e.stopPropagation();
6926
7179
  this._currentHandler = e.target;
6927
7180
  this._prePos = this._isHorizontal ? e.clientX : e.clientY;
6928
- if (vrender.vglobal.env === 'browser') {
6929
- vrender.vglobal.addEventListener('pointermove', this._onHandlerPointerMove);
6930
- vrender.vglobal.addEventListener('pointerup', this._onHandlerPointerUp);
7181
+ if (vrender.global.env === 'browser') {
7182
+ vrender.global.addEventListener('pointermove', this._onHandlerPointerMove);
7183
+ vrender.global.addEventListener('pointerup', this._onHandlerPointerUp);
6931
7184
  }
6932
7185
  else {
6933
7186
  this._currentHandler.addEventListener('pointermove', this._onHandlerPointerMove);
@@ -6969,9 +7222,9 @@
6969
7222
  _onHandlerPointerUp = (e) => {
6970
7223
  e.preventDefault();
6971
7224
  this._currentHandler = null;
6972
- if (vrender.vglobal.env === 'browser') {
6973
- vrender.vglobal.removeEventListener('pointermove', this._onHandlerPointerMove);
6974
- vrender.vglobal.removeEventListener('pointerup', this._onHandlerPointerUp);
7225
+ if (vrender.global.env === 'browser') {
7226
+ vrender.global.removeEventListener('pointermove', this._onHandlerPointerMove);
7227
+ vrender.global.removeEventListener('pointerup', this._onHandlerPointerUp);
6975
7228
  }
6976
7229
  else {
6977
7230
  const currentTarget = e.target;
@@ -6983,9 +7236,9 @@
6983
7236
  _onTrackPointerdown = (e) => {
6984
7237
  e.stopPropagation();
6985
7238
  this._prePos = this._isHorizontal ? e.clientX : e.clientY;
6986
- if (vrender.vglobal.env === 'browser') {
6987
- vrender.vglobal.addEventListener('pointermove', this._onTrackPointerMove);
6988
- vrender.vglobal.addEventListener('pointerup', this._onTrackPointerUp);
7239
+ if (vrender.global.env === 'browser') {
7240
+ vrender.global.addEventListener('pointermove', this._onTrackPointerMove);
7241
+ vrender.global.addEventListener('pointerup', this._onTrackPointerUp);
6989
7242
  }
6990
7243
  else {
6991
7244
  this._track.addEventListener('pointermove', this._onTrackPointerMove);
@@ -7037,9 +7290,9 @@
7037
7290
  };
7038
7291
  _onTrackPointerUp = (e) => {
7039
7292
  e.preventDefault();
7040
- if (vrender.vglobal.env === 'browser') {
7041
- vrender.vglobal.removeEventListener('pointermove', this._onTrackPointerMove);
7042
- vrender.vglobal.removeEventListener('pointerup', this._onTrackPointerUp);
7293
+ if (vrender.global.env === 'browser') {
7294
+ vrender.global.removeEventListener('pointermove', this._onTrackPointerMove);
7295
+ vrender.global.removeEventListener('pointerup', this._onTrackPointerUp);
7043
7296
  }
7044
7297
  else {
7045
7298
  this._track.removeEventListener('pointermove', this._onTrackPointerMove);
@@ -8580,7 +8833,7 @@
8580
8833
  this.dispatchCustomEvent(exports.PlayerEventEnum.OnPlay);
8581
8834
  this._isReachEnd = false;
8582
8835
  this._tickTime = Date.now();
8583
- this._rafId = vrender.vglobal.getRequestAnimationFrame()(this._play.bind(this, true));
8836
+ this._rafId = vrender.global.getRequestAnimationFrame()(this._play.bind(this, true));
8584
8837
  };
8585
8838
  _play = (isFirstPlay) => {
8586
8839
  const now = Date.now();
@@ -8603,7 +8856,7 @@
8603
8856
  (this._direction === 'reverse' && this._dataIndex <= this._minIndex)) {
8604
8857
  this._isReachEnd = true;
8605
8858
  }
8606
- this._rafId = vrender.vglobal.getRequestAnimationFrame()(this._play.bind(this, false));
8859
+ this._rafId = vrender.global.getRequestAnimationFrame()(this._play.bind(this, false));
8607
8860
  };
8608
8861
  _updateDataIndex = (dataIndex) => {
8609
8862
  this._dataIndex = dataIndex;
@@ -8612,7 +8865,7 @@
8612
8865
  _playEnd = () => {
8613
8866
  this._isPlaying = false;
8614
8867
  this._controller.togglePlay();
8615
- vrender.vglobal.getCancelAnimationFrame()(this._rafId);
8868
+ vrender.global.getCancelAnimationFrame()(this._rafId);
8616
8869
  this._activeIndex = -1;
8617
8870
  this.dispatchCustomEvent(exports.PlayerEventEnum.OnEnd);
8618
8871
  };
@@ -8621,7 +8874,7 @@
8621
8874
  return;
8622
8875
  }
8623
8876
  this._isPlaying = false;
8624
- vrender.vglobal.getCancelAnimationFrame()(this._rafId);
8877
+ vrender.global.getCancelAnimationFrame()(this._rafId);
8625
8878
  this._controller.togglePlay();
8626
8879
  this.dispatchCustomEvent(exports.PlayerEventEnum.OnPause);
8627
8880
  };
@@ -8732,7 +8985,7 @@
8732
8985
  }
8733
8986
  this._startTime = Date.now() - this._elapsed;
8734
8987
  this.dispatchCustomEvent(exports.PlayerEventEnum.OnPlay);
8735
- this._rafId = vrender.vglobal.getRequestAnimationFrame()(this._play.bind(this));
8988
+ this._rafId = vrender.global.getRequestAnimationFrame()(this._play.bind(this));
8736
8989
  };
8737
8990
  _play = () => {
8738
8991
  this._elapsed = Date.now() - this._startTime;
@@ -8742,11 +8995,11 @@
8742
8995
  this._playEnd();
8743
8996
  return;
8744
8997
  }
8745
- this._rafId = vrender.vglobal.getRequestAnimationFrame()(this._play.bind(this));
8998
+ this._rafId = vrender.global.getRequestAnimationFrame()(this._play.bind(this));
8746
8999
  };
8747
9000
  _playEnd = () => {
8748
9001
  this._isPlaying = false;
8749
- vrender.vglobal.getCancelAnimationFrame()(this._rafId);
9002
+ vrender.global.getCancelAnimationFrame()(this._rafId);
8750
9003
  this._controller.togglePlay();
8751
9004
  this.dispatchCustomEvent(exports.PlayerEventEnum.OnEnd);
8752
9005
  };
@@ -8756,7 +9009,7 @@
8756
9009
  }
8757
9010
  this._isPlaying = false;
8758
9011
  this._elapsed = Date.now() - this._startTime;
8759
- vrender.vglobal.getCancelAnimationFrame()(this._rafId);
9012
+ vrender.global.getCancelAnimationFrame()(this._rafId);
8760
9013
  this._controller.togglePlay();
8761
9014
  this.dispatchCustomEvent(exports.PlayerEventEnum.OnPause);
8762
9015
  };
@@ -9501,7 +9754,7 @@
9501
9754
  }
9502
9755
  }
9503
9756
 
9504
- const version = "0.14.0-alpha.0";
9757
+ const version = "0.14.0-alpha.2";
9505
9758
 
9506
9759
  exports.AbstractComponent = AbstractComponent;
9507
9760
  exports.BasePlayer = BasePlayer;