Closed serkserk closed 6 years ago
Use the mode parameter in animate_process(data, mode = c("off","absolute","relative"))
and set it to 'off' to stop the animation, or if you want to toggle animation on and off in the UI you can assign mode
as an input variable.
See example below
library(eventdataR)
library(processanimateR)
library(shiny)
ui <- fluidPage(
titlePanel("Start shiny app without animation"),
mainPanel(
h3("Options"),
selectInput(
inputId = "type",
label = "Animation Type",
choices = c("absolute", "relative", "off"),
# Set 'selected' to 'off'
selected = "off"),
h3("Process"),
processanimaterOutput("process")
)
)
server <- function(input, output, session) {
data <- eventdataR::patients
# Using input for animation type
output$process <- renderProcessanimater(expr = {
animate_process(data, mode = input$type, duration = 60)
})
}
shinyApp(ui = ui, server = server)
Thanks for your reply, what I'm actually looking is a way to start an absolute or relative animated process map on a "paused" state so I can toggle the animation after rendering it. Your suggestion is fine for small amount of data but it will redraw the process map every time which take time on large data.
Should be easy to do, but it will take some time to look into this. If you want to have a go at a pull request, please go ahead. I think adding a parameter to the R code to call the pauseAnimation()
function in animation_slider.js
(https://github.com/fmannhardt/processanimateR/blob/master/inst/htmlwidgets/lib/modules/animation_slider.js) would be the way to go.
Eventually, the pause and unpause methods should be factored out of the slider, but that is a bit more work. Also, it might be needed to reset the SVG time to 0 with svg.setCurrentTime
.
Thanks, I will see what I can do.
Just implemented the feature in 9199ffc
I just had the occasion of testing it only now, it's working great Thank you a lot !
Hi,
I'm creating a Shiny Dashboard around a process map and would like to not automatically play the animation on render, is there curently any way to achieve that or a posibility to add a parameter otherwise ?
Thanks again for your awesome library !