This commit is contained in:
Vincent van der Wal
2026-07-19 14:57:26 +02:00
parent 9e1944396e
commit 6d81af8df5
26 changed files with 408 additions and 466 deletions
+3 -1
View File
@@ -45,7 +45,9 @@ export const getColor = (temperature: number, unit = 'celsius'): string => {
} else if (temperature >= 60) {
index = colorScaleHex.length - 1;
} else {
index = Math.round(temperature) + 45;
// clamp: the scale has exactly 100 entries (-45..54), temperatures in
// [55, 60) would otherwise index past the end
index = Math.min(colorScaleHex.length - 1, Math.max(0, Math.round(temperature) + 45));
}
return colorScaleHex[index];