Skip to content

Commit

Permalink
PieDiagram: draw empty circle if all attribute values == 0
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 15, 2012
1 parent e0f38d0 commit 97a5427
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/core/diagram/qgspiediagram.cpp
Expand Up @@ -114,14 +114,24 @@ void QgsPieDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext&
setPenWidth( mPen, s, c );
p->setPen( mPen );

QList<double>::const_iterator valIt = values.constBegin();
QList< QColor >::const_iterator colIt = s.categoryColors.constBegin();
for ( ; valIt != values.constEnd(); ++valIt, ++colIt )
// draw empty circle if no values are defined at all
if ( valSum > 0 )
{
currentAngle = *valIt / valSum * 360 * 16;
mCategoryBrush.setColor( *colIt );
QList<double>::const_iterator valIt = values.constBegin();
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 );
p->drawPie( baseX, baseY, w, h, totalAngle, currentAngle );
totalAngle += currentAngle;
}
}
else // valSum > 0
{
mCategoryBrush.setColor( Qt::transparent );
p->setBrush( mCategoryBrush );
p->drawPie( baseX, baseY, w, h, totalAngle, currentAngle );
totalAngle += currentAngle;
p->drawEllipse( baseX, baseY, w, h );
}
}

0 comments on commit 97a5427

Please sign in to comment.