ProcessanimateR animation can be also used interactively as part of a (Shiny) web-application. Here, an example application that expects attributes are of an appropriate data type and automatically chooses appropriate color scales is given. We first define a function ianimate_process that defines our Shiny application as follows:

library(processanimateR)
library(shiny)
library(shinycssloaders)
ianimate_process <- function(eventlog, min.time = 30, max.time = 600, default.time = 60) {

  ui <- function(request) {
    fluidPage(
      tags$head(tags$style("#process{height:90vh !important;}")),
      titlePanel("Hello processanimateR!"),

      sidebarLayout(

        sidebarPanel(
          width = 2,
          sliderInput("duration", "Animation duration", min.time, max.time, default.time),
          selectInput("type", "Animation type", c("relative", "absolute"), "relative"),
          selectInput("sizeAttribute", "Size attribute", c("none", colnames(eventlog)), "none"),
          selectInput("colorAttribute", "Color attribute", c("none", colnames(eventlog)), "none"),
          selectInput("orientation", "Orientation", c("horizontal"="LR", "vertical"="TB"), "horizontal"),
          h4("Selected cases"),
          textOutput("token_selection"),
          h4("Selected activities"),
          textOutput("activity_selection")
        ),

        mainPanel(
          width = 10,
          shinycssloaders::withSpinner(processanimaterOutput("process"))
        )
      )
    )
  }

  server <- function(session, input, output) {

    data <- reactive({

      if (input$colorAttribute != "none") {
        attr <- rlang::sym(input$colorAttribute)
        val <- eventlog %>% pull(!!attr)
        if (is.character(val) || is.factor(val)) {
          eventlog <- eventlog %>%
            add_token_color(input$colorAttribute, "color",
                            color_mapping = scales::col_factor("YlOrBr", val, na.color = "red"))
        } else if (is.logical(val)) {
          eventlog <- eventlog %>%
            add_token_color(input$colorAttribute, "color",
                            color_mapping = scales::col_factor(c("green", "orange"), levels = c(T,F), na.color = "red"))
        } else { #fallback to numeric
          eventlog <- eventlog %>%
            mutate(!!attr := as.numeric(!!attr)) %>%
            add_token_color(input$colorAttribute, "color")
        }
      }

      if (input$sizeAttribute != "none") {
        # This only works for numeric attributes
        attr <- rlang::sym(input$sizeAttribute)
        val <- eventlog %>% pull(!!attr)
        if (is.numeric(val)) {
          eventlog <- eventlog %>%
            mutate(!!attr := as.numeric(!!attr)) %>%
            add_token_size(input$sizeAttribute, "size")
        } else {
          warning("Trying to use a non-numeric attribute for the token size!")
          eventlog <- eventlog %>%
            mutate(size = 6)
        }
      }

      eventlog

    })

    output$token_selection <- renderText({

      paste0(input$process_tokens, ",")

    })

    output$activity_selection <- renderText({

      paste0(input$process_activities, ",")

    })

    output$process <- renderProcessanimater(expr = {
      graph <- processmapR::process_map(data(), render = F)
      model <- DiagrammeR::add_global_graph_attrs(graph, attr = "rankdir", value = input$orientation, attr_type = "graph")
      if (input$sizeAttribute != "none" && input$colorAttribute != "none") {
        animate_process(data(), model,
                        animation_mode = input$type,
                        token_size = "size",
                        token_color = "color",
                        animation_duration = input$duration,
                        elementId = "process")
      } else if (input$sizeAttribute != "none") {
        animate_process(data(), model,
                        animation_mode = input$type,
                        token_size = "size",
                        animation_duration = input$duration)

      } else if (input$colorAttribute != "none") {
        animate_process(data(), model,
                        animation_mode = input$type,
                        token_color = "color",
                        animation_duration = input$duration)
      } else {
        animate_process(data(), model,
                        animation_mode = input$type,
                        animation_duration = input$duration)
      }

    })

  }

  shinyApp(ui, server, options = list(height = 500))

}

Then, the application can be, for example, launched by calling: