@visactor/vrender-components 0.14.3-alpha.0 → 0.14.3

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 (45) hide show
  1. package/cjs/index.d.ts +1 -1
  2. package/cjs/index.js +1 -1
  3. package/cjs/index.js.map +1 -1
  4. package/cjs/label/arc.d.ts +7 -2
  5. package/cjs/label/arc.js +24 -25
  6. package/cjs/label/arc.js.map +1 -1
  7. package/cjs/label/base.d.ts +2 -2
  8. package/cjs/label/base.js +10 -10
  9. package/cjs/label/base.js.map +1 -1
  10. package/cjs/label/type.d.ts +1 -1
  11. package/cjs/label/type.js.map +1 -1
  12. package/cjs/legend/constant.d.ts +2 -1
  13. package/cjs/legend/constant.js +1 -1
  14. package/cjs/legend/constant.js.map +1 -1
  15. package/cjs/legend/discrete/discrete.js +15 -7
  16. package/cjs/legend/discrete/discrete.js.map +1 -1
  17. package/cjs/marker/base.d.ts +3 -0
  18. package/cjs/marker/base.js +25 -6
  19. package/cjs/marker/base.js.map +1 -1
  20. package/cjs/marker/type.d.ts +6 -0
  21. package/cjs/marker/type.js.map +1 -1
  22. package/dist/index.js +77 -24
  23. package/dist/index.min.js +1 -1
  24. package/es/index.d.ts +1 -1
  25. package/es/index.js +1 -1
  26. package/es/index.js.map +1 -1
  27. package/es/label/arc.d.ts +7 -2
  28. package/es/label/arc.js +7 -6
  29. package/es/label/arc.js.map +1 -1
  30. package/es/label/base.d.ts +2 -2
  31. package/es/label/base.js +11 -9
  32. package/es/label/base.js.map +1 -1
  33. package/es/label/type.d.ts +1 -1
  34. package/es/label/type.js.map +1 -1
  35. package/es/legend/constant.d.ts +2 -1
  36. package/es/legend/constant.js +1 -1
  37. package/es/legend/constant.js.map +1 -1
  38. package/es/legend/discrete/discrete.js +15 -7
  39. package/es/legend/discrete/discrete.js.map +1 -1
  40. package/es/marker/base.d.ts +3 -0
  41. package/es/marker/base.js +26 -5
  42. package/es/marker/base.js.map +1 -1
  43. package/es/marker/type.d.ts +6 -0
  44. package/es/marker/type.js.map +1 -1
  45. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1680,6 +1680,7 @@
1680
1680
  }
1681
1681
  }
1682
1682
  layout(data = []) {
1683
+ var _a;
1683
1684
  const { textStyle = {}, position, offset } = this.attribute;
1684
1685
  const labels = [];
1685
1686
  const textBoundsArray = [];
@@ -1706,13 +1707,10 @@
1706
1707
  const textData = data[i];
1707
1708
  const basedArc = arcs.find(arc => arc.labelText === textData.text);
1708
1709
  const labelAttribute = {
1709
- visible: basedArc.labelVisible,
1710
1710
  x: basedArc.labelPosition.x,
1711
1711
  y: basedArc.labelPosition.y,
1712
- angle: basedArc.angle,
1713
- 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)
1714
- ? [basedArc.pointA, basedArc.pointB, basedArc.pointC]
1715
- : undefined
1712
+ angle: (_a = this.attribute.angle) !== null && _a !== void 0 ? _a : basedArc.angle,
1713
+ labelLinePath: basedArc.labelLinePath
1716
1714
  };
1717
1715
  labels[i].setAttributes(labelAttribute);
1718
1716
  }
@@ -1848,12 +1846,12 @@
1848
1846
  const texts = [];
