Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6db7e9e

Browse files
committedSep 16, 2019
[categorized renderer] When color ramp is set to random, randomize color
of appended categories to pre-existing list when hitting the classify button (fixes #31579)
1 parent 7413335 commit 6db7e9e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,9 @@ void QgsCategorizedSymbolRendererWidget::addCategories()
739739
{
740740
QgsCategoryList prevCats = mRenderer->categories();
741741
keepExistingColors = !prevCats.isEmpty();
742+
QgsRandomColorRamp randomColors;
743+
if ( keepExistingColors && btnColorRamp->isRandomColorRamp() )
744+
randomColors.setTotalColorCount( cats.size() );
742745
for ( int i = 0; i < cats.size(); ++i )
743746
{
744747
bool contains = false;
@@ -753,7 +756,14 @@ void QgsCategorizedSymbolRendererWidget::addCategories()
753756
}
754757

755758
if ( !contains )
759+
{
760+
if ( keepExistingColors && btnColorRamp->isRandomColorRamp() )
761+
{
762+
// insure that append symbols have random colors
763+
cats.at( i ).symbol()->setColor( randomColors.color( i ) );
764+
}
756765
prevCats.append( cats.at( i ) );
766+
}
757767
}
758768
cats = prevCats;
759769
}

0 commit comments

Comments
 (0)
Please sign in to comment.