@visactor/vrender-components 0.14.3 → 0.14.4

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 (59) hide show
  1. package/cjs/axis/base.d.ts +4 -0
  2. package/cjs/axis/base.js +3 -5
  3. package/cjs/axis/base.js.map +1 -1
  4. package/cjs/axis/circle.d.ts +5 -1
  5. package/cjs/axis/circle.js +6 -0
  6. package/cjs/axis/circle.js.map +1 -1
  7. package/cjs/axis/line.d.ts +5 -0
  8. package/cjs/axis/line.js +10 -3
  9. package/cjs/axis/line.js.map +1 -1
  10. package/cjs/axis/overlap/auto-rotate.d.ts +9 -1
  11. package/cjs/axis/overlap/auto-rotate.js +41 -30
  12. package/cjs/axis/overlap/auto-rotate.js.map +1 -1
  13. package/cjs/index.d.ts +1 -1
  14. package/cjs/index.js +1 -1
  15. package/cjs/index.js.map +1 -1
  16. package/cjs/label/arc.d.ts +4 -9
  17. package/cjs/label/arc.js +56 -48
  18. package/cjs/label/arc.js.map +1 -1
  19. package/cjs/label/base.d.ts +3 -3
  20. package/cjs/label/base.js +61 -44
  21. package/cjs/label/base.js.map +1 -1
  22. package/cjs/label/type.d.ts +7 -1
  23. package/cjs/label/type.js.map +1 -1
  24. package/cjs/legend/discrete/discrete.js +11 -6
  25. package/cjs/legend/discrete/discrete.js.map +1 -1
  26. package/cjs/util/labelSmartInvert.d.ts +2 -1
  27. package/cjs/util/labelSmartInvert.js +2 -2
  28. package/cjs/util/labelSmartInvert.js.map +1 -1
  29. package/dist/index.js +205 -153
  30. package/dist/index.min.js +1 -1
  31. package/es/axis/base.d.ts +4 -0
  32. package/es/axis/base.js +3 -5
  33. package/es/axis/base.js.map +1 -1
  34. package/es/axis/circle.d.ts +5 -1
  35. package/es/axis/circle.js +6 -0
  36. package/es/axis/circle.js.map +1 -1
  37. package/es/axis/line.d.ts +5 -0
  38. package/es/axis/line.js +11 -3
  39. package/es/axis/line.js.map +1 -1
  40. package/es/axis/overlap/auto-rotate.d.ts +9 -1
  41. package/es/axis/overlap/auto-rotate.js +38 -28
  42. package/es/axis/overlap/auto-rotate.js.map +1 -1
  43. package/es/index.d.ts +1 -1
  44. package/es/index.js +1 -1
  45. package/es/index.js.map +1 -1
  46. package/es/label/arc.d.ts +4 -9
  47. package/es/label/arc.js +37 -32
  48. package/es/label/arc.js.map +1 -1
  49. package/es/label/base.d.ts +3 -3
  50. package/es/label/base.js +59 -46
  51. package/es/label/base.js.map +1 -1
  52. package/es/label/type.d.ts +7 -1
  53. package/es/label/type.js.map +1 -1
  54. package/es/legend/discrete/discrete.js +11 -6
  55. package/es/legend/discrete/discrete.js.map +1 -1
  56. package/es/util/labelSmartInvert.d.ts +2 -1
  57. package/es/util/labelSmartInvert.js +1 -1
  58. package/es/util/labelSmartInvert.js.map +1 -1
  59. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import type { IText } from '@visactor/vrender';
1
+ import type { IText, TextAlignType, TextBaselineType } from '@visactor/vrender';
2
2
  type RotateConfig = {
3
3
  orient: string;
4
4
  labelRotateAngle?: number[];
@@ -6,4 +6,12 @@ type RotateConfig = {
6
6
  export declare function autoRotate(items: IText[], rotateConfig: RotateConfig): void;
7
7
  export declare function rotateYAxis(orient: string, items: IText[]): void;
8
8
  export declare function rotateXAxis(orient: string, items: IText[]): void;
9
+ export declare function getXAxisLabelAlign(orient: string, angle?: number): {
10
+ textAlign: TextAlignType;
11
+ textBaseline: TextBaselineType;
12
+ };
13
+ export declare function getYAxisLabelAlign(orient: string, angle?: number): {
14
+ textAlign: TextAlignType;
15
+ textBaseline: TextBaselineType;
16
+ };
9
17
  export {};
@@ -55,41 +55,51 @@ function genRotateBounds(items) {
55
55
  }));
56
56
  }
57
57
 
58
+ function clampAngle(angle = 0) {
59
+ if (angle < 0) for (;angle < 0; ) angle += 2 * Math.PI;
60
+ if (angle > 0) for (;angle >= 2 * Math.PI; ) angle -= 2 * Math.PI;
61
+ return angle;
62
+ }
63
+
58
64
  export function rotateYAxis(orient, items) {
59
- let align = [ "right", "right", "center", "left", "center", "left", "center", "right", "right" ], baseline = [ "middle", "middle", "top", "top", "middle", "middle", "bottom", "bottom", "middle" ];
60
- "right" === orient && (align = [ "left", "right", "right", "right", "left", "left", "left", "left", "right" ],
61
- baseline = [ "middle", "bottom", "middle", "top", "top", "top", "middle", "bottom", "bottom" ]),
62
65
  items.forEach(((item, i) => {
63
- let angle = item.attribute.angle || 0;
64
- if (angle < 0) for (;angle < 0; ) angle += 2 * Math.PI;
65
- if (angle > 0) for (;angle >= 2 * Math.PI; ) angle -= 2 * Math.PI;
66
- const step = angle / (.5 * Math.PI);
67
- let index;
68
- index = step === Math.floor(step) ? 2 * Math.floor(step) : 2 * Math.floor(step) + 1,
69
- item.setAttributes({
70
- textAlign: align[index],
71
- textBaseline: baseline[index],
72
- angle: angle
73
- });
66
+ item.setAttributes(Object.assign(Object.assign({}, getYAxisLabelAlign(orient, item.attribute.angle)), {
67
+ angle: clampAngle(item.attribute.angle)
68
+ }));
74
69
  }));
75
70
  }
76
71
 
77
72
  export function rotateXAxis(orient, items) {
78
- let align = [ "center", "left", "left", "left", "center", "right", "right", "right", "left" ], baseline = [ "top", "top", "middle", "bottom", "bottom", "bottom", "middle", "top", "top" ];
79
- "top" === orient && (align = [ "center", "right", "right", "right", "center", "left", "left", "left", "right" ],
80
- baseline = [ "bottom", "bottom", "middle", "top", "top", "top", "middle", "bottom", "bottom" ]),
81
73
  items.forEach((item => {
82
- let angle = item.attribute.angle || 0;
83
- if (angle < 0) for (;angle < 0; ) angle += 2 * Math.PI;
84
- if (angle > 0) for (;angle >= 2 * Math.PI; ) angle -= 2 * Math.PI;
85
- const step = angle / (.5 * Math.PI);
86
- let index;
87
- index = step === Math.floor(step) ? 2 * Math.floor(step) : 2 * Math.floor(step) + 1,
88
- item.setAttributes({
89
- textAlign: align[index],
90
- textBaseline: baseline[index],
91
- angle: angle
92
- });
74
+ item.setAttributes(Object.assign(Object.assign({}, getXAxisLabelAlign(orient, item.attribute.angle)), {
75
+ angle: clampAngle(item.attribute.angle)
76
+ }));
93
77
  }));
94
78
  }
