Hakushi.Edge (Hakushi v0.1.0)

Copy Markdown View Source

An edge of a canvas: a line from a handle of one node to a handle of another.

%Hakushi.Edge{id: "e1", source: "orders", source_handle: "user_id", target: "users", target_handle: "id"}
  • id - a string, unique in the canvas.
  • source, target - the ids of its nodes.
  • source_handle, target_handle - the ids of the handles in those nodes (Hakushi.Components.handle/1); nil for the node's first handle of that kind, or its side when it has none.
  • path - how it is drawn: "bezier" (the default), "smooth" (steps with round corners), "step" or "straight".
  • label - a text on its middle, or nil.
  • marker - the end of the line at the target: "arrow" (the default), "dot" or "none".
  • animated - a line that flows from the source to the target.
  • data - anything of the app's; it stays on the server.

Summary

Functions

The id of an edge made of its ends, as new/1 gives an edge with none: the same ends make the same id.

Makes an edge of a map or a keyword list: the struct's keys as atoms or strings. An edge with no id gets one made of its ends.

The kinds of path.

Types

id()

@type id() :: String.t()

t()

@type t() :: %Hakushi.Edge{
  animated: boolean(),
  data: term(),
  id: id(),
  label: String.t() | nil,
  marker: String.t(),
  path: String.t(),
  source: Hakushi.Node.id(),
  source_handle: String.t() | nil,
  target: Hakushi.Node.id(),
  target_handle: String.t() | nil
}

Functions

default_id(source, source_handle, target, target_handle)

@spec default_id(String.t(), String.t() | nil, String.t(), String.t() | nil) ::
  String.t()

The id of an edge made of its ends, as new/1 gives an edge with none: the same ends make the same id.

new(edge)

@spec new(t() | map() | keyword()) :: t()

Makes an edge of a map or a keyword list: the struct's keys as atoms or strings. An edge with no id gets one made of its ends.

paths()

@spec paths() :: [String.t()]

The kinds of path.