3

I have the shiny app below in which an activity frequency bar is displayed on top and a process bar in the bottom. Is it possible to enable clicking on a bar in the upper bar graph and subset the process map based on that selection in order to display only the relative nodes connected ?

enter image description here

app.R

library(shiny)
library(shinydashboard)
library(bupaR)
library(processmapR)
library(eventdataR)
library(DiagrammeR)
library(svgPanZoom)
library(DiagrammeRsvg)
library(plotly)
ui <- dashboardPage(
  dashboardHeader(title = "decio"),
  dashboardSidebar(
    collapsed = TRUE
    
  ),
  dashboardBody(
    
    plotlyOutput("activity_frequency"),
    svgPanZoomOutput("pmap"),
        
    )
    
)
  


server <- function(input, output,session) {
  sip<-bupaR::simple_eventlog(eventlog = eventdataR::sepsis,
                              case_id = "case_id",
                              activity_id = "activity",
                              #activity_instance_id = "activity_instance_id",
                              timestamp = "timestamp",
                              #lifecycle_id = "lifecycle",
                              resource_id = "resource"
  )
  output$activity_frequency <- renderPlotly({
    
    ggplotly(sip %>% activity_frequency("trace") %>% plot())
  })
  output$pmap <- renderSvgPanZoom({
    
    process_map(sip, type_nodes = frequency("relative_case",color_scale = "Purples"),type_edges = performance(mean,"days", color_edges = "Purples"),
                rankdir = "TB", render = FALSE) %>% 
      generate_dot() %>% 
      grViz(width = 800, height = 1600) %>% 
      export_svg %>% 
      svgPanZoom(height=800, controlIconsEnabled = TRUE)
    
  })
  
  
}

shinyApp(ui, server)
ismirsehregal
  • 30,045
  • 5
  • 31
  • 78
firmo23
  • 7,490
  • 2
  • 38
  • 114
  • This should be possible using `plotly::event_data()` as done [here](https://stackoverflow.com/questions/70109559/is-there-a-way-to-open-a-dataset-when-i-click-on-a-section-in-pie-chart/70110162#70110162). – ismirsehregal Sep 05 '22 at 08:29

0 Answers0