@visactor/vrender-components 0.13.5-alpha.6 → 0.13.6

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 (71) 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 +10 -13
  5. package/cjs/label/base.js +56 -113
  6. package/cjs/label/base.js.map +1 -1
  7. package/cjs/label/dataLabel.js +2 -3
  8. package/cjs/label/dataLabel.js.map +1 -1
  9. package/cjs/label/index.d.ts +0 -1
  10. package/cjs/label/index.js +1 -2
  11. package/cjs/label/index.js.map +1 -1
  12. package/cjs/label/overlap/place.d.ts +4 -8
  13. package/cjs/label/overlap/place.js +2 -14
  14. package/cjs/label/overlap/place.js.map +1 -1
  15. package/cjs/label/rect.d.ts +3 -5
  16. package/cjs/label/rect.js.map +1 -1
  17. package/cjs/label/symbol.d.ts +3 -5
  18. package/cjs/label/symbol.js.map +1 -1
  19. package/cjs/label/type.d.ts +7 -48
  20. package/cjs/label/type.js.map +1 -1
  21. package/cjs/link-path/link-path.js +2 -1
  22. package/cjs/marker/base.js +1 -2
  23. package/cjs/marker/type.js +1 -1
  24. package/cjs/pager/index.js +1 -1
  25. package/cjs/pager/pager.js +1 -1
  26. package/dist/index.js +75 -926
  27. package/dist/index.min.js +1 -1
  28. package/es/index.d.ts +1 -1
  29. package/es/index.js +1 -1
  30. package/es/index.js.map +1 -1
  31. package/es/label/base.d.ts +10 -13
  32. package/es/label/base.js +59 -115
  33. package/es/label/base.js.map +1 -1
  34. package/es/label/dataLabel.js +1 -4
  35. package/es/label/dataLabel.js.map +1 -1
  36. package/es/label/index.d.ts +0 -1
  37. package/es/label/index.js +0 -2
  38. package/es/label/index.js.map +1 -1
  39. package/es/label/overlap/place.d.ts +4 -8
  40. package/es/label/overlap/place.js +0 -11
  41. package/es/label/overlap/place.js.map +1 -1
  42. package/es/label/rect.d.ts +3 -5
  43. package/es/label/rect.js.map +1 -1
  44. package/es/label/symbol.d.ts +3 -5
  45. package/es/label/symbol.js.map +1 -1
  46. package/es/label/type.d.ts +7 -48
  47. package/es/label/type.js.map +1 -1
  48. package/es/link-path/link-path.js +2 -1
  49. package/es/marker/base.js +1 -2
  50. package/es/marker/type.js +1 -1
  51. package/es/pager/index.js +1 -1
  52. package/es/pager/pager.js +1 -1
  53. package/package.json +4 -4
  54. package/cjs/label/arc.d.ts +0 -69
  55. package/cjs/label/arc.js +0 -396
  56. package/cjs/label/arc.js.map +0 -1
  57. package/cjs/label/constant.d.ts +0 -18
  58. package/cjs/label/constant.js +0 -15
  59. package/cjs/label/constant.js.map +0 -1
  60. package/cjs/label/util.d.ts +0 -10
  61. package/cjs/label/util.js +0 -102
  62. package/cjs/label/util.js.map +0 -1
  63. package/es/label/arc.d.ts +0 -69
  64. package/es/label/arc.js +0 -390
  65. package/es/label/arc.js.map +0 -1
  66. package/es/label/constant.d.ts +0 -18
  67. package/es/label/constant.js +0 -36
  68. package/es/label/constant.js.map +0 -1
  69. package/es/label/util.d.ts +0 -10
  70. package/es/label/util.js +0 -89
  71. package/es/label/util.js.map +0 -1
package/cjs/label/util.js DELETED
@@ -1,102 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: !0
5
- }), exports.degrees = exports.checkBoundsOverlap = exports.connectLineRadian = exports.lineCirclePoints = exports.isQuadrantRight = exports.isQuadrantLeft = exports.circlePoint = exports.polarToCartesian = void 0;
6
-
7
- const vutils_1 = require("@visactor/vutils");
8
-
9
- function polarToCartesian(point) {
10
- return point.radius ? {
11
- x: Math.cos(point.angle) * point.radius,
12
- y: Math.sin(point.angle) * point.radius
13
- } : {
14
- x: 0,
15
- y: 0
16
- };
17
- }
18
-
19
- function circlePoint(x0, y0, radius, radian) {
20
- const offset = polarToCartesian({
21
- radius: radius,
22
- angle: radian
23
- });
24
- return {
25
- x: x0 + offset.x,
26
- y: y0 + offset.y
27
- };
28
- }
29
-
30
- function isQuadrantLeft(quadrant) {
31
- return 3 === quadrant || 4 === quadrant;
32
- }
33
-
34
- function isQuadrantRight(quadrant) {
35
- return 1 === quadrant || 2 === quadrant;
36
- }
37
-
38
- function lineCirclePoints(a, b, c, x0, y0, r) {
39
- if (0 === a && 0 === b || r <= 0) return [];
40
- if (0 === a) {
41
- const y1 = -c / b, fd = r ** 2 - (y1 - y0) ** 2;
42
- if (fd < 0) return [];
43
- if (0 === fd) return [ {
44
- x: x0,
45
- y: y1
46
- } ];
47
- return [ {
48
- x: Math.sqrt(fd) + x0,
49
- y: y1
50
- }, {
51
- x: -Math.sqrt(fd) + x0,
52
- y: y1
53
- } ];
54
- }
55
- if (0 === b) {
56
- const x1 = -c / a, fd = r ** 2 - (x1 - x0) ** 2;
57
- if (fd < 0) return [];
58
- if (0 === fd) return [ {
59
- x: x1,
60
- y: y0
61
- } ];
62
- return [ {
63
- x: x1,
64
- y: Math.sqrt(fd) + y0
65
- }, {
66
- x: x1,
67
- y: -Math.sqrt(fd) + y0
68
- } ];
69
- }
70
- const fa = (b / a) ** 2 + 1, fb = 2 * ((c / a + x0) * (b / a) - y0), fd = fb ** 2 - 4 * fa * ((c / a + x0) ** 2 + y0 ** 2 - r ** 2);
71
- if (fd < 0) return [];
72
- const y1 = (-fb + Math.sqrt(fd)) / (2 * fa), y2 = (-fb - Math.sqrt(fd)) / (2 * fa), x1 = -(b * y1 + c) / a;
73
- return 0 === fd ? [ {
74
- x: x1,
75
- y: y1
76
- } ] : [ {
77
- x: x1,
78
- y: y1
79
- }, {
80
- x: -(b * y2 + c) / a,
81
- y: y2
82
- } ];
83
- }
84
-
85
- function connectLineRadian(radius, length) {
86
- return length > 2 * radius ? NaN : 2 * Math.asin(length / 2 / radius);
87
- }
88
-
89
- function checkBoundsOverlap(boundsA, boundsB) {
90
- const {x1: ax1, y1: ay1, x2: ax2, y2: ay2} = boundsA, {x1: bx1, y1: by1, x2: bx2, y2: by2} = boundsB;
91
- return !(ax1 <= bx1 && ax2 <= bx1 || ax1 >= bx2 && ax2 >= bx2 || ay1 <= by1 && ay2 <= by1 || ay1 >= by2 && ay2 >= by2);
92
- }
93
-
94
- exports.polarToCartesian = polarToCartesian, exports.circlePoint = circlePoint,
95
- exports.isQuadrantLeft = isQuadrantLeft, exports.isQuadrantRight = isQuadrantRight,
96
- exports.lineCirclePoints = lineCirclePoints, exports.connectLineRadian = connectLineRadian,
97
- exports.checkBoundsOverlap = checkBoundsOverlap;
98
-
99
- const degrees = angle => (0, vutils_1.isValidNumber)(angle) ? (0, vutils_1.radianToDegree)(angle) : null;
100
-
101
- exports.degrees = degrees;
102
- //# sourceMappingURL=util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["label/util.ts"],"names":[],"mappings":";;;AAEA,6CAAiE;AAOjE,SAAgB,gBAAgB,CAAC,KAAkB;IACjD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;KACvB;IACD,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM;QACvC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,MAAM;KACxC,CAAC;AACJ,CAAC;AARD,4CAQC;AASD,SAAgB,WAAW,CAAC,EAAU,EAAE,EAAU,EAAE,MAAc,EAAE,MAAc;IAChF,MAAM,MAAM,GAAG,gBAAgB,CAAC;QAC9B,MAAM;QACN,KAAK,EAAE,MAAM;KACd,CAAC,CAAC;IACH,OAAO;QACL,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC;QAChB,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC;KACjB,CAAC;AACJ,CAAC;AATD,kCASC;AAED,SAAgB,cAAc,CAAC,QAAkB;IAC/C,OAAO,QAAQ,KAA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G,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;QAC1B,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;QAC1B,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;QAC1B,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,CAC3B,CAAC;AACJ,CAAC;AATD,gDASC;AAEM,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,EAAE;IACxC,IAAI,CAAC,IAAA,sBAAa,EAAC,KAAK,CAAC,EAAE;QACzB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAA,uBAAc,EAAC,KAAK,CAAC,CAAC;AAC/B,CAAC,CAAC;AALW,QAAA,OAAO,WAKlB","file":"util.js","sourcesContent":["import type { IPolarPoint, IPoint, Quadrant } from './type';\nimport type { IBoundsLike } from '@visactor/vutils';\nimport { radianToDegree, isValidNumber } from '@visactor/vutils';\n\n/**\n * 极坐标系 -> 直角坐标系\n * @param point\n * @returns\n */\nexport function polarToCartesian(point: IPolarPoint): IPoint {\n if (!point.radius) {\n return { x: 0, y: 0 };\n }\n return {\n x: Math.cos(point.angle) * point.radius,\n y: Math.sin(point.angle) * point.radius\n };\n}\n\n/**\n * 计算圆弧上的点坐标\n * @param x0 圆心 x 坐标\n * @param y0 圆心 y 坐标\n * @param radius 圆弧半径\n * @param radian 点所在弧度\n */\nexport function circlePoint(x0: number, y0: number, radius: number, radian: number): IPoint {\n const offset = polarToCartesian({\n radius,\n angle: radian\n });\n return {\n x: x0 + offset.x,\n y: y0 + offset.y\n };\n}\n\nexport function isQuadrantLeft(quadrant: Quadrant): boolean {\n return quadrant === 3 || quadrant === 4;\n}\n\nexport function isQuadrantRight(quadrant: Quadrant): boolean {\n return quadrant === 1 || quadrant === 2;\n}\n\n/**\n * 计算直线与圆交点\n * 直线方程:ax + by + c = 0\n * 圆方程:(x - x0)^2 + (y - y0)^2 = r^2\n */\nexport function lineCirclePoints(a: number, b: number, c: number, x0: number, y0: number, r: number): IPoint[] {\n if ((a === 0 && b === 0) || r <= 0) {\n return [];\n }\n if (a === 0) {\n const y1 = -c / b;\n const fy = (y1 - y0) ** 2;\n const fd = r ** 2 - fy;\n if (fd < 0) {\n return [];\n } else if (fd === 0) {\n return [{ x: x0, y: y1 }];\n }\n const x1 = Math.sqrt(fd) + x0;\n const x2 = -Math.sqrt(fd) + x0;\n return [\n { x: x1, y: y1 },\n { x: x2, y: y1 }\n ];\n } else if (b === 0) {\n const x1 = -c / a;\n const fx = (x1 - x0) ** 2;\n const fd = r ** 2 - fx;\n if (fd < 0) {\n return [];\n } else if (fd === 0) {\n return [{ x: x1, y: y0 }];\n }\n const y1 = Math.sqrt(fd) + y0;\n const y2 = -Math.sqrt(fd) + y0;\n return [\n { x: x1, y: y1 },\n { x: x1, y: y2 }\n ];\n }\n const fa = (b / a) ** 2 + 1;\n const fb = 2 * ((c / a + x0) * (b / a) - y0);\n const fc = (c / a + x0) ** 2 + y0 ** 2 - r ** 2;\n const fd = fb ** 2 - 4 * fa * fc;\n if (fd < 0) {\n return [];\n }\n const y1 = (-fb + Math.sqrt(fd)) / (2 * fa);\n const y2 = (-fb - Math.sqrt(fd)) / (2 * fa);\n const x1 = -(b * y1 + c) / a;\n const x2 = -(b * y2 + c) / a;\n if (fd === 0) {\n return [{ x: x1, y: y1 }];\n }\n return [\n { x: x1, y: y1 },\n { x: x2, y: y2 }\n ];\n}\n\n/**\n * 根据圆弧两点连接线长度计算弧度\n * @param radius 圆弧半径\n * @param length 连接线长度\n */\nexport function connectLineRadian(radius: number, length: number) {\n if (length > radius * 2) {\n return NaN;\n }\n return Math.asin(length / 2 / radius) * 2;\n}\n\nexport function checkBoundsOverlap(boundsA: IBoundsLike, boundsB: IBoundsLike): boolean {\n const { x1: ax1, y1: ay1, x2: ax2, y2: ay2 } = boundsA;\n const { x1: bx1, y1: by1, x2: bx2, y2: by2 } = boundsB;\n return !(\n (ax1 <= bx1 && ax2 <= bx1) ||\n (ax1 >= bx2 && ax2 >= bx2) ||\n (ay1 <= by1 && ay2 <= by1) ||\n (ay1 >= by2 && ay2 >= by2)\n );\n}\n\nexport const degrees = (angle?: number) => {\n if (!isValidNumber(angle)) {\n return null;\n }\n return radianToDegree(angle);\n};\n"]}
package/es/label/arc.d.ts DELETED
@@ -1,69 +0,0 @@
1
- import type { IBoundsLike } from '@visactor/vutils';
2
- import { LabelBase } from './base';
3
- import type { ArcLabelAttrs, IPoint, Quadrant } from './type';
4
- import type { BaseLabelAttrs } from './type';
5
- import type { TextAlignType, TextBaselineType } from '@visactor/vrender';
6
- import type { IGraphic } from '@visactor/vrender';
7
- export declare class ArcInfo {
8
- key: string;
9
- refDatum: any;
10
- center: IPoint;
11
- outerCenter: IPoint;
12
- labelSize: {
13
- width: number;
14
- height: number;
15
- };
16
- labelPosition: IPoint;
17
- labelLimit: number;
18
- labelVisible: boolean;
19
- lastLabelY: number;
20
- labelYRange: [number, number];
21
- labelText: string | string[];
22
- pointA: IPoint;
23
- pointB: IPoint;
24
- pointC: IPoint;
25
- quadrant: Quadrant;
26
- radian: number;
27
- middleAngle: number;
28
- k: number;
29
- textAlign: TextAlignType;
30
- textBaseline: TextBaselineType;
31
- angle: number;
32
- constructor(refDatum: any, center: IPoint, outerCenter: IPoint, quadrant: Quadrant, radian: number, middleAngle: number, k: number);
33
- getLabelBounds(): IBoundsLike;
34
- }
35
- export declare class ArcLabel extends LabelBase<ArcLabelAttrs> {
36
- name: string;
37
- static defaultAttributes: Partial<ArcLabelAttrs>;
38
- private _ellipsisWidth;
39
- private _arcLeft;
40
- private _arcRight;
41
- constructor(attributes: ArcLabelAttrs);
42
- protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position: string, offset: number, graphicAttributes: any, textData: any, width: number, height: number, attribute: any): {
43
- x: number;
44
- y: number;
45
- } | undefined;
46
- protected layoutArcLabels(position: BaseLabelAttrs['position'], attribute: any, currentMarks?: IGraphic[]): ArcInfo[];
47
- private _layoutInsideLabels;
48
- private _layoutOutsideLabels;
49
- private _computeX;
50
- private _computeAlignOffset;
51
- private _computeAlign;
52
- private _getFormatLabelText;
53
- private _adjustY;
54
- private _shiftY;
55
- private _findNextVisibleIndex;
56
- private _computePointB;
57
- private _storeY;
58
- private _computeYRange;
59
- private _computeLayoutRadius;
60
- private _findNeighborIndex;
61
- private _twoWayShift;
62
- private _restoreY;
63
- private _checkYRange;
64
- private _coverLabels;
65
- protected computeRadius(r: number, width?: number, height?: number, k?: number): number;
66
- protected computeLayoutRadius(width: number, height: number): number;
67
- private computeLayoutOuterRadius;
68
- private computeDatumRadius;
69
- }
package/es/label/arc.js DELETED
@@ -1,390 +0,0 @@
1
- import { merge } from "@visactor/vutils";
2
-
3
- import { LabelBase } from "./base";
4
-
5
- import { isValidNumber, isNil, isLess, isGreater, isNumberClose as isClose } from "@visactor/vutils";
6
-
7
- import { circlePoint, isQuadrantRight, isQuadrantLeft, lineCirclePoints, connectLineRadian, checkBoundsOverlap } from "./util";
8
-
9
- import { ARC_K, ARC_MIDDLE_ANGLE, ARC_QUADRANT, ARC_RADIAN } from "./constant";
10
-
11
- export class ArcInfo {
12
- constructor(refDatum, center, outerCenter, quadrant, radian, middleAngle, k) {
13
- this.refDatum = refDatum, this.center = center, this.outerCenter = outerCenter,
14
- this.quadrant = quadrant, this.radian = radian, this.middleAngle = middleAngle,
15
- this.k = k, this.labelVisible = !0, this.labelLimit = 0;
16
- }
17
- getLabelBounds() {
18
- return this.labelPosition && this.labelSize ? {
19
- x1: this.labelPosition.x - this.labelSize.width / 2,
20
- y1: this.labelPosition.y - this.labelSize.height / 2,
21
- x2: this.labelPosition.x + this.labelSize.width / 2,
22
- y2: this.labelPosition.y + this.labelSize.height / 2
23
- } : {
24
- x1: 0,
25
- x2: 0,
26
- y1: 0,
27
- y2: 0
28
- };
29
- }
30
- }
31
-
32
- export class ArcLabel extends LabelBase {
33
- constructor(attributes) {
34
- super(merge({}, ArcLabel.defaultAttributes, attributes)), this.name = "arc-label",
35
- this._ellipsisWidth = 0, this._arcLeft = new Map, this._arcRight = new Map;
36
- }
37
- labeling(textBounds, graphicBounds, position = "outside", offset = 0, graphicAttributes, textData, width, height, attribute) {
38
- var _a;
39
- if (!textBounds || !graphicBounds) return;
40
- const radiusRatio = this.computeLayoutOuterRadius(graphicAttributes.outerRadius, width, height), radius = this.computeRadius(radiusRatio, width, height), center = null !== (_a = attribute.center) && void 0 !== _a ? _a : {
41
- x: 0,
42
- y: 0
43
- }, item = textData, arcMiddle = circlePoint(center.x, center.y, radius * item[ARC_K], item[ARC_MIDDLE_ANGLE]), outerArcMiddle = circlePoint(center.x, center.y, radius + attribute.line.line1MinLength, item[ARC_MIDDLE_ANGLE]), arc = new ArcInfo(item, arcMiddle, outerArcMiddle, item[ARC_QUADRANT], item[ARC_RADIAN], item[ARC_MIDDLE_ANGLE], item[ARC_K]);
44
- arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(2 * center.x, 2 * center.y, graphicAttributes.outerRadius), arc.middleAngle),
45
- arc.labelSize = {
46
- width: textBounds.x2 - textBounds.x1,
47
- height: textBounds.y2 - textBounds.y1
48
- }, isQuadrantRight(arc.quadrant) ? (arc.textAlign = "left", arc.textBaseline = "bottom",
49
- this._arcRight.set(arc.refDatum, arc)) : isQuadrantLeft(arc.quadrant) && (arc.textAlign = "right",
50
- arc.textBaseline = "bottom", this._arcLeft.set(arc.refDatum, arc));
51
- }
52
- layoutArcLabels(position, attribute, currentMarks) {
53
- const leftArcs = Array.from(this._arcLeft.values()), rightArcs = Array.from(this._arcRight.values()), arcs = [];
54
- return "inside" === position ? (arcs.push(...this._layoutInsideLabels(rightArcs, attribute, currentMarks)),
55
- arcs.push(...this._layoutInsideLabels(leftArcs, attribute, currentMarks))) : (arcs.push(...this._layoutOutsideLabels(rightArcs, attribute, currentMarks)),
56
- arcs.push(...this._layoutOutsideLabels(leftArcs, attribute, currentMarks))), arcs;
57
- }
58
- _layoutInsideLabels(arcs, attribute, currentMarks) {
59
- var _a;
60
- const center = null !== (_a = attribute.center) && void 0 !== _a ? _a : {
61
- x: 0,
62
- y: 0
63
- }, innerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.innerRadius, attribute.width, attribute.height), outerRadiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height), labelConfig = attribute, spaceWidth = labelConfig.spaceWidth;
64
- return arcs.forEach((arc => {
65
- const {labelSize: labelSize, radian: radian} = arc, innerRadius = this.computeRadius(innerRadiusRatio, attribute.width, attribute.height, 1), outerRadius = this.computeRadius(outerRadiusRatio, attribute.width, attribute.height, 1);
66
- let limit;
67
- if (radian < connectLineRadian(outerRadius, labelSize.height)) limit = 0; else {
68
- let minRadius;
69
- minRadius = radian >= Math.PI ? innerRadius : Math.max(innerRadius, labelSize.height / 2 / Math.tan(radian / 2)),
70
- limit = outerRadius - minRadius - spaceWidth;
71
- }
72
- !0 !== (null == labelConfig ? void 0 : labelConfig.rotate) && (limit = outerRadius - spaceWidth);
73
- const text = this._getFormatLabelText(arc.refDatum, limit);
74
- arc.labelText = text;
75
- const labelWidth = Math.min(limit, arc.labelSize.width), align = this._computeAlign(arc, attribute), labelRadius = outerRadius - spaceWidth - ("left" === align ? labelWidth : "right" === align ? 0 : labelWidth / 2);
76
- arc.labelPosition = circlePoint(center.x, center.y, labelRadius, arc.middleAngle),
77
- arc.labelLimit = labelWidth, isGreater(labelWidth, 0) || (arc.labelVisible = !1),
78
- arc.textAlign = "center", arc.textBaseline = "middle", arc.angle = arc.middleAngle;
79
- })), arcs;
80
- }
81
- _layoutOutsideLabels(arcs, attribute, currentMarks) {
82
- var _a;
83
- const height = 2 * attribute.center.y, line2MinLength = attribute.line.line2MinLength, labelLayout = attribute.layout, spaceWidth = attribute.spaceWidth;
84
- if (arcs.forEach((arc => {
85
- const direction = isQuadrantLeft(arc.quadrant) ? -1 : 1;
86
- arc.labelPosition = {
87
- x: arc.outerCenter.x + direction * (arc.labelSize.width / 2 + line2MinLength + spaceWidth),
88
- y: arc.outerCenter.y
89
- };
90
- })), arcs.sort(((a, b) => a.labelPosition.y - b.labelPosition.y)), !1 !== attribute.coverEnable || "none" === labelLayout.strategy) {
91
- for (const arc of arcs) {
92
- const {labelPosition: labelPosition, labelSize: labelSize} = arc;
93
- arc.labelLimit = labelSize.width, arc.pointB = isQuadrantLeft(arc.quadrant) ? {
94
- x: labelPosition.x + labelSize.width / 2 + line2MinLength + spaceWidth,
95
- y: labelPosition.y
96
- } : {
97
- x: labelPosition.x - labelSize.width / 2 - line2MinLength - spaceWidth,
98
- y: labelPosition.y
99
- }, this._computeX(arc, attribute, currentMarks);
100
- }
101
- !1 === attribute.coverEnable && "none" === labelLayout.strategy && this._coverLabels(arcs);
102
- } else {
103
- const maxLabels = height / ((null === (_a = attribute.textStyle) || void 0 === _a ? void 0 : _a.fontSize) || 16);
104
- this._adjustY(arcs, maxLabels, attribute, currentMarks);
105
- const {minY: minY, maxY: maxY} = arcs.reduce(((yInfo, arc) => {
106
- const {y1: y1, y2: y2} = arc.getLabelBounds();
107
- return yInfo.minY = Math.max(0, Math.min(y1, yInfo.minY)), yInfo.maxY = Math.min(height, Math.max(y2, yInfo.maxY)),
108
- yInfo;
109
- }), {
110
- minY: 1 / 0,
111
- maxY: -1 / 0
112
- }), halfY = Math.max(Math.abs(height / 2 - minY), Math.abs(maxY - height / 2)), r = this._computeLayoutRadius(halfY, attribute, currentMarks);
113
- for (const arc of arcs) this._computePointB(arc, r, attribute, currentMarks), this._computeX(arc, attribute, currentMarks);
114
- }
115
- const width = 2 * attribute.center.x;
116
- return arcs.forEach((arc => {
117
- arc.labelVisible && (isLess(arc.pointB.x, line2MinLength + spaceWidth) || isGreater(arc.pointB.x, width - line2MinLength - spaceWidth)) && (arc.labelVisible = !1),
118
- arc.angle = 0;
119
- })), arcs;
120
- }
121
- _computeX(arc, attribute, currentMarks) {
122
- var _a, _b;
123
- const center = null !== (_a = attribute.center) && void 0 !== _a ? _a : {
124
- x: 0,
125
- y: 0
126
- }, plotLayout_width = 2 * attribute.center.x, radiusRatio = (attribute.center.y,
127
- this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height)), line1MinLength = attribute.line.line1MinLength, line2MinLength = attribute.line.line2MinLength, labelLayoutAlign = null === (_b = attribute.layout) || void 0 === _b ? void 0 : _b.align, spaceWidth = attribute.spaceWidth, align = this._computeAlign(arc, attribute), {labelPosition: labelPosition, quadrant: quadrant, pointB: pointB} = arc;
128
- isValidNumber(pointB.x * pointB.y) || (arc.pointC = {
129
- x: NaN,
130
- y: NaN
131
- }, labelPosition.x = NaN, arc.labelLimit = 0);
132
- const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height), flag = isQuadrantLeft(quadrant) ? -1 : 1;
133
- let cx = 0;
134
- let limit = (flag > 0 ? plotLayout_width - pointB.x : pointB.x) - line2MinLength - spaceWidth;
135
- "labelLine" === labelLayoutAlign && (cx = (radius + line1MinLength + line2MinLength) * flag + center.x,
136
- limit = (flag > 0 ? plotLayout_width - cx : cx) - spaceWidth);
137
- const text = this._getFormatLabelText(arc.refDatum, limit);
138
- arc.labelText = text;
139
- let labelWidth = Math.min(limit, arc.labelSize.width);
140
- switch (labelLayoutAlign) {
141
- case "labelLine":
142
- break;
143
-
144
- case "edge":
145
- cx = flag > 0 ? plotLayout_width - labelWidth - spaceWidth : labelWidth + spaceWidth;
146
- break;
147
-
148
- default:
149
- cx = pointB.x + flag * line2MinLength;
150
- }
151
- if (labelWidth = Math.max(this._ellipsisWidth, labelWidth), arc.pointC = {
152
- x: cx,
153
- y: labelPosition.y
154
- }, "edge" === labelLayoutAlign) {
155
- const alignOffset = this._computeAlignOffset(align, labelWidth, -flag);
156
- labelPosition.x = flag > 0 ? plotLayout_width + alignOffset : alignOffset;
157
- } else {
158
- const alignOffset = this._computeAlignOffset(align, labelWidth, flag);
159
- labelPosition.x = cx + alignOffset + flag * spaceWidth;
160
- }
161
- arc.labelLimit = labelWidth;
162
- }
163
- _computeAlignOffset(align, labelWidth, alignFlag) {
164
- switch (align) {
165
- case "left":
166
- return alignFlag < 0 ? -labelWidth : 0;
167
-
168
- case "right":
169
- return alignFlag < 0 ? 0 : labelWidth;
170
-
171
- default:
172
- return labelWidth / 2 * alignFlag;
173
- }
174
- }
175
- _computeAlign(arc, attribute) {
176
- var _a, _b, _c, _d, _e, _f;
177
- const labelConfig = attribute, textAlign = null !== (_b = null === (_a = labelConfig.textStyle) || void 0 === _a ? void 0 : _a.textAlign) && void 0 !== _b ? _b : null === (_c = labelConfig.textStyle) || void 0 === _c ? void 0 : _c.align, layoutAlign = null !== (_e = null === (_d = labelConfig.layout) || void 0 === _d ? void 0 : _d.textAlign) && void 0 !== _e ? _e : null === (_f = labelConfig.layout) || void 0 === _f ? void 0 : _f.align;
178
- return "inside" !== labelConfig.position ? isNil(textAlign) || "auto" === textAlign ? "edge" === layoutAlign ? isQuadrantLeft(arc.quadrant) ? "left" : "right" : isQuadrantLeft(arc.quadrant) ? "right" : "left" : textAlign : isNil(textAlign) || "auto" === textAlign ? "center" : textAlign;
179
- }
180
- _getFormatLabelText(value, limit) {
181
- return value.text;
182
- }
183
- _adjustY(arcs, maxLabels, attribute, currentMarks) {
184
- attribute.center.x;
185
- const plotRect_height = 2 * attribute.center.y, labelLayout = attribute.layout;
186
- if ("vertical" === labelLayout.strategy) {
187
- let delta, lastY = 0;
188
- const len = arcs.length;
189
- if (len <= 0) return;
190
- for (let i = 0; i < len; i++) {
191
- const {y1: y1} = arcs[i].getLabelBounds();
192
- if (delta = y1 - lastY, isLess(delta, 0)) {
193
- const index = this._shiftY(arcs, i, len - 1, -delta);
194
- this._shiftY(arcs, index, 0, delta / 2);
195
- }
196
- const {y2: y2} = arcs[i].getLabelBounds();
197
- lastY = y2;
198
- }
199
- const {y1: firstY1} = arcs[0].getLabelBounds();
200
- delta = firstY1 - 0, isLess(delta, 0) && this._shiftY(arcs, 0, len - 1, -delta);
201
- for (let i = arcs.length - 1; i >= 0 && arcs[i].getLabelBounds().y2 > plotRect_height; i--) arcs[i].labelVisible = !1;
202
- } else if ("none" !== labelLayout.strategy) {
203
- const priorityArcs = arcs.map(((arc, i) => ({
204
- arc: arc,
205
- originIndex: i,
206
- priorityIndex: 0
207
- })));
208
- priorityArcs.sort(((a, b) => b.arc.radian - a.arc.radian)), priorityArcs.forEach(((priorityArc, i) => {
209
- priorityArc.priorityIndex = i, priorityArc.arc.labelVisible = !1;
210
- }));
211
- let topLabelIndex = 1 / 0, bottomLabelIndex = -1 / 0;
212
- for (let i = 0; i < maxLabels && i < arcs.length; i++) {
213
- this._storeY(arcs);
214
- const arc = priorityArcs[i].arc;
215
- this._computeYRange(arc, attribute, currentMarks), arc.labelVisible = !0;
216
- const curY = arc.labelPosition.y, {lastIndex: lastIndex, nextIndex: nextIndex} = this._findNeighborIndex(arcs, priorityArcs[i]), lastArc = arcs[lastIndex], nextArc = arcs[nextIndex];
217
- if (-1 === lastIndex && -1 !== nextIndex) {
218
- const nextY = nextArc.labelPosition.y;
219
- curY > nextY ? arc.labelPosition.y = nextY - nextArc.labelSize.height / 2 - arc.labelSize.height / 2 : this._twoWayShift(arcs, arc, nextArc, nextIndex);
220
- } else if (-1 !== lastIndex && -1 === nextIndex) {
221
- const lastY = lastArc.labelPosition.y;
222
- curY < lastY ? arc.labelPosition.y = lastY + lastArc.labelSize.height / 2 + arc.labelSize.height / 2 : this._twoWayShift(arcs, lastArc, arc, priorityArcs[i].originIndex);
223
- } else if (-1 !== lastIndex && -1 !== nextIndex) {
224
- const lastY = lastArc.labelPosition.y, nextY = nextArc.labelPosition.y;
225
- curY > nextY ? (arc.labelPosition.y = nextY - nextArc.labelSize.height / 2 - arc.labelSize.height / 2,
226
- this._twoWayShift(arcs, lastArc, arc, priorityArcs[i].originIndex)) : curY < lastY ? (arc.labelPosition.y = lastY + lastArc.labelSize.height / 2 + arc.labelSize.height / 2,
227
- this._twoWayShift(arcs, arc, nextArc, nextIndex)) : (this._twoWayShift(arcs, lastArc, arc, priorityArcs[i].originIndex),
228
- this._twoWayShift(arcs, arc, nextArc, nextIndex));
229
- }
230
- const nextTopIndex = Math.min(topLabelIndex, priorityArcs[i].originIndex), nextBottomIndex = Math.max(bottomLabelIndex, priorityArcs[i].originIndex);
231
- let delta;
232
- if (delta = arcs[nextBottomIndex].getLabelBounds().y2 - plotRect_height, isGreater(delta, 0) && this._shiftY(arcs, nextBottomIndex, 0, -delta),
233
- delta = arcs[nextTopIndex].getLabelBounds().y1 - 0, isLess(delta, 0) && this._shiftY(arcs, nextTopIndex, arcs.length - 1, -delta),
234
- delta = arcs[nextBottomIndex].getLabelBounds().y2 - plotRect_height, isGreater(delta, 0)) {
235
- arc.labelVisible = !1, this._restoreY(arcs);
236
- break;
237
- }
238
- labelLayout.tangentConstraint && !this._checkYRange(arcs) ? (arc.labelVisible = !1,
239
- this._restoreY(arcs)) : (topLabelIndex = nextTopIndex, bottomLabelIndex = nextBottomIndex);
240
- }
241
- }
242
- }
243
- _shiftY(arcs, start, end, delta) {
244
- const direction = start < end ? 1 : -1;
245
- let index = start;
246
- for (;-1 !== index; ) {
247
- arcs[index].labelPosition.y += delta;
248
- const nextIndex = this._findNextVisibleIndex(arcs, index, end, direction);
249
- if (nextIndex >= 0 && nextIndex < arcs.length) {
250
- const {y1: curY1, y2: curY2} = arcs[index].getLabelBounds(), {y1: nextY1, y2: nextY2} = arcs[nextIndex].getLabelBounds();
251
- if (direction > 0 && curY2 < nextY1 || direction < 0 && curY1 > nextY2) return index;
252
- }
253
- index = nextIndex;
254
- }
255
- return end;
256
- }
257
- _findNextVisibleIndex(arcs, start, end, direction) {
258
- const diff = (end - start) * direction;
259
- for (let i = 1; i <= diff; i++) {
260
- const index = start + i * direction;
261
- if (arcs[index].labelVisible) return index;
262
- }
263
- return -1;
264
- }
265
- _computePointB(arc, r, attribute, currentMarks) {
266
- var _a;
267
- const labelConfig = attribute, radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height), line1MinLength = labelConfig.line.line1MinLength;
268
- if ("none" === labelConfig.layout.strategy) arc.pointB = {
269
- x: arc.outerCenter.x,
270
- y: arc.outerCenter.y
271
- }; else {
272
- const center = null !== (_a = attribute.center) && void 0 !== _a ? _a : {
273
- x: 0,
274
- y: 0
275
- }, radius = this.computeRadius(radiusRatio, attribute.width, attribute.height), {labelPosition: labelPosition, quadrant: quadrant} = arc, rd = r - Math.max(radius + line1MinLength, currentMarks[0].attribute.outerRadius), x = Math.sqrt(r ** 2 - Math.abs(center.y - labelPosition.y) ** 2) - rd;
276
- isValidNumber(x) ? arc.pointB = {
277
- x: center.x + x * (isQuadrantLeft(quadrant) ? -1 : 1),
278
- y: labelPosition.y
279
- } : arc.pointB = {
280
- x: NaN,
281
- y: NaN
282
- };
283
- }
284
- }
285
- _storeY(arcs) {
286
- for (const arc of arcs) arc.labelVisible && (arc.lastLabelY = arc.labelPosition.y);
287
- }
288
- _computeYRange(arc, attribute, currentMarks) {
289
- const plotRect = {
290
- width: 2 * attribute.center.x,
291
- height: 2 * attribute.center.y
292
- }, radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height), line1MinLength = attribute.line.line1MinLength, {width: width, height: height} = plotRect, radius = this.computeRadius(radiusRatio, attribute.width, attribute.height), r = this._computeLayoutRadius(height / 2, attribute, currentMarks), cx = Math.abs(arc.center.x - width / 2), cy = arc.center.y - height / 2;
293
- let a, b, c;
294
- if (isClose(width / 2, cx)) a = 0, b = 1, c = -cy; else if (isClose(height / 2, cy)) a = 1,
295
- b = 0, c = -cx; else {
296
- const k = -1 / (cy / cx);
297
- a = k, b = -1, c = cy - k * cx;
298
- }
299
- const points = lineCirclePoints(a, b, c, line1MinLength + radius - r, 0, r);
300
- if (points.length < 2) return;
301
- let min, max;
302
- points[0].x > points[1].x && points.reverse(), points[0].x < 0 ? isClose(points[0].y, points[1].y) ? Math.abs(arc.middleAngle) < Math.PI / 2 ? (min = 0,
303
- max = points[1].y + height / 2) : (min = points[1].y + height / 2, max = height) : points[0].y < points[1].y ? (min = 0,
304
- max = points[1].y + height / 2) : (min = points[1].y + height / 2, max = plotRect.height) : (min = Math.min(points[0].y, points[1].y) + height / 2,
305
- max = Math.max(points[0].y, points[1].y) + height / 2), arc.labelYRange = [ min, max ];
306
- }
307
- _computeLayoutRadius(halfYLength, attribute, currentMarks) {
308
- const labelConfig = attribute, layoutArcGap = labelConfig.layoutArcGap, line1MinLength = labelConfig.line.line1MinLength, radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height), outerR = this.computeRadius(radiusRatio, attribute.width, attribute.height) + line1MinLength, a = outerR - layoutArcGap;
309
- return Math.max((a ** 2 + halfYLength ** 2) / (2 * a), outerR);
310
- }
311
- _findNeighborIndex(arcs, priorityArc) {
312
- const index = priorityArc.originIndex;
313
- let lastIndex = -1, nextIndex = -1;
314
- for (let i = index - 1; i >= 0; i--) if (arcs[i].labelVisible) {
315
- lastIndex = i;
316
- break;
317
- }
318
- for (let i = index + 1; i < arcs.length; i++) if (arcs[i].labelVisible) {
319
- nextIndex = i;
320
- break;
321
- }
322
- return {
323
- lastIndex: lastIndex,
324
- nextIndex: nextIndex
325
- };
326
- }
327
- _twoWayShift(arcs, lastArc, nextArc, nextIndex) {
328
- const delta = nextArc.getLabelBounds().y1 - lastArc.getLabelBounds().y2;
329
- if (isLess(delta, 0)) {
330
- const i = this._shiftY(arcs, nextIndex, arcs.length - 1, -delta);
331
- this._shiftY(arcs, i, 0, delta / 2);
332
- }
333
- }
334
- _restoreY(arcs) {
335
- for (const arc of arcs) arc.labelVisible && (arc.labelPosition.y = arc.lastLabelY);
336
- }
337
- _checkYRange(arcs) {
338
- for (const arc of arcs) {
339
- const {labelYRange: labelYRange, labelPosition: labelPosition} = arc;
340
- if (arc.labelVisible && labelYRange && (isLess(labelPosition.y, labelYRange[0]) || isGreater(labelPosition.y, labelYRange[1]))) return !1;
341
- }
342
- return !0;
343
- }
344
- _coverLabels(arcs) {
345
- if (arcs.length <= 1) return;
346
- let lastBounds = arcs[0].getLabelBounds();
347
- for (let i = 1; i < arcs.length; i++) {
348
- const bounds = arcs[i].getLabelBounds();
349
- checkBoundsOverlap(lastBounds, bounds) ? arcs[i].labelVisible = !1 : lastBounds = bounds;
350
- }
351
- }
352
- computeRadius(r, width, height, k) {
353
- return this.computeLayoutRadius(width || 0, height || 0) * r * (isNil(k) ? 1 : k);
354
- }
355
- computeLayoutRadius(width, height) {
356
- return Math.min(width / 2, height / 2);
357
- }
358
- computeLayoutOuterRadius(r, width, height) {
359
- return r / (Math.min(width, height) / 2);
360
- }
361
- computeDatumRadius(width, height, outerRadius) {
362
- const outerRadiusRatio = this.computeLayoutOuterRadius(outerRadius, width, height);
363
- return this.computeLayoutRadius(width || 0, height || 0) * outerRadiusRatio;
364
- }
365
- }
366
-
367
- ArcLabel.defaultAttributes = {
368
- coverEnable: !1,
369
- spaceWidth: 5,
370
- layoutArcGap: 6,
371
- textStyle: {
372
- visible: !0,
373
- fontSize: 14,
374
- fontWeight: "normal",
375
- fillOpacity: 1
376
- },
377
- position: "outside",
378
- offset: 0,
379
- line: {
380
- visible: !0,
381
- line1MinLength: 20,
382
- line2MinLength: 10
383
- },
384
- layout: {
385
- align: "arc",
386
- strategy: "priority",
387
- tangentConstraint: !0
388
- }
389
- };
390
- //# sourceMappingURL=arc.js.map