我试图在input$Product !=A && input$month !="All"
使用 Shinyjs 包时禁用闪亮的应用单选按钮(“趋势”),但没有成功。
我的ui页面定义为:
ui <- fluidPage(
shinyjs::useShinyjs(),
pageWithSidebar(
titlePanel("Analytics"),
sidebarPanel(
selectInput("product",
label = "Choose a Product",
choices = list("A", "B", "C", "All")),
selectInput("month",
label = "Choose TimeFrame",
choices = list("June", "July", "August", "September", "All")),
radioButtons('ptype', label ="Plot Type",
c(Histogram = 'histogram',
Box = 'boxp',
Trend = 'trendp')
)
),
我的服务器端代码:
shinyServer(function (input, output, session) {
mydata<- read.csv("mydataQ1fy16.csv")
observe({shinyjs::toggleState("trendp", input$product != "A" && input$month != "All") })
getMonthproduct <- reactive( {
if(input$month != "All" &input$product !="All") {
plotdata <- mydata %>% filter(Product ==input$product, Monthly ==input$month)}
else if (input$month =="All" & input$product =="All") {
plotdata <- mydata
}
else if(input$product == "All") {
plotdata <- mydata %>% filter(Monthly == input$month)
}
else if(input$month == "All") {
plotdata <- mydata %>% filter(Product == input$product)
}
return(plotdata)
})