Versions in this module Expand all Collapse all v0 v0.8.2 Aug 24, 2026 Changes in this version type Edge + func (e *Edge) IsEquivalent(src *Object, srcArrow bool, dst *Object, dstArrow bool) bool v0.8.1 Aug 7, 2026 v0.8.0 Aug 7, 2026 Changes in this version + const DEFAULT_SHAPE_SIZE + const INNER_LABEL_PADDING + const MIN_SEGMENT_LEN + const MIN_SHAPE_SIZE + func CompareSerializedEdge(edge, other *Edge) error + func CompareSerializedGraph(g, other *Graph) error + func CompareSerializedObject(obj, other *Object) error + func Convert[T, Q any](from T, to *Q) error + func DeserializeGraph(bytes []byte, g *Graph) error + func GetTextDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler, t *d2target.MText, ...) *d2target.TextDimensions + func GetTextDimensionsWithMono(mtexts []*d2target.MText, ruler *textmeasure.Ruler, t *d2target.MText, ...) *d2target.TextDimensions + func Key(k *d2ast.KeyPath) []string + func SerializeGraph(g *Graph) ([]byte, error) + type Attributes struct + Classes []string + Constraint []string + Direction Scalar + GridColumns *Scalar + GridGap *Scalar + GridRows *Scalar + HeightAttr *Scalar + HorizontalGap *Scalar + Icon *url.URL + IconPosition *Scalar + IconStyle Style + Label Scalar + LabelDimensions d2target.TextDimensions + LabelPosition *Scalar + Language string + Left *Scalar + Link *Scalar + NearKey *d2ast.KeyPath + Shape Scalar + Style Style + Tooltip *Scalar + TooltipPosition *Scalar + Top *Scalar + VerticalGap *Scalar + WidthAttr *Scalar + func (a *Attributes) ApplyTextTransform() + func (a *Attributes) ToArrowhead() d2target.Arrowhead + type ContainerLevel int + func (l ContainerLevel) LabelSize() int + type Edge struct + Dst *Object + DstArrow bool + DstArrowhead *Attributes + DstTableColumnIndex *int + Index int + IsCurve bool + LabelPercentage *float64 + LabelPosition *string + References []EdgeReference + Route []*geo.Point + Src *Object + SrcArrow bool + SrcArrowhead *Attributes + SrcTableColumnIndex *int + ZIndex int + func (e *Edge) AbsID() string + func (e *Edge) ArrowString() string + func (e *Edge) ContainedBy(obj *Object) bool + func (e *Edge) GetAstEdge() *d2ast.Edge + func (e *Edge) GetGroup() *Object + func (e *Edge) GetStroke(dashGapSize interface{}) string + func (e *Edge) Move(dx, dy float64) + func (e *Edge) Text() *d2target.MText + func (edge *Edge) ShiftEnd(delta float64, isHorizontal bool) + func (edge *Edge) ShiftStart(delta float64, isHorizontal bool) + func (edge *Edge) TraceToShape(points []*geo.Point, startIndex, endIndex int) (newStart, newEnd int) + type EdgeReference struct + Edge *d2ast.Edge + MapKey *d2ast.Key + MapKeyEdgeIndex int + Scope *d2ast.Map + ScopeAST *d2ast.Map + ScopeObj *Object + type Graph struct + AST *d2ast.Map + BaseAST *d2ast.Map + Data map[string]interface{} + Edges []*Edge + FS fs.FS + IsFolderOnly bool + Layers []*Graph + Legend *Legend + Name string + Objects []*Object + Parent *Graph + Root *Object + RootLevel int + Scenarios []*Graph + Steps []*Graph + Theme *d2themes.Theme + func NewGraph() *Graph + func (g *Graph) ApplyTheme(themeID int64) error + func (g *Graph) ExtractAsNestedGraph(obj *Object) *Graph + func (g *Graph) GetBoard(name string) *Graph + func (g *Graph) IDA() []string + func (g *Graph) InjectNestedGraph(tempGraph *Graph, parent *Object) + func (g *Graph) PrintString() string + func (g *Graph) RootBoard() *Graph + func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler, ...) error + func (g *Graph) SortEdgesByAST() + func (g *Graph) SortObjectsByAST() + func (g *Graph) Texts() []*d2target.MText + type LayoutGraph func(context.Context, *Graph) error + type Legend struct + Edges []*Edge + Label string + Objects []*Object + type Object struct + Children map[string]*Object + ChildrenArray []*Object + Class *d2target.Class + ContentAspectRatio *float64 + Graph *Graph + ID string + IDVal string + IconPosition *string + LabelPosition *string + Map *d2ast.Map + Parent *Object + References []Reference + SQLTable *d2target.SQLTable + ZIndex int + func ResolveUnderscoreKey(ida []string, obj *Object) (resolvedObj *Object, resolvedIDA []string, _ error) + func (o *Object) ContainedBy(obj *Object) bool + func (obj *Object) AbsID() string + func (obj *Object) AbsIDArray() []string + func (obj *Object) AppendReferences(ida []string, ref Reference, unresolvedObj *Object) + func (obj *Object) ClosestGridCell() *Object + func (obj *Object) ClosestGridDiagram() *Object + func (obj *Object) Connect(srcID, dstID []d2ast.String, srcArrow, dstArrow bool, label string) (*Edge, error) + func (obj *Object) ContainsAnyEdge(edges []*Edge) bool + func (obj *Object) ContainsAnyObject(objects []*Object) bool + func (obj *Object) EnsureChild(ida []d2ast.String) *Object + func (obj *Object) FindEdges(mk *d2ast.Key) ([]*Edge, bool) + func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.Ruler, ...) (*d2target.TextDimensions, error) + func (obj *Object) GetFill() string + func (obj *Object) GetIconTopLeft() *geo.Point + func (obj *Object) GetLabelSize(mtexts []*d2target.MText, ruler *textmeasure.Ruler, ...) (*d2target.TextDimensions, error) + func (obj *Object) GetLabelTopLeft() *geo.Point + func (obj *Object) GetMargin() geo.Spacing + func (obj *Object) GetModifierElementAdjustments() (dx, dy float64) + func (obj *Object) GetStroke(dashGapSize interface{}) string + func (obj *Object) HasChild(ids []string) (*Object, bool) + func (obj *Object) HasEdge(mk *d2ast.Key) (*Edge, bool) + func (obj *Object) HasIcon() bool + func (obj *Object) HasLabel() bool + func (obj *Object) HasOutsideBottomLabel() bool + func (obj *Object) Is3D() bool + func (obj *Object) IsConstantNear() bool + func (obj *Object) IsContainer() bool + func (obj *Object) IsDescendantOf(ancestor *Object) bool + func (obj *Object) IsGridDiagram() bool + func (obj *Object) IsMultiple() bool + func (obj *Object) IsSequenceDiagram() bool + func (obj *Object) IsSequenceDiagramGroup() bool + func (obj *Object) IsSequenceDiagramNote() bool + func (obj *Object) IterDescendants(apply func(parent, child *Object)) + func (obj *Object) Level() ContainerLevel + func (obj *Object) MoveWithDescendants(dx, dy float64) + func (obj *Object) MoveWithDescendantsTo(x, y float64) + func (obj *Object) OuterNearContainer() *Object + func (obj *Object) OuterSequenceDiagram() *Object + func (obj *Object) ShiftDescendants(dx, dy float64) + func (obj *Object) SizeToContent(contentWidth, contentHeight, paddingX, paddingY float64) + func (obj *Object) Spacing() (margin, padding geo.Spacing) + func (obj *Object) SpacingOpt(labelPadding, iconPadding float64, maxIconSize bool) (margin, padding geo.Spacing) + func (obj *Object) Text() *d2target.MText + func (obj *Object) ToShape() shape.Shape + func (obj *Object) TopGridDiagram() *Object + func (parent *Object) RemoveChild(child *Object) + type Reference struct + IsVar bool + Key *d2ast.KeyPath + KeyPathIndex int + MapKey *d2ast.Key + MapKeyEdgeIndex int + Scope *d2ast.Map + ScopeAST *d2ast.Map + ScopeObj *Object + func (r Reference) InEdge() bool + func (r Reference) MapKeyEdgeDest() bool + type RouteEdges func(context.Context, *Graph, []*Edge) error + type Scalar struct + MapKey *d2ast.Key + Value string + type SerializedEdge map[string]interface + func ToSerializedEdge(e *Edge) (SerializedEdge, error) + type SerializedGraph struct + Data map[string]interface{} + Edges []SerializedEdge + Objects []SerializedObject + Root SerializedObject + RootLevel int + type SerializedObject map[string]interface + type Style struct + Animated *Scalar + Bold *Scalar + BorderRadius *Scalar + DoubleBorder *Scalar + Fill *Scalar + FillPattern *Scalar + Filled *Scalar + Font *Scalar + FontColor *Scalar + FontSize *Scalar + Italic *Scalar + Multiple *Scalar + Opacity *Scalar + Shadow *Scalar + Stroke *Scalar + StrokeDash *Scalar + StrokeWidth *Scalar + TextTransform *Scalar + ThreeDee *Scalar + Underline *Scalar + func (s *Style) Apply(key, value string) error + func (s Style) NoneTextTransform() bool