flowchart

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package flowchart provides functionality for creating Mermaid flowcharts

Index

Constants

View Source
const (
	FlowchartDirectionTopToBottom flowchartDirection = "TB"
	FlowchartDirectionTopDown     flowchartDirection = "TD"
	FlowchartDirectionBottomUp    flowchartDirection = "BT"
	FlowchartDirectionRightLeft   flowchartDirection = "RL"
	FlowchartDirectionLeftRight   flowchartDirection = "LR"
)

List of possible Flowchart directions. Reference: https://mermaid.js.org/syntax/flowchart.html#direction

View Source
const (
	CurveStyleNone       curveStyle = ""
	CurveStyleBasis      curveStyle = "basis"
	CurveStyleBumpX      curveStyle = "bumpX"
	CurveStyleBumpY      curveStyle = "bumpY"
	CurveStyleCardinal   curveStyle = "cardinal"
	CurveStyleCatmullRom curveStyle = "catmullRom"
	CurveStyleLinear     curveStyle = "linear"
	CurveStyleMonotoneX  curveStyle = "monotoneX"
	CurveStyleMonotoneY  curveStyle = "monotoneY"
	CurveStyleNatural    curveStyle = "natural"
	CurveStyleStep       curveStyle = "step"
	CurveStyleStepAfter  curveStyle = "stepAfter"
	CurveStyleStepBefore curveStyle = "stepBefore"
)

List of possible Flowchart directions. Reference: https://mermaid.js.org/syntax/flowchart.html#styling-line-curves

View Source
const (
	LinkShapeOpen      linkShape = "--%s"
	LinkShapeDotted    linkShape = "-.%s-"
	LinkShapeThick     linkShape = "==%s"
	LinkShapeInvisible linkShape = "~~%s"
)

List of possible Link shapes. Reference: https://mermaid.js.org/syntax/flowchart.html#links-between-nodes

View Source
const (
	LinkArrowTypeNone      linkArrowType = ""
	LinkArrowTypeArrow     linkArrowType = ">"
	LinkArrowTypeLeftArrow linkArrowType = "<"
	LinkArrowTypeBullet    linkArrowType = "o"
	LinkArrowTypeCross     linkArrowType = "x"
)

List of possible Link arrow types. Reference: https://mermaid.js.org/syntax/flowchart.html#links-between-nodes

View Source
const (
	// Basic shapes
	NodeShapeProcess          nodeShape = `rect`       // Process (Rectangle)
	NodeShapeEvent            nodeShape = `rounded`    // Event (Rounded rectangle)
	NodeShapeTerminal         nodeShape = `stadium`    // Terminal (Stadium-shaped)
	NodeShapeSubprocess       nodeShape = `fr-rect`    // Subprocess (Framed rectangle)
	NodeShapeDatabase         nodeShape = `cyl`        // Database (Cylinder)
	NodeShapeStart            nodeShape = `circle`     // Start (Circle)
	NodeShapeOdd              nodeShape = `odd`        // Odd shape (Asymmetric)
	NodeShapeDecision         nodeShape = `diam`       // Decision (Diamond)
	NodeShapePrepare          nodeShape = `hex`        // Prepare (Hexagon)
	NodeShapeInputOutput      nodeShape = `lean-r`     // Input/Output (Parallelogram)
	NodeShapeOutputInput      nodeShape = `lean-l`     // Output/Input (Alt Parallelogram)
	NodeShapeManualOperation  nodeShape = `trap-b`     // Manual Operation (Trapezoid)
	NodeShapeManual           nodeShape = `trap-t`     // Manual (Alt Trapezoid)
	NodeShapeStopDouble       nodeShape = `dbl-circ`   // Stop (Double Circle)
	NodeShapeText             nodeShape = `text`       // Text block
	NodeShapeCard             nodeShape = `notch-rect` // Card
	NodeShapeLinedProcess     nodeShape = `lin-rect`   // Lined Process (Rectangle with shadow)
	NodeShapeStartSmall       nodeShape = `sm-circ`    // Start (Small circle)
	NodeShapeStopFramed       nodeShape = `fr-circ`    // Stop (Circle with frame)
	NodeShapeForkJoin         nodeShape = `fork`       // Fork/Join
	NodeShapeCollate          nodeShape = `hourglass`  // Collate (Hourglass)
	NodeShapeComment          nodeShape = `brace`      // Comment (Left brace)
	NodeShapeCommentRight     nodeShape = `brace-r`    // Comment Right (Right brace)
	NodeShapeCommentBothSides nodeShape = `braces`     // Comment (Both braces)
	NodeShapeComLink          nodeShape = `bolt`       // Com Link (Lightning bolt)
	NodeShapeDocument         nodeShape = `doc`        // Document
	NodeShapeDelay            nodeShape = `delay`      // Delay
	NodeShapeStorage          nodeShape = `h-cyl`      // Storage (Horizontal cylinder)
	NodeShapeDiskStorage      nodeShape = `lin-cyl`    // Disk Storage (Lined cylinder)
	NodeShapeDisplay          nodeShape = `curv-trap`  // Display (Curved trapezoid)
	NodeShapeDividedProcess   nodeShape = `div-rect`   // Divided Process
	NodeShapeExtract          nodeShape = `tri`        // Extract (Triangle)
	NodeShapeInternalStorage  nodeShape = `win-pane`   // Internal Storage
	NodeShapeJunction         nodeShape = `f-circ`     // Junction (Filled circle)
	NodeShapeLinedDocument    nodeShape = `lin-doc`    // Lined Document
	NodeShapeLoopLimit        nodeShape = `notch-pent` // Loop Limit
	NodeShapeManualFile       nodeShape = `flip-tri`   // Manual File
	NodeShapeManualInput      nodeShape = `sl-rect`    // Manual Input (Sloped rectangle)
	NodeShapeMultiDocument    nodeShape = `docs`       // Multi-Document
	NodeShapeMultiProcess     nodeShape = `st-rect`    // Multi-Process
	NodeShapePaperTape        nodeShape = `flag`       // Paper Tape
	NodeShapeStoredData       nodeShape = `bow-rect`   // Stored Data
	NodeShapeSummary          nodeShape = `cross-circ` // Summary (Circle with cross)
	NodeShapeTaggedDocument   nodeShape = `tag-doc`    // Tagged Document
	NodeShapeTaggedProcess    nodeShape = `tag-rect`   // Tagged Process
)

