Skip to content

Commit

Permalink
[diagrams] Diagram fixes and UI improvements (Fix #7960)
Browse files Browse the repository at this point in the history
  * Use correct color for pie chart if only one value is >0
  * Show default text in scaling text box
  • Loading branch information
m-kuhn committed Jun 7, 2013
1 parent eda9cd3 commit 8c840e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/core/diagram/qgspiediagram.cpp
Expand Up @@ -128,19 +128,22 @@ void QgsPieDiagram::renderDiagram( const QgsAttributes& att, QgsRenderContext& c
QList< QColor >::const_iterator colIt = s.categoryColors.constBegin();
for ( ; valIt != values.constEnd(); ++valIt, ++colIt )
{
currentAngle = *valIt / valSum * 360 * 16;
mCategoryBrush.setColor( *colIt );
p->setBrush( mCategoryBrush );
// if only 1 value is > 0, draw a circle
if ( valCount == 1 )
if ( *valIt )
{
p->drawEllipse( baseX, baseY, w, h );
currentAngle = *valIt / valSum * 360 * 16;
mCategoryBrush.setColor( *colIt );
p->setBrush( mCategoryBrush );
// if only 1 value is > 0, draw a circle
if ( valCount == 1 )
{
p->drawEllipse( baseX, baseY, w, h );
}
else
{
p->drawPie( baseX, baseY, w, h, totalAngle + s.angleOffset, currentAngle );
}
totalAngle += currentAngle;
}
else
{
p->drawPie( baseX, baseY, w, h, totalAngle + s.angleOffset, currentAngle );
}
totalAngle += currentAngle;
}
}
else // valSum > 0
Expand Down
3 changes: 3 additions & 0 deletions src/ui/qgsdiagrampropertiesbase.ui
Expand Up @@ -431,6 +431,9 @@
<string>The attribute value you enter here will correspond to the size entered in the field &quot;Size&quot; and the chosen &quot;Size unit&quot;.
Leave empty to automatically apply the maximum value.</string>
</property>
<property name="placeholderText">
<string>Empty: Use maximum value</string>
</property>
</widget>
</item>
</layout>
Expand Down

0 comments on commit 8c840e9

Please sign in to comment.