summaryrefslogtreecommitdiffstats
path: root/src/charts/axis/chartaxiselement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/charts/axis/chartaxiselement.cpp')
-rw-r--r--src/charts/axis/chartaxiselement.cpp44
1 files changed, 20 insertions, 24 deletions
diff --git a/src/charts/axis/chartaxiselement.cpp b/src/charts/axis/chartaxiselement.cpp
index 17f36e61..2a874216 100644
--- a/src/charts/axis/chartaxiselement.cpp
+++ b/src/charts/axis/chartaxiselement.cpp
@@ -1,12 +1,11 @@
/****************************************************************************
**
-** Copyright (C) 2021 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Charts module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:COMM$
-**
+** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -15,15 +14,16 @@
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
-** $QT_END_LICENSE$
-**
-**
-**
-**
-**
-**
-**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -339,7 +339,7 @@ bool ChartAxisElement::isEmpty()
{
return axisGeometry().isEmpty()
|| gridGeometry().isEmpty()
- || qFuzzyCompare(min(), max());
+ || qFuzzyIsNull(max() - min());
}
qreal ChartAxisElement::min() const
@@ -430,13 +430,11 @@ QStringList ChartAxisElement::createValueLabels(qreal min, qreal max, int ticks,
labels << presenter()->numberToString(value, 'f', n);
}
} else {
- qreal value = tickAnchor;
- if (value > min)
- value = value - int((value - min) / tickInterval) * tickInterval;
- else
- value = value + qCeil((min - value) / tickInterval) * tickInterval;
+ const qreal ticksFromAnchor = (tickAnchor - min) / tickInterval;
+ const qreal firstMajorTick = tickAnchor - std::floor(ticksFromAnchor) * tickInterval;
- while (value <= max || qFuzzyCompare(value, max)) {
+ qreal value = firstMajorTick;
+ while (value <= max) {
labels << presenter()->numberToString(value, 'f', n);
value += tickInterval;
}
@@ -472,13 +470,11 @@ QStringList ChartAxisElement::createValueLabels(qreal min, qreal max, int ticks,
labels << formatLabel(formatSpec, array, value, precision, preStr, postStr);
}
} else {
- qreal value = tickAnchor;
- if (value > min)
- value = value - int((value - min) / tickInterval) * tickInterval;
- else
- value = value + qCeil((min - value) / tickInterval) * tickInterval;
+ const qreal ticksFromAnchor = (tickAnchor - min) / tickInterval;
+ const qreal firstMajorTick = tickAnchor - std::floor(ticksFromAnchor) * tickInterval;
- while (value <= max || qFuzzyCompare(value, max)) {
+ qreal value = firstMajorTick;
+ while (value <= max) {
labels << formatLabel(formatSpec, array, value, precision, preStr, postStr);
value += tickInterval;
}