diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2019-10-10 11:27:32 +0300 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2019-10-10 11:57:47 +0300 |
commit | 289b9904a7c9ce241896f65509a19d0213def35c (patch) | |
tree | 8ffa86eff80570dbb96e4274a05b12eeba2cec0e /src | |
parent | e757445355dbb3f3001fae49bb72113d7a52173d (diff) |
Round adjustedMin for offset value in ChartBarCategoryAxis
Using qCeil(adjustedMin) to calculate the offset caused some labels
to be trimmed, rounding the value is more appropriate.
Task-number: QTBUG-62230
Change-Id: I2c7c09ae50f8a4f4958653fa557159962da9a8a2
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.cpp | 4 | ||||
-rw-r--r-- | src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.cpp b/src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.cpp index a515d797..26a159b4 100644 --- a/src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.cpp +++ b/src/charts/axis/barcategoryaxis/chartbarcategoryaxisx.cpp @@ -59,7 +59,7 @@ QVector<qreal> ChartBarCategoryAxisX::calculateLayout() const return points; qreal adjustedMin = min() + 0.5; - qreal offset = (qCeil(adjustedMin) - adjustedMin) * delta; + qreal offset = (qRound(adjustedMin) - adjustedMin) * delta; int count = qFloor(range); if (count < 1) @@ -80,7 +80,7 @@ QStringList ChartBarCategoryAxisX::createCategoryLabels(const QVector<qreal>& la qreal d = (max() - min()) / gridRect.width(); for (int i = 0; i < layout.count() - 1; ++i) { - qreal x = qFloor((((layout[i] + layout[i + 1]) / 2 - gridRect.left()) * d + min() + 0.5)); + int x = qFloor((((layout[i] + layout[i + 1]) / 2 - gridRect.left()) * d + min() + 0.5)); if (x < max() && (x >= 0) && x < m_categoriesAxis->categories().count()) { result << m_categoriesAxis->categories().at(x); } else { diff --git a/src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.cpp b/src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.cpp index bc5bf97f..a8ef0aa5 100644 --- a/src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.cpp +++ b/src/charts/axis/barcategoryaxis/chartbarcategoryaxisy.cpp @@ -59,7 +59,7 @@ QVector<qreal> ChartBarCategoryAxisY::calculateLayout() const return points; qreal adjustedMin = min() + 0.5; - qreal offset = (qCeil(adjustedMin) - adjustedMin) * delta; + qreal offset = (qRound(adjustedMin) - adjustedMin) * delta; int count = qFloor(range); if (count < 1) @@ -80,7 +80,7 @@ QStringList ChartBarCategoryAxisY::createCategoryLabels(const QVector<qreal>& la qreal d = (max() - min()) / gridRect.height(); for (int i = 0; i < layout.count() - 1; ++i) { - qreal x = qFloor(((gridRect.height() - (layout[i + 1] + layout[i]) / 2 + gridRect.top()) * d + min() + 0.5)); + int x = qFloor(((gridRect.height() - (layout[i + 1] + layout[i]) / 2 + gridRect.top()) * d + min() + 0.5)); if ((x < m_categoriesAxis->categories().count()) && (x >= 0)) { result << m_categoriesAxis->categories().at(x); } else { |