Skip to content

Commit

Permalink
Graduated renderer: handle the case with only one class
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jul 4, 2011
1 parent 0a3583d commit cd6a24b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Expand Up @@ -557,7 +557,7 @@ static QList<double> _calcJenksBreaks( QList<double> values, int classes,
// assuring heterogeneity among classes.

QList<double> breaks;
if ( classes < 1 )
if ( classes <= 1 )
{
breaks.append( maximum );
return breaks;
Expand Down Expand Up @@ -769,7 +769,8 @@ QgsGraduatedSymbolRendererV2* QgsGraduatedSymbolRendererV2::createRenderer(
}

QgsSymbolV2* newSymbol = symbol->clone();
newSymbol->setColor( ramp->color(( double ) i / ( breaks.count() - 1 ) ) ); // color from (0 / cl-1) to (cl-1 / cl-1)
double colorValue = ( breaks.count() > 1 ? ( double ) i / ( breaks.count() - 1 ) : 0 );
newSymbol->setColor( ramp->color( colorValue ) ); // color from (0 / cl-1) to (cl-1 / cl-1)

ranges.append( QgsRendererRangeV2( lower, upper, newSymbol, label ) );
}
Expand Down

0 comments on commit cd6a24b

Please sign in to comment.