@visactor/vrender-components 0.16.3-alpha.0 → 0.16.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 (51) 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/base.d.ts +4 -1
  5. package/cjs/label/base.js +47 -27
  6. package/cjs/label/base.js.map +1 -1
  7. package/cjs/label/dataLabel.js +3 -2
  8. package/cjs/label/dataLabel.js.map +1 -1
  9. package/cjs/label/index.d.ts +1 -0
  10. package/cjs/label/index.js +1 -1
  11. package/cjs/label/index.js.map +1 -1
  12. package/cjs/label/line-data.d.ts +12 -0
  13. package/cjs/label/line-data.js +30 -0
  14. package/cjs/label/line-data.js.map +1 -0
  15. package/cjs/label/symbol.js +2 -42
  16. package/cjs/label/symbol.js.map +1 -1
  17. package/cjs/label/type.d.ts +8 -3
  18. package/cjs/label/type.js.map +1 -1
  19. package/cjs/label/util.d.ts +7 -1
  20. package/cjs/label/util.js +63 -1
  21. package/cjs/label/util.js.map +1 -1
  22. package/cjs/legend/base.js +1 -2
  23. package/cjs/legend/constant.js +2 -1
  24. package/cjs/marker/base.js +1 -1
  25. package/dist/index.js +307 -213
  26. package/dist/index.min.js +1 -1
  27. package/es/index.d.ts +1 -1
  28. package/es/index.js +1 -1
  29. package/es/index.js.map +1 -1
  30. package/es/label/base.d.ts +4 -1
  31. package/es/label/base.js +49 -28
  32. package/es/label/base.js.map +1 -1
  33. package/es/label/dataLabel.js +4 -1
  34. package/es/label/dataLabel.js.map +1 -1
  35. package/es/label/index.d.ts +1 -0
  36. package/es/label/index.js +2 -0
  37. package/es/label/index.js.map +1 -1
  38. package/es/label/line-data.d.ts +12 -0
  39. package/es/label/line-data.js +28 -0
  40. package/es/label/line-data.js.map +1 -0
  41. package/es/label/symbol.js +3 -41
  42. package/es/label/symbol.js.map +1 -1
  43. package/es/label/type.d.ts +8 -3
  44. package/es/label/type.js.map +1 -1
  45. package/es/label/util.d.ts +7 -1
  46. package/es/label/util.js +58 -0
  47. package/es/label/util.js.map +1 -1
  48. package/es/legend/base.js +1 -2
  49. package/es/legend/constant.js +2 -1
  50. package/es/marker/base.js +1 -1
  51. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -19921,7 +19921,11 @@
19921
19921
  }, {
19922
19922
  key: "containsPoint",
19923
19923
  value: function containsPoint(graphic, point, params) {
19924
- return !!this.pickItem(graphic, point, null, params);
19924
+ var _a;
19925
+ return !!(null === (_a = this.pickItem(graphic, point, null, null != params ? params : {
19926
+ pickContext: this.pickContext,
19927
+ pickerService: this
19928
+ })) || void 0 === _a ? void 0 : _a.graphic);
19925
19929
  }
19926
19930
  }, {
19927
19931
  key: "pickGroup",
@@ -21787,6 +21791,194 @@
21787
21791
  easing: 'linear'
21788
21792
  };
21789
21793
 
