victory-native
Version:
A charting library for React Native with a focus on performance and customization.
30 lines (24 loc) • 542 B
text/typescript
import type { PointsArray } from "../../types";
type Point = PointsArray[number];
export type VerticalBarRect = {
x: number;
y: number;
width: number;
height: number;
};
export const getVerticalBarRect = (
point: Point,
baselineY: number,
barThickness: number,
): VerticalBarRect | null => {
const { x, y } = point;
if (typeof y !== "number" || !Number.isFinite(x) || !Number.isFinite(y)) {
return null;
}
return {
x: x - barThickness / 2,
y,
width: barThickness,
height: baselineY - y,
};
};