Use special linear scale for time values
This commit is contained in:
parent
f62816a250
commit
25381714a1
47
dashboard.py
47
dashboard.py
|
@ -310,17 +310,50 @@ class TimeSeries(Widget):
|
||||||
|
|
||||||
def set_y_tickmarks():
|
def set_y_tickmarks():
|
||||||
log.debug("")
|
log.debug("")
|
||||||
|
unit = self.lts.description["unit"]
|
||||||
self.y_tickmarks = []
|
self.y_tickmarks = []
|
||||||
if self.yscale == "linear":
|
if self.yscale == "linear":
|
||||||
log.debug("")
|
log.debug("")
|
||||||
step = 10 ** math.floor(math.log10(max_value))
|
if unit == "s" and max_value > 3600:
|
||||||
v = 0
|
if max_value >= 4 * 7 * 86400:
|
||||||
while v < max_value:
|
step = 7 * 86400
|
||||||
self.y_tickmarks.append({"y": v2y(v), "v_h": str(v)})
|
step_d = 1
|
||||||
v += step
|
unit = "w"
|
||||||
log.debug("")
|
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:
|
||||||
|
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":
|
elif self.yscale == "log":
|
||||||
unit = self.lts.description["unit"]
|
|
||||||
if unit == "s" and max_value > 3600:
|
if unit == "s" and max_value > 3600:
|
||||||
steps = (
|
steps = (
|
||||||
(3600, "1 h"),
|
(3600, "1 h"),
|
||||||
|
|
Loading…
Reference in New Issue