i have not found the solution for my question about ProgressBar in Shiny for loading the data from database. My Shiny App is connected to database and the user directly gets the data from there (as my SQL Query is reactive, the amount of the data varies). Sometimes the data is quite big and loading it takes some time. The user does not know if something is going on or the app got "stuck". I implemented in my app (in output$tabelle <- DT::renderDataTable({...) the easiest possible process indicator but it seems to not be enough:
progress <- shiny::Progress$new()
on.exit(progress$close())
progress$set(message = "Processing", value = 0)
The user still gets bit confused.
I would like to have smthg like this (showing a status message in R) using ?tcltk::tkProgressBar:

pb <- tkProgressBar("test progress bar", "Some information in %",
0, 100, 50)
Sys.sleep(0.5)
u <- c(0, sort(runif(20, 0 ,100)), 100)
for(i in u) {
Sys.sleep(0.1)
info <- sprintf("%d%% done", round(i))
setTkProgressBar(pb, i, sprintf("test (%s)", info), info)
}
Sys.sleep(5)
close(pb)
with some percentage valuating the progress of data loading from database.
I do not know how i can use it inside my shiny app. Any ideas will be helpful.
Thanks in advance!
*some simple app:
library("shiny")
library("DT")
shinyApp(
ui = fluidPage(DT::dataTableOutput('tbl')),
server = function(input, output) {
output$tbl = DT::renderDataTable(
iris)
}
)
Probably the easiest way is to use a package shinysky which offers busyIndicator. You won't get a progress bar but a loading animation in the middle should do work too. You can also customise it by setting the text to show, gif and the time after which the indicator should be shown. (by default after one second).
Full example:
library("shiny")
library("DT")
library("shinysky")
shinyApp(
ui = fluidPage(
busyIndicator(),
h3("Test"),
hr(),
DT::dataTableOutput('tbl')
),
server = function(input, output) {
output$tbl = DT::renderDataTable({
data.frame(x = rnorm(7000000), y = runif(7000000))
})
}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With