LiveFlow.Export (LiveFlow v0.3.2)

Copy Markdown View Source

Server-side SVG rendering of a flow, without a browser.

Useful to generate thumbnails, previews or downloads from a LiveView or a background job. Nodes are drawn as rounded boxes with their label (data.label, data.title or the node id); edges use the same path algorithms as the client. Custom node content (function components) is not rendered: use the client-side exportSVG/exportPNG for pixel-perfect output.

Examples

svg = LiveFlow.Export.to_svg(flow, theme: :dark)
File.write!("flow.svg", svg)

Summary

Functions

Renders the flow as an SVG document.

Functions

to_svg(flow, opts \\ [])

@spec to_svg(
  LiveFlow.State.t(),
  keyword()
) :: String.t()

Renders the flow as an SVG document.

Options

  • :padding - Space around the content (default: 40)
  • :theme - :light or :dark, or a map overriding the colors (:background, :node_bg, :node_border, :text, :edge, :selected, :label_bg) (default: :light)
  • :background - Draw the background (default: true)
  • :font_family - (default: "system-ui, sans-serif")