From 9e61a6372a0709a6ddaef5749a27b05d84c5f70c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 18 Jan 2021 22:41:43 +0100 Subject: statistics: fix range in categorical axes Fix a bug that was fixed in b5c8d0dbb4 and reintroduced in e7907c494f. Here is the original commit message: The range for a one-bin chart is [-0.5,0.5], thus the range in an n-bin chart is [-0.5,n-0.5], not [-0.5,n+0.5]. Signed-off-by: Berthold Stoeger --- stats/statsaxis.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'stats') diff --git a/stats/statsaxis.cpp b/stats/statsaxis.cpp index 7af41c14b..92c972e0e 100644 --- a/stats/statsaxis.cpp +++ b/stats/statsaxis.cpp @@ -379,7 +379,10 @@ CategoryAxis::CategoryAxis(StatsView &view, const QString &title, const std::vec StatsAxis(view, title, horizontal, true), labelsText(labels) { - setRange(-0.5, static_cast(labels.size()) + 0.5); + if (!labels.empty()) + setRange(-0.5, static_cast(labels.size()) - 0.5); + else + setRange(-1.0, 1.0); } // No implementation because the labels are inside ticks and this -- cgit v1.2.3-70-g09d2