admin管理员组文章数量:1425862
Is it possible to use a selection widget for displaying a colour palette for reactive colour picking? I'd like to let the user pick the colour(s) for the plot that is created by a shiny app.
Is it possible to use a selection widget for displaying a colour palette for reactive colour picking? I'd like to let the user pick the colour(s) for the plot that is created by a shiny app.
Share Improve this question edited Jul 2, 2014 at 11:42 Spacedman 94.5k12 gold badges147 silver badges230 bronze badges asked Jul 2, 2014 at 11:40 AnjaMAnjaM 3,04910 gold badges41 silver badges65 bronze badges2 Answers
Reset to default 6The shinysky
package has a colorpicker which 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)) })
}
))
It is currently not on CRAN so you will need to install it via devtools
details are at https://github./AnalytixWare/ShinySky
For anyone ing here looking for a colour picker, the previous answer using shinysky
is outdated (the colour picker from there has been moved to a package that is not under maintenance)
There is another colour picker available for shiny in the shinyjs package.
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))
})
}
))
Disclaimer: I'm the author of this package.
本文标签: javascriptReactive colours in shinyStack Overflow
版权声明:本文标题:javascript - Reactive colours in shiny - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745459323a2659249.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论