From 0e82bb0d49f5803129f15efbb5ccbc3f2365a93a 2015-10-30 11:24:40 From: Miikka Heikkinen Date: 2015-10-30 11:24:40 Subject: [PATCH] Fix the minor axis grid animation Task-number: QTRD-3735 Change-Id: Ica883d01686e41735506e6ea7b1d344738bb5f0d Reviewed-by: Titta Heikkala --- diff --git a/src/charts/axis/horizontalaxis.cpp b/src/charts/axis/horizontalaxis.cpp index e7a59b6..a6b3888 100644 --- a/src/charts/axis/horizontalaxis.cpp +++ b/src/charts/axis/horizontalaxis.cpp @@ -293,24 +293,19 @@ void HorizontalAxis::updateGeometry() int minorTickCount = valueAxis->minorTickCount(); if (minorTickCount != 0) { qreal minorTickDistance = (layout[i] - layout[i + 1]) / qreal(minorTickCount + 1); + if (axis()->isReverse()) + minorTickDistance = -minorTickDistance; for (int j = 0; j < minorTickCount; j++) { QGraphicsLineItem *minorGridItem = static_cast(minorLines.at(i * minorTickCount + j)); QGraphicsLineItem *minorArrowItem = static_cast(minorArrows.at(i * minorTickCount + j)); - if (i == 0) { - minorGridItem->setLine(gridRect.left() - minorTickDistance * qreal(j + 1), - gridRect.top(), - gridRect.left() - minorTickDistance * qreal(j + 1), - gridRect.bottom()); - } else { - minorGridItem->setLine(gridItem->line().p1().x() - - minorTickDistance * qreal(j + 1), - gridRect.top(), - gridItem->line().p1().x() - - minorTickDistance * qreal(j + 1), - gridRect.bottom()); - } + minorGridItem->setLine(gridItem->line().p1().x() + - minorTickDistance * qreal(j + 1), + gridRect.top(), + gridItem->line().p1().x() + - minorTickDistance * qreal(j + 1), + gridRect.bottom()); if (axis()->alignment() == Qt::AlignTop) { minorArrowItem->setLine(minorGridItem->line().p1().x(), axisRect.bottom(), diff --git a/src/charts/axis/verticalaxis.cpp b/src/charts/axis/verticalaxis.cpp index 7ce4307..d267a32 100644 --- a/src/charts/axis/verticalaxis.cpp +++ b/src/charts/axis/verticalaxis.cpp @@ -309,24 +309,19 @@ void VerticalAxis::updateGeometry() int minorTickCount = valueAxis->minorTickCount(); if (minorTickCount != 0) { qreal minorTickDistance = (layout[i] - layout[i + 1]) / qreal(minorTickCount + 1); + if (axis()->isReverse()) + minorTickDistance = -minorTickDistance; for (int j = 0; j < minorTickCount; j++) { QGraphicsLineItem *minorGridItem = static_cast(minorLines.at(i * minorTickCount + j)); QGraphicsLineItem *minorArrowItem = static_cast(minorArrows.at(i * minorTickCount + j)); - if (i == 0) { - minorGridItem->setLine(gridRect.left(), - gridRect.bottom() - minorTickDistance * qreal(j + 1), - gridRect.right(), - gridRect.bottom() - minorTickDistance * qreal(j + 1)); - } else { - minorGridItem->setLine(gridRect.left(), - gridItem->line().p1().y() - - minorTickDistance * qreal(j + 1), - gridRect.right(), - gridItem->line().p1().y() - - minorTickDistance * qreal(j + 1)); - } + minorGridItem->setLine(gridRect.left(), + gridItem->line().p1().y() + - minorTickDistance * qreal(j + 1), + gridRect.right(), + gridItem->line().p1().y() + - minorTickDistance * qreal(j + 1)); if (axis()->alignment() == Qt::AlignLeft) { minorArrowItem->setLine(gridRect.left() - labelPadding() / 2, minorGridItem->line().p1().y(),