@@ -24,6 +24,7 | |||||
24 | #include "qabstractaxis.h" |
|
24 | #include "qabstractaxis.h" | |
25 | #include "qabstractaxis_p.h" |
|
25 | #include "qabstractaxis_p.h" | |
26 | #include <QDebug> |
|
26 | #include <QDebug> | |
|
27 | #include <qmath.h> | |||
27 |
|
28 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
30 | |||
@@ -357,10 +358,23 qreal PolarChartAxisAngular::preferredAxisRadius(const QSizeF &maxSize) | |||||
357 | QPointF labelPoint = QLineF::fromPolar(radius + tickWidth(), 90.0 - labelCoordinate).p2(); |
|
358 | QPointF labelPoint = QLineF::fromPolar(radius + tickWidth(), 90.0 - labelCoordinate).p2(); | |
358 |
|
359 | |||
359 | boundingRect = moveLabelToPosition(labelCoordinate, labelPoint, boundingRect); |
|
360 | boundingRect = moveLabelToPosition(labelCoordinate, labelPoint, boundingRect); | |
360 |
|
|
361 | QRectF intersectRect = maxRect.intersected(boundingRect); | |
|
362 | if (boundingRect.isEmpty() || intersectRect == boundingRect) { | |||
361 | i++; |
|
363 | i++; | |
362 | } else { |
|
364 | } else { | |
363 |
|
|
365 | qreal reduction(0.0); | |
|
366 | // If there is no intersection, reduce by smallest dimension of label rect to be on the safe side | |||
|
367 | if (intersectRect.isEmpty()) { | |||
|
368 | reduction = qMin(boundingRect.height(), boundingRect.width()); | |||
|
369 | } else { | |||
|
370 | // Approximate needed radius reduction is the amount label rect exceeds max rect in either dimension. | |||
|
371 | // Could be further optimized by figuring out the proper math how to calculate exact needed reduction. | |||
|
372 | reduction = qMax(boundingRect.height() - intersectRect.height(), | |||
|
373 | boundingRect.width() - intersectRect.width()); | |||
|
374 | } | |||
|
375 | // Typically the approximated reduction is little low, so add one | |||
|
376 | radius -= (reduction + 1.0); | |||
|
377 | ||||
364 | if (radius < 1.0) // safeguard |
|
378 | if (radius < 1.0) // safeguard | |
365 | return 1.0; |
|
379 | return 1.0; | |
366 | } |
|
380 | } |
General Comments 0
You need to be logged in to leave comments.
Login now