dm_draw() uses DiagrammeR to draw diagrams. Use DiagrammeRsvg::export_svg() to convert the diagram to an SVG file.

dm_draw(
  dm,
  rankdir = "LR",
  col_attr = NULL,
  view_type = c("keys_only", "all", "title_only"),
  columnArrows = TRUE,
  graph_attrs = "",
  node_attrs = "",
  edge_attrs = "",
  focus = NULL,
  graph_name = "Data Model",
  ...,
  column_types = NULL
)

Arguments

dm

A dm object.

rankdir

Graph attribute for direction (e.g., 'BT' = bottom --> top).

col_attr

Deprecated, use colummn_types instead.

view_type

Can be "keys_only" (default), "all" or "title_only". It defines the level of details for rendering tables (only primary and foreign keys, all columns, or no columns).

columnArrows

Edges from columns to columns (default: TRUE).

graph_attrs

Additional graph attributes.

node_attrs

Additional node attributes.

edge_attrs

Additional edge attributes.

focus

A list of parameters for rendering (table filter).

graph_name

The name of the graph.

...

These dots are for future extensions and must be empty.

column_types

Set to TRUE to show column types.

Value

An object of class grViz (see also DiagrammeR::grViz()), which, when printed, produces the output seen in the viewer as a side effect.

See also

dm_set_colors() for defining the table colors.

Examples

dm_nycflights13() %>%
  dm_draw()
%0

airlinesairlinescarrierairportsairportsfaaflightsflightscarriertailnumoriginorigin, time_hourflights:carrier->airlines:carrierflights:origin->airports:faaplanesplanestailnumflights:tailnum->planes:tailnumweatherweatherorigin, time_hourflights:origin, time_hour->weather:origin, time_hour
dm_nycflights13(cycle = TRUE) %>%
  dm_draw(view_type = "title_only")
%0

airlinesairlinesairportsairportsflightsflightsflights:carrier->airlines:carrierflights:origin->airports:faaflights:dest->airports:faaplanesplanesflights:tailnum->planes:tailnumweatherweatherflights:origin, time_hour->weather:origin, time_hour
head(dm_get_available_colors())
#> [1] "default"       "white"         "aliceblue"     "antiquewhite" 
#> [5] "antiquewhite1" "antiquewhite2"
length(dm_get_available_colors())
#> [1] 658

dm_nycflights13() %>%
  dm_get_colors()
#>  #ED7D31FF  #ED7D31FF  #5B9BD5FF  #ED7D31FF  #70AD47FF 
#> "airlines" "airports"  "flights"   "planes"  "weather"