@@ -981,23 +981,19 @@ vcol2 <- reactive({
981981 full_list <- get.vertex.attribute(allmodelsimreac()[[input $ thissim ]],input $ colorby2 )
982982 }
983983 short_list <- sort(unique(full_list ))
984+ ncolors <- length(short_list )
984985 if (is.element(" Other" , short_list )){ # to be consistent with order of legend
985986 short_list <- short_list [- which(short_list == " Other" )]
986987 short_list <- c(short_list , " Other" )
987988 }
988989 full_list <- match(full_list , short_list )
989990 # each elt is an integer position in short_list
990- if (length(short_list )> 9 ){
991- full_list <- full_list %% 9
992- full_list [full_list == 0 ] <- 9
993- }
994991 pal <- c(' red' , ' blue' , ' green3' , ' cyan' , ' magenta3' ,
995992 ' yellow' , ' orange' , ' black' , ' grey' )
996- assigncolor <- function (x ){
997- switch (x , pal [1 ], pal [2 ], pal [3 ], pal [4 ], pal [5 ],
998- pal [6 ], pal [7 ], pal [8 ], pal [9 ])
993+ if (ncolors > 9 ){
994+ pal <- colorRampPalette(brewer.pal(11 ," RdYlBu" ))(ncolors )
999995 }
1000- vcol <- sapply( X = full_list , FUN = assigncolor )
996+ vcol <- pal [ full_list ]
1001997 }
1002998 }
1003999 vcol
@@ -1024,8 +1020,12 @@ legendfill2 <- reactive({
10241020 if (input $ colorby2 == 2 ){
10251021 legendfill <- NULL
10261022 } else {
1023+ n <- length(legendlabels2())
10271024 pal <- c(' red' , ' blue' , ' green3' , ' cyan' , ' magenta3' ,
10281025 ' yellow' , ' orange' , ' black' , ' grey' )
1026+ if (n > 9 ){
1027+ pal <- colorRampPalette(brewer.pal(11 ," RdYlBu" ))(n )
1028+ }
10291029 legendfill <- adjustcolor(pal , alpha.f = input $ transp2 )
10301030 }
10311031 }
@@ -1130,15 +1130,15 @@ output$dynamiccolor <- renderUI({
11301130})
11311131outputOptions(output ,' dynamiccolor' ,suspendWhenHidden = FALSE , priority = 10 )
11321132
1133- observe({
1134- if (length(legendlabels())> 9 ){
1135- createAlert(session , inputId = " colorwarning" ,
1136- title = NULL ,
1137- message = " Note: Color palette changes for attributes with more than nine levels." ,
1138- type = " warning" , dismiss = TRUE ,
1139- block = FALSE , append = FALSE )
1140- }
1141- })
1133+ # observe({
1134+ # if(length(legendlabels())>9){
1135+ # createAlert(session, inputId = "colorwarning",
1136+ # title=NULL,
1137+ # message="Note: Color palette changes for attributes with more than nine levels.",
1138+ # type="warning", dismiss=TRUE,
1139+ # block=FALSE, append=FALSE)
1140+ # }
1141+ # })
11421142
11431143output $ dynamicsize <- renderUI({
11441144 selectInput(' sizeby' ,
@@ -1291,19 +1291,19 @@ dd_plotdata <- reactive({
12911291 data
12921292})
12931293
1294- observe({
1295- if (! is.null(input $ colorby_dd )){
1296- if (input $ colorby_dd != " None" ){
1297- if (dim(dd_plotdata())[1 ]> 9 ){
1298- createAlert(session , inputId = " colorwarning_dd" ,
1299- title = NULL ,
1300- message = " Warning: Colors get recycled for attributes with more than nine levels." ,
1301- type = " warning" , dismiss = TRUE ,
1302- block = FALSE , append = FALSE )
1303- }
1304- }
1305- }
1306- })
1294+ # observe({
1295+ # if(!is.null(input$colorby_dd)){
1296+ # if(input$colorby_dd != "None"){
1297+ # if(dim(dd_plotdata())[1]>9){
1298+ # createAlert(session, inputId = "colorwarning_dd",
1299+ # title=NULL,
1300+ # message="Warning: Colors get recycled for attributes with more than nine levels.",
1301+ # type="warning", dismiss=TRUE,
1302+ # block=FALSE, append=FALSE)
1303+ # }
1304+ # }
1305+ # }
1306+ # })
13071307
13081308dd_uniformoverlay <- reactive({
13091309 if (! is.network(nw())){
@@ -3149,15 +3149,15 @@ output$dynamiccolor2 <- renderUI({
31493149})
31503150outputOptions(output ,' dynamiccolor2' ,suspendWhenHidden = FALSE , priority = 10 )
31513151
3152- observe({
3153- if (length(legendlabels2())> 9 ){
3154- createAlert(session , inputId = " colorwarning2" ,
3155- title = NULL ,
3156- message = " Warning: Colors get recycled for attributes with more than nine levels." ,
3157- type = " warning" , dismiss = TRUE ,
3158- block = FALSE , append = FALSE )
3159- }
3160- })
3152+ # observe({
3153+ # if(length(legendlabels2())>9){
3154+ # createAlert(session, inputId = "colorwarning2",
3155+ # title=NULL,
3156+ # message="Warning: Colors get recycled for attributes with more than nine levels.",
3157+ # type="warning", dismiss=TRUE,
3158+ # block=FALSE, append=FALSE)
3159+ # }
3160+ # })
31613161
31623162output $ dynamicsize2 <- renderUI({
31633163 selectInput(' sizeby2' ,
0 commit comments