Giter Site home page Giter Site logo

plantuml's Introduction

PlantUML in R


DOI

Build Status Coverage Status lifecycle


Overview

This package provides the functionality to create UML graphs using the PlantUML language.

Installation

Prerequisites

The actual work is done by the program plantuml. Please see the plantuml installation page for prerequisites of running plantuml. You don’t have tio install the plantuml.jar file, as the packagae maintains it’s own version (see below).

As the package is only on github, you need devtools to install it easily as a prerequisite

install.packages("devtools")

Installation of plantuml

The package is not on CRAN, so you have to install it from github. Also, it doez not come with the plantuml binary, which needs to be installed as well:

# Install plantuml from github
devtools::install_github("rkrug/plantuml")

# download and install the PlantUML jar file from \link{http://plantuml.com/download}
# whenever you call this command again, the plantuml binary will be updated to the newest version
library(plantuml)
updatePlantumlJar()

Plotting Plantuml graphics

Define plantuml code

First, we define a plantuml object based on some plantuml code

library(plantuml)
x <- '
(*) --> "Initialization"

if "Some Test" then
  -->[true] "Some Activity"
  --> "Another activity"
  -right-> (*)
else
  ->[false] "Something else"
  -->[Ending process] (*)
endif
'
x <- plantuml( 
  x
)

Plot via vector format

Now we plot in in a device using vector format (svg) as intermediate format, which is the default

plot( 
  x = x
# vector = TRUE
  )

Plot via raster format

When using vector = FALSE uses a raster format (png) as intermediate format

plot( 
  x = x,
  vector = FALSE
  )

Plotting to a file

To save the graph in a file, we simply specify the file argument in the plot command:

plot( 
  x, 
  file = "./README_files/test.svg" 
)

And here is the file

README_files/test.svg

The type of the file is automatically determined based on the extension. Suported extensions in plantuml are:

- png       To generate images using PNG format (default)
- svg       To generate images using SVG format
- eps       To generate images using EPS format
- pdf       To generate images using PDF format
- vdx       To generate images using VDX format
- xmi       To generate XMI file for class diagram
- scxml     To generate SCXML file for state diagram
- html      To generate HTML file for class diagram
- txt       To generate images with ASCII art
- utxt      To generate images with ASCII art using Unicode characters
- latex     To generate images using LaTeX/Tikz format
- latex:nopreamble  To generate images using LaTeX/Tikz format without preamble

Plotting R objects

In addition to plotting based on plantuml code some basic functionality to document R objects has been included.

This is not much more than a proof of concept but includes all standard R objects.

If you think this is usefull, pelase let me know and leave sugestions in the issue tracker.

One example is:

x <- list(
  a = 1:10,
  b = letters[1:4],
  c = data.frame(
    x = 1:10,
    y = c(TRUE, FALSE)
  )
)
plot(
  as.plantuml(x)
)

TODO

  • make selection dependant on installed packages, as vector = TRUE requires postscript to be installed!
  • update documentation and
  • add tests for plot.plantuml()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.