r - Change style and position of the message box generated by withProgress() -


the withprogress() function can generate message box indicating shiny app running. message @ top-right conner of browser small text size, makes message not eye-catching.

so wonder there way change style , position of box, message can more expressive.

here part of code:

output$plot <- renderplot({   if (input$button){   withprogress(               distributionpolygon(data(),unit="years",colors=c("black","gray30","gray50","gray70","blue3","dodgerblue3","steelblue1","lightskyblue1","red4","indianred3","orange","seagreen4"),main=title(),tpsmax=input$months),               message = 'loading...',               detail = ''               )       }    }) 

update

this updated version can refer example, example taken here

server <- function(input, output) {   output$plot <- renderplot({     input$goplot # re-run when button clicked      # create 0-row data frame used store data     dat <- data.frame(x = numeric(0), y = numeric(0))      withprogress(message = 'making plot', value = 0, {       # number of times we'll go through loop       n <- 10        (i in 1:n) {         # each time through loop, add row of data.         # stand-in long-running computation.         dat <- rbind(dat, data.frame(x = rnorm(1), y = rnorm(1)))          # increment progress bar, , update detail text.         incprogress(1/n, detail = paste("doing part", i))          # pause 0.1 seconds simulate long computation.         sys.sleep(0.1)       }     })      plot(dat$x, dat$y)   }) }  ui <- shinyui(basicpage(   plotoutput('plot', width = "300px", height = "300px"),   actionbutton('goplot', 'go plot') ))  shinyapp(ui = ui, server = server) 

original post

this related previous question too. want change cssstyle of progress bar. feel free play around , more research if want fancier css progress bar.

note: during calculations have disabled button users not click button multiple times forcing computation repeat itself. can further shinyjs more information. can see in image below during computation button disabled. once finished

rm(list = ls()) library(shiny) library(shinyincubator) library(shinyjs)  server <- function(input, output, session) {   observe({     if(input$abutton==0) return(null)     withprogress(session, min=1, max=15, expr={       disable("abutton")       for(i in 1:20) {         setprogress(message = 'finished...',detail = paste0('number ',i, ':20'))         sys.sleep(0.1)       }       sys.sleep(1.5)     })     enable("abutton")   }) }  ui <- fluidpage(   tags$head(tags$style(".shiny-progress {top: 50% !important;left: 50% !important;margin-top: -100px !important;margin-left: -250px !important; color: blue;font-size: 20px;font-style: italic;}")),   sidebarpanel(actionbutton("abutton", "let's go!"), width=2),   useshinyjs(),   mainpanel(progressinit()) )  shinyapp(ui = ui, server = server) 

enter image description here


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -