@@ -32,17 +32,37 @@ QgsTextDiagram::~QgsTextDiagram()
3232
3333QSizeF QgsTextDiagram::diagramSize ( const QgsAttributeMap& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is )
3434{
35- QgsAttributeMap::const_iterator attIt = attributes.find ( is.classificationAttribute );
35+ QgsAttributeMap::const_iterator attIt = attributes.find ( is.classificationAttribute );
3636 if ( attIt == attributes.constEnd () )
3737 {
3838 return QSizeF (); // zero size if attribute is missing
3939 }
40- double value = attIt.value ().toDouble ();
40+
41+ double scaledValue = attIt.value ().toDouble ();
42+ double scaledLowerValue = is.lowerValue ;
43+ double scaledUpperValue = is.upperValue ;
44+ double scaledLowerSizeWidth = is.lowerSize .width ();
45+ double scaledLowerSizeHeight = is.lowerSize .height ();
46+ double scaledUpperSizeWidth = is.upperSize .width ();
47+ double scaledUpperSizeHeight = is.upperSize .height ();
48+
49+ // interpolate the squared value if scale by area
50+ if ( s.scaleByArea )
51+ {
52+ scaledValue = sqrt ( scaledValue );
53+ scaledLowerValue = sqrt ( scaledLowerValue );
54+ scaledUpperValue = sqrt ( scaledUpperValue );
55+ scaledLowerSizeWidth = sqrt ( scaledLowerSizeWidth );
56+ scaledLowerSizeHeight = sqrt ( scaledLowerSizeHeight );
57+ scaledUpperSizeWidth = sqrt ( scaledUpperSizeWidth );
58+ scaledUpperSizeHeight = sqrt ( scaledUpperSizeHeight );
59+ }
4160
4261 // interpolate size
43- double ratio = ( value - is.lowerValue ) / ( is.upperValue - is.lowerValue );
44- QSizeF size = QSizeF ( sqrt ( is.upperSize .width () * ratio + is.lowerSize .width () * ( 1 - ratio ) ),
45- sqrt ( is.upperSize .height () * ratio + is.lowerSize .height () * ( 1 - ratio ) ) );
62+ double scaledRatio = ( scaledValue - scaledLowerValue ) / ( scaledUpperValue - scaledLowerValue );
63+
64+ QSizeF size = QSizeF ( is.upperSize .width () * scaledRatio + is.lowerSize .width () * ( 1 - scaledRatio ),
65+ is.upperSize .height () * scaledRatio + is.lowerSize .height () * ( 1 - scaledRatio ) );
4666
4767 // Scale, if extension is smaller than the specified minimum
4868 if ( size.width () <= s.minimumSize && size.height () <= s.minimumSize )
0 commit comments