in packages/api-builder/src/xform/axes/getContext.ts [13:53]
export function getContext(
axis: Axis,
frame: SceneFrame,
axisSpace: AxisSpace,
): Partial<AxisContext> {
// Create the new axis space
const thickness = getThickness(axis, axisSpace)
const axisFrame = frame.pushView(
getScaleSize(axis, axisSpace, thickness, frame.view),
getScaleTL(axis, axisSpace, frame.view),
getScaleBR(axis, axisSpace, frame.view),
)
const scaleName = axis.scale
const scale = axisFrame.scales[scaleName]
const range: [number, number] = ((scale.range && scale.range()) as [
number,
number,
]) || [0, 0]
const horizontal =
axis.orient === AxisOrientation.Top ||
axis.orient === AxisOrientation.Bottom
const topOrLeft =
axis.orient === AxisOrientation.Top || axis.orient === AxisOrientation.Left
return {
axis,
range,
scale,
thickness,
horizontal,
topOrLeft,
frame: axisFrame,
rangeProperty: horizontal ? 'x' : 'y',
rangeEndProperty: horizontal ? 'x2' : 'y2',
crossProperty: horizontal ? 'y' : 'x',
crossEndProperty: horizontal ? 'y2' : 'x2',
}
}