본문으로 건너뛰기

Positions

In general, positioning is controlled entirely by the layout engine. It's one of the primary benefits of text-to-diagram that you don't have to manually define all the positions of objects.

However, there are occasions where you want to have some control over positions. Currently, there are two ways to do that.

Near

D2 allows you to position items on set points around your diagram.

Possible values

top-left, top-center, top-right,

center-left, center-right,

bottom-left, bottom-center, bottom-right

Let's explore some use cases:

Giving your diagram a title

A winning strategy

poll the peopleresultsunfavorablefavorablewill of the people

Creating a legend

xyzlegendfoobar

Longform description or explanation

LLMs

The Large Language Model (LLM) is a powerful AI
system that learns from vast amounts of text data.
By analyzing patterns and structures in language,
it gains an understanding of grammar, facts,
and even some reasoning abilities. As users input text,
the LLM predicts the most likely next words or phrases
to create coherent responses. The model
continuously fine-tunes its output, considering both the
user's input and its own vast knowledge base.
This cutting-edge technology enables LLM to generate human-like text,
making it a valuable tool for various applications.

ML PlatformPre-trained modelsModel registryCompilerValidationAuditingServerBatch PredictorOnline Model Server

Label and icon positioning

The near can be nested to label and icon to specify their positions.

workerprofits
Extra values

When positioning labels and icons, in addition to the values that near can take elsewhere, an outside- prefix can be added to specify positioning outside the bounding box of the shape.

outside-top-left, outside-top-center, outside-top-right,

outside-left-center, outside-right-center,

outside-bottom-left, outside-bottom-center, outside-bottom-right

Note that outside-left-center is a different order than center-left.

Near objects

정보

Works in TALA only. We are working on shims to make this possible in other layout engines.

You can also set near to the absolute ID of another shape to hint to the layout engine that they should be in the vicinity of one another.

Notice how the text is positioned near the aws node and not the gcloud node.

text near example

Top and left

On the TALA engine, you can also directly set the top and left values for objects, and the layout engine will only move other objects around it.

For more on this, see page 17 of the TALA user manual.