@visactor/vchart 1.3.0 → 1.3.1-test.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +23 -814
  3. package/build/index.min.js +1 -1
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/chart/area/area.js +1 -1
  6. package/cjs/chart/area/area.js.map +1 -1
  7. package/cjs/chart/bar/bar-3d.js +1 -1
  8. package/cjs/chart/bar/bar-3d.js.map +1 -1
  9. package/cjs/chart/bar/bar.js +1 -1
  10. package/cjs/chart/bar/bar.js.map +1 -1
  11. package/cjs/chart/base-chart.js.map +1 -1
  12. package/cjs/chart/histogram/histogram-3d.js +1 -1
  13. package/cjs/chart/histogram/histogram-3d.js.map +1 -1
  14. package/cjs/chart/histogram/histogram.js +1 -1
  15. package/cjs/chart/histogram/histogram.js.map +1 -1
  16. package/cjs/chart/interface/chart.d.ts +1 -1
  17. package/cjs/chart/interface/chart.js.map +1 -1
  18. package/cjs/chart/map/map.js +1 -1
  19. package/cjs/chart/map/map.js.map +1 -1
  20. package/cjs/chart/pie/pie-3d.js +1 -1
  21. package/cjs/chart/pie/pie-3d.js.map +1 -1
  22. package/cjs/chart/pie/pie.js +1 -1
  23. package/cjs/chart/pie/pie.js.map +1 -1
  24. package/cjs/chart/radar/radar.js +1 -1
  25. package/cjs/chart/radar/radar.js.map +1 -1
  26. package/cjs/chart/rose/rose.js +1 -1
  27. package/cjs/chart/rose/rose.js.map +1 -1
  28. package/cjs/chart/scatter/scatter.js +1 -1
  29. package/cjs/chart/scatter/scatter.js.map +1 -1
  30. package/cjs/chart/sequence/sequence.js +1 -1
  31. package/cjs/chart/sequence/sequence.js.map +1 -1
  32. package/cjs/component/index.js +2 -1
  33. package/cjs/component/legend/discrete/legend.js +9 -1
  34. package/cjs/component/legend/discrete/legend.js.map +1 -1
  35. package/cjs/component/tooltip/interface/common.d.ts +1 -1
  36. package/cjs/component/tooltip/interface/common.js.map +1 -1
  37. package/cjs/constant/polar.js +1 -2
  38. package/cjs/core/factory.js +2 -1
  39. package/cjs/core/index.js +1 -1
  40. package/cjs/core/index.js.map +1 -1
  41. package/cjs/core/vchart.js +1 -2
  42. package/cjs/data/initialize.d.ts +1 -1
  43. package/cjs/data/initialize.js +1 -1
  44. package/cjs/data/initialize.js.map +1 -1
  45. package/cjs/event/events/dimension/base.d.ts +1 -1
  46. package/cjs/event/events/dimension/base.js +1 -1
  47. package/cjs/event/events/dimension/base.js.map +1 -1
  48. package/cjs/layout/base-layout.d.ts +1 -1
  49. package/cjs/layout/base-layout.js.map +1 -1
  50. package/cjs/layout/grid-layout/grid-layout.d.ts +1 -1
  51. package/cjs/layout/grid-layout/grid-layout.js.map +1 -1
  52. package/cjs/layout/interface.d.ts +1 -1
  53. package/cjs/layout/interface.js.map +1 -1
  54. package/cjs/layout/layout3d/index.d.ts +1 -1
  55. package/cjs/layout/layout3d/index.js.map +1 -1
  56. package/cjs/mark/arc-3d.js +1 -1
  57. package/cjs/mark/arc.js +1 -1
  58. package/cjs/mark/area.js +1 -1
  59. package/cjs/mark/box-plot.js +1 -1
  60. package/cjs/mark/cell.js +1 -1
  61. package/cjs/mark/image.d.ts +1 -1
  62. package/cjs/mark/image.js.map +1 -1
  63. package/cjs/model/base-model.js +1 -1
  64. package/cjs/model/interface.js +1 -1
  65. package/cjs/model/layout-item.js +1 -1
  66. package/cjs/model/model-state-manager.js +1 -1
  67. package/cjs/model/tooltip-helper.js +1 -1
  68. package/cjs/plugin/components/axis-sync-plugin/axis-sync.js +1 -1
  69. package/cjs/plugin/components/axis-sync-plugin/axis-sync.js.map +1 -1
  70. package/cjs/series/mixin/line-mixin.d.ts +2 -2
  71. package/cjs/series/mixin/line-mixin.js +14 -12
  72. package/cjs/series/mixin/line-mixin.js.map +1 -1
  73. package/cjs/series/pie/pie.js +2 -8
  74. package/cjs/series/pie/pie.js.map +1 -1
  75. package/cjs/series/util/utils.d.ts +1 -1
  76. package/cjs/series/util/utils.js.map +1 -1
  77. package/cjs/typings/spec/common.d.ts +1 -1
  78. package/cjs/typings/spec/common.js.map +1 -1
  79. package/cjs/util/image.d.ts +1 -1
  80. package/cjs/util/image.js.map +1 -1
  81. package/esm/chart/area/area.js +1 -1
  82. package/esm/chart/area/area.js.map +1 -1
  83. package/esm/chart/bar/bar-3d.js +1 -1
  84. package/esm/chart/bar/bar-3d.js.map +1 -1
  85. package/esm/chart/bar/bar.js +1 -1
  86. package/esm/chart/bar/bar.js.map +1 -1
  87. package/esm/chart/base-chart.js.map +1 -1
  88. package/esm/chart/histogram/histogram-3d.js +1 -1
  89. package/esm/chart/histogram/histogram-3d.js.map +1 -1
  90. package/esm/chart/histogram/histogram.js +1 -1
  91. package/esm/chart/histogram/histogram.js.map +1 -1
  92. package/esm/chart/interface/chart.d.ts +1 -1
  93. package/esm/chart/interface/chart.js.map +1 -1
  94. package/esm/chart/map/map.js +1 -1
  95. package/esm/chart/map/map.js.map +1 -1
  96. package/esm/chart/pie/pie-3d.js +1 -1
  97. package/esm/chart/pie/pie-3d.js.map +1 -1
  98. package/esm/chart/pie/pie.js +1 -1
  99. package/esm/chart/pie/pie.js.map +1 -1
  100. package/esm/chart/radar/radar.js +1 -1
  101. package/esm/chart/radar/radar.js.map +1 -1
  102. package/esm/chart/rose/rose.js +1 -1
  103. package/esm/chart/rose/rose.js.map +1 -1
  104. package/esm/chart/scatter/scatter.js +1 -1
  105. package/esm/chart/scatter/scatter.js.map +1 -1
  106. package/esm/chart/sequence/sequence.js +2 -2
  107. package/esm/chart/sequence/sequence.js.map +1 -1
  108. package/esm/component/index.js +2 -1
  109. package/esm/component/legend/discrete/legend.js +9 -1
  110. package/esm/component/legend/discrete/legend.js.map +1 -1
  111. package/esm/component/tooltip/interface/common.d.ts +1 -1
  112. package/esm/component/tooltip/interface/common.js.map +1 -1
  113. package/esm/constant/polar.js +1 -2
  114. package/esm/core/factory.js +2 -1
  115. package/esm/core/index.js +1 -1
  116. package/esm/core/index.js.map +1 -1
  117. package/esm/core/vchart.js +1 -2
  118. package/esm/data/initialize.d.ts +1 -1
  119. package/esm/data/initialize.js +1 -1
  120. package/esm/data/initialize.js.map +1 -1
  121. package/esm/event/events/dimension/base.d.ts +1 -1
  122. package/esm/event/events/dimension/base.js +1 -1
  123. package/esm/event/events/dimension/base.js.map +1 -1
  124. package/esm/layout/base-layout.d.ts +1 -1
  125. package/esm/layout/base-layout.js.map +1 -1
  126. package/esm/layout/grid-layout/grid-layout.d.ts +1 -1
  127. package/esm/layout/grid-layout/grid-layout.js.map +1 -1
  128. package/esm/layout/interface.d.ts +1 -1
  129. package/esm/layout/interface.js.map +1 -1
  130. package/esm/layout/layout3d/index.d.ts +1 -1
  131. package/esm/layout/layout3d/index.js.map +1 -1
  132. package/esm/mark/arc-3d.js +1 -1
  133. package/esm/mark/arc.js +1 -1
  134. package/esm/mark/area.js +1 -1
  135. package/esm/mark/box-plot.js +1 -1
  136. package/esm/mark/cell.js +1 -1
  137. package/esm/mark/image.d.ts +1 -1
  138. package/esm/mark/image.js.map +1 -1
  139. package/esm/model/base-model.js +1 -1
  140. package/esm/model/interface.js +1 -1
  141. package/esm/model/layout-item.js +1 -1
  142. package/esm/model/model-state-manager.js +1 -1
  143. package/esm/model/tooltip-helper.js +1 -1
  144. package/esm/plugin/components/axis-sync-plugin/axis-sync.js +1 -1
  145. package/esm/plugin/components/axis-sync-plugin/axis-sync.js.map +1 -1
  146. package/esm/series/mixin/line-mixin.d.ts +2 -2
  147. package/esm/series/mixin/line-mixin.js +13 -13
  148. package/esm/series/mixin/line-mixin.js.map +1 -1
  149. package/esm/series/pie/pie.js +2 -10
  150. package/esm/series/pie/pie.js.map +1 -1
  151. package/esm/series/util/utils.d.ts +1 -1
  152. package/esm/series/util/utils.js.map +1 -1
  153. package/esm/typings/spec/common.d.ts +1 -1
  154. package/esm/typings/spec/common.js.map +1 -1
  155. package/esm/util/image.d.ts +1 -1
  156. package/esm/util/image.js.map +1 -1
  157. package/package.json +39 -38
  158. package/cjs/layout/label/arc-label.d.ts +0 -42
  159. package/cjs/layout/label/arc-label.js +0 -416
  160. package/cjs/layout/label/arc-label.js.map +0 -1
  161. package/esm/layout/label/arc-label.d.ts +0 -42
  162. package/esm/layout/label/arc-label.js +0 -401
  163. package/esm/layout/label/arc-label.js.map +0 -1
