加载绘图/反应元素时是否可以禁用闪亮的按钮?我知道shinyjs
可以禁用和启用输入元素,但我不知道如何设置与加载图/反应元素的连接。该示例基于单文件闪亮应用程序页面 https://shiny.rstudio.com/articles/single-file.html。我刚刚添加了一个按钮和隔离的部分。不基于的解决方案shinyjs
也很感激:)
library(shiny)
server <- function(input, output) {
output$distPlot <- renderPlot({
input$button
isolate(
hist(rnorm(input$obs), col = 'darkgray', border = 'white')
)
})
}
ui <- fluidPage(
shinyjs::useShinyjs(),
sidebarLayout(
sidebarPanel(
sliderInput("obs", "Number of observations:", min = 10, max = 500, value = 100),
actionButton("button", "OK!")
),
mainPanel(plotOutput("distPlot"))
)
)
shinyApp(ui = ui, server = server)
像这样的东西吗?
library(shiny)
library(shinyjs)
server <- function(input, output) {
PlotData <- eventReactive(input$button,{
disable("button")
Sys.sleep(2)
hist(rnorm(input$obs), col = 'darkgray', border = 'white')
enable("button")
})
output$distPlot <- renderPlot({
PlotData()
})
}
ui <- fluidPage(
shinyjs::useShinyjs(),
sidebarLayout(
sidebarPanel(
sliderInput("obs", "Number of observations:", min = 10, max = 1000, value = 2000),
actionButton("button", "OK!")
),
mainPanel(plotOutput("distPlot"))
)
)
shinyApp(ui = ui, server = server)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)