Use special log scale for time values
Seconds are a bit unintuitive for everything above 1 hour.
This commit is contained in:
parent
fedc4c66ac
commit
4b6e6c6eed
41
dashboard.py
41
dashboard.py
|
@ -314,19 +314,34 @@ class TimeSeries(Widget):
|
||||||
v += step
|
v += step
|
||||||
log.debug("")
|
log.debug("")
|
||||||
elif self.yscale == "log":
|
elif self.yscale == "log":
|
||||||
log.debug("")
|
unit = self.lts.description["unit"]
|
||||||
v = 10 ** math.ceil(math.log10(min_value))
|
if unit == "s" and max_value > 3600:
|
||||||
log.debug("v = %s", v)
|
steps = (
|
||||||
if v > max_value:
|
(3600, "1 h"),
|
||||||
# Implement that when it happens
|
(86400, "1 d"),
|
||||||
log.warning("No tickmark between %s and %s", min_value, max_value)
|
(7*86400, "1 w"),
|
||||||
return
|
(28*86400, "4 w"),
|
||||||
while v <= max_value:
|
(365*86400, "1 y"),
|
||||||
y = v2y(v)
|
(3652.5 * 86400, "10 y"),
|
||||||
log.debug("v = %s, y = %s", v, y)
|
)
|
||||||
self.y_tickmarks.append({"y": y, "v_h": str(v)})
|
for s in steps:
|
||||||
v *= 10
|
if min_value <= s[0] <= max_value:
|
||||||
log.debug("")
|
self.y_tickmarks.append({"y": v2y(s[0]), "v_h": s[1]})
|
||||||
|
|
||||||
|
else:
|
||||||
|
log.debug("")
|
||||||
|
v = 10 ** math.ceil(math.log10(min_value))
|
||||||
|
log.debug("v = %s", v)
|
||||||
|
if v > max_value:
|
||||||
|
# Implement that when it happens
|
||||||
|
log.warning("No tickmark between %s and %s", min_value, max_value)
|
||||||
|
return
|
||||||
|
while v <= max_value:
|
||||||
|
y = v2y(v)
|
||||||
|
log.debug("v = %s, y = %s", v, y)
|
||||||
|
self.y_tickmarks.append({"y": y, "v_h": str(v)})
|
||||||
|
v *= 10
|
||||||
|
log.debug("")
|
||||||
else:
|
else:
|
||||||
log.debug("")
|
log.debug("")
|
||||||
raise ValueError(f"Unknown yscale {self.yscale}")
|
raise ValueError(f"Unknown yscale {self.yscale}")
|
||||||
|
|
Loading…
Reference in New Issue