package/build/index.js CHANGED
@@ -8245,7 +8245,6 @@
8245
8245
  };
8246
8246
  }
8247
8247
 
8248
- const isClose = isNumberClose;
8249
8248
  function normalizeAngle$2(angle) {
8250
8249
  while (angle < 0) {
8251
8250
  angle += Math.PI * 2;
@@ -8276,79 +8275,6 @@
8276
8275
  y: Math.sin(point.angle) * point.radius
8277
8276
  };
8278
8277
  }
8279
- function circlePoint$1(x0, y0, radius, radian) {
8280
- const offset = polarToCartesian$1({
8281
- radius,
8282
- angle: radian
8283
- });
8284
- return {
8285
- x: x0 + offset.x,
8286
- y: y0 + offset.y
8287
- };
8288
- }
8289
- function lineCirclePoints$1(a, b, c, x0, y0, r) {
8290
- if ((a === 0 && b === 0) || r <= 0) {
8291
- return [];
8292
- }
8293
- if (a === 0) {
8294
- const y1 = -c / b;
8295
- const fy = (y1 - y0) ** 2;
8296
- const fd = r ** 2 - fy;
8297
- if (fd < 0) {
8298
- return [];
8299
- }
8300
- else if (fd === 0) {
8301
- return [{ x: x0, y: y1 }];
8302
- }
8303
- const x1 = Math.sqrt(fd) + x0;
8304
- const x2 = -Math.sqrt(fd) + x0;
8305
- return [
8306
- { x: x1, y: y1 },
8307
- { x: x2, y: y1 }
8308
- ];
8309
- }
8310
- else if (b === 0) {
8311
- const x1 = -c / a;
8312
- const fx = (x1 - x0) ** 2;
8313
- const fd = r ** 2 - fx;
8314
- if (fd < 0) {
8315
- return [];
8316
- }
8317
- else if (fd === 0) {
8318
- return [{ x: x1, y: y0 }];
8319
- }
8320
- const y1 = Math.sqrt(fd) + y0;
8321
- const y2 = -Math.sqrt(fd) + y0;
8322
- return [
8323
- { x: x1, y: y1 },
8324
- { x: x1, y: y2 }
8325
- ];
8326
- }
8327
- const fa = (b / a) ** 2 + 1;
8328
- const fb = 2 * ((c / a + x0) * (b / a) - y0);
8329
- const fc = (c / a + x0) ** 2 + y0 ** 2 - r ** 2;
8330
- const fd = fb ** 2 - 4 * fa * fc;
8331
- if (fd < 0) {
8332
- return [];
8333
- }
8334
- const y1 = (-fb + Math.sqrt(fd)) / (2 * fa);
8335
- const y2 = (-fb - Math.sqrt(fd)) / (2 * fa);
8336
- const x1 = -(b * y1 + c) / a;
8337
- const x2 = -(b * y2 + c) / a;
8338
- if (fd === 0) {
8339
- return [{ x: x1, y: y1 }];
8340
- }
8341
- return [
8342
- { x: x1, y: y1 },
8343
- { x: x2, y: y2 }
8344
- ];
8345
- }
8346
- function connectLineRadian$1(radius, length) {
8347
- if (length > radius * 2) {
8348
- return NaN;
8349
- }
8350
- return Math.asin(length / 2 / radius) * 2;
8351
- }
8352
8278
  function computeQuadrant$2(angle) {
8353
8279
  angle = normalizeAngle$2(angle);
8354
8280
  if (angle > 0 && angle <= Math.PI / 2) {
@@ -8396,20 +8322,6 @@
8396
8322
  }
8397
8323
  return { startAngle, endAngle };
8398
8324
  }
8399
- function isQuadrantLeft$1(quadrant) {
8400
- return quadrant === 3 || quadrant === 4;
8401
- }
8402
- function isQuadrantRight$1(quadrant) {
8403
- return quadrant === 1 || quadrant === 2;
8404
- }
8405
- function checkBoundsOverlap$1(boundsA, boundsB) {
8406
- const { x1: ax1, y1: ay1, x2: ax2, y2: ay2 } = boundsA;
8407
- const { x1: bx1, y1: by1, x2: bx2, y2: by2 } = boundsB;
8408
- return !((ax1 <= bx1 && ax2 <= bx1) ||
8409
- (ax1 >= bx2 && ax2 >= bx2) ||
8410
- (ay1 <= by1 && ay2 <= by1) ||
8411
- (ay1 >= by2 && ay2 >= by2));
8412
- }
8413
8325
  function outOfBounds(bounds, x, y) {
8414
8326
  return bounds.x1 > x || bounds.x2 < x || bounds.y1 > y || bounds.y2 < y;
8415
8327
  }
