Progress: Multiple progress bars

Created on 27 Dec 2015  ·  7Comments  ·  Source: r-lib/progress

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

Most helpful comment

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.

All 7 comments

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)
    }
}

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.

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

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

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

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)

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Spatial-R picture Spatial-R  ·  3Comments

sammerk picture sammerk  ·  3Comments

HarlanH picture HarlanH  ·  3Comments

seankross picture seankross  ·  3Comments

Spatial-R picture Spatial-R  ·  3Comments