21794
+ function polarToCartesian(point) {
21795
+ if (!point.radius) {
21796
+ return { x: 0, y: 0 };
21797
+ }
21798
+ return {
21799
+ x: Math.cos(point.angle) * point.radius,
21800
+ y: Math.sin(point.angle) * point.radius
21801
+ };
21802
+ }
21803
+ function circlePoint(x0, y0, radius, radian) {
21804
+ const offset = polarToCartesian({
21805
+ radius,
21806
+ angle: radian
21807
+ });
21808
+ return {
21809
+ x: x0 + offset.x,
21810
+ y: y0 + offset.y
21811
+ };
21812
+ }
21813
+ function computeQuadrant(angle) {
21814
+ angle = normalizeAngle(angle);
21815
+ if (angle > 0 && angle <= Math.PI / 2) {
21816
+ return 2;
21817
+ }
21818
+ else if (angle > Math.PI / 2 && angle <= Math.PI) {
21819
+ return 3;
21820
+ }
21821
+ else if (angle > Math.PI && angle <= (3 * Math.PI) / 2) {
21822
+ return 4;
21823
+ }
21824
+ return 1;
21825
+ }
21826
+ function normalizeAngle(angle) {
21827
+ while (angle < 0) {
21828
+ angle += Math.PI * 2;
21829
+ }
21830
+ while (angle >= Math.PI * 2) {
21831
+ angle -= Math.PI * 2;
21832
+ }
21833
+ return angle;
21834
+ }
21835
+ function isQuadrantLeft(quadrant) {
21836
+ return quadrant === 3 || quadrant === 4;
21837
+ }
21838
+ function isQuadrantRight(quadrant) {
21839
+ return quadrant === 1 || quadrant === 2;
21840
+ }
21841
+ function lineCirclePoints(a, b, c, x0, y0, r) {
21842
+ if ((a === 0 && b === 0) || r <= 0) {
21843
+ return [];
21844
+ }
21845
+ if (a === 0) {
21846
+ const y1 = -c / b;
21847
+ const fy = (y1 - y0) ** 2;
21848
+ const fd = r ** 2 - fy;
21849
+ if (fd < 0) {
21850
+ return [];
21851
+ }
21852
+ else if (fd === 0) {
21853
+ return [{ x: x0, y: y1 }];
21854
+ }
21855
+ const x1 = Math.sqrt(fd) + x0;
21856
+ const x2 = -Math.sqrt(fd) + x0;
21857
+ return [
21858
+ { x: x1, y: y1 },
21859
+ { x: x2, y: y1 }
21860
+ ];
21861
+ }
21862
+ else if (b === 0) {
21863
+ const x1 = -c / a;
21864
+ const fx = (x1 - x0) ** 2;
21865
+ const fd = r ** 2 - fx;
21866
+ if (fd < 0) {
21867
+ return [];
21868
+ }
21869
+ else if (fd === 0) {
21870
+ return [{ x: x1, y: y0 }];
21871
+ }
21872
+ const y1 = Math.sqrt(fd) + y0;
21873
+ const y2 = -Math.sqrt(fd) + y0;
21874
+ return [
21875
+ { x: x1, y: y1 },
21876
+ { x: x1, y: y2 }
21877
+ ];
21878
+ }
21879
+ const fa = (b / a) ** 2 + 1;
21880
+ const fb = 2 * ((c / a + x0) * (b / a) - y0);
21881
+ const fc = (c / a + x0) ** 2 + y0 ** 2 - r ** 2;
21882
+ const fd = fb ** 2 - 4 * fa * fc;
21883
+ if (fd < 0) {
21884
+ return [];
21885
+ }
21886
+ const y1 = (-fb + Math.sqrt(fd)) / (2 * fa);
21887
+ const y2 = (-fb - Math.sqrt(fd)) / (2 * fa);
21888
+ const x1 = -(b * y1 + c) / a;
21889
+ const x2 = -(b * y2 + c) / a;
21890
+ if (fd === 0) {
21891
+ return [{ x: x1, y: y1 }];
21892
+ }
21893
+ return [
21894
+ { x: x1, y: y1 },
21895
+ { x: x2, y: y2 }
21896
+ ];
21897
+ }
21898
+ function connectLineRadian(radius, length) {
21899
+ if (length > radius * 2) {
21900
+ return NaN;
21901
+ }
21902
+ return Math.asin(length / 2 / radius) * 2;
21903
+ }
21904
+ function checkBoundsOverlap(boundsA, boundsB) {
21905
+ const { x1: ax1, y1: ay1, x2: ax2, y2: ay2 } = boundsA;
21906
+ const { x1: bx1, y1: by1, x2: bx2, y2: by2 } = boundsB;
21907
+ return !((ax1 <= bx1 && ax2 <= bx1) ||
21908
+ (ax1 >= bx2 && ax2 >= bx2) ||
21909
+ (ay1 <= by1 && ay2 <= by1) ||
21910
+ (ay1 >= by2 && ay2 >= by2));
21911
+ }
21912
+ const labelingPoint = (textBounds, graphicBounds, position = 'top', offset = 0) => {
21913
+ if (!textBounds) {
21914
+ return;
21915
+ }
21916
+ const { x1, y1, x2, y2 } = textBounds;
21917
+ const width = Math.abs(x2 - x1);
21918
+ const height = Math.abs(y2 - y1);
21919
+ const anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;
21920
+ const anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;
21921
+ let sx = 0;
21922
+ let sy = 0;
21923
+ let offsetX = 0;
21924
+ let offsetY = 0;
21925
+ if (graphicBounds) {
21926
+ offsetX = Math.abs(graphicBounds.x1 - graphicBounds.x2) / 2;
21927
+ offsetY = Math.abs(graphicBounds.y1 - graphicBounds.y2) / 2;
21928
+ }
21929
+ const angle = {
21930
+ 'top-right': -235,
21931
+ 'top-left': 235,
21932
+ 'bottom-right': 45,
21933
+ 'bottom-left': -45
21934
+ };
21935
+ switch (position) {
21936
+ case 'top':
21937
+ sy = -1;
21938
+ break;
21939
+ case 'bottom':
21940
+ sy = 1;
21941
+ break;
21942
+ case 'left':
21943
+ sx = -1;
21944
+ break;
21945
+ case 'right':
21946
+ sx = 1;
21947
+ break;
21948
+ case 'bottom-left':
21949
+ case 'bottom-right':
21950
+ case 'top-left':
21951
+ case 'top-right':
21952
+ sx = Math.sin(angle[position] * (Math.PI / 180));
21953
+ sy = Math.cos(angle[position] * (Math.PI / 180));
21954
+ break;
21955
+ case 'center':
21956
+ sx = 0;
21957
+ sy = 0;
21958
+ break;
21959
+ }
21960
+ const x = anchorX + sx * (offset + offsetX) + Math.sign(sx) * (width / 2);
21961
+ const y = anchorY + sy * (offset + offsetY) + Math.sign(sy) * (height / 2);
21962
+ return { x, y };
21963
+ };
21964
+ const getPointsOfLineArea = (graphic) => {
21965
+ if (!graphic || !graphic.attribute) {
21966
+ return [];
21967
+ }
21968
+ const { points, segments } = graphic.attribute;
21969
+ if (segments && segments.length) {
21970
+ const res = [];
21971
+ segments.forEach(seg => {
21972
+ const segPoints = seg.points;
21973
+ segPoints.forEach(point => {
21974
+ res.push(point);
21975
+ });
21976
+ });
21977
+ return res;
21978
+ }
21979
+ return points;
21980
+ };
21981
+
21790
21982
  class LabelBase extends AbstractComponent {
21791
21983
  setBitmap(bitmap) {
21792
21984
  this._bitmap = bitmap;
@@ -21846,15 +22038,17 @@
21846
22038
  var _a, _b, _c;
21847
22039
  if (((_a = e.detail) === null || _a === void 0 ? void 0 : _a.type) === AttributeUpdateType.STATE) {
21848
22040
  const currentStates = (_c = (_b = e.target) === null || _b === void 0 ? void 0 : _b.currentStates) !== null && _c !== void 0 ? _c : [];
21849
- const label = this._graphicToText.get(e.target);
21850
- if (label) {
21851
- if (label.text) {
21852
- label.text.useStates(currentStates);
21853
- }
21854
- if (label.labelLine) {
21855
- label.labelLine.useStates(currentStates);
22041
+ const labels = this._isCollectionBase ? [...this._graphicToText.values()] : [this._graphicToText.get(e.target)];
22042
+ labels.forEach(label => {
22043
+ if (label) {
22044
+ if (label.text) {
22045
+ label.text.useStates(currentStates);
22046
+ }
22047
+ if (label.labelLine) {
22048
+ label.labelLine.useStates(currentStates);
22049
+ }
21856
22050
  }
21857
- }
22051
+ });
21858
22052
  }
21859
22053
  };
21860
22054
  }
@@ -21866,7 +22060,7 @@
21866
22060
  }
