@@ -28,4 +28,18 qreal PlotDomain::spanY() const | |||
|
28 | 28 | return m_maxY - m_minY; |
|
29 | 29 | } |
|
30 | 30 | |
|
31 | PlotDomain PlotDomain::subDomain(const QRect& rect, qreal maxWidth,qreal maxHeight) const | |
|
32 | { | |
|
33 | PlotDomain domain; | |
|
34 | ||
|
35 | qreal dx = spanX() / maxWidth; | |
|
36 | qreal dy = spanY() / maxHeight; | |
|
37 | ||
|
38 | domain.m_minX = m_minX + dx * rect.left(); | |
|
39 | domain.m_maxX = m_minX + dx * rect.right(); | |
|
40 | domain.m_minY = m_maxY - dy * rect.bottom(); | |
|
41 | domain.m_maxY = m_maxY - dy * rect.top(); | |
|
42 | ||
|
43 | return domain; | |
|
44 | } | |
|
31 | 45 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -13,6 +13,9 public: | |||
|
13 | 13 | qreal spanX() const; |
|
14 | 14 | qreal spanY() const; |
|
15 | 15 | |
|
16 | PlotDomain subDomain(const QRect& rect, qreal maxWidth, qreal maxHeight) const; | |
|
17 | ||
|
18 | ||
|
16 | 19 | public: |
|
17 | 20 | qreal m_minX; |
|
18 | 21 | qreal m_maxX; |
@@ -269,18 +269,11 void QChart::zoomInToRect(const QRect& rectangle) | |||
|
269 | 269 | rect.translate(-margin, -margin); |
|
270 | 270 | |
|
271 | 271 | PlotDomain& oldDomain = m_plotDomainList[m_plotDataIndex]; |
|
272 | PlotDomain newDomain; | |
|
273 | 272 | |
|
274 |
|
|
|
275 | qreal dy = oldDomain.spanY() / (m_rect.height() - 2 * margin); | |
|
276 | ||
|
277 | newDomain.m_minX = oldDomain.m_minX + dx * rect.left(); | |
|
278 | newDomain.m_maxX = oldDomain.m_minX + dx * rect.right(); | |
|
279 | newDomain.m_minY = oldDomain.m_maxY - dy * rect.bottom(); | |
|
280 | newDomain.m_maxY = oldDomain.m_maxY - dy * rect.top(); | |
|
273 | PlotDomain domain = oldDomain.subDomain(rect,m_rect.width() - 2 * margin,m_rect.height() - 2 * margin); | |
|
281 | 274 | |
|
282 | 275 | m_plotDomainList.resize(m_plotDataIndex + 1); |
|
283 |
m_plotDomainList<< |
|
|
276 | m_plotDomainList<<domain; | |
|
284 | 277 | m_plotDataIndex++; |
|
285 | 278 | |
|
286 | 279 | foreach (ChartItem* item ,m_chartItems) |
General Comments 0
You need to be logged in to leave comments.
Login now