diff options
author | Dimitrios Apostolou <jimis@qt.io> | 2021-05-10 16:21:18 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-05-12 15:19:52 +0000 |
commit | a94abfbfa2f2dd233395ac611033f89ba6ba7507 (patch) | |
tree | d00fe2bc11a6bc9ec9f8077bae8aab5dd955e7fe | |
parent | 846f29bd29edc488f0637664e4f5ffd848f9eaae (diff) |
Fix X axis labels to not draw over each other
When the label numbers on the Y axis become too wide then the plot area
width is shrunk to accommodate for that. But the X axis label numbers
were calculated for the wider X axis, and printed on the shrunk X axis,
so they overlapped each other.
This is addressed in the Qt::AlignBottom part of the fix. Presumably the
same issue happens with different alignments so respective change has
been applied to those too.
Fixes: QTBUG-79218
Change-Id: I2ad8c62f8c8d6308ab13b9da42fa6bd5e9192ee3
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
(cherry picked from commit 5b6e1042bd0aa4514df71209e7784b23490dbd1e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/charts/layout/cartesianchartlayout.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/charts/layout/cartesianchartlayout.cpp b/src/charts/layout/cartesianchartlayout.cpp index e46b3f15..ae4f8d3d 100644 --- a/src/charts/layout/cartesianchartlayout.cpp +++ b/src/charts/layout/cartesianchartlayout.cpp @@ -193,14 +193,18 @@ QRectF CartesianChartLayout::calculateAxisGeometry(const QRectF &geometry, if (leftSqueezeRatio < 1.0) width *= leftSqueezeRatio; leftOffset+=width; - axis->setGeometry(QRect(chartRect.left()-leftOffset, geometry.top(),width, geometry.bottom()),chartRect); + axis->setGeometry(QRect(chartRect.left() - leftOffset, chartRect.top(), + width, chartRect.bottom()), + chartRect); break; } case Qt::AlignRight:{ qreal width = size.width(); if (rightSqueezeRatio < 1.0) width *= rightSqueezeRatio; - axis->setGeometry(QRect(chartRect.right()+rightOffset,geometry.top(),width,geometry.bottom()),chartRect); + axis->setGeometry(QRect(chartRect.right() + rightOffset, chartRect.top(), + width, chartRect.bottom()), + chartRect); rightOffset+=width; break; } @@ -208,7 +212,9 @@ QRectF CartesianChartLayout::calculateAxisGeometry(const QRectF &geometry, qreal height = size.height(); if (topSqueezeRatio < 1.0) height *= topSqueezeRatio; - axis->setGeometry(QRect(geometry.left(), chartRect.top() - topOffset - height, geometry.width(), height), chartRect); + axis->setGeometry(QRect(chartRect.left(), chartRect.top() - topOffset - height, + chartRect.width(), height), + chartRect); topOffset += height; break; } @@ -216,7 +222,9 @@ QRectF CartesianChartLayout::calculateAxisGeometry(const QRectF &geometry, qreal height = size.height(); if (bottomSqueezeRatio < 1.0) height *= bottomSqueezeRatio; - axis->setGeometry(QRect(geometry.left(), chartRect.bottom() + bottomOffset, geometry.width(), height), chartRect); + axis->setGeometry(QRect(chartRect.left(), chartRect.bottom() + bottomOffset, + chartRect.width(), height), + chartRect); bottomOffset += height; break; } |