Type Package Package processanimater Title Process Map Token Replay Animation Version 0.3.0 October 5, 2018 Token replay animation for process maps created with 'processmapr' by using SVG animations ('SMIL') and the 'htmlwidget' package. License MIT + file LICENSE Encoding UTF-8 LazyData true Imports bupar, processmapr (>= 0.3.1), rlang, magrittr, dplyr, htmlwidgets, DiagrammeR (>= 1.0.0), zoo, scales Suggests eventdatar, edear, testthat, knitr, rmarkdown, shiny, RColorBrewer RoxygenNote 6.1.0 URL https://github.com/fmannhardt/processanimater/ BugReports https://github.com/fmannhardt/processanimater/issues VignetteBuilder knitr NeedsCompilation no Author Felix Mannhardt [aut, cre], Gert Janssenswillen [ctb] Maintainer Felix Mannhardt <felix.mannhardt@sintef.no> Repository CRAN Date/Publication 2018-10-05 11:30:03 UTC R topics documented: add_token_color...................................... 2 add_token_size....................................... 3 animate_process....................................... 4 processanimateroutput................................... 7 renderprocessanimater................................... 8 1
2 add_token_color Index 9 add_token_color Adds a token color attribute Adds a color attribute to an event log that can be used in combination with the token_color parameter of animate_process add_token_color(eventlog, attribute, color_attribute, palette = "YlOrBr", na.color = "red", color_mapping = scales::col_numeric(palette, eventlog %>% pull(!! (attr)), na.color = na.color)) eventlog The source eventlog attribute The source attribute to calculate the color on color_attribute The target attribute to store the color information in palette na.color color_mapping The palette to use with the default color mapping The color for NA values A function that takes the attribute and returns a color, the default is using scales::col_numeric. Examples { # Load example event log library(eventdatar) # Add token color based on a numeric attribute add_token_color(patients, "time", "color") # Add token color based on a factor attribute add_token_color(patients, "employee", "color", color_mapping = scales::col_factor("set3", patients$employee)) }
add_token_size 3 add_token_size Adds a token size attribute Adds a size attribute to an event log that can be used in combination with the token_size parameter of animate_process add_token_size(eventlog, attribute, size_attribute, min.size = 2, max.size = 8, na.size = 2, size_mapping = size_numeric(eventlog %>% pull(!! (attr)), min.size, max.size, na.size)) eventlog attribute The source eventlog The source attribute to calculate the size on size_attribute The target attribute to store the size information in min.size max.size na.size size_mapping The minimum size The maximum size The size for NA values A function that takes the attribute and returns a size between min.size and max.size, the default is a linear transformation that only works for numeric attributes.. Examples { } # Load example event log library(eventdatar) # Generate random numeric attribute patients$test <- rnorm(nrow(patients), 5) # Add token size based on a numeric attribute add_token_size(patients, "test", "size")
4 animate_process animate_process Animate cases on a process map A function for creating a SVG animation of an event log on a process map created by processmapr. animate_process(eventlog, processmap = process_map(eventlog, render = F,...), animation_mode = c("absolute", "relative", "off"), animation_duration = 60, animation_jitter = 0, animation_timeline = TRUE, animation_legend = NULL, token_size = NULL, token_size_scale = c("identity", "linear", "sqrt", "log", "quantize", "ordinal", "time"), token_size_scale_domain = NULL, token_size_scale_range = NULL, token_color = NULL, token_color_scale = c("identity", "linear", "sqrt", "log", "quantize", "ordinal", "time"), token_color_scale_domain = NULL, token_color_scale_range = NULL, token_image = NULL, token_opacity = NULL, token_shape = c("circle", "rect", "image"), token_attributes = NULL, token_callback_onclick = c("function(svg_root, svg_element, case_id) {", "}"), activity_callback_onclick = c("function(svg_root, svg_element, activity_id) {", "}"), elementid = NULL, prerenderhook = NULL, width = NULL, height = NULL,...) eventlog processmap The event log object that should be animated The process map created with processmapr that the event log should be animated on, if not provided a standard process map will be generated by using processmapr::process_map. animation_mode Whether to animate the cases according to their actual time of occurence ("absolute") or to start all cases at once ("relative"). animation_duration The overall duration of the animation, all times are scaled according to this overall duration. animation_jitter The magnitude of a random coordinate translation, known as jitter in scatterplots, which is added to each token. Adding jitter can help to disambiguate tokens traveling on top of each other. animation_timeline Whether to render a timeline slider in supported browsers (Recent versions of Chrome and Firefox only).
animate_process 5 animation_legend Whether to show a legend for the size or the color scale. token_size The event attribute (character) or alternatively a data frame with three columns (case, time, size) matching the case identifier of the supplied event log. The token size is scaled accordingly during the animation (default size is 4). You may use add_token_size to add a suitable attribute to the event log. token_size_scale Which D3 scale function to use for generating the size scale. token_size_scale_domain The domain of the D3 scale function. Can be left NULL in which case it will be automatically determined. token_size_scale_range The range of the D3 scale function. Should be a vector of two or more numerical values. token_color The event attribute (character) or alternatively a data frame with three columns (case, time, color) matching the case identifier of the supplied event log. The token color is change accordingly during the animation (default color is orange). You may use add_token_color to add a suitable attribute to the event log. token_color_scale Which D3 scale function to use for generating the color scale. token_color_scale_domain The domain of the D3 scale function. Can be left NULL in which case it will be automatically determined. token_color_scale_range The range of the D3 scale function. Should be a vector of two or more numerical values. token_image token_opacity The event attribute (character) or alternatively a data frame with three columns (case, time, image) matching the case identifier of the supplied event log. The token image is change accordingly during the animation (by default a SVG shape is used). The event attribute (character) or alternatively a data frame with three columns (case, time, transparency) matching the case identifier of the supplied event log. The token fill-opacity is change accordingly during the animation (by default the token is drawn with 0.9 opacity). token_shape The (fixed) SVG shape to be used to draw tokens. Can be either circle (default), rect or image. In the latter case the image URL needs to be specified as parameter token_image. token_attributes A list of additional (fixed) SVG attributes to be added to each token. token_callback_onclick A javascript function that is called when a token is clicked. The function is parsed by JS and received three parameters: svg_root, svg_element, and case_id. activity_callback_onclick A javascript function that is called when an activity is clicked. The function is parsed by JS and received three parameters: svg_root, svg_element, and activity_id.
6 animate_process elementid passed through to createwidget. A custom elementid is useful to capture the selection events via input$elementid_tokens and input$elementid_activities when used in Shiny. prerenderhook width, height passed through to createwidget. Fixed size for widget (in css units). The default is NULL, which results in intelligent automatic sizing based on the widget s container.... Options passed on to process_map. Author(s) See Also Felix Mannhardt <felix.mannhardt@sintef.no> (SINTEF Digital) processmapr:process_map Examples # Create small example event log library(bupar) example_log <- bupar::eventlog( eventlog = data.frame( case = c(rep(1,6),rep(2,6),rep(3,8)), act = c(rep(c("a","a","b","b","c","c"),2), rep(c("a", "B", "D", "C"), each = 2)), act_id = rep(c(1:10),each=2), lifecycle = rep(c("start", "complete"),10), res = rep(sample(letters[1:3], 10, replace = TRUE), each = 2), time = as.posixct(c(0,5,10,15,20,25, 5,10,15,20,25,30, 10,20,30,40,50,60,70,80) * 600, origin = "2018/10/03")), case_id = "case", activity_id = "act", timestamp = "time", activity_instance_id = "act_id", lifecycle_id = "lifecycle", resource_id = "res") # Animate the process with default options (absolute time and 60s duration) animate_process(example_log) # Animate the process with default options (relative time and with jitter) animate_process(example_log, animation_mode = "relative", animation_jitter = 10) # Change default token sizes animate_process(example_log, token_size = 2) # Change default token color animate_process(example_log, token_color = "red")
processanimateroutput 7 # Change default token opacity animate_process(example_log, token_opacity = 0.5) # Change default token image (GIFs work too) animate_process(example_log, token_shape = "image", token_size = 10, token_image = "https://upload.wikimedia.org/wikipedia/en/5/5f/pacman.gif") # Change token color based on a factor attribute animate_process(example_log, animation_legend = "color", token_color = "res", token_color_scale = "ordinal", token_color_scale_range = RColorBrewer::brewer.pal(8, "Paired")) # This requires example data library(eventdatar) data(traffic_fines) # Change token color based on a numeric attribute, here the nonsensical 'time' of an event animate_process(edear::filter_trace_frequency(bupar::sample_n(traffic_fines,1000),percentage=0.95), animation_legend = "color", token_color = "amount", token_color_scale = "linear", token_color_scale_range = c("yellow","red"), animation_mode = "relative") processanimateroutput Create a process animation output element Renders a renderprocessanimater within an application page. processanimateroutput(outputid, width = "100%", height = "400px") outputid width, height Output variable to read the animation from Must be a valid CSS unit (like 100 which will be coerced to a string and have px appended.
8 renderprocessanimater renderprocessanimater Renders process animation output Renders a SVG process animation suitable to be used by processanimateroutput. renderprocessanimater(expr, env = parent.frame(), quoted = FALSE) expr env quoted The expression generating a process animation (animate_process). The environment in which to evaluate expr. Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.
Index add_token_color, 2, 5 add_token_size, 3, 5 animate_process, 2, 3, 4 createwidget, 6 JS, 5 process_map, 6 processanimateroutput, 7 renderprocessanimater, 8 9