List of possible Node shapes. Reference: https://mermaid.js.org/syntax/flowchart.html#complete-list-of-new-shapes

View Source
const (
	SubgraphDirectionNone        subgraphDirection = ""
	SubgraphDirectionTopToBottom subgraphDirection = "TB"
	SubgraphDirectionBottomUp    subgraphDirection = "BT"
	SubgraphDirectionRightLeft   subgraphDirection = "RL"
	SubgraphDirectionLeftRight   subgraphDirection = "LR"
)

List of possible Subgraph directions. Reference: https://mermaid.js.org/syntax/flowchart.html#direction

Variables

This section is empty.

Functions

This section is empty.

Types

type Class

type Class struct {
	Name  string
	Style *NodeStyle
}

Classes are a convenient way of creating a node style since you can attach them directly to a node. Reference: https://mermaid.js.org/syntax/flowchart.html#classes

func NewClass

func NewClass(name string) (newClass *Class)

NewClass creates a new Class with the given name and a default node style.

func (*Class) String

func (c *Class) String() string

String generates a Mermaid string representation of the class definition, including its name and style properties.

type Flowchart

type Flowchart struct {
	basediagram.BaseDiagram[FlowchartConfigurationProperties]
	Direction  flowchartDirection
	CurveStyle curveStyle
	// contains filtered or unexported fields
}

Flowcharts are composed of nodes (geometric shapes) and links (arrows or lines). The Mermaid code defines how nodes and links are made and accommodates different arrow types, multi-directional arrows, and any linking to and from subgraphs. Reference: https://mermaid.js.org/syntax/flowchart.html

func NewFlowchart

func NewFlowchart() *Flowchart

NewFlowchart creates a new flowchart diagram

func (*Flowchart) AddClass

func (f *Flowchart) AddClass(name string) (newClass *Class)

AddClass adds a new class to the flowchart and returns the created class.

func (f *Flowchart) AddLink(from *Node, to *Node) (newLink *Link)

AddLink adds a new link between two nodes in the flowchart and returns the created link.

func (*Flowchart) AddNode

func (f *Flowchart) AddNode(text string) (newNode *Node)

AddNode adds a new node to the flowchart and returns the created node.

func (*Flowchart) AddSubgraph

func (f *Flowchart) AddSubgraph(title string) (newSubgraph *Subgraph)

AddSubgraph adds a new subgraph to the flowchart and returns the created subgraph.

func (*Flowchart) RenderToFile

func (f *Flowchart) RenderToFile(path string) error

RenderToFile saves the flowchart diagram to a file at the specified path.

func (*Flowchart) SetDirection

func (f *Flowchart) SetDirection(direction flowchartDirection) *Flowchart

SetDirection sets the flowchart direction and returns the flowchart for chaining

func (*Flowchart) String

