(
rotation: number, textPosition: AxisBaseOptionCommon['nameLocation'], textRotate: number, extent: number[]
)
| 1020 | }; |
| 1021 | |
| 1022 | function endTextLayout( |
| 1023 | rotation: number, textPosition: AxisBaseOptionCommon['nameLocation'], textRotate: number, extent: number[] |
| 1024 | ) { |
| 1025 | const rotationDiff = remRadian(textRotate - rotation); |
| 1026 | let textAlign: ZRTextAlign; |
| 1027 | let textVerticalAlign: ZRTextVerticalAlign; |
| 1028 | const inverse = extent[0] > extent[1]; |
| 1029 | const onLeft = (textPosition === 'start' && !inverse) |
| 1030 | || (textPosition !== 'start' && inverse); |
| 1031 | |
| 1032 | if (isRadianAroundZero(rotationDiff - PI / 2)) { |
| 1033 | textVerticalAlign = onLeft ? 'bottom' : 'top'; |
| 1034 | textAlign = 'center'; |
| 1035 | } |
| 1036 | else if (isRadianAroundZero(rotationDiff - PI * 1.5)) { |
| 1037 | textVerticalAlign = onLeft ? 'top' : 'bottom'; |
| 1038 | textAlign = 'center'; |
| 1039 | } |
| 1040 | else { |
| 1041 | textVerticalAlign = 'middle'; |
| 1042 | if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) { |
| 1043 | textAlign = onLeft ? 'left' : 'right'; |
| 1044 | } |
| 1045 | else { |
| 1046 | textAlign = onLeft ? 'right' : 'left'; |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | return { |
| 1051 | rotation: rotationDiff, |
| 1052 | textAlign: textAlign, |
| 1053 | textVerticalAlign: textVerticalAlign |
| 1054 | }; |
| 1055 | } |
| 1056 | |
| 1057 | /** |
| 1058 | * Assume `labelLayoutList` has no `label.ignore: true`. |
no test coverage detected
searching dependent graphs…