fix(dashboard): fix temperature gauge positioning when low temp is 0
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 1m6s

This commit is contained in:
2025-11-19 10:34:47 +00:00
parent 3af86d80c7
commit bdd1cae5ae
2 changed files with 6 additions and 1 deletions

View File

@@ -251,7 +251,11 @@ function WeatherTile() {
const temperature = Math.round(currentWeather.temperature) const temperature = Math.round(currentWeather.temperature)
const lowTemp = Math.round(dailyForecastData?.forecastDaily?.days[0].temperatureMin ?? 0) const lowTemp = Math.round(dailyForecastData?.forecastDaily?.days[0].temperatureMin ?? 0)
const highTemp = Math.round(dailyForecastData?.forecastDaily?.days[0].temperatureMax ?? 0) const highTemp = Math.round(dailyForecastData?.forecastDaily?.days[0].temperatureMax ?? 0)
const percentage = lowTemp && highTemp ? (temperature - lowTemp) / (highTemp - lowTemp) : 0 // Calculate percentage: handle case where lowTemp might be 0 (falsy) by checking for valid numbers
const tempRange = highTemp - lowTemp
const percentage = tempRange !== 0 && !Number.isNaN(tempRange)
? Math.max(0, Math.min(1, (temperature - lowTemp) / tempRange))
: 0
const highlightIndexStart = Math.floor((1 - percentage) * 23) const highlightIndexStart = Math.floor((1 - percentage) * 23)
const WeatherIcon = getWeatherIcon(currentWeather.conditionCode) const WeatherIcon = getWeatherIcon(currentWeather.conditionCode)

View File

@@ -1,5 +1,6 @@
{ {
"lockfileVersion": 1, "lockfileVersion": 1,
"configVersion": 0,
"workspaces": { "workspaces": {
"": { "": {
"name": "monorepo", "name": "monorepo",