Title: | Sassy 'UML' Diagrams |
---|---|
Description: | A tool for drawing sassy 'UML' (Unified Modeling Language) diagrams based on a simple syntax, see <https://www.nomnoml.com>. Supports styling, R Markdown and exporting diagrams in the PNG format. Note: you need a chromium based browser installed on your system. |
Authors: | Andrie de Vries [aut, cre], Javier Luraschi [aut], Daniel Kallin [cph] (nomnoml.js library, <https://nomnoml.com>), RStudio [cph, fnd] |
Maintainer: | Andrie de Vries <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2024-12-11 13:35:33 UTC |
Source: | https://github.com/rstudio/nomnoml |
Renders a 'nomnoml' diagram as an 'htmlwidget' or saves it as a '.png' or '.svg' image.
nomnoml( code = "[Hello]-[World!]", png = NULL, width = NULL, height = NULL, svg = FALSE, ... )
nomnoml( code = "[Hello]-[World!]", png = NULL, width = NULL, height = NULL, svg = FALSE, ... )
code |
The nomnoml diagram code. |
png |
Optional file name to export diagram as 'png'. |
width |
Optional width in pixels for the exported 'png'. |
height |
Optional height in pixels for the exported 'png'. |
svg |
Use 'svg' output instead of 'png'? Notice that rendering in 'svg' is not at a par with 'png' and renders incorrectly at times. |
... |
Additional parameters. |
The 'nomnoml' syntax is simple and intuitive, a "Hello World" example can be rendered as an 'htmlwidget' as follows:
nomnoml::nomnoml("[Hello]-[World!]")
You can also render as a 'png' file with specific dimensions:
nomnoml::nomnoml("[Hello]-[World!]", png = "hello.png", 600, 100)
Still, complex diagrams can be defined by combining multiple association types, classifier types, directives and custom classifier styles.
You can also use of the nomnoml
'knitr' chunk
to render inline diagrams in R Markdown documents.
For a summary of available nomnoml
syntax, including association types,
directives and customer classifier styles, see nomnoml_syntax
nomnomlOutput()
, renderNomnoml()
, nomnoml_validate()
, nomnoml_syntax()
# Render simple diagram: nomnoml::nomnoml("[Hello]-[World!]") # Render complex diagram: nomnoml::nomnoml(" #stroke: #a86128 [<frame>Decorator pattern| [<abstract>Component||+ operation()] [Client] depends --> [Component] [Decorator|- next: Component] [Decorator] decorates -- [ConcreteComponent] [Component] <:- [Decorator] [Component] <:- [ConcreteComponent] ]")
# Render simple diagram: nomnoml::nomnoml("[Hello]-[World!]") # Render complex diagram: nomnoml::nomnoml(" #stroke: #a86128 [<frame>Decorator pattern| [<abstract>Component||+ operation()] [Client] depends --> [Component] [Decorator|- next: Component] [Decorator] decorates -- [ConcreteComponent] [Component] <:- [Decorator] [Component] <:- [ConcreteComponent] ]")
Summary of nomnoml syntax.
association -
association ->
association <->
dependency -->
dependency <-->
generalization -:>
generalization <:-
implementation --:>
implementation <:--
composition +-
composition +->
aggregation o-
aggregation o->
note --
hidden -/-
weightless edge _>
weightless dashed __
[name]
[<abstract> name]
[<instance> name]
[<note> name]
[<reference> name]
[<package> name]
[<frame> name]
[<database> name]
[<start> name]
[<end> name]
[<state> name]
[<choice> name]
[<input> name]
[<sender> name]
[<receiver> name]
[<transceiver> name]
[<actor> name]
[<usecase> name]
[<label> name]
[<hidden> name]
[<table> table | a | 5 | b | 7]
#arrowSize: 1
#bendSize: 0.3
#direction: down | right
#gutter: 5
#edgeMargin: 0
#edges: hard | rounded
#background: transparent
#fill: #eee8d5; #fdf6e3
#fillArrows: false
#font: Calibri
#fontSize: 12
#leading: 1.25
#lineWidth: 3
#padding: 8
#spacing: 40
#stroke: #33322E
#title: filename
#zoom: 1
#acyclicer: greedy
#ranker: network-simplex | tight-tree | longest-path
A directive that starts with .
define a classifier style.
The style is written as a space separated list of modifiers and
key/value pairs.
#.box: fill=#8f8 dashed
#.blob: visual=ellipse
[<box> GreenBox]
[<blob> HideousBlob]
fill=(any css color)
stroke=(any css color)
align=center
align=left
direction=right
direction=down
visual=actor
visual=class
visual=database
visual=ellipse
visual=end
visual=frame
visual=hidden
visual=input
visual=none
visual=note
visual=package
visual=receiver
visual=rhomb
visual=roundrect
visual=sender
visual=start
visual=transceiver
title=left,italic,bold
body=center,italic,bold
bold
underline
italic
dashed
empty
V8
JavaScript engine to validate a nomnoml
diagram.Although the nomnoml
widgets render very quickly in the IDE, it can take a
few seconds to grab a static screenshot and create a png
file. In these
situations it can be helpful to validate if the nomnoml
JS library can
parse a diagram.
This function returns TRUE
if a diagram can be parsed, and FALSE
otherwise. If FALSE
the function also throws a warning.
nomnoml_validate(diagram = "[test]")
nomnoml_validate(diagram = "[test]")
diagram |
A |
Either TRUE or FALSE
## Not run: if (requireNamespace("V8", quietly = TRUE)) nomnoml_validate("[hello] -> [world]") ## End(Not run)
## Not run: if (requireNamespace("V8", quietly = TRUE)) nomnoml_validate("[hello] -> [world]") ## End(Not run)
Output and render functions for using nomnoml within Shiny applications and interactive Rmd documents.
nomnomlOutput(outputId, width = "100%", height = "400px") renderNomnoml(expr, env = parent.frame(), quoted = FALSE)
nomnomlOutput(outputId, width = "100%", height = "400px") renderNomnoml(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a nomnoml |
env |
The environment in which to evaluate |
quoted |
Is |