@@ -36,12 +36,34 @@ QSizeF QgsPieDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsR
36
36
{
37
37
return QSizeF (); // zero size if attribute is missing
38
38
}
39
- double value = attIt.value ().toDouble ();
39
+
40
+ bool scaleByArea = true ;
41
+
42
+ double scaledValue = attIt.value ().toDouble ();
43
+ double scaledLowerValue = is.lowerValue ;
44
+ double scaledUpperValue = is.upperValue ;
45
+ double scaledLowerSizeWidth = is.lowerSize .width ();
46
+ double scaledLowerSizeHeight = is.lowerSize .height ();
47
+ double scaledUpperSizeWidth = is.upperSize .width ();
48
+ double scaledUpperSizeHeight = is.upperSize .height ();
49
+
50
+ // interpolate the squared value if scale by area
51
+ if ( scaleByArea )
52
+ {
53
+ scaledValue = sqrt ( scaledValue );
54
+ scaledLowerValue = sqrt ( scaledLowerValue );
55
+ scaledUpperValue = sqrt ( scaledUpperValue );
56
+ scaledLowerSizeWidth = sqrt ( scaledLowerSizeWidth );
57
+ scaledLowerSizeHeight = sqrt ( scaledLowerSizeHeight );
58
+ scaledUpperSizeWidth = sqrt ( scaledUpperSizeWidth );
59
+ scaledUpperSizeHeight = sqrt ( scaledUpperSizeHeight );
60
+ }
40
61
41
62
// interpolate size
42
- double ratio = ( value - is.lowerValue ) / ( is.upperValue - is.lowerValue );
43
- QSizeF size = QSizeF ( sqrt ( is.upperSize .width () * ratio + is.lowerSize .width () * ( 1 - ratio ) ),
44
- sqrt ( is.upperSize .height () * ratio + is.lowerSize .height () * ( 1 - ratio ) ) );
63
+ double scaledRatio = ( scaledValue - scaledLowerValue ) / ( scaledUpperValue - scaledLowerValue );
64
+
65
+ QSizeF size = QSizeF ( is.upperSize .width () * scaledRatio + is.lowerSize .width () * ( 1 - scaledRatio ),
66
+ is.upperSize .height () * scaledRatio + is.lowerSize .height () * ( 1 - scaledRatio ) );
45
67
46
68
// Scale, if extension is smaller than the specified minimum
47
69
if ( size.width () <= s.minimumSize && size.height () <= s.minimumSize )
0 commit comments