Skip to contents

Draws a lineage graph with React Flow: tables as draggable nodes, column-to-column edges, and zoom/pan controls. Pass the result of extract_lineage() directly (it is detected automatically, so piping works), or build nodes and edges yourself with create_table_node() and create_column_edge().

Usage

lineage_flow(
  nodes = list(),
  edges = list(),
  width = NULL,
  height = NULL,
  elementId = NULL,
  minimap = FALSE,
  legend = TRUE,
  theme = c("light", "dark", "auto"),
  export_button = TRUE
)

Arguments

nodes

The output of extract_lineage(), or a list of nodes created with create_table_node().

edges

A list of edges created with create_column_edge(). Ignored when nodes is an extract_lineage() result, which carries its own edges.

width, height

CSS dimensions of the widget, e.g. "100%" or "600px". Default to full width and 600px tall.

elementId

Explicit HTML element id for the widget. Usually left NULL so one is generated.

minimap

If TRUE, draws a pannable overview map in the corner. Off by default; it earns its space on large multi-model graphs.

legend

If TRUE (the default), overlays a small legend naming the node colors and edge styles present in the graph.

theme

"light" (the default), "dark", or "auto", which follows the viewer's prefers-color-scheme. That is the operating-system setting, not the theme of a surrounding Quarto or R Markdown document, so documents rendered dark should pass theme = "dark" explicitly.

export_button

If TRUE (the default), the zoom controls gain a button that downloads the diagram as a PNG.

Value

An htmlwidget that prints in the RStudio viewer, R Markdown / Quarto documents, and Shiny apps.

Details

Clicking a column isolates its trace cone (the transitive upstream and downstream subgraph) and dims everything else; clicking it again, clicking the background, or pressing Escape releases it. In Shiny, the traced column is reported as input$<outputId>_selected, a list with table and column entries (NULL when nothing is traced).

Hovering a column shows a small card with its captured type and label (see extract_lineage()'s schema and labels arguments); columns with neither stay quiet. The static SVG fallback shows the same information through native browser tooltips.

See also

extract_lineage() to compute lineage automatically; lineage_flowOutput() and renderLineageFlow() for Shiny.

Examples

# Build a small diagram by hand
nodes <- list(
  create_table_node("orders", c("order_id", "amount"), x = 0, y = 0),
  create_table_node("daily_totals", c("total"),
    x = 400, y = 0, table_type = "target"
  )
)
edges <- list(
  create_column_edge("orders", "amount", "daily_totals", "total",
    label = "SUM()", animated = TRUE
  )
)
lineage_flow(nodes, edges)
# Dark theme with the overview map lineage_flow(nodes, edges, theme = "dark", minimap = TRUE)
# Or pipe from extract_lineage() extract_lineage("SELECT id, name FROM customers") |> lineage_flow()