in packages/charts/src/chart_types/xy_chart/state/selectors/get_debug_state.ts [69:119]
function getAxes(
axesGeoms: AxisGeometry[],
axesSpecs: AxisSpec[],
gridLines: LinesGrid[],
rotation: Rotation,
locale: string,
): DebugStateAxes {
return axesSpecs.reduce<DebugStateAxes>(
(acc, { position, title, id }) => {
const geom = axesGeoms.find(({ axis }) => axis.id === id);
if (!geom) {
return acc;
}
const isXAxis =
(isHorizontalAxis(position) && isHorizontalRotation(rotation)) ||
(isVerticalAxis(position) && isVerticalRotation(rotation));
// sorted starting from the axis origin
const sortingOrder = isHorizontalAxis(position)
? rotation === 0 || rotation === 90
? Predicate.NumAsc
: Predicate.NumDesc
: rotation === 0 || rotation === -90
? Predicate.NumDesc
: Predicate.NumAsc;
const visibleTicks = geom.visibleTicks
.filter(({ label }) => label !== '')
.sort(getPredicateFn(sortingOrder, locale, 'position'));
const labels = visibleTicks.map(({ label }) => label);
const values = visibleTicks.map(({ value }) => value);
const gridlines = gridLines
.flatMap(({ lineGroups }) => lineGroups.find(({ axisId }) => axisId === geom.axis.id)?.lines ?? [])
.map(({ x1: x, y1: y }) => ({ x, y }));
acc[isXAxis ? 'x' : 'y'].push({
id,
title,
position,
labels,
values,
gridlines,
});
return acc;
},
{ x: [], y: [] },
);
}