I am testing the feasibility of generating random sentences from a list and rendering those in a progressSweetAlert
. So far, I have been unable to get further than having the first randomly selected sentence post as the 'value' object.
What I am trying to achieve is, as the progress bar ... progresses, the randomly selected sentences render for a couple of seconds and then proceeds to the next string...such as...
"Eating bugs..." "Watching paint dry..." "Thinking big thoughts.."
Using the LaF package, I have succesfully created a list of sentencs and called it:
x<-c('Locating evil driods.',
'Planting happy thoughts.',
'Checking the water for bugs.',
'Reading "A Tale of Two Cities" ',
'Questioning the matrix.',
'Generating apple clones.',
'Discovering new things.')
writeLines(x, con="tmp.csv")
As per BDS masterly guidance, here is a working example :) :
library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(LaF)
ui <- fluidPage(
tags$h1("Progress bar in Sweet Alert"),
useSweetAlert(), # /!\ needed with 'progressSweetAlert'
actionButton(
inputId = "go",
label = "Launch long calculation !"
)
)
server <- function(input, output, session) {
observeEvent(input$go, {
x<-sample_lines("tmp.csv", 5)
y <- paste(x, 1:length(x), sep = "")
progressSweetAlert(
session = session, id = "myprogress",
title = y,
display_pct = TRUE, value = 0
)
for (i in seq_len(50)) {
Sys.sleep(0.1)
updateProgressBar(
session = session,
id = "myprogress",
value = i*2
)
}
closeSweetAlert(session = session)
sendSweetAlert(
session = session,
title =" Calculation completed !",
type = "success"
)
})
}
shinyApp(ui = ui, server = server)
I am hoping to get something not dissimilar from what you can see in these examples (https://blog.teamtreehouse.com/make-loading-screen-unity).
However, this is what I got: