Любой способ сделать серые панели в Shiny на условной основе? - PullRequest
0 голосов
/ 08 июня 2018

Я работаю над базовым шаблоном Shiny UI, в котором пользователь должен выбрать определенную кнопку, чтобы предоставить приложение для ввода.Прямо сейчас я использую conditionalPanel (), но вместо того, чтобы кнопки ввода полностью исчезали, возможно ли их выделять серым цветом?

Вот следующий код:

  library(shiny)
  library(shinyjs)
 ui<-fluidPage(

 headerPanel("Title"),
 sidebarPanel(
 radioButtons("toggle", "Some Buttons",
             choices = list("Choice 1" = 1,
                           "Choice 2" = 2),
            selected = "Choice 2")),
conditionalPanel(
 condition = "input.toggle % 2 == 0",
 sidebarPanel(radioButtons("otherButtons","Buttons",
              choices = list("Choice 1"=1,
                            "Choice 2"=2)),
 radioButtons("moreButtons","Buttons",
              choices = list("Choice 1"= 1,
                            "Choice 2" = 2))
  ),
  "Some Text"
 )


 )




server<-function(input,output,session){



 }

shinyApp(ui,server)

1 Ответ

0 голосов
/ 08 июня 2018

Может быть, вы могли бы попробовать это.Вы не сможете ничего выбрать на второй панели, когда выберете вариант 1 на первой панели.

ui <- fluidPage(

  headerPanel("Title"), shinyjs::useShinyjs(),

  sidebarPanel(id = "mySideBar",
               radioButtons("toggle", "Some Buttons",
                            choices = list("Choice 1" = 1,
                                           "Choice 2" = 2),
                            selected = "Choice 2")),

      sidebarPanel(id = "mySideBar2",
        radioButtons("otherButtons","Buttons",
                                choices = list("Choice 1"=1,
                                               "Choice 2"=2)),
                   radioButtons("moreButtons","Buttons",
                                choices = list("Choice 1"= 1,
                                               "Choice 2" = 2))

)   
)


server<-function(input,output,session){

  shinyjs::onclick("advanced2",
                   shinyjs::toggle(id = "advanced2", anim = TRUE))

  observeEvent(input$toggle, {
    if(input$toggle == "1"){
      shinyjs::disable(id = "mySideBar2")
    } else {
      shinyjs::enable(id = "mySideBar2")
    }
  })

}

shinyApp(ui,server)
...