INNER CODE UNIT · TypeScript
getNextPixelValue
margelo/react-native-graph · src/CreateGraphPath.ts:171
const getNextPixelValue = (pixel: number) => {
if (pixel === endX || pixel + PIXEL_RATIO < endX)
return pixel + PIXEL_RATIO;
return endX;
};
for (
let pixel = startX;
startX <= pixel && pixel <= endX;
pixel = getNextPixelValue(pixel)
) {
const index = getGraphDataIndex(pixel);
// Draw first point only on the very first pixel
if (index === 0 && pixel !== startX) continue;
// Draw last point only on the very last pixel
if (index === graphData.length - 1 && pixel !== endX) continue;