DEV Community

Cover image for Using BPMN Visualization in R
Souchet Céline for Process Analytics

Posted on • Edited on • Originally published at Medium

3 1

Using BPMN Visualization in R

With the bpmn-visualization TypeScript library, you can visualize process execution data on BPMN diagrams in a web browser, by adding custom overlays and customizing the style of the diagram.

The new BPMN Visualization - R Package is being developed to offer another way to visualize process execution data in R.

Let's see how it works.

Prerequisites

R Studio or R Console

Installation

First, you need to install the package from Github:

> devtools::install_github("process-analytics/bpmn-visualization-R")
> library(bpmnVisualization)
view raw Installation.R hosted with ❤ by GitHub

Load a BPMN file

The bpmnVisualization package accepts a BPMN file in XML format.
There are several ways to load this file. However, in this article, we will focus on how to load an example file from the package.

> bpmn_file <- system.file("examples/Email_Voting.bpmn", package = "bpmnVisualization")

You will find the other ways to load a BPMN file in the README of the package.

Display the BPMN diagram

At the moment, there are 2 ways to display the BPMN diagram: Just the diagram without overlay or The diagram with overlay(s).

Just the diagram

> bpmnVisualization::display(bpmn_file)

Just the diagram

The diagram with overlays

> overlays <- list(bpmnVisualization::create_overlay("bpmn_element_id_1", "42"), bpmnVisualization::create_overlay("bpmn_element_id_2", "9"))
> bpmnVisualization::display(bpmn_file, overlays)

The diagram with overlays

Overlays customization and positioning will be possible in a future version of the package.

Integrate in a Shiny App

You can also use the bpmnVisualization package in a Shiny app.

If you are not familiar with Shiny, it is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in R Markdown documents or build dashboards.

The following example displays a BPMN diagram provided as an example by the package, with an overlay on top of a BPMN element.

# Install and load packages
> install.packages("shiny")
> library(shiny)
> devtools::install_github("process-analytics/bpmn-visualization-R")
> library(bpmnVisualization)
> displayBpmn <- function() {
bpmn_file <- system.file("examples/Travel_Booking.bpmn", package = "bpmnVisualization")
overlays <- list(bpmnVisualization::create_overlay("_6–203", "9"))
bpmnVisualization::display(bpmn_file, overlays)
}
> ui <- shinyUI(fluidPage(
titlePanel("Display bpmn diagrams with execution data"),
bpmnVisualizationOutput('bpmnContainer')
)
)
> server = function(input, output) {
# renderBpmnVisualization is the R bridge function to the html widgets
output$bpmnContainer <- renderBpmnVisualization({ displayBpmn() })
}
> shinyApp(ui, server)
view raw Shiny App.R hosted with ❤ by GitHub

Shiny App

Participation in Hacktoberfest 2021

If you want to participate in Hacktoberfest to promote Open Source development and you don't know where to make a contribution, you can try with the labeled issues from the BPMN Visualization - R Package repository.

We are also waiting for contributions in other repositories. For more information, see this article.

If you have any questions - let us know directly on GitHub issues or via Twitter.

Hacktoberfest 2021

Conclusion

Now, you have everything you need to start your first project with BPMN Visualization in R.

Thank you for reading and I hope I helped or inspired you 😊

We also plan to publish the BPMN Visualization package in CRAN soon.

Follow us to keep up to date on the latest news:

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay