package d2talalayout
Import Path
github.com/pancsta/d2/d2layouts/d2talalayout (on go.dev)
Dependency Relation
imports 25 packages, and imported by one package
Involved Source Files
adapter.go
adapter_validate.go
Package d2talalayout adapts D2 graphs to TALA's layout and edge-routing
engine.
Like the other packages under d2layouts, its public boundary is limited to
layout options plus graph layout and routing entry points. Layout coordinates
bounded seed attempts locally and selects the result deterministically.
layout.go
limits.go
patch.go
result.go
result_validate.go
seedgraph.go
Code Examples
package main
import (
"context"
"fmt"
"github.com/pancsta/d2/d2graph"
"github.com/pancsta/d2/d2layouts/d2talalayout"
"github.com/pancsta/d2/lib/geo"
)
func main() {
ctx := context.Background()
graph := d2graph.NewGraph()
object := &d2graph.Object{
Graph: graph,
Parent: graph.Root,
ID: "a",
IDVal: "a",
Box: geo.NewBox(geo.NewPoint(0, 0), 100, 60),
Children: make(map[string]*d2graph.Object),
Attributes: d2graph.Attributes{},
}
graph.Root.Children[object.ID] = object
graph.Root.ChildrenArray = append(graph.Root.ChildrenArray, object)
graph.Objects = append(graph.Objects, object)
opts := d2talalayout.DefaultOptions()
opts.Seeds = []int64{1}
if err := d2talalayout.Layout(ctx, graph, &opts); err != nil {
fmt.Println(err)
return
}
fmt.Printf("%.0f %.0f\n", object.Box.TopLeft.X, object.Box.TopLeft.Y)
}
Package-Level Type Names (only one)
Options controls deterministic local layout attempts. The zero value uses
the package defaults. Seeds stored on the D2 graph take precedence over
Seeds. MaxConcurrency bounds simultaneous attempts; zero selects the package
default.
MaxConcurrency bounds simultaneous attempts. Zero uses the package default.
Seeds selects deterministic attempts. Nil uses the package defaults; an
explicitly empty slice is invalid.
func DefaultOptions() Options
func Layout(ctx context.Context, graph *d2graph.Graph, opts *Options) (err error)
Package-Level Functions (total 4)
DefaultLayout lays out graph with fresh default options. Like all D2 layout
functions, it mutates graph and must not run concurrently against the same
graph.
DefaultOptions returns an independent copy of the package defaults.
Layout runs every configured seed locally, selects the best complete result
deterministically, and then atomically applies it to graph. It never selects
a result from only a timing-dependent subset of the configured seeds. The
caller must not mutate graph concurrently.
RouteEdges reroutes edges in g. It mutates g and must not run concurrently
against the same graph.
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |