Skip to content
Permalink
Browse files

PieDiagram: draw empty circle if all attribute values == 0

  • Loading branch information
m-kuhn committed Aug 15, 2012
1 parent e0f38d0 commit 97a542750cb5c0afac04d3c7d824db4ceb233bfa
Showing with 17 additions and 7 deletions.
  1. +17 −7 src/core/diagram/qgspiediagram.cpp
@@ -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.
You can’t perform that action at this time.