Reputation: 61
in my application I want to upload a local csv-file (eventlog), display the datatable and after that create a processmap with the data from the csv-file (bupar). In a normal R-script, the creation of a processmap is working fine. But how can I plot a processmap (below the DataTables) in a shiny application with a button press on the button 'createDiagram'? Thanks in advance!
Below the code:
library(shiny)
ui <- fluidPage(
titlePanel("Visualization"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose a File:",
multiple = FALSE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
tags$hr(),
actionButton("createDiagram","Create a Process Diagram"),
tags$hr()
),
mainPanel(
tableOutput("contents"),
plotOutput("plot")
)
)
)
server <- function(input, output) {
output$contents <- renderTable({
req(input$file1)
tryCatch(
{
inputData <- read.csv2(input$file1$datapath)
},
error = function(e) {
stop(safeError(e))
}
)
})
}
# Create Shiny app ----
shinyApp(ui, server)
Upvotes: 4
Views: 889
Reputation: 56
processmap() outputs a dgr_graph object. These can be rendered in a shiny app with
library(DiagrammeR)
grVizOutput(outputId = "process")
and
output$process <- renderGrViz({
plot <- process_map(eventlog, render = F)
render_graph(plot)
})
Upvotes: 1