function getVerticalAlign()

in packages/charts/src/chart_types/xy_chart/utils/axis_utils.ts [177:205]


function getVerticalAlign(
  position: Position,
  rotation: number,
  alignment: VerticalAlignment,
): Exclude<VerticalAlignment, typeof VerticalAlignment.Far | typeof VerticalAlignment.Near> {
  if (
    alignment === VerticalAlignment.Middle ||
    alignment === VerticalAlignment.Top ||
    alignment === VerticalAlignment.Bottom
  ) {
    return alignment;
  }

  if (rotation % 180 === 0) {
    if (position === Position.Left) {
      return rotation === 0 ? VerticalAlignment.Bottom : VerticalAlignment.Top;
    } else if (position === Position.Right) {
      return rotation === 180 ? VerticalAlignment.Bottom : VerticalAlignment.Top;
    }
  } else {
    if (position === Position.Top) {
      return alignment === VerticalAlignment.Near ? VerticalAlignment.Bottom : VerticalAlignment.Top;
    } else if (position === Position.Bottom) {
      return alignment === VerticalAlignment.Near ? VerticalAlignment.Top : VerticalAlignment.Bottom;
    }
  }

  return VerticalAlignment.Middle; // fallback for near/far on left/right axis
}