Use special log scale for time values

Seconds are a bit unintuitive for everything above 1 hour.
This commit is contained in:
Peter J. Holzer 2022-12-31 17:51:38 +01:00 committed by Peter J. Holzer
parent fedc4c66ac
commit 4b6e6c6eed
1 changed files with 28 additions and 13 deletions

View File

@ -314,6 +314,21 @@ class TimeSeries(Widget):
v += step v += step
log.debug("") log.debug("")
elif self.yscale == "log": elif self.yscale == "log":
unit = self.lts.description["unit"]
if unit == "s" and max_value > 3600:
steps = (
(3600, "1 h"),
(86400, "1 d"),
(7*86400, "1 w"),
(28*86400, "4 w"),
(365*86400, "1 y"),
(3652.5 * 86400, "10 y"),
)
for s in steps:
if min_value <= s[0] <= max_value:
self.y_tickmarks.append({"y": v2y(s[0]), "v_h": s[1]})
else:
log.debug("") log.debug("")
v = 10 ** math.ceil(math.log10(min_value)) v = 10 ** math.ceil(math.log10(min_value))
log.debug("v = %s", v) log.debug("v = %s", v)