79
+
80
+ export function getXAxisLabelAlign(orient, angle = 0) {
81
+ let align = [ "center", "left", "left", "left", "center", "right", "right", "right", "left" ], baseline = [ "top", "top", "middle", "bottom", "bottom", "bottom", "middle", "top", "top" ];
82
+ "top" === orient && (align = [ "center", "right", "right", "right", "center", "left", "left", "left", "right" ],
83
+ baseline = [ "bottom", "bottom", "middle", "top", "top", "top", "middle", "bottom", "bottom" ]);
84
+ const step = (angle = clampAngle(angle)) / (.5 * Math.PI);
85
+ let index;
86
+ return index = step === Math.floor(step) ? 2 * Math.floor(step) : 2 * Math.floor(step) + 1,
87
+ {
88
+ textAlign: align[index],
89
+ textBaseline: baseline[index]
90
+ };
91
+ }
92
+
93
+ export function getYAxisLabelAlign(orient, angle = 0) {
94
+ let align = [ "right", "right", "center", "left", "center", "left", "center", "right", "right" ], baseline = [ "middle", "middle", "top", "top", "middle", "middle", "bottom", "bottom", "middle" ];
95
+ "right" === orient && (align = [ "left", "right", "right", "right", "left", "left", "left", "left", "right" ],
96
+ baseline = [ "middle", "bottom", "middle", "top", "top", "top", "middle", "bottom", "bottom" ]);
97
+ const step = (angle = clampAngle(angle)) / (.5 * Math.PI);
98
+ let index;
99
+ return index = step === Math.floor(step) ? 2 * Math.floor(step) : 2 * Math.floor(step) + 1,
100
+ {
101
+ textAlign: align[index],
102
+ textBaseline: baseline[index]
103
+ };
104
+ }
95
105
  //# sourceMappingURL=auto-rotate.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["axis/overlap/auto-rotate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAalF,MAAM,UAAU,UAAU,CAAC,KAAc,EAAE,YAA0B;IACnE,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO;KACR;IAED,MAAM,EAAE,MAAM,EAAE,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AC,EAAE;YAC7B,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC9B;aAAM;YACL,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAClC;QACD,IAAI,CAAC,aAAa,CAAC;YACjB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAkB;YACxC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAqB;YACjD,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","file":"auto-rotate.js","sourcesContent":["/**\n * @description 坐标轴标签自动旋转\n */\nimport type { IText, TextAlignType, TextBaselineType } from '@visactor/vrender';\nimport { degreeToRadian, isEmpty, isRotateAABBIntersect } from '@visactor/vutils';\n\ntype RotateConfig = {\n /**\n * 坐标轴的显示位置\n */\n orient: string;\n /**\n * 自动旋转的可选角度\n */\n labelRotateAngle?: number[];\n};\n\nexport function autoRotate(items: IText[], rotateConfig: RotateConfig) {\n if (isEmpty(items)) {\n return;\n }\n\n const { orient, labelRotateAngle = [0, 45, 90] } = rotateConfig;\n if (labelRotateAngle.length === 0 || items.some(item => !!item.attribute.angle)) {\n return;\n }\n\n let i = 0;\n let n = 0;\n if (labelRotateAngle && labelRotateAngle.length > 0) {\n n = labelRotateAngle.length;\n }\n\n while (i < n) {\n const angle = labelRotateAngle[i++];\n items.forEach(item => {\n // item.angle = angle;\n item.attribute.angle = degreeToRadian(angle);\n });\n tryRotate(orient, items);\n if (!hasIntersect(items)) {\n break;\n }\n }\n}\n\nfunction hasIntersect(items: IText[]): boolean {\n for (let i = 1; i < items.length; i++) {\n if (itemIntersect(items[i - 1], items[i])) {\n return true;\n }\n }\n return false;\n}\n\nfunction itemIntersect(item1: IText, item2: IText) {\n return isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true);\n}\n\nfunction tryRotate(orient: string, items: IText[]) {\n // 针对 top bottom轴的自动旋转逻辑\n if (orient === 'bottom' || orient === 'top') {\n rotateXAxis(orient, items);\n }\n if (orient === 'left' || orient === 'right') {\n rotateYAxis(orient, items);\n }\n // 先旋转,再计算这个limit,避免算limit后发现不需要旋转,导致莫名的水平limit\n genRotateBounds(items);\n}\n\nfunction rotate(x: number, y: number, deg: number, originX: number, originY: number) {\n return {\n x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,\n y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY\n };\n}\n\n// 计算水平情况下的包围盒\nfunction genNormalBounds(item: IText) {\n const bounds = item.AABBBounds;\n\n return {\n x1: bounds.x1,\n x2: bounds.x2,\n y1: bounds.y1,\n y2: bounds.y2,\n centerX: item.attribute.x,\n centerY: item.attribute.y,\n angle: item.attribute.angle\n };\n}\n\nfunction genRotateBounds(items: IText[]) {\n items.forEach(item => {\n // 计算水平情况下的包围盒\n const bounds = genNormalBounds(item);\n // 旋转\n const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);\n const deltaX = rotatedCenter.x - bounds.centerX;\n const deltaY = rotatedCenter.y - bounds.centerY;\n bounds.x1 += deltaX;\n bounds.x2 += deltaX;\n bounds.y1 += deltaY;\n bounds.y2 += deltaY;\n bounds.centerX += deltaX;\n bounds.centerY += deltaY;\n item.rotatedBounds = bounds;\n });\n}\n\nexport function rotateYAxis(orient: string, items: IText[]) {\n // 0, 0-90, 90, 90-180, 180, 180-270, 270, 270-360, 360\n let align = ['right', 'right', 'center', 'left', 'center', 'left', 'center', 'right', 'right'];\n let baseline = ['middle', 'middle', 'top', 'top', 'middle', 'middle', 'bottom', 'bottom', 'middle'];\n\n if (orient === 'right') {\n // 0, 0-90, 90, 90-180, 180, 180-270, 270, 270-360, 360\n align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];\n baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];\n }\n // 由于左右轴会裁切,所以上下两个label需要额外处理,做tighten处理\n items.forEach((item, i) => {\n let angle = item.attribute.angle || 0;\n if (angle < 0) {\n while (angle < 0) {\n angle += Math.PI * 2;\n }\n }\n if (angle > 0) {\n while (angle >= Math.PI * 2) {\n angle -= Math.PI * 2;\n }\n }\n const step = angle / (Math.PI * 0.5);\n let index;\n if (step === Math.floor(step)) {\n index = Math.floor(step) * 2;\n } else {\n index = Math.floor(step) * 2 + 1;\n }\n item.setAttributes({\n textAlign: align[index] as TextAlignType,\n textBaseline: baseline[index] as TextBaselineType,\n angle: angle\n });\n });\n}\n\nexport function rotateXAxis(orient: string, items: IText[]) {\n // 0, 0-90, 90, 90-180, 180, 180-270, 270, 270-360, 360\n let align = ['center', 'left', 'left', 'left', 'center', 'right', 'right', 'right', 'left'];\n let baseline = ['top', 'top', 'middle', 'bottom', 'bottom', 'bottom', 'middle', 'top', 'top'];\n if (orient === 'top') {\n // 0, 0-90, 90, 90-180, 180, 180-270, 270, 270-360, 360\n align = ['center', 'right', 'right', 'right', 'center', 'left', 'left', 'left', 'right'];\n baseline = ['bottom', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];\n }\n items.forEach(item => {\n let angle = item.attribute.angle || 0;\n // todo angle为0跳过会导致下轴高度有bug\n // if (angle === 0) return;\n if (angle < 0) {\n while (angle < 0) {\n angle += Math.PI * 2;\n }\n }\n if (angle > 0) {\n while (angle >= Math.PI * 2) {\n angle -= Math.PI * 2;\n }\n }\n const step = angle / (Math.PI * 0.5);\n let index;\n if (step === Math.floor(step)) {\n index = Math.floor(step) * 2;\n } else {\n index = Math.floor(step) * 2 + 1;\n }\n item.setAttributes({\n textAlign: align[index] as TextAlignType,\n textBaseline: baseline[index] as TextBaselineType,\n angle\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["axis/overlap/auto-rotate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAA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E,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;KAC9F;IAED,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC;IACV,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QAC7B,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC9B;SAAM;QACL,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KAClC;IAED,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,KAAK,CAAkB;QACxC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAqB;KAClD,CAAC;AACJ,CAAC","file":"auto-rotate.js","sourcesContent":["/**\n * @description 坐标轴标签自动旋转\n */\nimport type { IText, TextAlignType, TextBaselineType } from '@visactor/vrender';\nimport { degreeToRadian, isEmpty, isRotateAABBIntersect } from '@visactor/vutils';\n\ntype RotateConfig = {\n /**\n * 坐标轴的显示位置\n */\n orient: string;\n /**\n * 自动旋转的可选角度\n */\n labelRotateAngle?: number[];\n};\n\nexport function autoRotate(items: IText[], rotateConfig: RotateConfig) {\n if (isEmpty(items)) {\n return;\n }\n\n const { orient, labelRotateAngle = [0, 45, 90] } = rotateConfig;\n if (labelRotateAngle.length === 0 || items.some(item => !!item.attribute.angle)) {\n return;\n }\n\n let i = 0;\n let n = 0;\n if (labelRotateAngle && labelRotateAngle.length > 0) {\n n = labelRotateAngle.length;\n }\n\n while (i < n) {\n const angle = labelRotateAngle[i++];\n items.forEach(item => {\n // item.angle = angle;\n item.attribute.angle = degreeToRadian(angle);\n });\n tryRotate(orient, items);\n if (!hasIntersect(items)) {\n break;\n }\n }\n}\n\nfunction hasIntersect(items: IText[]): boolean {\n for (let i = 1; i < items.length; i++) {\n if (itemIntersect(items[i - 1], items[i])) {\n return true;\n }\n }\n return false;\n}\n\nfunction itemIntersect(item1: IText, item2: IText) {\n return isRotateAABBIntersect(item1.rotatedBounds, item2.rotatedBounds, true);\n}\n\nfunction tryRotate(orient: string, items: IText[]) {\n // 针对 top bottom轴的自动旋转逻辑\n if (orient === 'bottom' || orient === 'top') {\n rotateXAxis(orient, items);\n }\n if (orient === 'left' || orient === 'right') {\n rotateYAxis(orient, items);\n }\n // 先旋转,再计算这个limit,避免算limit后发现不需要旋转,导致莫名的水平limit\n genRotateBounds(items);\n}\n\nfunction rotate(x: number, y: number, deg: number, originX: number, originY: number) {\n return {\n x: (x - originX) * Math.cos(deg) + (y - originY) * Math.sin(deg) + originX,\n y: (x - originX) * Math.sin(deg) + (originY - y) * Math.cos(deg) + originY\n };\n}\n\n// 计算水平情况下的包围盒\nfunction genNormalBounds(item: IText) {\n const bounds = item.AABBBounds;\n\n return {\n x1: bounds.x1,\n x2: bounds.x2,\n y1: bounds.y1,\n y2: bounds.y2,\n centerX: item.attribute.x,\n centerY: item.attribute.y,\n angle: item.attribute.angle\n };\n}\n\nfunction genRotateBounds(items: IText[]) {\n items.forEach(item => {\n // 计算水平情况下的包围盒\n const bounds = genNormalBounds(item);\n // 旋转\n const rotatedCenter = rotate(bounds.centerX, bounds.centerY, bounds.angle, item.attribute.x, item.attribute.y);\n const deltaX = rotatedCenter.x - bounds.centerX;\n const deltaY = rotatedCenter.y - bounds.centerY;\n bounds.x1 += deltaX;\n bounds.x2 += deltaX;\n bounds.y1 += deltaY;\n bounds.y2 += deltaY;\n bounds.centerX += deltaX;\n bounds.centerY += deltaY;\n item.rotatedBounds = bounds;\n });\n}\n\nfunction clampAngle(angle = 0) {\n if (angle < 0) {\n while (angle < 0) {\n angle += Math.PI * 2;\n }\n }\n if (angle > 0) {\n while (angle >= Math.PI * 2) {\n angle -= Math.PI * 2;\n }\n }\n\n return angle;\n}\n\nexport function rotateYAxis(orient: string, items: IText[]) {\n // 由于左右轴会裁切,所以上下两个label需要额外处理,做tighten处理\n items.forEach((item, i) => {\n item.setAttributes({\n ...getYAxisLabelAlign(orient, item.attribute.angle),\n angle: clampAngle(item.attribute.angle)\n });\n });\n}\n\nexport function rotateXAxis(orient: string, items: IText[]) {\n items.forEach(item => {\n item.setAttributes({\n ...getXAxisLabelAlign(orient, item.attribute.angle),\n angle: clampAngle(item.attribute.angle)\n });\n });\n}\n\nexport function getXAxisLabelAlign(orient: string, angle: number = 0) {\n // 0, 0-90, 90, 90-180, 180, 180-270, 270, 270-360, 360\n let align = ['center', 'left', 'left', 'left', 'center', 'right', 'right', 'right', 'left'];\n let baseline = ['top', 'top', 'middle', 'bottom', 'bottom', 'bottom', 'middle', 'top', 'top'];\n if (orient === 'top') {\n // 0, 0-90, 90, 90-180, 180, 180-270, 270, 270-360, 360\n align = ['center', 'right', 'right', 'right', 'center', 'left', 'left', 'left', 'right'];\n baseline = ['bottom', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];\n }\n\n angle = clampAngle(angle);\n const step = angle / (Math.PI * 0.5);\n let index;\n if (step === Math.floor(step)) {\n index = Math.floor(step) * 2;\n } else {\n index = Math.floor(step) * 2 + 1;\n }\n\n return {\n textAlign: align[index] as TextAlignType,\n textBaseline: baseline[index] as TextBaselineType\n };\n}\n\nexport function getYAxisLabelAlign(orient: string, angle: number = 0) {\n // 0, 0-90, 90, 90-180, 180, 180-270, 270, 270-360, 360\n let align = ['right', 'right', 'center', 'left', 'center', 'left', 'center', 'right', 'right'];\n let baseline = ['middle', 'middle', 'top', 'top', 'middle', 'middle', 'bottom', 'bottom', 'middle'];\n\n if (orient === 'right') {\n // 0, 0-90, 90, 90-180, 180, 180-270, 270, 270-360, 360\n align = ['left', 'right', 'right', 'right', 'left', 'left', 'left', 'left', 'right'];\n baseline = ['middle', 'bottom', 'middle', 'top', 'top', 'top', 'middle', 'bottom', 'bottom'];\n }\n\n angle = clampAngle(angle);\n const step = angle / (Math.PI * 0.5);\n let index;\n if (step === Math.floor(step)) {\n index = Math.floor(step) * 2;\n } else {\n index = Math.floor(step) * 2 + 1;\n }\n\n return {\n textAlign: align[index] as TextAlignType,\n textBaseline: baseline[index] as TextBaselineType\n };\n}\n"]}
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.14.3";
1
+ export declare const version = "0.14.4";
2
2
  export * from './core/base';
