[gnome-weather] ui: Fix chart distortion when all values in the forecast are equal



commit ecd1fafce8738d335df5e87494886f8e8ae885d2
Author: Vitaly Dyachkov <obyknovenius me com>
Date:   Wed Jan 6 17:51:22 2021 +0100

    ui: Fix chart distortion when all values in the forecast are equal

 src/app/hourlyForecast.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/app/hourlyForecast.js b/src/app/hourlyForecast.js
index 7ebb670..8f52815 100644
--- a/src/app/hourlyForecast.js
+++ b/src/app/hourlyForecast.js
@@ -141,7 +141,12 @@ var HourlyForecastFrame = GObject.registerClass(class ForecastFrame extends Gtk.
         const maxTemp = Math.max(...temps);
         const minTemp = Math.min(...temps);
 
-        const values = temps.map(t => (t - minTemp) / (maxTemp - minTemp));
+        let values;
+        if (minTemp != maxTemp) {
+            values = temps.map(t => (t - minTemp) / (maxTemp - minTemp));
+        } else {
+            values = temps.map(t => t / 2);
+        }
 
         const frameWidth = this.get_allocated_width();
         const frameHeight = this.get_allocated_height();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]