progress icon indicating copy to clipboard operation
progress copied to clipboard

Multiple progress bars

Open gaborcsardi opened this issue 9 years ago • 7 comments

Would be great. E.g. if there is a progress bar within a progress bar...

gaborcsardi avatar Dec 27 '15 20:12 gaborcsardi

It would be nice if something like this worked:

pb1 <- progress_bar$new(total = 100)
for(i in 1:100){
  pb1$tick()
  pb2 <- progress_bar$new(total = 100)  
  for(j in 1:100){
    pb2$tick()
    Sys.sleep(1/1000)
    }
}

dfalbel avatar Mar 21 '16 20:03 dfalbel

Yeah, exactly.

I think we can have a global stack of active progress bars. In displays that only support one progress bar, most notably R Studio, we would only show the top one, and potentially show a summary for the rest. E.g. for three levels:

85% | 34% | 50% [====================--------------------] ETA 13s

For terminals with proper ANSI support, we can show all progress bars (well, up to 10-20) at once.

gaborcsardi avatar Mar 21 '16 20:03 gaborcsardi

I think one way you could support 3 or 4 simultaneous progress bars on one line is using unicode braille patterns

[⠿⠿⠟⠛⠛⠛⠒⠒⠒⠒       ]

jimhester avatar Oct 03 '17 19:10 jimhester

@jimhester that is smart, but also very limited, unfortunately.

gaborcsardi avatar Oct 03 '17 19:10 gaborcsardi

The below function I built is very crude, but why isn't something like below possible? I'd love to have it in a progress style package with the options of progress.

Recreate data:


df <- data.frame(samplecol=c(1:50),
           file=c(1:50))
df$file <- paste0("file",df$file)

x <-function() {Sys.sleep(1/100)}
y <-function() {Sys.sleep(1/20)}

Function:

doubleProgressBar <- function(x, y) {
    for (i in 1:100) {
      x()
        for(j in 1:50){ 
          y()
          cat("\014")
          writeLines(c(paste0("OVERALL PROGRESS:", i,"%"," [",paste(rep("+",round((i/5))), collapse="")), 
                      paste0("FILE%: ",(j*2),"%"," CURRENTLY LOADING FILE: ",df[j,"file"], " [",paste(rep("+",round((j/2.5))), collapse=""))))
        }
      cat("\014")
      writeLines(c(paste0("OVERALL PROGRESS:", i,"%"," [",paste(rep("+",round((i/5))), collapse="")), 
                   paste0("FILE%: ",(j*2),"%"," CURRENTLY LOADING FILE: ",df[j,"file"], " [",paste(rep("+",round((j/2.5))), collapse=""))))
    }
}

###Does what I want, but with crude text entry. 
###Would be nice to have a package with nice entry have a double bar
doubleProgressBar(x,y)

nbarsch avatar Mar 10 '18 23:03 nbarsch

This would be easy to do if all R terminals supported the ANSI escape sequence to move the cursor up lines unfortunately some (notably the default windows terminal) does not, so you are limited to only clearing the last line of text with \r.

jimhester avatar Mar 12 '18 13:03 jimhester

Can you add an option to use full ANSI escape sequences?

Alternatively, you could split the horizontal space between progress bars...

warnes avatar May 17 '19 18:05 warnes