@@ -40174,7 +40086,7 @@
40174
40086
  mergedParameters = Object.assign({
40175
40087
  [DefaultAnimationParameters]: animationParameters
40176
40088
  }, parameters),
40177
- animationUnit = this.getAnimationUnit(config.timeline, element, index, animatedElements.length, parameters);
40089
+ animationUnit = this.getAnimationUnit(config.timeline, element, index, animatedElements.length, mergedParameters);
40178
40090
  animators.push(this.animateElement(config, animationUnit, element, animationParameters, mergedParameters));
40179
40091
  })), animators;
40180
40092
  }
@@ -40415,7 +40327,7 @@
40415
40327
  parameters() {
40416
40328
  const params = {};
40417
40329
  return this.references.forEach((count, ref) => {
40418
- params[ref.id()] = ref.output();
40330
+ isValid(ref.id()) && (params[ref.id()] = ref.output());
40419
40331
  }), params;
40420
40332
  }
40421
40333
  getSpec() {
@@ -40876,8 +40788,8 @@
40876
40788
  return !isNil(this.spec.layout);
40877
40789
  }
40878
40790
  handleLayoutEnd() {
40879
- var _a;
40880
- (null === (_a = this.spec.layout) || void 0 === _a ? void 0 : _a.skipBeforeLayouted) && this.run();
40791
+ var _a, _b;
40792
+ (null === (_b = null === (_a = this.spec) || void 0 === _a ? void 0 : _a.layout) || void 0 === _b ? void 0 : _b.skipBeforeLayouted) && this.run();
40881
40793
  }
