From 5e1619e3f13e71f4b112d29eed9063ad031c6e59 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 16 Apr 2024 09:15:29 -0400 Subject: [PATCH] fix: remove unnecessary casts, rounding from series.estimate Signed-off-by: Evan Prodromou --- app/src/util/series.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/util/series.ts b/app/src/util/series.ts index 4f53ea722..02453bc98 100644 --- a/app/src/util/series.ts +++ b/app/src/util/series.ts @@ -19,27 +19,27 @@ export function estimate(series: { year: number, value: number }[], year: number if (!next) { return null } - let rate = (1.0 * (next.value - first.value)) / (next.year - first.year); + let rate = (next.value - first.value) / (next.year - first.year); let value = first.value - rate * (first.year - year) - return Math.round(value) + return value } else if (year > series[series.length - 1].year) { // extrapolate forwards let last = series[series.length - 1] let prev = series.findLast(e => last.year - e.year >= year - last.year) if (!prev) { return null } - let rate = (1.0 * (last.value - prev.value)) / (last.year - prev.year); + let rate = (last.value - prev.value) / (last.year - prev.year); let value = last.value + rate * (year - last.year) - return Math.round(value) + return value } else { // interpolate let prev = series.findLast(e => e.year < year) let next = series.find(e => e.year > year) if (!prev || !next) { return null } - let rate = (1.0 * (next.value - prev.value)) / (next.year - prev.year); + let rate = (next.value - prev.value) / (next.year - prev.year); let value = prev.value + rate * (year - prev.year) - return Math.round(value) + return value } return null;