From a803e4e9381b66fe6dd6727581b685f5569d531d 2014-11-27 12:45:31 From: Titta Heikkala Date: 2014-11-27 12:45:31 Subject: [PATCH] Fix category axis shades and labels The shade is cropped to the grid rectangle when range is set so that category spans over grid. Also the label of a category outside range is hidden. Change-Id: I09bba2951bc230053bf62cb382021a438fdc2b95 Task-number: QTRD-3443 Reviewed-by: Miikka Heikkinen --- diff --git a/src/charts/axis/horizontalaxis.cpp b/src/charts/axis/horizontalaxis.cpp index de15fcb..72ede18 100644 --- a/src/charts/axis/horizontalaxis.cpp +++ b/src/charts/axis/horizontalaxis.cpp @@ -144,8 +144,7 @@ void HorizontalAxis::updateGeometry() const qreal delta = rightBound - leftBound; // Hide label in case visible part of the category at the grid edge is too narrow if (delta < boundingRect.width() - && (leftBound == gridRect.left() || rightBound == gridRect.right()) - && !intervalAxis()) { + && (leftBound == gridRect.left() || rightBound == gridRect.right())) { forceHide = true; } else { labelItem->setPos(leftBound + (delta / 2.0) - center.x(), labelItem->pos().y()); @@ -181,6 +180,10 @@ void HorizontalAxis::updateGeometry() else rightBound = qMin(layout[i + 1], gridRect.right()); } + if (leftBound < gridRect.left()) + leftBound = gridRect.left(); + if (rightBound > gridRect.right()) + rightBound = gridRect.right(); shadeItem->setRect(leftBound, gridRect.top(), rightBound - leftBound, gridRect.height()); if (shadeItem->rect().width() <= 0.0) diff --git a/src/charts/axis/verticalaxis.cpp b/src/charts/axis/verticalaxis.cpp index ddea15c..4faf9c1 100644 --- a/src/charts/axis/verticalaxis.cpp +++ b/src/charts/axis/verticalaxis.cpp @@ -146,8 +146,7 @@ void VerticalAxis::updateGeometry() const qreal delta = lowerBound - upperBound; // Hide label in case visible part of the category at the grid edge is too narrow if (delta < boundingRect.height() - && (lowerBound == gridRect.bottom() || upperBound == gridRect.top()) - && !intervalAxis()) { + && (lowerBound == gridRect.bottom() || upperBound == gridRect.top())) { forceHide = true; } else { labelItem->setPos(labelItem->pos().x() , lowerBound - (delta / 2.0) - center.y()); @@ -185,6 +184,10 @@ void VerticalAxis::updateGeometry() upperBound = qMax(layout[i + 1], gridRect.top()); } + if (lowerBound > gridRect.bottom()) + lowerBound = gridRect.bottom(); + if (upperBound < gridRect.top()) + upperBound = gridRect.top(); shadeItem->setRect(gridRect.left(), upperBound, gridRect.width(), lowerBound - upperBound); if (shadeItem->rect().height() <= 0.0)