MCPcopy Index your code
hub / github.com/apache/echarts / endTextLayout

Function endTextLayout

src/component/axis/AxisBuilder.ts:1022–1055  ·  view source on GitHub ↗
(
    rotation: number, textPosition: AxisBaseOptionCommon['nameLocation'], textRotate: number, extent: number[]
)

Source from the content-addressed store, hash-verified

1020};
1021
1022function 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`.

Callers 1

axisNameFunction · 0.85

Calls 2

remRadianFunction · 0.90
isRadianAroundZeroFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…