Skip to content

Instantly share code, notes, and snippets.

@gdepalma
Created January 9, 2013 18:24
Show Gist options
  • Save gdepalma/4495519 to your computer and use it in GitHub Desktop.
Save gdepalma/4495519 to your computer and use it in GitHub Desktop.
Testing progress bar for shiny app.
library(shiny)
shinyServer(function(input, output) {
output$intense <- reactivePrint(function() {
if(input$panel==2){
Sys.sleep(10)
return('Finished')
}else({return(NULL)})
})
})
<script type="text/javascript">
var wasBusy = false;
var elapsedTimer = null;
var startTime = null;
function updateBusy() {
var isBusy = $('html').hasClass('shiny-busy');
if (isBusy && !wasBusy) {
startTime = new Date().getTime();
elapsedTimer = setInterval(function() {
var millisElapsed = new Date().getTime() - startTime;
$('progress').text(Math.round(millisElapsed/1000) + ' seconds have elapsed');
}, 1000);
}
else if (!isBusy && wasBusy) {
clearInterval(elapsedTimer);
}
wasBusy = isBusy;
}
</script>
library(shiny)
shinyUI(pageWithSidebar(
# Application title
headerPanel("Testing..."),
sidebarPanel(
helpText("Panel compute is where I wish for a 'progress bar' to show how much
time has elapsed.")
),
mainPanel(
tabsetPanel(
tabPanel("Start",value=1),
tabPanel("Compute", list(
### show timer
div(id='progress',includeHTML("timer.js")),
### long function
verbatimTextOutput("intense")),
value=2),id='panel')
)
))
@xiaodaigh
Copy link

does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment