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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-18 22:41:43 +01:00 committed by bstoeger
parent db69c38245
commit 9e61a6372a

View file

@ -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<double>(labels.size()) + 0.5);
if (!labels.empty())
setRange(-0.5, static_cast<double>(labels.size()) - 0.5);
else
setRange(-1.0, 1.0);
}
// No implementation because the labels are inside ticks and this