diff --git a/src/axis/horizontalaxis.cpp b/src/axis/horizontalaxis.cpp index d09cb5f..5d2bfbd 100644 --- a/src/axis/horizontalaxis.cpp +++ b/src/axis/horizontalaxis.cpp @@ -142,10 +142,10 @@ void HorizontalAxis::updateGeometry() labelItem->setPos(layout[i] + delta - center.x(), labelItem->pos().y()); } - //label overlap detection + //label overlap detection - compensate one pixel for rounding errors if(labelItem->pos().x() < width || - labelItem->pos().x() < axisRect.left() || - labelItem->pos().x() + boundingRect.width() -1 > axisRect.right()){ + labelItem->pos().x() < (axisRect.left() - 1.0) || + (labelItem->pos().x() + boundingRect.width() - 1.0) > axisRect.right()){ labelItem->setVisible(false); } else { labelItem->setVisible(true); diff --git a/src/axis/verticalaxis.cpp b/src/axis/verticalaxis.cpp index 0c6ecac..9c9d462 100644 --- a/src/axis/verticalaxis.cpp +++ b/src/axis/verticalaxis.cpp @@ -152,10 +152,10 @@ void VerticalAxis::updateGeometry() labelItem->setPos(labelItem->pos().x() , layout[i] + delta - center.y()); } - //label overlap detection - if(labelItem->pos().y() + boundingRect.height() > height || - labelItem->pos().y() + boundingRect.height()/2 > axisRect.bottom() || - labelItem->pos().y() + boundingRect.height()/2 < axisRect.top()) { + //label overlap detection - compensate one pixel for rounding errors + if (labelItem->pos().y() + boundingRect.height() > height || + (labelItem->pos().y() + (boundingRect.height() / 2.0) - 1.0) > axisRect.bottom() || + labelItem->pos().y() + (boundingRect.height() / 2.0) < (axisRect.top() - 1.0)) { labelItem->setVisible(false); } else {