mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 18:31:24 +02:00
Fix edge case in weather widget graph
This commit is contained in:
parent
804cf9916b
commit
949fde1517
@ -189,12 +189,19 @@ func FetchWeatherForPlace(place *PlaceJson, units string) (*Weather, error) {
|
|||||||
minT := slices.Min(temperatures)
|
minT := slices.Min(temperatures)
|
||||||
maxT := slices.Max(temperatures)
|
maxT := slices.Max(temperatures)
|
||||||
|
|
||||||
|
temperaturesRange := float64(maxT - minT)
|
||||||
|
|
||||||
for i := 0; i < 12; i++ {
|
for i := 0; i < 12; i++ {
|
||||||
bars = append(bars, weatherColumn{
|
bars = append(bars, weatherColumn{
|
||||||
Temperature: temperatures[i],
|
Temperature: temperatures[i],
|
||||||
Scale: float64(temperatures[i]-minT) / float64(maxT-minT),
|
|
||||||
HasPrecipitation: precipitations[i],
|
HasPrecipitation: precipitations[i],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if temperaturesRange > 0 {
|
||||||
|
bars[i].Scale = float64(temperatures[i]-minT) / temperaturesRange
|
||||||
|
} else {
|
||||||
|
bars[i].Scale = 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user