Created
January 9, 2013 18:24
-
-
Save gdepalma/4495519 to your computer and use it in GitHub Desktop.
Testing progress bar for shiny app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyServer(function(input, output) { | |
output$intense <- reactivePrint(function() { | |
if(input$panel==2){ | |
Sys.sleep(10) | |
return('Finished') | |
}else({return(NULL)}) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does not work