From 2a850025b26df4f6babd825cac911b6e3d98ffe2 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 7 Jan 2021 14:59:47 +0100 Subject: statistics: add ticks at beginning and end of the axis The grid is based on the axis ticks. If labels in histogram axes were skipped (because there are too many bins), it could happen that the grid was incomplete, because the first and/or last tick were missing. Add these explicitly. Signed-off-by: Berthold Stoeger --- stats/statsaxis.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'stats') diff --git a/stats/statsaxis.cpp b/stats/statsaxis.cpp index ebd41fb94..734de6a63 100644 --- a/stats/statsaxis.cpp +++ b/stats/statsaxis.cpp @@ -411,11 +411,20 @@ void HistogramAxis::updateLabels() } } labels.reserve((bin_values.size() - first) / step + 1); + // Always add a tick at the beginning of the axis - this is + // important for the grid, which uses the ticks. + if (first != 0) + addTick(bin_values.front().value); + int last = first; for (int i = first; i < (int)bin_values.size(); i += step) { const auto &[name, value, recommended] = bin_values[i]; addLabel(name, value); addTick(value); + last = i; } + // Always add a tick at the end of the axis (see above). + if (last != (int)bin_values.size() - 1) + addTick(bin_values.back().value); } // Helper function to turn days since "Unix epoch" into a timestamp_t -- cgit v1.2.3-70-g09d2