diff --git a/lib/graphs.ts b/lib/graphs.ts index a99e3fc..3af2282 100644 --- a/lib/graphs.ts +++ b/lib/graphs.ts @@ -172,6 +172,9 @@ export const calculateCenteredMovingAverage = ( points: GenerationDataPoint[], period: number ): GenerationDataPoint[] => { + if (points.length === 0) { + return []; + } if (period % 2 == 0) { throw new Error('Period must be an odd number'); } else if (period > points.length) {