On a Shiny page I notice that on a given tabPanel, plots for all renderPlot() statements are displayed simultaneously rather than one after another. Even when I add Sys.sleep(n) in between these renderPlot ... it simply deplays the rendering, but the renderPlot() outputs are not displayed in the order of their execution. I would like them to display one after another and provide user progress bar to indicate which plot is being plotted. Thanks.
UI
tabPanel
(
sidebarLayout
(
sidebarPanel
(
fileInput('dataSource', 'Upload Data',accept = c('text/csv','text/comma-separated-values','text/tab-separated-values','text/plain','.csv','.tsv'),multiple=TRUE)
),
mainPanel
(
fluidRow(column(width = 3, style = "background-color: transparent;", class = "well",plotOutput("comp1", height = 300,width = 300)),
column(width = 3, style = "background-color: transparent;", class = "well",plotOutput("comp2", height = 300,width = 300))),
tags$hr()
)
)
)
Server
values <- reactiveValues(df_data = NULL)
observeEvent(input$dataSource, { values$df_data <- read.csv(input$dataSource$datapath)})
Comp1 <- reactive({
plComp1 <- eqComp1(values$df_data [-(1:2)]))))
})
Comp2 <- reactive({
plComp2 <- eqComp2(values$df_data [-(1:2)]))))
})
output$comp1 <- renderPlot({
withProgress(message = 'Plotting in progress ...', value = 0, {
for (i in 1:15) {
incProgress(1/15)
Sys.sleep(0.5)
}
plot( values@df_data[,1], Comp1())
})
})
output$comp2 <- renderPlot({
withProgress(message = 'Plotting in progress ...', value = 0, {
for (i in 1:15) {
incProgress(1/15)
Sys.sleep(0.5)
}
plot( values@df_data[,1], Comp2())
})
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.