40882
40794
  handleRenderEnd() {
40883
40795
  this.needClear && (this.cleanExitElements(), this.elementMap.forEach(element => {
@@ -43371,7 +43283,7 @@
43371
43283
  return !(ax1 <= bx1 && ax2 <= bx1 || ax1 >= bx2 && ax2 >= bx2 || ay1 <= by1 && ay2 <= by1 || ay1 >= by2 && ay2 >= by2);
43372
43284
  }
43373
43285
 
43374
- let ArcInfo$1 = class ArcInfo {
43286
+ class ArcInfo {
43375
43287
  constructor(refDatum, center, outerCenter, quadrant, radian, middleAngle) {
43376
43288
  this.refDatum = refDatum, this.center = center, this.outerCenter = outerCenter, this.quadrant = quadrant, this.radian = radian, this.middleAngle = middleAngle, this.labelVisible = !0, this.labelLimit = 0;
43377
43289
  }
@@ -43388,7 +43300,7 @@
43388
43300
  y2: 0
43389
43301
  };
43390
43302
  }
43391
- };
43303
+ }
43392
43304
  class ArcLabel extends LabelBase {
43393
43305
  constructor(attributes) {
43394
43306
  super(merge$2({}, ArcLabel.defaultAttributes, attributes)), this.name = "arc-label", this._ellipsisWidth = 0, this._arcLeft = new Map(), this._arcRight = new Map();
@@ -43449,7 +43361,7 @@
43449
43361
  arcQuadrant = computeQuadrant(graphicAttribute.endAngle - intervalAngle / 2),
43450
43362
  arcMiddle = circlePoint(center.x, center.y, graphicAttribute.outerRadius, arcMiddleAngle),
43451
43363
  outerArcMiddle = circlePoint(center.x, center.y, maxRadius + attribute.line.line1MinLength, arcMiddleAngle),
43452
- arc = new ArcInfo$1(item, arcMiddle, outerArcMiddle, arcQuadrant, intervalAngle, arcMiddleAngle);
43364
+ arc = new ArcInfo(item, arcMiddle, outerArcMiddle, arcQuadrant, intervalAngle, arcMiddleAngle);
43453
43365
  arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(2 * center.x, 2 * center.y, graphicAttribute.outerRadius, centerOffset), arc.middleAngle), arc.labelSize = {
43454
43366
  width: textBounds.x2 - textBounds.x1,
43455
43367
  height: textBounds.y2 - textBounds.y1
@@ -50056,7 +49968,7 @@
50056
49968
  },
50057
49969
  smartInvert: !1
50058
49970
  };
50059
- const arcLabel$1 = {
49971
+ const arcLabel = {
50060
49972
  type: "arc",
50061
49973
  data: [{
50062
49974
  text: "",
@@ -50102,7 +50014,7 @@
50102
50014
  lineLabel: lineLabel,
50103
50015
  rectLabel: rectLabel,
50104
50016
  symbolLabel: symbolLabel$1,
50105
- arcLabel: arcLabel$1,
50017
+ arcLabel: arcLabel,
50106
50018
  datazoom: datazoom,
50107
50019
  continuousPlayer: continuousPlayer,
50108
50020
  discretePlayer: discretePlayer,
@@ -53622,11 +53534,11 @@
53622
53534
  }
53623
53535
  }
53624
53536
  addGrammar(grammar) {
53625
- return this.grammars.find(storedGrammar => storedGrammar.uid === grammar.uid) || (this.grammars.record(grammar), this._dataflow.add(grammar), grammar.parse(grammar.getSpec())), this;
53537
+ return this.grammars.find(storedGrammar => storedGrammar.uid === grammar.uid) || (this.grammars.record(grammar), this._dataflow.add(grammar), grammar.parse(grammar.getSpec()), this._needBuildLayoutTree = !0), this;
53626
53538
  }
53627
53539
  removeGrammar(grammar) {
53628
53540
  const recordedGrammar = isString(grammar) ? this.getGrammarById(grammar) : grammar;
53629
- return recordedGrammar && this.grammars.find(storedGrammar => storedGrammar.uid === recordedGrammar.uid) ? ("mark" === recordedGrammar.grammarType && recordedGrammar.prepareRelease(), this._cachedGrammars.record(recordedGrammar), this._dataflow.remove(recordedGrammar), this.grammars.unrecord(recordedGrammar), this) : this;
53541
+ return recordedGrammar && this.grammars.find(storedGrammar => storedGrammar.uid === recordedGrammar.uid) ? ("mark" === recordedGrammar.grammarType && recordedGrammar.prepareRelease(), this._cachedGrammars.record(recordedGrammar), this._dataflow.remove(recordedGrammar), this.grammars.unrecord(recordedGrammar), this._needBuildLayoutTree = !0, this) : this;
53630
53542
  }
53631
53543
  removeAllGrammars() {
53632
53544
  return this.grammars.traverse(grammar => {
@@ -54271,16 +54183,10 @@
54271
54183
  const ARC_START_ANGLE = `${PREFIX}_ARC_START_ANGLE`;
54272
54184
  const ARC_END_ANGLE = `${PREFIX}_ARC_END_ANGLE`;
54273
54185
  const ARC_K = `${PREFIX}_ARC_K`;
54274
- const ARC_LABEL_HOVER_AX = `${PREFIX}_ARC_LABEL_HOVER_AX`;
54275
- const ARC_LABEL_HOVER_AY = `${PREFIX}_ARC_LABEL_HOVER_AY`;
54276
- const ARC_LABEL_POINT_AX = `${PREFIX}_ARC_LABEL_POINT_AX`;
54277
- const ARC_LABEL_POINT_AY = `${PREFIX}_ARC_LABEL_POINT_AY`;
54278
54186
  const ARC_LABEL_POINT_BX = `${PREFIX}_ARC_LABEL_POINT_BX`;
54279
54187
  const ARC_LABEL_POINT_BY = `${PREFIX}_ARC_LABEL_POINT_BY`;
54280
54188
  const ARC_LABEL_POINT_CX = `${PREFIX}_ARC_LABEL_POINT_CX`;
54281
54189
  const ARC_LABEL_POINT_CY = `${PREFIX}_ARC_LABEL_POINT_CY`;
54282
- const ARC_LABEL_SELECTED_AX = `${PREFIX}_ARC_LABEL_SELECTED_AX`;
54283
- const ARC_LABEL_SELECTED_AY = `${PREFIX}_ARC_LABEL_SELECTED_AY`;
54284
54190
  const ARC_MIDDLE_ANGLE = `${PREFIX}_ARC_MIDDLE_ANGLE`;
54285
54191
  const ARC_QUADRANT = `${PREFIX}_ARC_QUADRANT`;
54286
54192
  const ARC_RADIAN = `${PREFIX}_ARC_RADIAN`;
@@ -56002,6 +55908,10 @@
56002
55908
  STATE_LEVEL[STATE_LEVEL["HOVER"] = 6] = "HOVER";
56003
55909
  })(STATE_LEVEL || (STATE_LEVEL = {}));
56004
55910
 
55911
+ const lineLikeSeriesMark = {
55912
+ [SeriesMarkNameEnum.point]: { name: SeriesMarkNameEnum.point, type: MarkTypeEnum.symbol },
55913
+ [SeriesMarkNameEnum.line]: { name: SeriesMarkNameEnum.line, type: MarkTypeEnum.line }
55914
+ };
56005
55915
  class LineLikeSeriesMixin {
56006
55916
  initLineMark(progressive, isSeriesMark) {
56007
55917
  this._lineMark = this._createMark(lineLikeSeriesMark.line, {
@@ -56182,10 +56092,6 @@
56182
56092
  }
56183
56093
  }
56184
56094
  }
56185
- const lineLikeSeriesMark = {
56186
- [SeriesMarkNameEnum.point]: { name: SeriesMarkNameEnum.point, type: MarkTypeEnum.symbol },
56187
- [SeriesMarkNameEnum.line]: { name: SeriesMarkNameEnum.line, type: MarkTypeEnum.line }
56188
- };
56189
56095
 
56190
56096
  const lineSeriesMark = Object.assign(Object.assign({}, baseSeriesMark), lineLikeSeriesMark);
56191
56097
 
@@ -71990,702 +71896,6 @@
71990
71896
  return data;
71991
71897
  };
71992
71898
 
71993
- const arcLabel = (data, op) => {
71994
- const latestData = data[0].latestData;
71995
- const layout = new ArcLabelLayout(op.series, latestData);
71996
- return layout.updateLabels();
71997
- };
71998
- class ArcInfo {
71999
- constructor(refDatum, center, outerCenter, quadrant, radian, middleAngle, k) {
72000
- this.refDatum = refDatum;
72001
- this.center = center;
72002
- this.outerCenter = outerCenter;
72003
- this.quadrant = quadrant;
72004
- this.radian = radian;
72005
- this.middleAngle = middleAngle;
72006
- this.k = k;
72007
- this.labelVisible = true;
72008
- this.labelLimit = 0;
72009
- }
72010
- getLabelBounds() {
72011
- if (!this.labelPosition || !this.labelSize) {
72012
- return { x1: 0, x2: 0, y1: 0, y2: 0 };
72013
- }
72014
- return {
72015
- x1: this.labelPosition.x - this.labelSize.width / 2,
72016
- y1: this.labelPosition.y - this.labelSize.height / 2,
72017
- x2: this.labelPosition.x + this.labelSize.width / 2,
72018
- y2: this.labelPosition.y + this.labelSize.height / 2
72019
- };
72020
- }
72021
- }
72022
- class ArcLabelLayout {
72023
- constructor(series, data) {
72024
- this._ellipsisWidth = 0;
72025
- this._arcLeft = new Map();
72026
- this._arcRight = new Map();
72027
- this._series = series;
72028
- this._data = data;
72029
- this._textMeasure = initTextMeasure(this._getMeasureSpec());
72030
- }
72031
- updateLabels() {
72032
- const labelConfig = this._series.getLabelConfig();
72033
- if (!(labelConfig === null || labelConfig === void 0 ? void 0 : labelConfig.visible)) {
72034
- return null;
72035
- }
72036
- this._setArcs();
72037
- this._layoutLabels();
72038
- return this._setLabelData();
72039
- }
72040
- _setArcs() {
72041
- var _a, _b, _c;
72042
- const valueField = this._series.getRadiusField()[0];
72043
- const radiusRatio = this._series.getRadius();
72044
- const labelConfig = this._series.getLabelConfig();
72045
- const line1MinLength = labelConfig.line.line1MinLength;
72046
- if (labelConfig === null || labelConfig === void 0 ? void 0 : labelConfig.visible) {
72047
- this._clearArcs();
72048
- const radius = this._series.computeRadius(radiusRatio);
72049
- const center = this._series.center;
72050
- const data = (_c = (_b = (_a = this._series).getViewData) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.latestData;
72051
- let values;
72052
- if (data.length <= 1) {
72053
- values = data.slice();
72054
- }
72055
- else {
72056
- switch (labelConfig === null || labelConfig === void 0 ? void 0 : labelConfig.showRule) {
72057
- case 'headAndTail':
72058
- values = [data[0], data[data.length - 1]];
72059
- break;
72060
- case 'max':
72061
- values = [
72062
- data.reduce((max, value) => {
72063
- return max[valueField] > value[valueField] ? max : value;
72064
- }, data[0])
72065
- ];
72066
- break;
72067
- case 'min':
72068
- values = [
72069
- data.reduce((min, value) => {
72070
- return min[valueField] < value[valueField] ? min : value;
72071
- }, data[0])
72072
- ];
72073
- break;
72074
- case 'minAndMax':
72075
- values = [
72076
- data.reduce((max, value) => {
72077
- return max[valueField] > value[valueField] ? max : value;
72078
- }, data[0]),
72079
- data.reduce((min, value) => {
72080
- return min[valueField] < value[valueField] ? min : value;
72081
- }, data[0])
72082
- ];
72083
- break;
72084
- case 'all':
72085
- default:
72086
- values = data.slice();
72087
- }
72088
- }
72089
- this._ellipsisWidth = this._measureTextSize('...').width;
72090
- for (const item of values) {
72091
- const arcMiddle = circlePoint$1(center.x, center.y, radius * item[ARC_K], item[ARC_MIDDLE_ANGLE]);
72092
- const outerArcMiddle = circlePoint$1(center.x, center.y, radius + line1MinLength, item[ARC_MIDDLE_ANGLE]);
72093
- const arc = new ArcInfo(item, arcMiddle, outerArcMiddle, item[ARC_QUADRANT], item[ARC_RADIAN], item[ARC_MIDDLE_ANGLE], item[ARC_K]);
72094
- const text = this._getFormatLabelText(item);
72095
- arc.labelSize = this._measureTextSize(text);
72096
- if (isQuadrantRight$1(arc.quadrant)) {
72097
- this._arcRight.set(arc.refDatum, arc);
72098
- }
72099
- else if (isQuadrantLeft$1(arc.quadrant)) {
72100
- this._arcLeft.set(arc.refDatum, arc);
72101
- }
72102
- }
72103
- }
72104
- }
72105
- _getArc(datum) {
72106
- return this._arcLeft.get(datum) || this._arcRight.get(datum);
72107
- }
72108
- _clearArcs() {
72109
- this._arcLeft.clear();
72110
- this._arcRight.clear();
72111
- }
72112
- _setLabelData() {
72113
- const labelConfig = this._series.getLabelConfig();
72114
- const center = this._series.center;
72115
- return this._data.map((v) => {
72116
- const arc = this._getArc(v);
72117
- const value = Object.assign({}, v);
72118
- if (!arc) {
72119
- value[DEFAULT_LABEL_VISIBLE] = false;
72120
- return value;
72121
- }
72122
- const { labelPosition, labelLimit, labelSize, pointB, pointC } = arc;
72123
- if ((labelConfig === null || labelConfig === void 0 ? void 0 : labelConfig.position) !== 'inside') {
72124
- const hoverLineA = circlePoint$1(center.x, center.y, this._series.computeDatumRadius(value, STATE_VALUE_ENUM.STATE_HOVER), arc.middleAngle);
72125
- const selectedLineA = circlePoint$1(center.x, center.y, this._series.computeDatumRadius(value, STATE_VALUE_ENUM.STATE_SELECTED), arc.middleAngle);
72126
- const pointA = circlePoint$1(center.x, center.y, this._series.computeDatumRadius(value, STATE_VALUE_ENUM.STATE_NORMAL), arc.middleAngle);
72127
- value[ARC_LABEL_POINT_AX] = pointA.x;
72128
- value[ARC_LABEL_POINT_AY] = pointA.y;
72129
- value[ARC_LABEL_HOVER_AX] = hoverLineA.x;
72130
- value[ARC_LABEL_HOVER_AY] = hoverLineA.y;
72131
- value[ARC_LABEL_SELECTED_AX] = selectedLineA.x;
72132
- value[ARC_LABEL_SELECTED_AY] = selectedLineA.y;
72133
- value[ARC_LABEL_POINT_BX] = pointB.x;
72134
- value[ARC_LABEL_POINT_BY] = pointB.y;
72135
- value[ARC_LABEL_POINT_CX] = pointC.x;
72136
- value[ARC_LABEL_POINT_CY] = pointC.y;
72137
- value[DEFAULT_LABEL_Y] = labelPosition.y - labelSize.height / 2;
72138
- }
72139
- else {
72140
- value[DEFAULT_LABEL_Y] = labelPosition.y;
72141
- }
72142
- value[DEFAULT_LABEL_ALIGN] = this._computeAlign(arc);
72143
- value[DEFAULT_LABEL_LIMIT] = Math.max(labelLimit, 0);
72144
- value[DEFAULT_LABEL_VISIBLE] = arc.labelVisible && !isNil(arc.labelText);
72145
- value[DEFAULT_LABEL_X] = labelPosition.x;
72146
- value[DEFAULT_LABEL_TEXT] = arc.labelText;
72147
- return value;
72148
- });
72149
- }
72150
- _layoutLabels() {
72151
- const labelConfig = this._series.getLabelConfig();
72152
- const leftArcs = Array.from(this._arcLeft.values());
72153
- const rightArcs = Array.from(this._arcRight.values());
72154
- if ((labelConfig === null || labelConfig === void 0 ? void 0 : labelConfig.position) === 'inside') {
72155
- this._layoutInsideLabels(rightArcs);
72156
- this._layoutInsideLabels(leftArcs);
72157
- }
72158
- else {
72159
- this._layoutOutsideLabels(rightArcs);
72160
- this._layoutOutsideLabels(leftArcs);
72161
- }
72162
- }
72163
- _layoutInsideLabels(arcs) {
72164
- const center = this._series.center;
72165
- const innerRadiusRatio = this._series.getInnerRadius();
72166
- const outerRadiusRatio = this._series.getRadius();
72167
- const labelConfig = this._series.getLabelConfig();
72168
- const spaceWidth = labelConfig.spaceWidth;
72169
- arcs.forEach((arc) => {
72170
- const { labelSize, radian } = arc;
72171
- const innerRadius = this._series.computeRadius(innerRadiusRatio, 1);
72172
- const outerRadius = this._series.computeRadius(outerRadiusRatio);
72173
- const minRadian = connectLineRadian$1(outerRadius, labelSize.height);
72174
- let limit;
72175
- if (radian < minRadian) {
72176
- limit = 0;
72177
- }
72178
- else {
72179
- let minRadius;
72180
- if (radian >= Math.PI) {
72181
- minRadius = innerRadius;
72182
- }
72183
- else {
72184
- minRadius = Math.max(innerRadius, labelSize.height / 2 / Math.tan(radian / 2));
72185
- }
72186
- limit = outerRadius - minRadius - spaceWidth;
72187
- }
72188
- if ((labelConfig === null || labelConfig === void 0 ? void 0 : labelConfig.rotate) !== true) {
72189
- limit = outerRadius - spaceWidth;
72190
- }
72191
- const text = this._getFormatLabelText(arc.refDatum, limit);
72192
- arc.labelText = text;
72193
- const labelWidth = Math.min(limit, this._measureTextSize(text).width);
72194
- const align = this._computeAlign(arc);
72195
- const alignOffset = align === 'left' ? labelWidth : align === 'right' ? 0 : labelWidth / 2;
72196
- const labelRadius = outerRadius - spaceWidth - alignOffset;
72197
- arc.labelPosition = circlePoint$1(center.x, center.y, labelRadius, arc.middleAngle);
72198
- arc.labelLimit = labelWidth;
72199
- if (!isGreater(labelWidth, 0)) {
72200
- arc.labelVisible = false;
72201
- }
72202
- });
72203
- }
72204
- _layoutOutsideLabels(arcs) {
72205
- var _a;
72206
- const { height } = this._getPlotLayout();
72207
- const labelConfig = this._series.getLabelConfig();
72208
- const line2MinLength = labelConfig.line.line2MinLength;
72209
- const labelLayout = labelConfig.layout;
72210
- const spaceWidth = labelConfig.spaceWidth;
72211
- arcs.forEach(arc => {
72212
- const direction = isQuadrantLeft$1(arc.quadrant) ? -1 : 1;
72213
- arc.labelPosition = {
72214
- x: arc.outerCenter.x + direction * (arc.labelSize.width / 2 + line2MinLength + spaceWidth),
72215
- y: arc.outerCenter.y
72216
- };
72217
- });
72218
- arcs.sort((a, b) => {
72219
- return a.labelPosition.y - b.labelPosition.y;
72220
- });
72221
- if (labelConfig.coverEnable !== false || labelLayout.strategy === 'none') {
72222
- for (const arc of arcs) {
72223
- const { labelPosition, labelSize } = arc;
72224
- arc.labelLimit = labelSize.width;
72225
- arc.pointB = isQuadrantLeft$1(arc.quadrant)
72226
- ? {
72227
- x: labelPosition.x + labelSize.width / 2 + line2MinLength + spaceWidth,
72228
- y: labelPosition.y
72229
- }
72230
- : {
72231
- x: labelPosition.x - labelSize.width / 2 - line2MinLength - spaceWidth,
72232
- y: labelPosition.y
72233
- };
72234
- this._computeX(arc);
72235
- }
72236
- if (labelConfig.coverEnable === false && labelLayout.strategy === 'none') {
72237
- this._coverLabels(arcs);
72238
- }
72239
- }
72240
- else {
72241
- const maxLabels = height / (((_a = labelConfig.style) === null || _a === void 0 ? void 0 : _a.fontSize) || 16);
72242
- this._adjustY(arcs, maxLabels);
72243
- const { minY, maxY } = arcs.reduce((yInfo, arc) => {
72244
- const { y1, y2 } = arc.getLabelBounds();
72245
- yInfo.minY = Math.max(0, Math.min(y1, yInfo.minY));
72246
- yInfo.maxY = Math.min(height, Math.max(y2, yInfo.maxY));
72247
- return yInfo;
72248
- }, { minY: Infinity, maxY: -Infinity });
72249
- const halfY = Math.max(Math.abs(height / 2 - minY), Math.abs(maxY - height / 2));
72250
- const r = this._computeLayoutRadius(halfY);
72251
- for (const arc of arcs) {
72252
- this._computePointB(arc, r);
72253
- this._computeX(arc);
72254
- }
72255
- }
72256
- const { width } = this._getPlotLayout();
72257
- arcs.forEach(arc => {
72258
- if (arc.labelVisible &&
72259
- (isLess(arc.pointB.x, line2MinLength + spaceWidth) ||
72260
- isGreater(arc.pointB.x, width - line2MinLength - spaceWidth))) {
72261
- arc.labelVisible = false;
72262
- }
72263
- });
72264
- }
72265
- _coverLabels(arcs) {
72266
- if (arcs.length <= 1) {
72267
- return;
72268
- }
72269
- let lastBounds = arcs[0].getLabelBounds();
72270
- for (let i = 1; i < arcs.length; i++) {
72271
- const bounds = arcs[i].getLabelBounds();
72272
- if (!checkBoundsOverlap$1(lastBounds, bounds)) {
72273
- lastBounds = bounds;
72274
- }
72275
- else {
72276
- arcs[i].labelVisible = false;
72277
- }
72278
- }
72279
- }
72280
- _computeLayoutRadius(halfYLength) {
72281
- const labelConfig = this._series.getLabelConfig();
72282
- const layoutArcGap = labelConfig.layoutArcGap;
72283
- const line1MinLength = labelConfig.line.line1MinLength;
72284
- const radiusRatio = this._series.getRadius();
72285
- const radius = this._series.computeRadius(radiusRatio);
72286
- const outerR = Math.max(radius + line1MinLength, this._series.computeDatumRadius(null));
72287
- const a = outerR - layoutArcGap;
72288
- return Math.max((a ** 2 + halfYLength ** 2) / (2 * a), outerR);
72289
- }
72290
- _computePointB(arc, r) {
72291
- const radiusRatio = this._series.getRadius();
72292
- const labelConfig = this._series.getLabelConfig();
72293
- const line1MinLength = labelConfig.line.line1MinLength;
72294
- const labelLayout = labelConfig.layout;
72295
- if (labelLayout.strategy === 'none') {
72296
- arc.pointB = {
72297
- x: arc.outerCenter.x,
72298
- y: arc.outerCenter.y
72299
- };
72300
- }
72301
- else {
72302
- const center = this._series.center;
72303
- const radius = this._series.computeRadius(radiusRatio);
72304
- const { labelPosition, quadrant } = arc;
72305
- const outerR = Math.max(radius + line1MinLength, this._series.computeDatumRadius(null));
72306
- const rd = r - outerR;
72307
- const x = Math.sqrt(r ** 2 - Math.abs(center.y - labelPosition.y) ** 2) - rd;
72308
- if (isValidNumber(x)) {
72309
- arc.pointB = {
72310
- x: center.x + x * (isQuadrantLeft$1(quadrant) ? -1 : 1),
72311
- y: labelPosition.y
72312
- };
72313
- }
72314
- else {
72315
- arc.pointB = { x: NaN, y: NaN };
72316
- }
72317
- }
72318
- }
72319
- _computeX(arc) {
72320
- var _a;
72321
- const center = this._series.center;
72322
- const plotLayout = this._getPlotLayout();
72323
- const radiusRatio = this._series.getRadius();
72324
- const labelConfig = this._series.getLabelConfig();
72325
- const line1MinLength = labelConfig.line.line1MinLength;
72326
- const line2MinLength = labelConfig.line.line2MinLength;
72327
- const labelLayoutAlign = (_a = labelConfig.layout) === null || _a === void 0 ? void 0 : _a.align;
72328
- const spaceWidth = labelConfig.spaceWidth;
72329
- const align = this._computeAlign(arc);
72330
- const { labelPosition, quadrant, pointB } = arc;
72331
- if (!isValidNumber(pointB.x * pointB.y)) {
72332
- arc.pointC = { x: NaN, y: NaN };
72333
- labelPosition.x = NaN;
72334
- arc.labelLimit = 0;
72335
- }
72336
- const radius = this._series.computeRadius(radiusRatio);
72337
- const flag = isQuadrantLeft$1(quadrant) ? -1 : 1;
72338
- let cx = 0;
72339
- const restWidth = flag > 0 ? plotLayout.width - pointB.x : pointB.x;
72340
- let limit = restWidth - line2MinLength - spaceWidth;
72341
- if (labelLayoutAlign === 'labelLine') {
72342
- cx = (radius + line1MinLength + line2MinLength) * flag + center.x;
72343
- limit = (flag > 0 ? plotLayout.width - cx : cx) - spaceWidth;
72344
- }
72345
- const text = this._getFormatLabelText(arc.refDatum, limit);
72346
- arc.labelText = text;
72347
- let labelWidth = Math.min(limit, this._measureTextSize(text).width);
72348
- switch (labelLayoutAlign) {
72349
- case 'labelLine':
72350
- break;
72351
- case 'edge':
72352
- cx = flag > 0 ? plotLayout.width - labelWidth - spaceWidth : labelWidth + spaceWidth;
72353
- break;
72354
- case 'arc':
72355
- default:
72356
- cx = pointB.x + flag * line2MinLength;
72357
- break;
72358
- }
72359
- labelWidth = Math.max(this._ellipsisWidth, labelWidth);
72360
- arc.pointC = { x: cx, y: labelPosition.y };
72361
- if (labelLayoutAlign === 'edge') {
72362
- const alignOffset = this._computeAlignOffset(align, labelWidth, -flag);
72363
- labelPosition.x = flag > 0 ? plotLayout.width + alignOffset : alignOffset;
72364
- }
72365
- else {
72366
- const alignOffset = this._computeAlignOffset(align, labelWidth, flag);
72367
- labelPosition.x = cx + alignOffset + flag * spaceWidth;
72368
- }
72369
- arc.labelLimit = labelWidth;
72370
- }
72371
- _computeAlignOffset(align, labelWidth, alignFlag) {
72372
- switch (align) {
72373
- case 'left':
72374
- return alignFlag < 0 ? -labelWidth : 0;
72375
- case 'right':
72376
- return alignFlag < 0 ? 0 : labelWidth;
72377
- case 'center':
72378
- default:
72379
- return (labelWidth / 2) * alignFlag;
72380
- }
72381
- }
72382
- _adjustY(arcs, maxLabels) {
72383
- const plotRect = this._getPlotLayout();
72384
- const labelLayout = this._series.getLabelConfig().layout;
72385
- if (labelLayout.strategy === 'vertical') {
72386
- let lastY = 0;
72387
- let delta;
72388
- const len = arcs.length;
72389
- if (len <= 0) {
72390
- return;
72391
- }
72392
- for (let i = 0; i < len; i++) {
72393
- const { y1 } = arcs[i].getLabelBounds();
72394
- delta = y1 - lastY;
72395
- if (isLess(delta, 0)) {
72396
- const index = this._shiftY(arcs, i, len - 1, -delta);
72397
- this._shiftY(arcs, index, 0, delta / 2);
72398
- }
72399
- const { y2 } = arcs[i].getLabelBounds();
72400
- lastY = y2;
72401
- }
72402
- const { y1: firstY1 } = arcs[0].getLabelBounds();
72403
- delta = firstY1 - 0;
72404
- if (isLess(delta, 0)) {
72405
- this._shiftY(arcs, 0, len - 1, -delta);
72406
- }
72407
- for (let i = arcs.length - 1; i >= 0; i--) {
72408
- if (arcs[i].getLabelBounds().y2 > plotRect.height) {
72409
- arcs[i].labelVisible = false;
72410
- }
72411
- else {
72412
- break;
72413
- }
72414
- }
72415
- }
72416
- else if (labelLayout.strategy !== 'none') {
72417
- const priorityArcs = arcs.map((arc, i) => {
72418
- return {
72419
- arc,
72420
- originIndex: i,
72421
- priorityIndex: 0
72422
- };
72423
- });
72424
- priorityArcs.sort((a, b) => {
72425
- return b.arc.radian - a.arc.radian;
72426
- });
72427
- priorityArcs.forEach((priorityArc, i) => {
72428
- priorityArc.priorityIndex = i;
72429
- priorityArc.arc.labelVisible = false;
72430
- });
72431
- let topLabelIndex = Infinity;
72432
- let bottomLabelIndex = -Infinity;
72433
- for (let i = 0; i < maxLabels && i < arcs.length; i++) {
72434
- this._storeY(arcs);
72435
- const arc = priorityArcs[i].arc;
72436
- this._computeYRange(arc);
72437
- arc.labelVisible = true;
72438
- const curY = arc.labelPosition.y;
72439
- const { lastIndex, nextIndex } = this._findNeighborIndex(arcs, priorityArcs[i]);
72440
- const lastArc = arcs[lastIndex];
72441
- const nextArc = arcs[nextIndex];
72442
- if (lastIndex === -1 && nextIndex !== -1) {
72443
- const nextY = nextArc.labelPosition.y;
72444
- if (curY > nextY) {
72445
- arc.labelPosition.y = nextY - nextArc.labelSize.height / 2 - arc.labelSize.height / 2;
72446
- }
72447
- else {
72448
- this._twoWayShift(arcs, arc, nextArc, nextIndex);
72449
- }
72450
- }
72451
- else if (lastIndex !== -1 && nextIndex === -1) {
72452
- const lastY = lastArc.labelPosition.y;
72453
- if (curY < lastY) {
72454
- arc.labelPosition.y = lastY + lastArc.labelSize.height / 2 + arc.labelSize.height / 2;
72455
- }
72456
- else {
72457
- this._twoWayShift(arcs, lastArc, arc, priorityArcs[i].originIndex);
72458
- }
72459
- }
72460
- else if (lastIndex !== -1 && nextIndex !== -1) {
72461
- const lastY = lastArc.labelPosition.y;
72462
- const nextY = nextArc.labelPosition.y;
72463
- if (curY > nextY) {
72464
- arc.labelPosition.y = nextY - nextArc.labelSize.height / 2 - arc.labelSize.height / 2;
72465
- this._twoWayShift(arcs, lastArc, arc, priorityArcs[i].originIndex);
72466
- }
72467
- else if (curY < lastY) {
72468
- arc.labelPosition.y = lastY + lastArc.labelSize.height / 2 + arc.labelSize.height / 2;
72469
- this._twoWayShift(arcs, arc, nextArc, nextIndex);
72470
- }
72471
- else {
72472
- this._twoWayShift(arcs, lastArc, arc, priorityArcs[i].originIndex);
72473
- this._twoWayShift(arcs, arc, nextArc, nextIndex);
72474
- }
72475
- }
72476
- const nextTopIndex = Math.min(topLabelIndex, priorityArcs[i].originIndex);
72477
- const nextBottomIndex = Math.max(bottomLabelIndex, priorityArcs[i].originIndex);
72478
- let delta;
72479
- delta = arcs[nextBottomIndex].getLabelBounds().y2 - plotRect.height;
72480
- if (isGreater(delta, 0)) {
72481
- this._shiftY(arcs, nextBottomIndex, 0, -delta);
72482
- }
72483
- delta = arcs[nextTopIndex].getLabelBounds().y1 - 0;
72484
- if (isLess(delta, 0)) {
72485
- this._shiftY(arcs, nextTopIndex, arcs.length - 1, -delta);
72486
- }
72487
- delta = arcs[nextBottomIndex].getLabelBounds().y2 - plotRect.height;
72488
- if (isGreater(delta, 0)) {
72489
- arc.labelVisible = false;
72490
- this._restoreY(arcs);
72491
- break;
72492
- }
72493
- else if (labelLayout.tangentConstraint && !this._checkYRange(arcs)) {
72494
- arc.labelVisible = false;
72495
- this._restoreY(arcs);
72496
- }
72497
- else {
72498
- topLabelIndex = nextTopIndex;
72499
- bottomLabelIndex = nextBottomIndex;
72500
- }
72501
- }
72502
- }
72503
- }
72504
- _checkYRange(arcs) {
72505
- for (const arc of arcs) {
72506
- const { labelYRange, labelPosition } = arc;
72507
- if (arc.labelVisible &&
72508
- labelYRange &&
72509
- (isLess(labelPosition.y, labelYRange[0]) || isGreater(labelPosition.y, labelYRange[1]))) {
72510
- return false;
72511
- }
72512
- }
72513
- return true;
72514
- }
72515
- _computeYRange(arc) {
72516
- const plotRect = this._getPlotLayout();
72517
- const radiusRatio = this._series.getRadius();
72518
- const line1MinLength = this._series.getLabelConfig().line.line1MinLength;
72519
- const { width, height } = plotRect;
72520
- const radius = this._series.computeRadius(radiusRatio);
72521
- const r = this._computeLayoutRadius(height / 2);
72522
- const cx = Math.abs(arc.center.x - width / 2);
72523
- const cy = arc.center.y - height / 2;
72524
- let a;
72525
- let b;
72526
- let c;
72527
- if (isClose(width / 2, cx)) {
72528
- a = 0;
72529
- b = 1;
72530
- c = -cy;
72531
- }
72532
- else if (isClose(height / 2, cy)) {
72533
- a = 1;
72534
- b = 0;
72535
- c = -cx;
72536
- }
72537
- else {
72538
- const k = -1 / (cy / cx);
72539
- a = k;
72540
- b = -1;
72541
- c = cy - k * cx;
72542
- }
72543
- const points = lineCirclePoints$1(a, b, c, line1MinLength + radius - r, 0, r);
72544
- if (points.length < 2) {
72545
- return;
72546
- }
72547
- let min;
72548
- let max;
72549
- if (points[0].x > points[1].x) {
72550
- points.reverse();
72551
- }
72552
- if (points[0].x < 0) {
72553
- if (isClose(points[0].y, points[1].y)) {
72554
- if (Math.abs(arc.middleAngle) < Math.PI / 2) {
72555
- min = 0;
72556
- max = points[1].y + height / 2;
72557
- }
72558
- else {
72559
- min = points[1].y + height / 2;
72560
- max = height;
72561
- }
72562
- }
72563
- else if (points[0].y < points[1].y) {
72564
- min = 0;
72565
- max = points[1].y + height / 2;
72566
- }
72567
- else {
72568
- min = points[1].y + height / 2;
72569
- max = plotRect.height;
72570
- }
72571
- }
72572
- else {
72573
- min = Math.min(points[0].y, points[1].y) + height / 2;
72574
- max = Math.max(points[0].y, points[1].y) + height / 2;
72575
- }
72576
- arc.labelYRange = [min, max];
72577
- }
72578
- _storeY(arcs) {
72579
- for (const arc of arcs) {
72580
- if (arc.labelVisible) {
72581
- arc.lastLabelY = arc.labelPosition.y;
72582
- }
72583
- }
72584
- }
72585
- _restoreY(arcs) {
72586
- for (const arc of arcs) {
72587
- if (arc.labelVisible) {
72588
- arc.labelPosition.y = arc.lastLabelY;
72589
- }
72590
- }
72591
- }
72592
- _findNeighborIndex(arcs, priorityArc) {
72593
- const index = priorityArc.originIndex;
72594
- let lastIndex = -1;
72595
- let nextIndex = -1;
72596
- for (let i = index - 1; i >= 0; i--) {
72597
- if (arcs[i].labelVisible) {
72598
- lastIndex = i;
72599
- break;
72600
- }
72601
- }
72602
- for (let i = index + 1; i < arcs.length; i++) {
72603
- if (arcs[i].labelVisible) {
72604
- nextIndex = i;
72605
- break;
72606
- }
72607
- }
72608
- return {
72609
- lastIndex,
72610
- nextIndex
72611
- };
72612
- }
72613
- _twoWayShift(arcs, lastArc, nextArc, nextIndex) {
72614
- const delta = nextArc.getLabelBounds().y1 - lastArc.getLabelBounds().y2;
72615
- if (isLess(delta, 0)) {
72616
- const i = this._shiftY(arcs, nextIndex, arcs.length - 1, -delta);
72617
- this._shiftY(arcs, i, 0, delta / 2);
72618
- }
72619
- }
72620
- _shiftY(arcs, start, end, delta) {
72621
- const direction = start < end ? 1 : -1;
72622
- let index = start;
72623
- while (index !== -1) {
72624
- arcs[index].labelPosition.y += delta;
72625
- const nextIndex = this._findNextVisibleIndex(arcs, index, end, direction);
72626
- if (nextIndex >= 0 && nextIndex < arcs.length) {
72627
- const { y1: curY1, y2: curY2 } = arcs[index].getLabelBounds();
72628
- const { y1: nextY1, y2: nextY2 } = arcs[nextIndex].getLabelBounds();
72629
- if ((direction > 0 && curY2 < nextY1) || (direction < 0 && curY1 > nextY2)) {
72630
- return index;
72631
- }
72632
- }
72633
- index = nextIndex;
72634
- }
72635
- return end;
72636
- }
72637
- _findNextVisibleIndex(arcs, start, end, direction) {
72638
- const diff = (end - start) * direction;
72639
- for (let i = 1; i <= diff; i++) {
72640
- const index = start + i * direction;
72641
- if (arcs[index].labelVisible) {
72642
- return index;
72643
- }
72644
- }
72645
- return -1;
72646
- }
72647
- _computeAlign(arc) {
72648
- var _a, _b, _c, _d, _e, _f;
72649
- const labelConfig = this._series.getLabelConfig();
72650
- const textAlign = (_b = (_a = labelConfig.style) === null || _a === void 0 ? void 0 : _a.textAlign) !== null && _b !== void 0 ? _b : (_c = labelConfig.style) === null || _c === void 0 ? void 0 : _c.align;
72651
- const layoutAlign = (_e = (_d = labelConfig.layout) === null || _d === void 0 ? void 0 : _d.textAlign) !== null && _e !== void 0 ? _e : (_f = labelConfig.layout) === null || _f === void 0 ? void 0 : _f.align;
72652
- if (labelConfig.position !== 'inside') {
72653
- if (isNil(textAlign) || textAlign === 'auto') {
72654
- if (layoutAlign === 'edge') {
72655
- return isQuadrantLeft$1(arc.quadrant) ? 'left' : 'right';
72656
- }
72657
- return isQuadrantLeft$1(arc.quadrant) ? 'right' : 'left';
72658
- }
72659
- return textAlign;
72660
- }
72661
- return isNil(textAlign) || textAlign === 'auto' ? 'center' : textAlign;
72662
- }
72663
- _getFormatLabelText(value, limit) {
72664
- var _a;
72665
- const textSpec = (_a = this._series.getLabelConfig().style) === null || _a === void 0 ? void 0 : _a.text;
72666
- const seriesField = this._series.getSeriesField();
72667
- const angleField = this._series.getAngleField()[0];
72668
- const isInvalidLabel = isNil(seriesField) || isNil(value[seriesField]) || isNil(value[angleField]);
72669
- if (isFunction(textSpec)) {
72670
- return isInvalidLabel ? null : textSpec.call(null, value, {});
72671
- }
72672
- return isInvalidLabel ? null : value[seriesField];
72673
- }
72674
- _getMeasureSpec() {
72675
- return Object.assign(Object.assign({}, this._series.getLabelConfig().style), { textAlign: 'center' });
72676
- }
72677
- _measureTextSize(text) {
72678
- const size = this._textMeasure.quickMeasure(text);
72679
- return {
72680
- width: Math.ceil(size.width) + 1,
72681
- height: size.height
72682
- };
72683
- }
72684
- _getPlotLayout() {
72685
- return this._series.getRegion().getLayoutRect();
72686
- }
72687
- }
72688
-
72689
71899
  function centerOffsetConfig(mark, originalConfig) {
72690
71900
  var _a, _b, _c, _d;
72691
71901
  const offset = (_b = (_a = originalConfig.options) === null || _a === void 0 ? void 0 : _a.distance) !== null && _b !== void 0 ? _b : 10;
@@ -72811,7 +72021,6 @@
72811
72021
  return;
72812
72022
  }
72813
72023
  registerDataSetInstanceTransform(this._dataSet, 'pie', pie);
72814
- registerDataSetInstanceTransform(this._dataSet, 'arcLabel', arcLabel);
72815
72024
  viewData.transform({
72816
72025
  type: 'pie',
72817
72026
  options: {
@@ -72832,10 +72041,6 @@
72832
72041
  type: 'dataview'
72833
72042
  });
72834
72043
  viewDataLabel.name = `${PREFIX}_series_${this.id}_viewDataLabel`;
72835
- viewDataLabel.transform({
72836
- type: 'arcLabel',
72837
- options: { series: this }
72838
- }, false);
72839
72044
  this._viewDataLabel = new SeriesData(this._option, viewDataLabel);
72840
72045
  }
72841
72046
  initMark() {
@@ -86639,10 +85844,14 @@
86639
85844
  type: 'discreteLegendDataMake',
86640
85845
  options: {
86641
85846
  series: () => {
86642
- return this._regions.reduce((pre, r) => {
86643
- pre.push(...r.getSeries());
86644
- return pre;
86645
- }, []);
85847
+ const result = [];
85848
+ eachSeries(this._regions, s => {
85849
+ result.push(s);
85850
+ }, {
85851
+ specIndex: this._spec.seriesIndex,
85852
+ userId: this._spec.seriesId
85853
+ });
85854
+ return result;
86646
85855
  },
86647
85856
  seriesField: (s) => this._getSeriesLegendField(s)
86648
85857
  }