graph: Make a UML graph of Shiny modules

View source: R/graph.R

graphR Documentation

Make a UML graph of Shiny modules

Description

Creates a UML-like graph from your 'Shiny application' developed with modules.

Usage

graph(x, fields = NULL, styles = NULL, options = NULL)

Arguments

x

a supreme object.

fields

optional. name of the fields to include in the graph. The possible values can be found at getOption("SUPREME_MODEL_REQUIRED_FIELDS") and getOption("SUPREME_MODEL_OPTIONAL_FIELDS"). By default, the required fields such as the "name" field always visible. There are no ways to exclude the required fields. This parameter is set to NULL as default.

styles

optional. a named list to apply custom styles on the graph nodes. A full list of the available styles can be seen from: nomnoml: Custom classifier styles

options

optional. custom options for the whole graph. A full list of the available options can be seen from: nomnoml: Directives

Details

The graph call uses the nomnoml tool to draw a UML diagram of the Shiny application.

Value

a supreme graph.

References

nomnoml: The sassy UML diagram renderer

Examples

# create a graph:
path <- example_yaml()
sp <- supreme(src_yaml(path))
graph(sp)

# filter fields, only return the certain fields in the graph entities:
graph(sp, fields = c("input", "return"))

# style entites:
graph(sp, styles = list(
 "server" = list(fill = "#ff0", "underline", "bold"),
 "module_modal_dialog" = list(fill = "lightblue", "dashed", visual = "note")
))

# style entities having a word "tab" in it:
sp_df <- as.data.frame(sp) # turn supreme object to data.frame
tab_modules <- sp_df$name[grep("_tab_", sp_df$name)]
styles <- lapply(seq_along(tab_modules), function(x) list(fill = "orange"))
names(styles) <- tab_modules
graph(sp, styles = styles)

# set graph options:
graph(sp, options = list(
  direction = "right",
  fontSize = 10,
  title = "Model application"
))

strboul/supreme documentation built on Jan. 11, 2024, 12:47 a.m.