Ben Engbers
Ben Engbers

Reputation: 453

How can I use svgPanZoom to show a bupaR process_map?

With bupaR, it's easy to create a process_map for an eventlog and the following code can be used to show this map in a shiny-app module:

fluidPage(
  fluidRow(
    column(10, grVizOutput(ns("ProcesAnalyse"))),
    column(2,
         fluidRow(actionButton(inputId = ns("doorloop_start_end_act_Button"), 
                               label = "Start en Eind", icon = NULL), 
                  actionButton(inputId = ns("doorloop_trace_freq_Button"), 
                               label = "Trace Frequentie", icon = NULL)
           )
    )
  ),
  fluidRow(h4("Metrieken"), br(), uiOutput(ns("Metrics")))
  )

  output$ProcesAnalyse <- renderGrViz({
    if (is.null(rv$Doorloop_events)) rv$Doorloop_events <- doorloop_events_reactive()
    withProgress(message = 'Verzamel de process-gegevens...', value = 0, {
    process_map(rv$Doorloop_events, rankdir = "TB", heigth = "2000px")
    })
  }) 

I am trying to use svgPanZoom to pan or zoom on the map. After changing

grVizOutput(ns("ProcesAnalyse"))

into

svgPanZoomOutput(ns("ProcesAnalyse"))

and output$ProcesAnalyse to

output$ProcesAnalyse <- renderSvgPanZoom({
  if (is.null(rv$Doorloop_events)) rv$Doorloop_events <- doorloop_events_reactive()
  withProgress(message = 'Verzamel de process-gegevens...', value = 0, {
    svgPanZoom(
      process_map(rv$Doorloop_events, rankdir = "TB", render = FALSE) %>%
      export_svg())
  })
})

the Metrics are still displayed but I don't get (see) a zoomable process_map. The documentation didn't give any help.

Where did I make a mistake?

Ben

Upvotes: 4

Views: 526

Answers (1)

Ben Engbers
Ben Engbers

Reputation: 453

The call : 'process_map(rv$Doorloop_events, rankdir = "TB", render = FALSE)' returns a dgr_graph object and I first understood that export_svg() would build and return a graph based on this object. However, first the dgr_graph object has to be used to build a dot-object. This output$ProcesAnalyse gives the desired output:

output$ProcesAnalyse <- renderSvgPanZoom({
  if (is.null(rv$Doorloop_events)) rv$Doorloop_events <- doorloop_events_reactive()
  withProgress(message = 'Verzamel de process-gegevens...', value = 0, {
    process_map(rv$Doorloop_events, rankdir = "TB", render = FALSE) %>% 
      generate_dot() %>% 
      grViz(width = 800, height = 1600) %>% 
      export_svg %>% 
      svgPanZoom(height=800, controlIconsEnabled = TRUE)
  })

})

Upvotes: 3

Related Questions