Diagram
Description
A flow-chart surface with draggable nodes and auto-routed arrows
Diagram is a pannable dotted canvas holding boxes you connect with Connect(from, to). The arrows are computed and drawn on a background canvas, so they follow the nodes as they are dragged. AutoArrange() positions the nodes from their sizes and how they are connected, which is usually enough for a graph you did not lay out by hand.
Nodes are created with DiagramNode(text) and carry Background, Foreground and Text. Nodes(params) replaces the set, Add / Remove / Clear change it afterwards.
DotSpacing(pixels) sets how dense the background grid is and NoDots() removes it entirely. NotDraggable() pins the nodes where they are, for a diagram meant to be read rather than rearranged.
Sample
A small pipeline
API reference
public partial class Diagram : IComponent, ISpecialCaseStylingA flow-chart style diagram surface with draggable nodes, auto-computed arrows drawn on a background canvas, a pannable dotted background and automatic node positioning based on node sizes and connectivity.
- Namespace
- Tesserae
- Implements
- IComponent, ISpecialCaseStyling
Constructors
| Name | Description |
|---|---|
| Diagram | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| StylingContainer | Gets the HTMLElement that should receive styling. |
| PropagateToStackItemParent | Gets whether styling should propagate to the stack item parent. |
public HTMLElement StylingContainerGets the HTMLElement that should receive styling.
Methods
| Name | Description |
|---|---|
| Nodes | Adds the given nodes to the diagram. |
| Add | Adds a single node to the diagram. |
| Remove | Removes a node (and any arrows connected to it) from the diagram. |
| Clear | Removes all nodes and arrows from the diagram. |
| Connect | Connects two nodes with an auto-computed arrow, adding them to the diagram if needed. |
| DotSpacing | Sets the spacing of the dotted background grid (in pixels). |
| NoDots | Hides the dotted background grid. |
| NotDraggable | Disables panning of the diagram background. |
| AutoArrange | Re-runs the automatic layout for all nodes (including ones previously dragged or explicitly positioned) and re-centers the view. |
| Render | Renders the component's root HTML element. |
| RunAutoArrange | Assigns layers to nodes based on connectivity (longest path from the roots), orders nodes within each layer by the position of their parents, and spaces everything using the measured node sizes. |
public Diagram Remove(Node node)Removes a node (and any arrows connected to it) from the diagram.
public Diagram Connect(Node from, Node to)Connects two nodes with an auto-computed arrow, adding them to the diagram if needed.
public Diagram DotSpacing(int pixels)Sets the spacing of the dotted background grid (in pixels).
public Diagram AutoArrange()Re-runs the automatic layout for all nodes (including ones previously dragged or explicitly positioned) and re-centers the view.
See also
- Workflow diagrams in docs — the static, Markdown-authored equivalent.
- Task Board — draggable cards in columns, when the layout is a board rather than a graph.
- Components overview