21867
22061
  render() {
21868
22062
  this._prepare();
21869
- if (vutils.isNil(this._idToGraphic)) {
22063
+ if ((this._isCollectionBase && vutils.isNil(this._idToPoint)) || (!this._isCollectionBase && vutils.isNil(this._idToGraphic))) {
21870
22064
  return;
21871
22065
  }
21872
22066
  const { overlap, smartInvert, dataFilter, customLayoutFunc, customOverlapFunc } = this.attribute;
@@ -21876,13 +22070,13 @@
21876
22070
  }
21877
22071
  let labels;
21878
22072
  if (vutils.isFunction(customLayoutFunc)) {
21879
- labels = customLayoutFunc(data, (d) => this._idToGraphic.get(d.id));
22073
+ labels = customLayoutFunc(data, this.getRelatedGrphic, this._isCollectionBase ? (d) => this._idToPoint.get(d.id) : null);
21880
22074
  }
21881
22075
  else {
21882
22076
  labels = this._layout(data);
21883
22077
  }
21884
22078
  if (vutils.isFunction(customOverlapFunc)) {
21885
- labels = customOverlapFunc(labels, (d) => this._idToGraphic.get(d.id));
22079
+ labels = customOverlapFunc(labels, this.getRelatedGrphic, this._isCollectionBase ? (d) => this._idToPoint.get(d.id) : null);
21886
22080
  }
21887
22081
  else {
21888
22082
  if (overlap !== false) {
@@ -21937,7 +22131,7 @@
21937
22131
  return text;
21938
22132
  }
21939
22133
  _prepare() {
21940
- var _a;
22134
+ var _a, _b, _c, _d;
21941
22135
  const currentBaseMarks = [];
21942
22136
  let baseMarks;
21943
22137
  if (vutils.isFunction(this.attribute.getBaseMarks)) {
@@ -21952,7 +22146,9 @@
21952
22146
  }
21953
22147
  });
21954
22148
  (_a = this._idToGraphic) === null || _a === void 0 ? void 0 : _a.clear();
22149
+ (_b = this._idToPoint) === null || _b === void 0 ? void 0 : _b.clear();
21955
22150
  this._baseMarks = currentBaseMarks;
22151
+ this._isCollectionBase = ((_c = currentBaseMarks === null || currentBaseMarks === void 0 ? void 0 : currentBaseMarks[0]) === null || _c === void 0 ? void 0 : _c.type) === 'line' || ((_d = currentBaseMarks === null || currentBaseMarks === void 0 ? void 0 : currentBaseMarks[0]) === null || _d === void 0 ? void 0 : _d.type) === 'area';
21956
22152
  if (!currentBaseMarks || currentBaseMarks.length === 0) {
21957
22153
  return;
21958
22154
  }
@@ -21960,30 +22156,59 @@
21960
22156
  if (!data || data.length === 0) {
21961
22157
  return;
21962
22158
  }
21963
- if (!this._idToGraphic) {
21964
- this._idToGraphic = new Map();
22159
+ if (this._isCollectionBase) {
22160
+ if (!this._idToPoint) {
22161
+ this._idToPoint = new Map();
22162
+ }
22163
+ const baseMark = currentBaseMarks[0];
22164
+ const points = getPointsOfLineArea(baseMark);
22165
+ if (points === null || points === void 0 ? void 0 : points.length) {
22166
+ for (let i = 0; i < points.length; i++) {
22167
+ const textData = data[i];
22168
+ if (textData && points[i]) {
22169
+ if (!vutils.isValid(textData.id)) {
22170
+ textData.id = `vrender-component-${this.name}-${i}`;
22171
+ }
22172
+ this._idToPoint.set(textData.id, points[i]);
22173
+ }
22174
+ }
22175
+ }
21965
22176
  }
21966
- for (let i = 0; i < currentBaseMarks.length; i++) {
21967
- const textData = data[i];
21968
- const baseMark = currentBaseMarks[i];
21969
- if (textData && baseMark) {
21970
- if (!vutils.isValid(textData.id)) {
21971
- textData.id = `vrender-component-${this.name}-${i}`;
22177
+ else {
22178
+ if (!this._idToGraphic) {
22179
+ this._idToGraphic = new Map();
22180
+ }
22181
+ for (let i = 0; i < currentBaseMarks.length; i++) {
22182
+ const textData = data[i];
22183
+ const baseMark = currentBaseMarks[i];
22184
+ if (textData && baseMark) {
22185
+ if (!vutils.isValid(textData.id)) {
22186
+ textData.id = `vrender-component-${this.name}-${i}`;
22187
+ }
22188
+ this._idToGraphic.set(textData.id, baseMark);
21972
22189
  }
21973
- this._idToGraphic.set(textData.id, baseMark);
21974
22190
  }
21975
22191
  }
21976
22192
  }
22193
+ getRelatedGrphic(item) {
22194
+ return this._isCollectionBase ? this._baseMarks[0] : this._idToGraphic.get(item.id);
22195
+ }
21977
22196
  _layout(data = []) {
21978
22197
  const { textStyle = {}, position, offset } = this.attribute;
21979
22198
  const labels = [];
21980
22199
  for (let i = 0; i < data.length; i++) {
21981
22200
  const textData = data[i];
21982
- const baseMark = this._idToGraphic.get(textData.id);
21983
- const labelAttribute = Object.assign(Object.assign({ fill: baseMark.attribute.fill }, textStyle), textData);
22201
+ const baseMark = this.getRelatedGrphic(textData);
22202
+ const labelAttribute = Object.assign(Object.assign({ fill: this._isCollectionBase
22203
+ ? vutils.isArray(baseMark.attribute.stroke)
22204
+ ? baseMark.attribute.stroke.find(entry => !!entry && entry !== true)
22205
+ : baseMark.attribute.stroke
22206
+ : baseMark.attribute.fill }, textStyle), textData);
21984
22207
  const text = this._createLabelText(labelAttribute);
21985
22208
  const textBounds = this.getGraphicBounds(text);
21986
- const graphicBounds = this.getGraphicBounds(baseMark, { x: textData.x, y: textData.y });
22209
+ const graphicBounds = this._isCollectionBase
22210
+ ? this.getGraphicBounds(null, this._idToPoint.get(textData.id))
22211
+ : this.getGraphicBounds(baseMark, { x: textData.x, y: textData.y });
21987
22212
  const textLocation = this.labeling(textBounds, graphicBounds, vutils.isFunction(position) ? position(textData) : position, offset);
21988
22213
  if (textLocation) {
21989
22214
  labelAttribute.x = textLocation.x;
@@ -22035,7 +22260,7 @@
22035
22260
  continue;
22036
22261
  }
22037
22262
  const text = labels[i];
22038
- const baseMark = this._idToGraphic.get(text.attribute.id);
22263
+ const baseMark = this.getRelatedGrphic(text.attribute);
22039
22264
  text.update();
22040
22265
  if (!vutils.isRectIntersect(baseMark.AABBBounds, { x1: 0, x2: bmpTool.width, y1: 0, y2: bmpTool.height }, true)) {
22041
22266
  continue;
@@ -22054,7 +22279,9 @@
22054
22279
  }
22055
22280
  let hasPlace = false;
22056
22281
  for (let j = 0; j < strategy.length; j++) {
22057
- hasPlace = place(bmpTool, bitmap, strategy[j], this.attribute, text, this.getGraphicBounds(baseMark, labels[i]), this.labeling);
22282
+ hasPlace = place(bmpTool, bitmap, strategy[j], this.attribute, text, this._isCollectionBase
22283
+ ? this.getGraphicBounds(null, this._idToPoint.get(labels[i].attribute.id))
22284
+ : this.getGraphicBounds(baseMark, labels[i].attribute), this.labeling);
22058
22285
  if (hasPlace !== false) {
22059
22286
  text.setAttributes({ x: hasPlace.x, y: hasPlace.y });
22060
22287
  result.push(text);
@@ -22121,11 +22348,13 @@
22121
22348
  labels.forEach((text, index) => {
22122
22349
  var _a, _b, _c, _d, _e, _f, _g;
22123
22350
  const labelLine = this._labelLine(text);
22124
- const relatedGraphic = this._idToGraphic.get(text.attribute.id);
22125
- const state = (prevTextMap === null || prevTextMap === void 0 ? void 0 : prevTextMap.get(relatedGraphic)) ? 'update' : 'enter';
22351
+ const relatedGraphic = this.getRelatedGrphic(text.attribute);
22352
+ const textId = text.attribute.id;
22353
+ const textKey = this._isCollectionBase ? textId : relatedGraphic;
22354
+ const state = (prevTextMap === null || prevTextMap === void 0 ? void 0 : prevTextMap.get(textKey)) ? 'update' : 'enter';
22126
22355
  if (state === 'enter') {
22127
22356
  texts.push(text);
22128
- currentTextMap.set(relatedGraphic, labelLine ? { text, labelLine } : { text });
22357
+ currentTextMap.set(textKey, labelLine ? { text, labelLine } : { text });
22129
22358
  if (relatedGraphic) {
22130
22359
  const { from, to } = getAnimationAttributes(text.attribute, 'fadeIn');
22131
22360
  this.add(text);
@@ -22134,7 +22363,7 @@
22134
22363
  this.add(labelLine);
22135
22364
  }
22136
22365
  this._syncStateWithRelatedGraphic(relatedGraphic);
22137
- relatedGraphic.once('animate-bind', () => {
22366
+ relatedGraphic.once('animate-bind', a => {
22138
22367
  text.setAttributes(from);
22139
22368
  const listener = this._afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, {
22140
22369
  mode,
@@ -22148,9 +22377,9 @@
22148
22377
  }
22149
22378
  }
22150
22379
  else if (state === 'update') {
22151
- const prevLabel = prevTextMap.get(relatedGraphic);
22152
- prevTextMap.delete(relatedGraphic);
22153
- currentTextMap.set(relatedGraphic, prevLabel);
22380
+ const prevLabel = prevTextMap.get(textKey);
22381
+ prevTextMap.delete(textKey);
22382
+ currentTextMap.set(textKey, prevLabel);
22154
22383
  const prevText = prevLabel.text;
22155
22384
  prevText.animate().to(text.attribute, duration, easing);
22156
22385
  if (prevLabel.labelLine) {
@@ -22185,10 +22414,11 @@
22185
22414
  labels.forEach(text => {
22186
22415
  var _a;
22187
22416
  const labelLine = this._labelLine(text);
22188
- const relatedGraphic = this._idToGraphic.get(text.attribute.id);
22417
+ const relatedGraphic = this.getRelatedGrphic(text.attribute);
22189
22418
  const state = (prevTextMap === null || prevTextMap === void 0 ? void 0 : prevTextMap.get(relatedGraphic)) ? 'update' : 'enter';
22419
+ const textKey = this._isCollectionBase ? text.attribute.id : relatedGraphic;
22190
22420
  if (state === 'enter') {
22191
- currentTextMap.set(relatedGraphic, labelLine ? { text, labelLine } : { text });
22421
+ currentTextMap.set(textKey, labelLine ? { text, labelLine } : { text });
22192
22422
  this.add(text);
22193
22423
  if (labelLine) {
22194
22424
  this.add(labelLine);
@@ -22196,9 +22426,9 @@
22196
22426
  this._syncStateWithRelatedGraphic(relatedGraphic);
22197
22427
  }
22198
22428
  else if (state === 'update') {
22199
- const prevLabel = prevTextMap.get(relatedGraphic);
22200
- prevTextMap.delete(relatedGraphic);
22201
- currentTextMap.set(relatedGraphic, prevLabel);
22429
+ const prevLabel = prevTextMap.get(textKey);
22430
+ prevTextMap.delete(textKey);
22431
+ currentTextMap.set(textKey, prevLabel);
22202
22432
  prevLabel.text.setAttributes(text.attribute);
22203
22433
  if (prevLabel === null || prevLabel === void 0 ? void 0 : prevLabel.labelLine) {
22204
22434
  prevLabel.labelLine.setAttributes({ points: (_a = text.attribute) === null || _a === void 0 ? void 0 : _a.points });
@@ -22220,7 +22450,7 @@
22220
22450
  }
22221
22451
  _afterRelatedGraphicAttributeUpdate(text, texts, index, relatedGraphic, { mode, duration, easing, to, delay }) {
22222
22452
  const listener = (event) => {
22223
- var _a;
22453
+ var _a, _b;
22224
22454
  const { detail } = event;
22225
22455
  if (!detail) {
22226
22456
  return {};
@@ -22259,7 +22489,15 @@
22259
22489
  break;
22260
22490
  case 'same-time':
22261
22491
  default:
22262
- if (detail.animationState.isFirstFrameOfStep) {
22492
+ if (this._isCollectionBase) {
22493
+ const point = this._idToPoint.get(text.attribute.id);
22494
+ if (point &&
22495
+ (!text.animates || !text.animates.has('label-animate')) &&
22496
+ this._baseMarks[0].containsPoint(point.x, point.y, IContainPointMode.LOCAL, (_b = this.stage) === null || _b === void 0 ? void 0 : _b.pickerService)) {
22497
+ text.animate({ onEnd }).wait(delay).to(to, duration, easing);
22498
+ }
22499
+ }
22500
+ else if (detail.animationState.isFirstFrameOfStep) {
22263
22501
  text.animate({ onEnd }).wait(delay).to(to, duration, easing);
22264
22502
  }
22265
22503
  break;
@@ -22284,7 +22522,7 @@
22284
22522
  if (!label) {
22285
22523
  continue;
22286
22524
  }
22287
- const baseMark = this._idToGraphic.get(label.attribute.id);
22525
+ const baseMark = this.getRelatedGrphic(label.attribute);
22288
22526
  const backgroundColor = baseMark.attribute.fill;
22289
22527
  const foregroundColor = label.attribute.fill;
22290
22528
  const baseColor = backgroundColor;
@@ -22361,56 +22599,7 @@
22361
22599
  this.name = 'symbol-label';
22362
22600
  }
22363
22601
  labeling(textBounds, graphicBounds, position = 'top', offset = 0) {
22364
- if (!textBounds) {
22365
- return;
22366
- }
22367
- const { x1, y1, x2, y2 } = textBounds;
22368
- const width = Math.abs(x2 - x1);
22369
- const height = Math.abs(y2 - y1);
22370
- const anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;
22371
- const anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;
22372
- let sx = 0;
22373
- let sy = 0;
22374
- let offsetX = 0;
22375
- let offsetY = 0;
22376
- if (graphicBounds) {
22377
- offsetX = Math.abs(graphicBounds.x1 - graphicBounds.x2) / 2;
22378
- offsetY = Math.abs(graphicBounds.y1 - graphicBounds.y2) / 2;
22379
- }
22380
- const angle = {
22381
- 'top-right': -235,
22382
- 'top-left': 235,
22383
- 'bottom-right': 45,
22384
- 'bottom-left': -45
22385
- };
22386
- switch (position) {
22387
- case 'top':
22388
- sy = -1;
22389
- break;
22390
- case 'bottom':
22391
- sy = 1;
22392
- break;
22393
- case 'left':
22394
- sx = -1;
22395
- break;
22396
- case 'right':
22397
- sx = 1;
22398
- break;
22399
- case 'bottom-left':
22400
- case 'bottom-right':
22401
- case 'top-left':
22402
- case 'top-right':
22403
- sx = Math.sin(angle[position] * (Math.PI / 180));
22404
- sy = Math.cos(angle[position] * (Math.PI / 180));
22405
- break;
22406
- case 'center':
22407
- sx = 0;
22408
- sy = 0;
22409
- break;
22410
- }
22411
- const x = anchorX + sx * (offset + offsetX) + Math.sign(sx) * (width / 2);
22412
- const y = anchorY + sy * (offset + offsetY) + Math.sign(sy) * (height / 2);
22413
- return { x, y };
22602
+ return labelingPoint(textBounds, graphicBounds, position, offset);
22414
22603
  }
22415
22604
  }
22416
22605
  SymbolLabel.defaultAttributes = {
@@ -22549,125 +22738,6 @@
22549
22738
  pickable: false
22550
22739
  };
22551
22740
 
22552
- function polarToCartesian(point) {
22553
- if (!point.radius) {
22554
- return { x: 0, y: 0 };
22555
- }
22556
- return {
22557
- x: Math.cos(point.angle) * point.radius,
22558
- y: Math.sin(point.angle) * point.radius
22559
- };
22560
- }
22561
- function circlePoint(x0, y0, radius, radian) {
22562
- const offset = polarToCartesian({
22563
- radius,
22564
- angle: radian
22565
- });
22566
- return {
22567
- x: x0 + offset.x,
22568
- y: y0 + offset.y
22569
- };
22570
- }
22571
- function computeQuadrant(angle) {
22572
- angle = normalizeAngle(angle);
22573
- if (angle > 0 && angle <= Math.PI / 2) {
22574
- return 2;
22575
- }
22576
- else if (angle > Math.PI / 2 && angle <= Math.PI) {
22577
- return 3;
22578
- }
22579
- else if (angle > Math.PI && angle <= (3 * Math.PI) / 2) {
22580
- return 4;
22581
- }
22582
- return 1;
22583
- }
22584
- function normalizeAngle(angle) {
22585
- while (angle < 0) {
22586
- angle += Math.PI * 2;
22587
- }
22588
- while (angle >= Math.PI * 2) {
22589
- angle -= Math.PI * 2;
22590
- }
22591
- return angle;
22592
- }
22593
- function isQuadrantLeft(quadrant) {
22594
- return quadrant === 3 || quadrant === 4;
22595
- }
22596
- function isQuadrantRight(quadrant) {
22597
- return quadrant === 1 || quadrant === 2;
22598
- }
22599
- function lineCirclePoints(a, b, c, x0, y0, r) {
22600
- if ((a === 0 && b === 0) || r <= 0) {
22601
- return [];
22602
- }
22603
- if (a === 0) {
22604
- const y1 = -c / b;
22605
- const fy = (y1 - y0) ** 2;
22606
- const fd = r ** 2 - fy;
22607
- if (fd < 0) {
22608
- return [];
22609
- }
22610
- else if (fd === 0) {
22611
- return [{ x: x0, y: y1 }];
22612
- }
22613
- const x1 = Math.sqrt(fd) + x0;
22614
- const x2 = -Math.sqrt(fd) + x0;
22615
- return [
22616
- { x: x1, y: y1 },
22617
- { x: x2, y: y1 }
22618
- ];
22619
- }
22620
- else if (b === 0) {
22621
- const x1 = -c / a;
22622
- const fx = (x1 - x0) ** 2;
22623
- const fd = r ** 2 - fx;
22624
- if (fd < 0) {
22625
- return [];
22626
- }
22627
- else if (fd === 0) {
22628
- return [{ x: x1, y: y0 }];
22629
- }
22630
- const y1 = Math.sqrt(fd) + y0;
22631
- const y2 = -Math.sqrt(fd) + y0;
22632
- return [
22633
- { x: x1, y: y1 },
22634
- { x: x1, y: y2 }
22635
- ];
22636
- }
22637
- const fa = (b / a) ** 2 + 1;
22638
- const fb = 2 * ((c / a + x0) * (b / a) - y0);
22639
- const fc = (c / a + x0) ** 2 + y0 ** 2 - r ** 2;
22640
- const fd = fb ** 2 - 4 * fa * fc;
22641
- if (fd < 0) {
22642
- return [];
22643
- }
22644
- const y1 = (-fb + Math.sqrt(fd)) / (2 * fa);
22645
- const y2 = (-fb - Math.sqrt(fd)) / (2 * fa);
22646
- const x1 = -(b * y1 + c) / a;
22647
- const x2 = -(b * y2 + c) / a;
22648
- if (fd === 0) {
22649
- return [{ x: x1, y: y1 }];
22650
- }
22651
- return [
22652
- { x: x1, y: y1 },
22653
- { x: x2, y: y2 }
22654
- ];
22655
- }
22656
- function connectLineRadian(radius, length) {
22657
- if (length > radius * 2) {
22658
- return NaN;
22659
- }
22660
- return Math.asin(length / 2 / radius) * 2;
22661
- }
22662
- function checkBoundsOverlap(boundsA, boundsB) {
22663
- const { x1: ax1, y1: ay1, x2: ax2, y2: ay2 } = boundsA;
22664
- const { x1: bx1, y1: by1, x2: bx2, y2: by2 } = boundsB;
22665
- return !((ax1 <= bx1 && ax2 <= bx1) ||
22666
- (ax1 >= bx2 && ax2 >= bx2) ||
22667
- (ay1 <= by1 && ay2 <= by1) ||
22668
- (ay1 >= by2 && ay2 >= by2));
22669
- }
22670
-
22671
22741
  class ArcInfo {
22672
22742
  constructor(refDatum, center, outerCenter, quadrant, radian, middleAngle, innerRadius, outerRadius, circleCenter) {
22673
22743
  this.refDatum = refDatum;
@@ -23392,10 +23462,33 @@
23392
23462
  pickable: false
23393
23463
  };
23394
23464
 
23465
+ class LineDataLabel extends LabelBase {
23466
+ constructor(attributes) {
23467
+ super(vutils.merge({}, LineDataLabel.defaultAttributes, attributes));
23468
+ this.name = 'line-data-label';
23469
+ }
23470
+ labeling(textBounds, graphicBounds, position = 'top', offset = 0) {
23471
+ return labelingPoint(textBounds, graphicBounds, position, offset);
23472
+ }
23473
+ }
23474
+ LineDataLabel.defaultAttributes = {
23475
+ textStyle: {
23476
+ fontSize: 12,
23477
+ fill: '#000',
23478
+ textAlign: 'center',
23479
+ textBaseline: 'middle',
23480
+ boundsPadding: [-1, 0, -1, 0]
23481
+ },
23482
+ position: 'top',
23483
+ offset: 5,
23484
+ pickable: false
23485
+ };
23486
+
23395
23487
  const labelComponentMap = {
23396
23488
  rect: RectLabel,
23397
23489
  symbol: SymbolLabel,
23398
- arc: ArcLabel
23490
+ arc: ArcLabel,
23491
+ 'line-data': LineDataLabel
23399
23492
  };
23400
23493
  class DataLabel extends AbstractComponent {
23401
23494
  constructor(attributes) {
@@ -30974,7 +31067,7 @@
30974
31067
  }
30975
31068
  };
30976
31069
 
30977
- const version = "0.16.3-alpha.0";
31070
+ const version = "0.16.3";
30978
31071
 
30979
31072
  exports.AbstractComponent = AbstractComponent;
30980
31073
  exports.ArcInfo = ArcInfo;
@@ -31008,6 +31101,7 @@
31008
31101
  exports.LineAxis = LineAxis;
31009
31102
  exports.LineAxisGrid = LineAxisGrid;
31010
31103
  exports.LineCrosshair = LineCrosshair;
31104
+ exports.LineDataLabel = LineDataLabel;
31011
31105
  exports.LineLabel = LineLabel;
31012
31106
  exports.LinkPath = LinkPath;
31013
31107
  exports.MarkArea = MarkArea;