This version has a rescalable plot from <<https://github.com/rstudio/shiny/issues/650>> that uses the session parameter in the server function setup:
library(ggraph)
library(igraph)(data.table)
t01 <- fread("C:/kewoo/git/eai-bw.master/BW_Projects/Tools/findOperationUsage.csv")
setnames(t01, "BW Calling Project", "BW_Calling_Project")
setnames(t01, "BW Project", "BW_Project")
setnames(t01, "BW Exposed Service", "BW_Exposed_Service")
setnames(t01, "BW Process", "BW_Process")
t01[,reqSUB1 := sub("Request", "", BW_Process)]
t01[,reqSUB2 := sub(".process", "", reqSUB1)]
t01[,reqSUB3 := sub("(\\w)", "\\L\\1", reqSUB2, perl=TRUE)]
t01[,operSUB1 := sub("(\\w)", "\\L\\1", Operation, perl=TRUE)]
# t01a is a caller-centred graph, giving you a callee-list (via subcomponent mode = out) for any given service operation
t01a <- t01[,.(caller = paste(BW_Calling_Project, reqSUB3, sep = "-"),
callee = paste(BW_Project, operSUB1, sep = "-"))]
ig01a <- graph_from_data_frame(t01a, directed = TRUE)
library(shiny)
# Define UI for app that draws a histogram ----
ui <- fluidPage(
titlePanel(h1("Service Operation Call Dependency Visualiser")),
sidebarLayout(
sidebarPanel(
h1("Service Operations"),
selectInput("ServiceOperation", h3("Choose"),
choices = sort(V(ig01a)$name))
),
mainPanel(
plotOutput("ServiceOpDependencies_ig")
)
)
)
# Define server logic required to draw a histogram ----
server <- function(input, output, session) {
output$ServiceOpDependencies_ig <- renderPlot({
plot.igraph(induced_subgraph(ig01a,
subcomponent(ig01a, input$ServiceOperation, mode = c("out"))),
frame = 1,
vertex.shape = "none",
vertex.label.dist = 1,
edge.curved = 0.1,
layout=layout_with_kk)},
height = function() {
0.75 * session$clientData$output_ServiceOpDependencies_ig_width
})
}
shinyApp(ui = ui, server = server)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.