Use special linear scale for time values

This commit is contained in:
Peter J. Holzer 2023-01-01 01:06:24 +01:00 committed by Peter J. Holzer
parent f62816a250
commit 25381714a1
1 changed files with 40 additions and 7 deletions

View File

@ -310,17 +310,50 @@ class TimeSeries(Widget):
def set_y_tickmarks():
log.debug("")
unit = self.lts.description["unit"]
self.y_tickmarks = []
if self.yscale == "linear":
log.debug("")
if unit == "s" and max_value > 3600:
if max_value >= 4 * 7 * 86400:
step = 7 * 86400
step_d = 1
unit = "w"
elif max_value >= 10 * 86400:
step = 3 * 86400
step_d = 3
unit = "d"
elif max_value >= 4 * 86400:
step = 86400
step_d = 1
unit = "d"
elif max_value >= 4 * 3600:
step = 3600
step_d = 1
unit = "h"
else:
step = 10 * 60
step_d = 10
unit = "m"
v = 0
v_d = 0
while v < max_value:
y = v2y(v)
log.debug("v = %s, y = %s", v, y)
self.y_tickmarks.append({"y": y, "v_h": f"{v_d} {unit}"})
v += step
v_d += step_d
else:
step = 10 ** math.floor(math.log10(max_value))
v = 0
while v < max_value:
self.y_tickmarks.append({"y": v2y(v), "v_h": str(v)})
y = v2y(v)
log.debug("v = %s, y = %s", v, y)
self.y_tickmarks.append({"y": y, "v_h": str(v)})
v += step
log.debug("")
elif self.yscale == "log":
unit = self.lts.description["unit"]
if unit == "s" and max_value > 3600:
steps = (
(3600, "1 h"),