summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTitta Heikkala <titta.heikkala@theqtcompany.com>2014-10-29 13:41:59 +0200
committerTitta Heikkala <titta.heikkala@theqtcompany.com>2014-10-29 14:37:10 +0200
commit2e341eff31afe36a87e1ff41680b6fbac39eb35d (patch)
tree7788474867c76d9673118a0e79722365c68ee002
parentd7bc4e870cddd45899d5e8cea4e4eca59a3261aa (diff)
Fix zooming
If chart is zoomed only horizontally or vertically then the range for the other direction should not change. This is now checked by comparing the minimum and maximum values to the axis span. Change-Id: Icb5e14fc41afcedd7f75e60ca3ad6f699b053ae7 Task-number: QTRD-3399 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
-rw-r--r--src/charts/domain/xydomain.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/charts/domain/xydomain.cpp b/src/charts/domain/xydomain.cpp
index e782716d..3e93ef68 100644
--- a/src/charts/domain/xydomain.cpp
+++ b/src/charts/domain/xydomain.cpp
@@ -75,6 +75,15 @@ void XYDomain::zoomIn(const QRectF &rect)
minY = maxY - dy * rect.bottom();
maxY = maxY - dy * rect.top();
+ if ((maxX - minX) == spanX()) {
+ minX = m_minX;
+ maxX = m_maxX;
+ }
+ if ((maxY - minY) == spanY()) {
+ minY = m_minY;
+ maxY = m_maxY;
+ }
+
setRange(minX, maxX, minY, maxY);
}
@@ -94,6 +103,15 @@ void XYDomain::zoomOut(const QRectF &rect)
maxY = minY + dy * rect.bottom();
minY = maxY - dy * m_size.height();
+ if ((maxX - minX) == spanX()) {
+ minX = m_minX;
+ maxX = m_maxX;
+ }
+ if ((maxY - minY) == spanY()) {
+ minY = m_minY;
+ maxY = m_maxY;
+ }
+
setRange(minX, maxX, minY, maxY);
}