react-plot
Version:
Library of React components to render SVG 2D plots.
29 lines (26 loc) • 633 B
text/typescript
import type { TickPosition } from '../types.js';
export function getInnerOffset(
hidden: boolean,
hiddenTicks: boolean,
tickPosition: TickPosition,
primaryTickLength: number,
): number {
return hidden || hiddenTicks
? 0
: getOffsetFromTickPosition(tickPosition, primaryTickLength);
}
function getOffsetFromTickPosition(
tickPosition: TickPosition,
primaryTickLength: number,
): number {
switch (tickPosition) {
case 'outer':
return 0;
case 'inner':
return primaryTickLength;
case 'center':
return primaryTickLength / 2;
default:
throw new Error('unreachable');
}
}