From b69433d4697a99473da9c0fac60c64452b267d71 Mon Sep 17 00:00:00 2001 From: Calvin Owens Date: Tue, 5 Sep 2023 12:17:02 -0700 Subject: [PATCH] Autoscale the x-axis on graphs --- backend/http_ui.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/http_ui.py b/backend/http_ui.py index 6c4ba96..c4ed95a 100755 --- a/backend/http_ui.py +++ b/backend/http_ui.py @@ -50,11 +50,14 @@ def send_error(self, code, explain=""): self.wfile.write(explain) def gnuplot_temperature(self, ext, start_epoch, end_epoch, x, y, locs=None): + xtics = (end_epoch - start_epoch) // 6 + xarr = [ plots.gnuplot_preamble(ext or "svg", x, y), plots.gnuplot_colors(), plots.gnuplot_plot_preamble("Temperature Sensor Data", - "UTC Time", "Temperature (F)"), + "UTC Time", "Temperature (F)", + xtics=xtics), ] if locs is None or (len(locs) == 1 and locs[0] == ''): @@ -69,11 +72,14 @@ def gnuplot_temperature(self, ext, start_epoch, end_epoch, x, y, locs=None): return plots.gnuplot(*xarr) def gnuplot_humidity(self, ext, start_epoch, end_epoch, x, y, locs=None): + xtics = (end_epoch - start_epoch) // 6 + xarr = [ plots.gnuplot_preamble(ext or "svg", x, y), plots.gnuplot_colors(), plots.gnuplot_plot_preamble("Humidity Sensor Data", - "UTC Time", "Relative Humidity (%)"), + "UTC Time", "Relative Humidity (%)", + xtics=xtics), ] if locs is None or (len(locs) == 1 and locs[0] == ''):