From dc5741d60515ec24b23e38e7bba499f4207901e9 Mon Sep 17 00:00:00 2001 From: alfrix Date: Sun, 4 Dec 2022 12:02:34 -0300 Subject: [PATCH] graph: autoscale time --- ks_includes/widgets/graph.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ks_includes/widgets/graph.py b/ks_includes/widgets/graph.py index 501e95c4..c99a0a8b 100644 --- a/ks_includes/widgets/graph.py +++ b/ks_includes/widgets/graph.py @@ -92,6 +92,8 @@ class HeaterGraph(Gtk.DrawingArea): points_per_pixel = self.max_length / graph_width data_points = int(round(graph_width * points_per_pixel, 0)) max_num = math.ceil(self.get_max_num(data_points) * 1.1 / 10) * 10 + if points_per_pixel == 0: + return d_width = 1 / points_per_pixel d_height_scale = self.graph_lines(ctx, gsize, max_num) @@ -188,7 +190,7 @@ class HeaterGraph(Gtk.DrawingArea): ctx.set_font_size(self.font_size) ctx.show_text(f"{h:2}:{m:02}") ctx.stroke() - i += 1 if self.max_length < 600 else 2 + i += 1 + self.max_length // 601 def is_showing(self, device): return False if device not in self.store else self.store[device]['show']