Skip to content

Commit

Permalink
warn with 0 or negative values when using log scale in graduated rend…
Browse files Browse the repository at this point in the history
…erer (#38138)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
qgis-bot and github-actions[bot] committed Aug 4, 2020
1 parent afaccb6 commit 51f3c7e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/classification/qgsclassificationlogarithmic.cpp
Expand Up @@ -110,9 +110,20 @@ QList<double> QgsClassificationLogarithmic::calculateBreaks( double &minimum, do
QString QgsClassificationLogarithmic::valueToLabel( double value ) const
{
if ( value <= 0 )
{
return QString( QStringLiteral( "%1" ) ).arg( value );
}
else
return QString( QStringLiteral( "10^%1" ) ).arg( std::log10( value ) );
{
if ( std::isnan( value ) )
{
return QObject::tr( "invalid (0 or negative values in the data)" );
}
else
{
return QString( QStringLiteral( "10^%1" ) ).arg( std::log10( value ) );
}
}
}

QString QgsClassificationLogarithmic::labelForRange( double lowerValue, double upperValue, QgsClassificationMethod::ClassPosition position ) const
Expand Down

0 comments on commit 51f3c7e

Please sign in to comment.