Skip to content

GraphTree

KeyAction
/ kMove up
/ jMove down
/ lExpand or move into first child
/ hCollapse or move to parent
Home / gJump to first node
End / GJump to last node
PgUpPage up
PgDnPage down
Ctrl+UHalf-page up
Ctrl+DHalf-page down
Space / oToggle expand/collapse
EnterSelect node (fires onSelect)

GraphTree is optimized for workflow/pipeline DAGs where nodes may have status states (running, success, failed, etc.). Node colors and icons reflect the Status field. Use the standard Tree component for general hierarchical data.

GraphTree preview

GraphTree is a tree view specialized for displaying workflow relationships.

Constructor func NewGraphTree() *GraphTree

Usage

data := components.NewGraphTreeData()
data.AddNode(&components.GraphTreeNode{ID: "root", Label: "Workflow", Status: "Running", Children: []string{"step1"}, Expanded: true})
data.AddNode(&components.GraphTreeNode{ID: "step1", Label: "Validate", Status: "Completed"})
tree := components.NewGraphTree().
SetData(data).
SetShowEdgeLabels(true)
fmt.Println(tree != nil)

Methods

Method Signature Description
GetSelected func (t *GraphTree) GetSelected() *GraphTreeNode GetSelected returns the currently selected node.
SetData func (t *GraphTree) SetData(data *GraphTreeData) *GraphTree SetData sets the tree data.
SetOnChange func (t *GraphTree) SetOnChange(fn func(node *GraphTreeNode)) *GraphTree SetOnChange sets the callback for selection changes.
SetOnLoadChildren func (t *GraphTree) SetOnLoadChildren(fn func(nodeID string) ([]*GraphTreeNode, []*GraphTreeEdge)) *GraphTree SetOnLoadChildren sets the lazy loading callback.
SetOnSelect func (t *GraphTree) SetOnSelect(fn func(node *GraphTreeNode)) *GraphTree SetOnSelect sets the callback for node selection (Enter).
SetShowEdgeLabels func (t *GraphTree) SetShowEdgeLabels(show bool) *GraphTree SetShowEdgeLabels enables/disables edge label display.

Types

type GraphTreeData struct GraphTreeData holds the data for a GraphTree.
FieldTypeDescription
RootID string
type GraphTreeEdge struct GraphTreeEdge represents an edge between nodes.
FieldTypeDescription
From string
To string
Type GraphEdgeType
Label string Optional edge label
type GraphTreeNode struct GraphTreeNode represents a node in the workflow graph tree.
FieldTypeDescription
ID string
Label string
Sublabel string Secondary text (e.g., workflow type)
Status string Status for coloring (e.g., "Running", "Completed")
NodeType GraphNodeType Visual type
Children []string Child node IDs
CanExpand bool Whether node can have children loaded
Expanded bool Whether children are visible
Loading bool Show loading indicator
Depth int Depth in tree
Data any Associated data
type GraphEdgeType GraphEdgeType defines the line style for edges.
ConstantDescription
GraphEdgeSolid
GraphEdgeDashed
GraphEdgeDotted
type GraphNodeType GraphNodeType defines the visual type of a node.
ConstantDescription
GraphNodePrimary
GraphNodeSecondary
GraphNodeLink