Make log scales more robust

This commit is contained in:
Peter J. Holzer 2023-04-15 00:31:00 +02:00 committed by Peter J. Holzer
parent 2e8641ad18
commit 206be6a8fa
1 changed files with 7 additions and 3 deletions

View File

@ -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: