diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-07 14:59:47 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-01-07 10:39:52 -0800 |
commit | 2a850025b26df4f6babd825cac911b6e3d98ffe2 (patch) | |
tree | 16d1bdb2eb46fc621d5dc2f456f16ecb83eab6d9 | |
parent | cad00032fc040973cd348bcc3708e054b6e6ffba (diff) | |
download | subsurface-2a850025b26df4f6babd825cac911b6e3d98ffe2.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | stats/statsaxis.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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 |