@@ -607,23 +607,19 @@ vcol <- reactive({
607607 } else {
608608 full_list <- get.vertex.attribute(nw_var ,input $ colorby )
609609 short_list <- sort(unique(full_list ))
610+ ncolors <- length(short_list )
610611 if (is.element(" Other" , short_list )){ # to be consistent with order of legend
611612 short_list <- short_list [- which(short_list == " Other" )]
612613 short_list <- c(short_list , " Other" )
613614 }
614615 full_list <- match(full_list , short_list )
615616 # each elt corresponds to integer position in short_list
616- if (length(short_list )> 9 ){
617- full_list <- full_list %% 9
618- full_list [full_list == 0 ] <- 9
619- }
620617 pal <- c(' red' , ' blue' , ' green3' , ' cyan' , ' magenta3' ,
621618 ' yellow' , ' orange' , ' black' , ' grey' )
622- assigncolor <- function (x ){
623- switch (x , pal [1 ], pal [2 ], pal [3 ], pal [4 ], pal [5 ],
624- pal [6 ], pal [7 ], pal [8 ], pal [9 ])
619+ if (ncolors > 9 ){
620+ pal <- colorRampPalette(c(" green" , " blue" ))(ncolors )
625621 }
626- vcol <- sapply( X = full_list , FUN = assigncolor )
622+ vcol <- pal [ full_list ]
627623 }
628624 vcol
629625})
@@ -650,6 +646,9 @@ legendfill <- reactive({
650646 n <- length(legendlabels())
651647 pal <- c(' red' , ' blue' , ' green3' , ' cyan' , ' magenta3' ,
652648 ' yellow' , ' orange' , ' black' , ' grey' )
649+ if (n > 9 ){
650+ pal <- colorRampPalette(c(" green" ," blue" ))(n )
651+ }
653652 legendfill <- adjustcolor(pal , alpha.f = input $ transp )
654653 }
655654 legendfill
@@ -1135,7 +1134,7 @@ observe({
11351134 if (length(legendlabels())> 9 ){
11361135 createAlert(session , inputId = " colorwarning" ,
11371136 title = NULL ,
1138- message = " Warning: Colors get recycled for attributes with more than nine levels." ,
1137+ message = " Note: Color palette becomes sequential for attributes with more than nine levels." ,
11391138 type = " warning" , dismiss = TRUE ,
11401139 block = FALSE , append = FALSE )
11411140 }
0 commit comments