是否可以使用选择小部件来显示用于响应式(Reactive)颜色选择的调色板?我想让用户为 Shiny 的应用程序创建的图选择颜色。
最佳答案
shinysky
包有一个颜色选择器,您可以将其与 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)) })
}
))
它目前不在 CRAN 上,因此您需要通过 devtools
安装它,详细信息位于 https://github.com/AnalytixWare/ShinySky
关于javascript - Shiny 的 active 颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24530195/