func (f *Flowchart) String() string

String generates a Mermaid flowchart string representation

type FlowchartConfigurationProperties

type FlowchartConfigurationProperties struct {
	basediagram.ConfigurationProperties
	// contains filtered or unexported fields
}

FlowchartConfigurationProperties holds flowchart-specific configuration

func NewFlowchartConfigurationProperties

func NewFlowchartConfigurationProperties() FlowchartConfigurationProperties

func (*FlowchartConfigurationProperties) SetArrowMarkerAbsolute

func (*FlowchartConfigurationProperties) SetCurve

func (*FlowchartConfigurationProperties) SetDefaultRenderer

func (*FlowchartConfigurationProperties) SetDiagramPadding

func (*FlowchartConfigurationProperties) SetHtmlLabels

func (*FlowchartConfigurationProperties) SetNodeSpacing

func (*FlowchartConfigurationProperties) SetPadding

func (*FlowchartConfigurationProperties) SetRankSpacing

func (*FlowchartConfigurationProperties) SetTitleTopMargin

func (*FlowchartConfigurationProperties) SetWrappingWidth

func (FlowchartConfigurationProperties) String

type Link struct {
	Shape  linkShape
	Head   linkArrowType
	Tail   linkArrowType
	Text   string
	From   *Node
	To     *Node
	Length int
}

Link represents a connection between nodes in a flowchart

func NewLink(from *Node, to *Node) (newLink *Link)

NewLink creates a new Link and sets default values to some attributes

func (*Link) SetHead

func (l *Link) SetHead(arrowType linkArrowType) *Link

SetHead sets the head arrow type and returns the link for chaining

func (*Link) SetLength

func (l *Link) SetLength(length int) *Link

SetLength sets the link length and returns the link for chaining

func (*Link) SetShape

func (l *Link) SetShape(shape linkShape) *Link

SetShape sets the link shape and returns the link for chaining

func (*Link) SetTail

func (l *Link) SetTail(arrowType linkArrowType) *Link

SetTail sets the tail arrow type and returns the link for chaining

func (*Link) SetText

func (l *Link) SetText(text string) *Link

SetText sets the link text and returns the link for chaining

func (*Link) String

func (l *Link) String() string

String generates a Mermaid string representation of the link, including its shape, arrow types, text, and length.

type Node

type Node struct {
	ID    string
	Shape nodeShape
	Text  string
	Style *NodeStyle
	Class *Class
}

Node represents a node in a flowchart

func NewNode

func NewNode(id string, text string) (newNode *Node)

NewNode creates a new Node with the given ID and text, setting default shape to round edges.

func (*Node) SetClass

func (n *Node) SetClass(class *Class) *Node

SetClass sets the node class and returns the node for chaining

func (*Node) SetShape

func (n *Node) SetShape(shape nodeShape) *Node

SetShape sets the node shape and returns the node for chaining

func (*Node) SetStyle

func (n *Node) SetStyle(style *NodeStyle) *Node

SetStyle sets the style for the node and returns the node for chaining

func (*Node) SetText

func (n *Node) SetText(text string) *Node

SetText sets the node text and returns the node for chaining

func (*Node) String

func (n *Node) String() string

String generates a Mermaid string representation of the node, including its shape, class, and style.

type NodeStyle

type NodeStyle struct {
	Color       string
	Fill        string
	Stroke      string
	StrokeWidth int
	StrokeDash  string
}

func NewNodeStyle

func NewNodeStyle() (newNodeStyle *NodeStyle)

NewNodeStyle creates a new NodeStyle with default stroke width and dash settings.

func (*NodeStyle) String

func (n *NodeStyle) String() string

String generates a formatted string representation of the node style, including color, fill, stroke, width, and dash properties.

type Subgraph

type Subgraph struct {
	ID        string
	Title     string
	Direction subgraphDirection
	// contains filtered or unexported fields
}

func NewSubgraph

func NewSubgraph(id string, title string) (newSubgraph *Subgraph)

NewSubgraph creates a new Subgraph with the given ID and title, setting the default direction to none.

func (s *Subgraph) AddLink(from *Node, to *Node) (newLink *Link)

AddLink adds a new Link to the Subgraph and returns the created link.

func (*Subgraph) AddSubgraph

func (s *Subgraph) AddSubgraph(title string) (newSubgraph *Subgraph)

AddSubgraph adds a new Subgraph to the current Subgraph and returns the created subgraph.

func (*Subgraph) String

func (s *Subgraph) String(curIndentation string) string

String generates a Mermaid string representation of the Subgraph, including its subgraphs, direction, and links with the specified indentation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL