From 206be6a8fa9ac0c80715fea916d17060c3554f5e Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sat, 15 Apr 2023 00:31:00 +0200 Subject: [PATCH] Make log scales more robust --- dashboard.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dashboard.py b/dashboard.py index 6cb6631..8e4c2d4 100644 --- a/dashboard.py +++ b/dashboard.py @@ -139,9 +139,13 @@ class TimeSeries(Widget): def v2y(v): if self.yscale == "log": - return (1 - math.log(v / min_value) - / math.log(max_value / min_value) - ) * 200 + try: + return (1 - math.log(max(v, min_value) / min_value) + / math.log(max_value / min_value) + ) * 200 + except ValueError: + log.error(f"ValueError: v = {v}, min_value = {min_value}, max_value = {max_value}") + return 0 elif self.yscale == "linear": return (1 - v/max_value) * 200 else: