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)