victory-native
Version:
A charting library for React Native with a focus on performance and customization.
27 lines (22 loc) • 562 B
text/typescript
import { type PointsArray } from "../types";
/**
* Takes a PointsArray and chunks it into groups, breaking at non-numerical y-values
*/
export const groupPointsArray = (points: PointsArray): PointsArray[] => {
const groups: PointsArray[] = [];
let group: PointsArray = [];
for (const point of points) {
if (typeof point.y !== "number") {
if (group.length > 0) {
groups.push(group);
group = [];
}
} else {
group.push(point);
}
}
if (group.length > 0) {
groups.push(group);
}
return groups;
};