diff --git a/dashboard.py b/dashboard.py index 37fd9bb..816e375 100644 --- a/dashboard.py +++ b/dashboard.py @@ -171,7 +171,7 @@ class TimeSeries(Widget): tickmarks.append({"t": t, "t_h": d.strftime("%Y-%m-%d %H:%M:%S"), "x": x}) min_step = 25 - steps = ("s", "m", "h", "D", "M", "Y") + steps = ("s", "m", "h", "D", "10D", "M", "Y") step_i = 0 while True: t0 = tickmarks[-1]["t"] @@ -226,6 +226,45 @@ class TimeSeries(Widget): step_i += 1 continue + if steps[step_i] == "10D": + year = d0.year + month = d0.month + day = d0.day + if day > 21: + day = 21 + elif day > 11: + day = 11 + elif day > 1: + day = 1 + else: + day = 21 + month -= 1 + if month < 1: + month += 12 + year -= 1 + d1 = datetime.datetime(year, month, day) + t1 = d1.timestamp() + x1 = t2x(t1) + if x0 - x1 < min_step: + if day > 21: + day = 21 + elif day > 11: + day = 11 + elif day > 1: + day = 1 + else: + day = 21 + month -= 1 + if month < 1: + month += 12 + year -= 1 + d1 = datetime.datetime(year, month, day) + t1 = d1.timestamp() + x1 = t2x(t1) + if x0 - x1 < min_step: + step_i += 1 + continue + if steps[step_i] == "M": d1 = datetime.datetime(d0.year, d0.month, 1) t1 = d1.timestamp()