File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -367,7 +367,22 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
367
367
entryValues.reserve ( numberOfEntries );
368
368
if ( discrete )
369
369
{
370
- double intervalDiff = ( max - min ) * ( numberOfEntries - 1 ) / numberOfEntries;
370
+ double intervalDiff = max - min;
371
+
372
+ // remove last class when ColorRamp is gradient and discrete, as they are implemented with an extra stop
373
+ QgsVectorGradientColorRampV2* colorGradientRamp = dynamic_cast <QgsVectorGradientColorRampV2*>( colorRamp );
374
+ if ( colorGradientRamp != NULL && colorGradientRamp->isDiscrete () )
375
+ {
376
+ numberOfEntries--;
377
+ }
378
+ else
379
+ {
380
+ // if color ramp is continuous scale values to get equally distributed classes.
381
+ // Doesn't work perfectly when stops are non equally distributed.
382
+ intervalDiff *= ( numberOfEntries - 1 ) / numberOfEntries;
383
+ }
384
+
385
+ // skip first value (always 0.0)
371
386
for ( int i = 1 ; i < numberOfEntries; ++i )
372
387
{
373
388
double value = colorRamp->value ( i );
You can’t perform that action at this time.
0 commit comments