2014-07-02 22 views
6

Có thể sử dụng tiện ích lựa chọn để hiển thị bảng màu để chọn màu phản ứng không? Tôi muốn cho phép người dùng chọn (các) màu cho cốt truyện được tạo bởi ứng dụng sáng bóng.Màu phản ứng trong sáng bóng

Trả lời

3

Đối với bất kỳ ai đến đây tìm kiếm bộ chọn màu, câu trả lời trước bằng cách sử dụng shinysky đã lỗi thời (bộ chọn màu từ đã được chuyển đến một gói không được bảo trì)

Có một bộ chọn màu khác có sẵn để sáng bóng trong gói shinyjs.

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: Tôi là tác giả của gói này.

6

Gói shinysky có ColorPicker mà bạn có thể sử dụng với 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

Nó hiện không ở trong cran vì vậy bạn sẽ cần phải cài đặt nó thông qua devtools chi tiết có tại https://github.com/AnalytixWare/ShinySky

Các vấn đề liên quan