1849
1847
  labels.forEach((text, index) => {
1850
1848
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1851
- const labelLine = ((_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points)
1852
- ? vrender.createLine({
1849
+ const labelLine = ((_a = text.attribute) === null || _a === void 0 ? void 0 : _a.labelLinePath)
1850
+ ? vrender.createPath({
1853
1851
  visible: (_c = (_b = text.attribute) === null || _b === void 0 ? void 0 : _b.visible) !== null && _c !== void 0 ? _c : true,
1854
1852
  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,
1855
1853
  lineWidth: 1,
1856
- points: (_h = text.attribute) === null || _h === void 0 ? void 0 : _h.points
1854
+ path: (_h = text.attribute) === null || _h === void 0 ? void 0 : _h.labelLinePath
1857
1855
  })
1858
1856
  : undefined;
1859
1857
  const relatedGraphic = this._idToGraphic.get(text.attribute.id);
@@ -1894,9 +1892,9 @@
1894
1892
  const prevText = prevLabel.text;
1895
1893
  prevText.animate().to(text.attribute, duration, easing);
1896
1894
  if (prevLabel.labelLine) {
1897
- prevLabel.labelLine.animate().to(vutils.merge({}, prevLabel.labelLine.attribute, {
1898
- points: (_j = text.attribute) === null || _j === void 0 ? void 0 : _j.points
1899
- }), duration, easing);
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);
1900
1898
  }
1901
1899
  if (animationConfig.increaseEffect !== false &&
1902
1900
  prevText.attribute.text !== text.attribute.text &&
@@ -1909,7 +1907,7 @@
1909
1907
  else {
1910
1908
  prevLabel.text.setAttributes(text.attribute);
1911
1909
  if (prevLabel === null || prevLabel === void 0 ? void 0 : prevLabel.labelLine) {
1912
- prevLabel.labelLine.setAttributes({ points: (_k = text.attribute) === null || _k === void 0 ? void 0 : _k.points });
1910
+ prevLabel.labelLine.setAttributes({ path: (_k = text.attribute) === null || _k === void 0 ? void 0 : _k.labelLinePath });
1913
1911
  }
1914
1912
  }
1915
1913
  }
@@ -2437,7 +2435,6 @@
2437
2435
  const labelConfig = attribute;
2438
2436
  const spaceWidth = labelConfig.spaceWidth;
2439
2437
  arcs.forEach((arc) => {
2440
- var _a, _b;
2441
2438
  const { labelSize, radian } = arc;
2442
2439
  const innerRadius = this.computeRadius(innerRadiusRatio, attribute.width, attribute.height, 1);
2443
2440
  const outerRadius = this.computeRadius(outerRadiusRatio, attribute.width, attribute.height, 1);
@@ -2470,7 +2467,7 @@
2470
2467
  if (!vutils.isGreater(labelWidth, 0)) {
2471
2468
  arc.labelVisible = false;
2472
2469
  }
2473
- 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;
2470
+ arc.angle = arc.middleAngle;
2474
2471
  });
2475
2472
  return arcs;
2476
2473
  }
@@ -2528,13 +2525,16 @@
2528
2525
  }
2529
2526
  const width = center.x * 2;
2530
2527
  arcs.forEach(arc => {
2531
- var _a, _b;
2532
2528
  if (arc.labelVisible &&
2533
2529
  (vutils.isLess(arc.pointB.x, line2MinLength + spaceWidth) ||
2534
2530
  vutils.isGreater(arc.pointB.x, width - line2MinLength - spaceWidth))) {
2535
2531
  arc.labelVisible = false;
2536
2532
  }
2537
- 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;
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)}`;
2538
2538
  });
2539
2539
  return arcs;
2540
2540
  }
@@ -2547,6 +2547,7 @@
2547
2547
  const line2MinLength = attribute.line.line2MinLength;
2548
2548
  const labelLayoutAlign = (_e = attribute.layout) === null || _e === void 0 ? void 0 : _e.align;
2549
2549
  const spaceWidth = attribute.spaceWidth;
2550
+ this._computeAlign(arc, attribute);
2550
2551
  const { labelPosition, quadrant, pointB } = arc;
2551
2552
  if (!vutils.isValidNumber(pointB.x * pointB.y)) {
2552
2553
  arc.pointC = { x: NaN, y: NaN };
@@ -5725,6 +5726,27 @@
5725
5726
  })(exports.IMarkPointItemPosition || (exports.IMarkPointItemPosition = {}));
5726
5727
 
5727
5728
  class Marker extends AbstractComponent {
5729
+ _initContainer() {
5730
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
5731
+ 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 }));
5732
+ groupClip.name = 'marker-container';
5733
+ const group = vrender.createGroup({
5734
+ 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),
5735
+ 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)
5736
+ });
5737
+ groupClip.add(group);
5738
+ this._containerClip = groupClip;
5739
+ this.add(groupClip);
5740
+ this._container = group;
5741
+ }
5742
+ _updateContainer() {
5743
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
5744
+ 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 }));
5745
+ this._container.setAttributes({
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
+ }
5728
5750
  render() {
5729
5751
  var _a, _b;
5730
5752
  const markerVisible = (_a = this.attribute.visible) !== null && _a !== void 0 ? _a : true;
@@ -5734,14 +5756,12 @@
5734
5756
  this.setAttribute('childrenPickable', false);
5735
5757
  }
5736
5758
  if (markerVisible) {
5737
- if (!this._container) {
5738
- const group = vrender.createGroup({});
5739
- group.name = 'marker-container';
5740
- this.add(group);
5741
- this._container = group;
5742
- this.initMarker(group);
5759
+ if (!this._containerClip) {
5760
+ this._initContainer();
5761
+ this.initMarker(this._container);
5743
5762
  }
5744
5763
  else {
5764
+ this._updateContainer();
5745
5765
  this.updateMarker();
5746
5766
  }
5747
5767
  }
@@ -6502,6 +6522,7 @@
6502
6522
  LegendEvent["legendItemHover"] = "legendItemHover";
6503
6523
  LegendEvent["legendItemUnHover"] = "legendItemUnHover";
6504
6524
  LegendEvent["legendItemClick"] = "legendItemClick";
6525
+ LegendEvent["legendItemAttributeUpdate"] = "legendItemAttributeUpdate";
6505
6526
  })(exports.LegendEvent || (exports.LegendEvent = {}));
6506
6527
  exports.LEGEND_ELEMENT_NAME = void 0;
6507
6528
  (function (LEGEND_ELEMENT_NAME) {
@@ -6625,12 +6646,21 @@
6625
6646
  const target = e.target;
6626
6647
  if ((_a = target === null || target === void 0 ? void 0 : target.name) === null || _a === void 0 ? void 0 : _a.startsWith(exports.LEGEND_ELEMENT_NAME.item)) {
6627
6648
  const legendItem = target.delegate;
6649
+ let attributeUpdate = false;
6650
+ if (legendItem.hasState(exports.LegendStateValue.unSelectedHover) ||
6651
+ legendItem.hasState(exports.LegendStateValue.selectedHover)) {
6652
+ attributeUpdate = true;
6653
+ }
6628
6654
  legendItem.removeState(exports.LegendStateValue.unSelectedHover);
6629
6655
  legendItem.removeState(exports.LegendStateValue.selectedHover);
6630
6656
  legendItem
6631
6657
  .getChildren()[0]
6632
6658
  .getChildren()
6633
6659
  .forEach((child) => {
6660
+ if (!attributeUpdate &&
6661
+ (child.hasState(exports.LegendStateValue.unSelectedHover) || child.hasState(exports.LegendStateValue.selectedHover))) {
6662
+ attributeUpdate = true;
6663
+ }
6634
6664
  child.removeState(exports.LegendStateValue.unSelectedHover);
6635
6665
  child.removeState(exports.LegendStateValue.selectedHover);
6636
6666
  });
@@ -6638,6 +6668,9 @@
6638
6668
  if (focusButton) {
6639
6669
  focusButton.setAttribute('visible', false);
6640
6670
  }
6671
+ if (attributeUpdate) {
6672
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
6673
+ }
6641
6674
  this._dispatchEvent(exports.LegendEvent.legendItemUnHover, legendItem);
6642
6675
  }
6643
6676
  };
@@ -7066,18 +7099,32 @@
7066
7099
  return true;
7067
7100
  }
7068
7101
  _setLegendItemState(legendItem, stateName, keepCurrentStates = true) {
7102
+ let attributeUpdate = false;
7103
+ if (!legendItem.hasState(stateName)) {
7104
+ attributeUpdate = true;
7105
+ }
7069
7106
  legendItem.addState(stateName, keepCurrentStates);
7070
7107
  legendItem
7071
7108
  .getChildren()[0]
7072
7109
  .getChildren()
7073
- .forEach(child => {
7110
+ .forEach((child) => {
7074
7111
  if (child.name !== exports.LEGEND_ELEMENT_NAME.focus) {
7112
+ if (!attributeUpdate && !child.hasState(stateName)) {
7113
+ attributeUpdate = true;
7114
+ }
7075
7115
  child.addState(stateName, keepCurrentStates);
7076
7116
  }
7077
7117
  });
7118
+ if (attributeUpdate) {
7119
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7120
+ }
7078
7121
  }
7079
7122
  _removeLegendItemState(legendItem, stateNames) {
7123
+ let attributeUpdate = false;
7080
7124
  stateNames.forEach(name => {
7125
+ if (!attributeUpdate && legendItem.hasState(name)) {
7126
+ attributeUpdate = true;
7127
+ }
7081
7128
  legendItem.removeState(name);
7082
7129
  });
7083
7130
  legendItem
@@ -7086,10 +7133,16 @@
7086
7133
  .forEach(child => {
7087
7134
  if (child.name !== exports.LEGEND_ELEMENT_NAME.focus) {
7088
7135
  stateNames.forEach(name => {
7136
+ if (!attributeUpdate && child.hasState(name)) {
7137
+ attributeUpdate = true;
7138
+ }
7089
7139
  child.removeState(name);
7090
7140
  });
7091
7141
  }
7092
7142
  });
7143
+ if (attributeUpdate) {
7144
+ this._dispatchEvent(exports.LegendEvent.legendItemAttributeUpdate, legendItem);
7145
+ }
7093
7146
  }
7094
7147
  _getSelectedLegends() {
7095
7148
  var _a;
@@ -9963,7 +10016,7 @@
9963
10016
  }
9964
10017
  Tooltip.defaultAttributes = defaultAttributes;
9965
10018
 
9966
- const version = "0.14.3-alpha.0";
10019
+ const version = "0.14.3";
9967
10020
 
9968
10021
  exports.AbstractComponent = AbstractComponent;
9969
10022
  exports.ArcInfo = ArcInfo;