Reactive colors in brilliant.

Can I use a selection widget to display a color palette for reactive color selection? I would like to let the user select the color (s) for the plot created by the brilliant application.

+6
source share
2 answers

For those who come here to look for a color picker, the previous answer using shinysky out of date (the color selection from there was moved to a package that is not under maintenance)

The shinyjs package has another set of color palettes.

 library(ggplot2) library(shiny) library(shinyjs) runApp(shinyApp( ui = fluidPage( colourInput("col", "Select colour", "grey"), plotOutput("plot") ), server = function(input, output, session) { output$plot <- renderPlot({ ggplot(cars, aes(speed, dist)) + geom_point() + theme(panel.background = element_rect(fill = input$col)) }) } )) 

enter image description here

Disclaimer: I am the author of this package.

+3
source

The shinysky package has a colorpicker that you can use with shiny :

 require(shinysky) require(shiny) runApp(list( ui = bootstrapPage( jscolorInput("colorid"), uiOutput('myPanel'), plotOutput('plot') ), server = function(input, output) { output$myPanel <- renderUI({ mystyle <- ifelse(is.null(input$colorid), "ffffff", input$colorid) inputPanel( numericInput('n', 'Number of obs', 100) , style = paste0("background-color:#", mystyle, ";") ) }) output$plot <- renderPlot({ hist(runif(input$n)) }) } )) 

enter image description here

It is not currently included in CRAN, so you will need to install it through devtools . Details are at https://github.com/AnalytixWare/ShinySky

+6
source

Source: https://habr.com/ru/post/971651/


All Articles