4

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:

enter image description here

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) } ) 
6
  • Have you already found a solution to this or still looking for it? :) Commented Aug 9, 2016 at 22:19
  • Hey You :) Well not really this what i wanted. I have used smthg like that: output$tabelle <- DT::renderDataTable({ withProgress(message = 'Processing...', value = 0, { for (i in 1:10) { incProgress(1/30) Sys.sleep(0.25) } datatable(... However this does not provide the percentage and either does not correspond much to the process of loading data as we need to set the incProgress Commented Aug 10, 2016 at 5:21
  • Ok, I'll take a look at it in a free time because it is a very interesting problem Commented Aug 10, 2016 at 5:52
  • hahah Well Thank You very much! Take Your time Commented Aug 10, 2016 at 5:53
  • You probably load data with some button, right? Commented Aug 10, 2016 at 6:04

1 Answer 1

9

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)) }) } ) 
Sign up to request clarification or add additional context in comments.

3 Comments

It will turn on always when shiny is busy longer than a second (by default)
shinysky is not on CRAN but on github
Back then it was still available on Cran.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.