3
3
  export * from './scrollbar';
4
4
  export * from './tag';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "0.14.3";
1
+ export const version = "0.14.4";
2
2
 
3
3
  export * from "./core/base";
4
4
 
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.14.3\";\n\nexport * from './core/base';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.14.4\";\n\nexport * from './core/base';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\n"]}
package/es/label/arc.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { IBoundsLike } from '@visactor/vutils';
2
2
  import { LabelBase } from './base';
3
- import type { ArcLabelAttrs, IPoint, Quadrant } from './type';
4
- import type { BaseLabelAttrs } from './type';
5
- import type { TextAlignType, TextBaselineType, IText } from '@visactor/vrender';
6
- import type { IGraphic } from '@visactor/vrender';
3
+ import type { ArcLabelAttrs, IPoint, Quadrant, BaseLabelAttrs } from './type';
4
+ import type { IText, IGraphic } from '@visactor/vrender';
7
5
  export declare class ArcInfo {
8
6
  key: string;
9
7
  refDatum: any;
@@ -22,13 +20,10 @@ export declare class ArcInfo {
22
20
  pointA: IPoint;
23
21
  pointB: IPoint;
24
22
  pointC: IPoint;
25
- labelLinePath: string;
26
23
  quadrant: Quadrant;
27
24
  radian: number;
28
25
  middleAngle: number;
29
26
  k: number;
30
- textAlign: TextAlignType;
31
- textBaseline: TextBaselineType;
32
27
  angle: number;
33
28
  constructor(refDatum: any, center: IPoint, outerCenter: IPoint, quadrant: Quadrant, radian: number, middleAngle: number);
34
29
  getLabelBounds(): IBoundsLike;
@@ -45,7 +40,7 @@ export declare class ArcLabel extends LabelBase<ArcLabelAttrs> {
45
40
  x: number;
46
41
  y: number;
47
42
  } | undefined;
48
- protected layoutArcLabels(position: BaseLabelAttrs['position'], attribute: any, currentMarks?: IGraphic[], data?: any, textBoundsArray?: any): ArcInfo[];
43
+ protected layoutArcLabels(position: BaseLabelAttrs['position'], attribute: any, currentMarks?: IGraphic[], data?: any, textBoundsArray?: any, ellipsisWidth?: number): ArcInfo[];
49
44
  private _layoutInsideLabels;
50
45
  private _layoutOutsideLabels;
51
46
  private _computeX;
@@ -64,7 +59,7 @@ export declare class ArcLabel extends LabelBase<ArcLabelAttrs> {
64
59
  private _restoreY;
65
60
  private _checkYRange;
66
61
  private _coverLabels;
67
- protected computeRadius(r: number, width?: number, height?: number, k?: number): number;
62
+ protected computeRadius(r: number, width?: number, height?: number, centerOffset?: number, k?: number): number;
68
63
  protected computeLayoutRadius(width: number, height: number): number;
69
64
  private computeLayoutOuterRadius;
70
65
  private computeDatumRadius;
package/es/label/arc.js CHANGED
@@ -1,9 +1,7 @@
1
- import { merge } from "@visactor/vutils";
1
+ import { merge, isValidNumber, isNil, isLess, isGreater, isNumberClose as isClose } from "@visactor/vutils";
2
2
 
3
3
  import { LabelBase } from "./base";
4
4
 
5
- import { isValidNumber, isNil, isLess, isGreater, isNumberClose as isClose } from "@visactor/vutils";
6
-
7
5
  import { circlePoint, isQuadrantRight, isQuadrantLeft, lineCirclePoints, connectLineRadian, checkBoundsOverlap, computeQuadrant } from "./util";
8
6
 
9
7
  export class ArcInfo {
@@ -41,16 +39,17 @@ export class ArcLabel extends LabelBase {
41
39
  y: 0
42
40
  };
43
41
  }
44
- layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray) {
45
- this._arcLeft.clear(), this._arcRight.clear();
46
- const {width: width, height: height} = attribute;
42
+ layoutArcLabels(position, attribute, currentMarks, data, textBoundsArray, ellipsisWidth) {
43
+ var _a;
44
+ this._arcLeft.clear(), this._arcRight.clear(), this._ellipsisWidth = ellipsisWidth;
45
+ const {width: width, height: height} = attribute, centerOffset = null !== (_a = null == attribute ? void 0 : attribute.centerOffset) && void 0 !== _a ? _a : 0;
47
46
  currentMarks.forEach(((currentMark, index) => {
48
47
  var _a, _b;
49
- const graphicAttribute = currentMark.attribute, radiusRatio = this.computeLayoutOuterRadius(graphicAttribute.outerRadius, width, height), radius = this.computeRadius(radiusRatio, width, height), center = {
48
+ const graphicAttribute = currentMark.attribute, radiusRatio = this.computeLayoutOuterRadius(graphicAttribute.outerRadius, width, height), radius = this.computeRadius(radiusRatio, width, height, centerOffset), center = {
50
49
  x: null !== (_a = null == graphicAttribute ? void 0 : graphicAttribute.x) && void 0 !== _a ? _a : 0,
51
50
  y: null !== (_b = null == graphicAttribute ? void 0 : graphicAttribute.y) && void 0 !== _b ? _b : 0
52
51
  }, item = data[index], textBounds = textBoundsArray[index], arcMiddleAngle = (graphicAttribute.startAngle + graphicAttribute.endAngle) / 2, intervalAngle = graphicAttribute.endAngle - graphicAttribute.startAngle, arcQuadrant = computeQuadrant(graphicAttribute.endAngle - intervalAngle / 2), arcMiddle = circlePoint(center.x, center.y, graphicAttribute.outerRadius, arcMiddleAngle), outerArcMiddle = circlePoint(center.x, center.y, radius + attribute.line.line1MinLength, arcMiddleAngle), arc = new ArcInfo(item, arcMiddle, outerArcMiddle, arcQuadrant, intervalAngle, arcMiddleAngle);
53
- arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(2 * center.x, 2 * center.y, graphicAttribute.outerRadius), arc.middleAngle),
52
+ arc.pointA = circlePoint(center.x, center.y, this.computeDatumRadius(2 * center.x, 2 * center.y, graphicAttribute.outerRadius, centerOffset), arc.middleAngle),
54
53
  arc.labelSize = {
55
54
  width: textBounds.x2 - textBounds.x1,
56
55
  height: textBounds.y2 - textBounds.y1
@@ -62,13 +61,14 @@ export class ArcLabel extends LabelBase {
62
61
  arcs.push(...this._layoutOutsideLabels(leftArcs, attribute, currentMarks))), arcs;
63
62
  }
64
63
  _layoutInsideLabels(arcs, attribute, currentMarks) {
65
- var _a, _b, _c, _d;
64
+ var _a, _b, _c, _d, _e;
66
65
  const center = {
67
66
  x: null !== (_b = null === (_a = currentMarks[0].attribute) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0,
68
67
  y: null !== (_d = null === (_c = currentMarks[0].attribute) || void 0 === _c ? void 0 : _c.y) && void 0 !== _d ? _d : 0
69
- }, 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;
68
+ }, centerOffset = null !== (_e = null == attribute ? void 0 : attribute.centerOffset) && void 0 !== _e ? _e : 0, 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;
70
69
  return arcs.forEach((arc => {
71
- const {labelSize: labelSize, radian: radian} = arc, innerRadius = this.computeRadius(innerRadiusRatio, attribute.width, attribute.height, 1), outerRadius = this.computeRadius(outerRadiusRatio, attribute.width, attribute.height, 1);
70
+ var _a, _b;
71
+ const {labelSize: labelSize, radian: radian} = arc, innerRadius = this.computeRadius(innerRadiusRatio, attribute.width, attribute.height, centerOffset, 1), outerRadius = this.computeRadius(outerRadiusRatio, attribute.width, attribute.height, centerOffset, 1);
72
72
  let limit;
73
73
  if (radian < connectLineRadian(outerRadius, labelSize.height)) limit = 0; else {
74
74
  let minRadius;
@@ -81,7 +81,7 @@ export class ArcLabel extends LabelBase {
81
81
  const labelWidth = Math.min(limit, arc.labelSize.width), align = this._computeAlign(arc, attribute), labelRadius = outerRadius - spaceWidth - ("left" === align ? labelWidth : "right" === align ? 0 : labelWidth / 2);
82
82
  arc.labelPosition = circlePoint(center.x, center.y, labelRadius, arc.middleAngle),
83
83
  arc.labelLimit = labelWidth, isGreater(labelWidth, 0) || (arc.labelVisible = !1),
84
- arc.angle = arc.middleAngle;
84
+ arc.angle = null !== (_b = null === (_a = null == attribute ? void 0 : attribute.textStyle) || void 0 === _a ? void 0 : _a.angle) && void 0 !== _b ? _b : arc.middleAngle;
85
85
  })), arcs;
86
86
  }
87
87
  _layoutOutsideLabels(arcs, attribute, currentMarks) {
@@ -120,20 +120,20 @@ export class ArcLabel extends LabelBase {
120
120
  }
121
121
  const width = 2 * center_x;
122
122
  return arcs.forEach((arc => {
123
+ var _a, _b;
123
124
  arc.labelVisible && (isLess(arc.pointB.x, line2MinLength + spaceWidth) || isGreater(arc.pointB.x, width - line2MinLength - spaceWidth)) && (arc.labelVisible = !1),
124
- arc.angle = 0, arc.labelLinePath = `M${Math.round(arc.pointA.x)},${Math.round(arc.pointA.y)} L${Math.round(arc.pointB.x)},${Math.round(arc.pointB.y)} L${Math.round(arc.pointC.x)},${Math.round(arc.pointC.y)}`;
125
+ arc.angle = null !== (_b = null === (_a = null == attribute ? void 0 : attribute.textStyle) || void 0 === _a ? void 0 : _a.angle) && void 0 !== _b ? _b : 0;
125
126
  })), arcs;
126
127
  }
127
128
  _computeX(arc, attribute, currentMarks) {
128
- var _a, _b, _c, _d, _e;
129
- const center_x = null !== (_b = null === (_a = currentMarks[0].attribute) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0, plotLayout_width = 2 * center_x, radiusRatio = (_d = null === (_c = currentMarks[0].attribute) || void 0 === _c ? void 0 : _c.y,
130
- this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height)), line1MinLength = attribute.line.line1MinLength, line2MinLength = attribute.line.line2MinLength, labelLayoutAlign = null === (_e = attribute.layout) || void 0 === _e ? void 0 : _e.align, spaceWidth = attribute.spaceWidth, {labelPosition: labelPosition, quadrant: quadrant, pointB: pointB} = (this._computeAlign(arc, attribute),
131
- arc);
129
+ var _a, _b, _c, _d, _e, _f;
130
+ const center_x = null !== (_b = null === (_a = currentMarks[0].attribute) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0, centerOffset = (_d = null === (_c = currentMarks[0].attribute) || void 0 === _c ? void 0 : _c.y,
131
+ null !== (_e = null == attribute ? void 0 : attribute.centerOffset) && void 0 !== _e ? _e : 0), plotLayout_width = 2 * center_x, radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height), line1MinLength = attribute.line.line1MinLength, line2MinLength = attribute.line.line2MinLength, labelLayoutAlign = null === (_f = attribute.layout) || void 0 === _f ? void 0 : _f.align, spaceWidth = attribute.spaceWidth, {labelPosition: labelPosition, quadrant: quadrant, pointB: pointB} = arc;
132
132
  isValidNumber(pointB.x * pointB.y) || (arc.pointC = {
133
133
  x: NaN,
134
134
  y: NaN
135
135
  }, labelPosition.x = NaN, arc.labelLimit = 0);
136
- const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height), flag = isQuadrantLeft(quadrant) ? -1 : 1;
136
+ const radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset), flag = isQuadrantLeft(quadrant) ? -1 : 1;
137
137
  let cx = 0;
138
138
  let limit = (flag > 0 ? plotLayout_width - pointB.x : pointB.x) - line2MinLength - spaceWidth;
139
139
  "labelLine" === labelLayoutAlign && (cx = (radius + line1MinLength + line2MinLength) * flag + center_x,
@@ -152,17 +152,19 @@ export class ArcLabel extends LabelBase {
152
152
  default:
153
153
  cx = pointB.x + flag * line2MinLength;
154
154
  }
155
- if (labelWidth = Math.max(this._ellipsisWidth, labelWidth), arc.pointC = {
155
+ labelWidth = Math.max(this._ellipsisWidth, labelWidth), arc.labelLimit = labelWidth,
156
+ arc.pointC = {
156
157
  x: cx,
157
158
  y: labelPosition.y
158
- }, "edge" === labelLayoutAlign) {
159
+ };
160
+ const targetCenterOffset = .5 * (arc.labelLimit < arc.labelSize.width ? arc.labelLimit : arc.labelSize.width);
161
+ if ("edge" === labelLayoutAlign) {
159
162
  const alignOffset = 0;
160
- labelPosition.x = flag > 0 ? plotLayout_width + alignOffset : alignOffset;
163
+ labelPosition.x = (flag > 0 ? plotLayout_width + alignOffset : alignOffset) - flag * targetCenterOffset;
161
164
  } else {
162
165
  const alignOffset = 0;
163
- labelPosition.x = cx + alignOffset + flag * (spaceWidth + .5 * arc.labelSize.width);
166
+ labelPosition.x = cx + alignOffset + flag * (spaceWidth + .5 * targetCenterOffset);
164
167
  }
165
- arc.labelLimit = labelWidth;
166
168
  }
167
169
  _computeAlignOffset(align, labelWidth, alignFlag) {
168
170
  switch (align) {
@@ -268,7 +270,7 @@ export class ArcLabel extends LabelBase {
268
270
  return -1;
269
271
  }
270
272
  _computePointB(arc, r, attribute, currentMarks) {
271
- var _a, _b, _c, _d;
273
+ var _a, _b, _c, _d, _e;
272
274
  const labelConfig = attribute, radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height), line1MinLength = labelConfig.line.line1MinLength;
273
275
  if ("none" === labelConfig.layout.strategy) arc.pointB = {
274
276
  x: arc.outerCenter.x,
@@ -277,7 +279,7 @@ export class ArcLabel extends LabelBase {
277
279
  const center = {
278
280
  x: null !== (_b = null === (_a = currentMarks[0].attribute) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0,
279
281
  y: null !== (_d = null === (_c = currentMarks[0].attribute) || void 0 === _c ? void 0 : _c.y) && void 0 !== _d ? _d : 0
280
- }, 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;
282
+ }, centerOffset = null !== (_e = null == attribute ? void 0 : attribute.centerOffset) && void 0 !== _e ? _e : 0, radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset), {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;
281
283
  isValidNumber(x) ? arc.pointB = {
282
284
  x: center.x + x * (isQuadrantLeft(quadrant) ? -1 : 1),
283
285
  y: labelPosition.y
@@ -291,11 +293,11 @@ export class ArcLabel extends LabelBase {
291
293
  for (const arc of arcs) arc.labelVisible && (arc.lastLabelY = arc.labelPosition.y);
292
294
  }
293
295
  _computeYRange(arc, attribute, currentMarks) {
294
- var _a, _b, _c, _d;
296
+ var _a, _b, _c, _d, _e;
295
297
  const plotRect = {
296
298
  width: 2 * (null !== (_b = null === (_a = currentMarks[0].attribute) || void 0 === _a ? void 0 : _a.x) && void 0 !== _b ? _b : 0),
297
299
  height: 2 * (null !== (_d = null === (_c = currentMarks[0].attribute) || void 0 === _c ? void 0 : _c.y) && void 0 !== _d ? _d : 0)
298
- }, 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;
300
+ }, radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height), line1MinLength = attribute.line.line1MinLength, {width: width, height: height} = plotRect, centerOffset = null !== (_e = null == attribute ? void 0 : attribute.centerOffset) && void 0 !== _e ? _e : 0, radius = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset), r = this._computeLayoutRadius(height / 2, attribute, currentMarks), cx = Math.abs(arc.center.x - width / 2), cy = arc.center.y - height / 2;
299
301
  let a, b, c;
300
302
  if (isClose(width / 2, cx)) a = 0, b = 1, c = -cy; else if (isClose(height / 2, cy)) a = 1,
301
303
  b = 0, c = -cx; else {
@@ -311,7 +313,8 @@ export class ArcLabel extends LabelBase {
311
313
  max = Math.max(points[0].y, points[1].y) + height / 2), arc.labelYRange = [ min, max ];
312
314
  }
313
315
  _computeLayoutRadius(halfYLength, attribute, currentMarks) {
314
- 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;
316
+ var _a;
317
+ const labelConfig = attribute, layoutArcGap = labelConfig.layoutArcGap, line1MinLength = labelConfig.line.line1MinLength, radiusRatio = this.computeLayoutOuterRadius(currentMarks[0].attribute.outerRadius, attribute.width, attribute.height), centerOffset = null !== (_a = null == attribute ? void 0 : attribute.centerOffset) && void 0 !== _a ? _a : 0, outerR = this.computeRadius(radiusRatio, attribute.width, attribute.height, centerOffset) + line1MinLength, a = outerR - layoutArcGap;
315
318
  return Math.max((a ** 2 + halfYLength ** 2) / (2 * a), outerR);
316
319
  }
317
320
  _findNeighborIndex(arcs, priorityArc) {
@@ -355,8 +358,9 @@ export class ArcLabel extends LabelBase {
355
358
  checkBoundsOverlap(lastBounds, bounds) ? arcs[i].labelVisible = !1 : lastBounds = bounds;
356
359
  }
357
360
  }
358
- computeRadius(r, width, height, k) {
359
- return this.computeLayoutRadius(width || 0, height || 0) * r * (isNil(k) ? 1 : k);
361
+ computeRadius(r, width, height, centerOffset, k) {
362
+ var _a;
363
+ return null !== (_a = this.computeLayoutRadius(width || 0, height || 0) * r * (isNil(k) ? 1 : k) + centerOffset) && void 0 !== _a ? _a : 0;
360
364
  }
361
365
  computeLayoutRadius(width, height) {
362
366
  return Math.min(width / 2, height / 2);
@@ -364,9 +368,10 @@ export class ArcLabel extends LabelBase {
364
368
  computeLayoutOuterRadius(r, width, height) {
365
369
  return r / (Math.min(width, height) / 2);
366
370
  }
367
- computeDatumRadius(width, height, outerRadius) {
371
+ computeDatumRadius(width, height, outerRadius, centerOffset) {
372
+ var _a;
368
373
  const outerRadiusRatio = this.computeLayoutOuterRadius(outerRadius, width, height);
369
- return this.computeLayoutRadius(width || 0, height || 0) * outerRadiusRatio;
374
+ return null !== (_a = this.computeLayoutRadius(width || 0, height || 0) * outerRadiusRatio + centerOffset) && void 0 !== _a ? _a : 0;
370
375
  }
371
376
  }
372
377