Skip to content

Commit 8541edf

Browse files
committed
docs(Diagram): Improve Diagram Layouts documentation
1 parent 01d8272 commit 8541edf

File tree

1 file changed

+104
-30
lines changed

1 file changed

+104
-30
lines changed

components/diagram/layouts.md

Lines changed: 104 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The Tree Diagram layout positions the shapes in a hierarchical way. A typical us
2626

2727
### Tree Layout Subtypes
2828

29-
The Layered Diagram layout has the following sub types:
29+
The Tree Diagram layout has the following sub types:
3030

3131
* `Down`—the root shape is at the top and all descendants are arranged below it.
3232
* `Left`—the root shape is on the right.
@@ -37,12 +37,44 @@ The Layered Diagram layout has the following sub types:
3737
* `TipOver`—a variation of the `Down` sub type. The root shape is at the top. The direct children are arranged horizontally in a row, while the grand children are arranged verticallu on columns.
3838
* `Up`—the root shape is at the bottom.
3939

40-
>caption Setting a Tree Diagram Layout Subtype
40+
`<DiagramLayout>` provides apperance settings that apply to specific tree layout sub types. The snippets below list these settings and their default values. `HorizontalSeparation` and `VerticalSeparation` apply to all sub types, except `Radial`.
41+
42+
>caption Using a classic Tree Diagram Layout
43+
44+
````RAZOR.skip-repl
45+
<TelerikDiagram>
46+
<DiagramLayout Type="@DiagramLayoutType.Tree"
47+
Subtype="@DiagramLayoutSubtype.Down"
48+
HorizontalSeparation="90"
49+
VerticalSeparation="50" />
50+
</TelerikDiagram>
51+
````
52+
53+
>caption Using a Radial Tree Diagram Layout
54+
55+
````RAZOR.skip-repl
56+
<TelerikDiagram>
57+
<DiagramLayout Type="@DiagramLayoutType.Tree"
58+
Subtype="@DiagramLayoutSubtype.Radial"
59+
StartRadialAngle="0"
60+
EndRadialAngle="360"
61+
RadialSeparation="150"
62+
RadialFirstLevelSeparation="200" />
63+
</TelerikDiagram>
64+
````
65+
66+
When using the Tree `TipOver` sub type, the `HorizontalSeparation` and `VerticalSeparation` parameters affect the distances between shapes at the initial levels, which are not affected by the tipover algorithm. The number of these levels depends on the value of `TipOverTreeStartLevel`.
67+
68+
>caption Using a TipOver Tree Diagram Layout
4169
4270
````RAZOR.skip-repl
4371
<TelerikDiagram>
4472
<DiagramLayout Type="@DiagramLayoutType.Tree"
45-
Subtype="@DiagramLayoutSubtype.Radial" />
73+
Subtype="@DiagramLayoutSubtype.TipOver"
74+
TipOverTreeStartLevel="1"
75+
UnderneathHorizontalOffset="15"
76+
UnderneathVerticalSeparation="15"
77+
UnderneathVerticalTopOffset="15" />
4678
</TelerikDiagram>
4779
````
4880

@@ -62,11 +94,14 @@ The layered layout works best with:
6294

6395
When the graph is a tree, the layout reduces to a standard tree layout and thus can be considered as an extension to the classic tree layout.
6496

97+
The `LayerSeparation` parameter sets the distance between the layout layers. The default value is `50`.
98+
6599
>caption Using the Layered Diagram Layout
66100
67101
````RAZOR.skip-repl
68102
<TelerikDiagram>
69-
<DiagramLayout Type="@DiagramLayoutType.Layered" />
103+
<DiagramLayout Type="@DiagramLayoutType.Layered"
104+
LayerSeparation="50" />
70105
</TelerikDiagram>
71106
````
72107

@@ -92,18 +127,25 @@ The Layered Diagram layout has the following sub types. Each subtype name signif
92127

93128
The [Force-directed Diagram layout](https://en.wikipedia.org/wiki/Force-directed_graph_drawing) (also known as the spring-embedder algorithm) is based on a physical simulation of forces acting on the Diagram nodes (shapes), whereby the connections define whether two nodes act upon each other. Each link is like a spring embedded in the Diagram. The simulation attempts to find a minimum energy state, so that the springs are in their base state and do not pull or push any linked node.
94129

95-
> The force-directed Diagram layout is non-deterministic. Each layout pass is unique, unpredictable, and not reproducible.
130+
The force-directed Diagram layout is non-deterministic. Each layout pass is unique, unpredictable, and not reproducible.
131+
132+
The layout provides two settings that affect the final appearance:
133+
134+
* `NodeDistance` defines the optimal distance between the shapes for minimum energy state. The default value is `50`.
135+
* `Iterations` sets the number of position calculations. A larger number produces better results, but is more resource-intensive. The default value is `300`.
136+
137+
The force-directed layout type has no subtypes.
96138

97139
>caption Using the Force Diagram Layout
98140
99141
````RAZOR.skip-repl
100142
<TelerikDiagram>
101-
<DiagramLayout Type="@DiagramLayoutType.Force" />
143+
<DiagramLayout Type="@DiagramLayoutType.Force"
144+
Iterations="300"
145+
NodeDistance="50" />
102146
</TelerikDiagram>
103147
````
104148

105-
The force-directed layout type has no subtypes.
106-
107149
## Example
108150

109151
The following example demonstrates all Diagram layout types and sub types.
@@ -317,46 +359,78 @@ The `<DiagramLayoutGrid>` tag exposes settings that allow you to define:
317359
* The horizontal and vertical distance (offset) between the components and the Diagram boundaries.
318360
* The width of the layout grid. If the width is large enough, the Diagram displays multiple components (groups) in a single row. Otherwise the components fall one below another.
319361

362+
The following example starts with the default values of the `DiagramLayoutGrid` parameters, except the `Width` which has a default value of `1500`. Use the Up and Down arrow keys to change the NumericTextBox values more easily and observe the result.
363+
320364
>caption Using Diagram Layout Grid settings
321365
322366
````RAZOR
323-
<TelerikDiagram Zoom="0.8">
367+
<TelerikDiagram Zoom="0.5" Height="360px">
324368
<DiagramLayout Type="@DiagramLayoutType.Tree">
325-
<DiagramLayoutGrid ComponentSpacingX="50"
326-
ComponentSpacingY="50"
327-
OffsetX="10"
328-
OffsetY="10"
329-
Width="300" />
369+
<DiagramLayoutGrid ComponentSpacingX="@XSpacing"
370+
ComponentSpacingY="@YSpacing"
371+
OffsetX="@XOffset"
372+
OffsetY="@YOffset"
373+
Width="@LayoutWidth" />
330374
</DiagramLayout>
331375
332376
<DiagramShapes>
333-
<DiagramShape Id="shape1">
334-
<DiagramShapeContent Text="Shape 1" />
377+
<DiagramShape Id="shape1-1">
378+
<DiagramShapeContent Text="Shape 1-1" />
335379
</DiagramShape>
336-
<DiagramShape Id="shape2">
337-
<DiagramShapeContent Text="Shape 2" />
380+
<DiagramShape Id="shape1-2">
381+
<DiagramShapeContent Text="Shape 1-2" />
338382
</DiagramShape>
339-
<DiagramShape Id="shape3">
340-
<DiagramShapeContent Text="Shape 3" />
383+
<DiagramShape Id="shape1-3">
384+
<DiagramShapeContent Text="Shape 1-3" />
341385
</DiagramShape>
342-
<DiagramShape Id="shape4">
343-
<DiagramShapeContent Text="Shape 4" />
386+
<DiagramShape Id="shape2-1">
387+
<DiagramShapeContent Text="Shape 2-1" />
344388
</DiagramShape>
345-
<DiagramShape Id="shape5">
346-
<DiagramShapeContent Text="Shape 5" />
389+
<DiagramShape Id="shape2-2">
390+
<DiagramShapeContent Text="Shape 2-2" />
347391
</DiagramShape>
348-
<DiagramShape Id="shape6">
349-
<DiagramShapeContent Text="Shape 6" />
392+
<DiagramShape Id="shape2-3">
393+
<DiagramShapeContent Text="Shape 2-3" />
394+
</DiagramShape>
395+
<DiagramShape Id="shape3-1">
396+
<DiagramShapeContent Text="Shape 3-1" />
397+
</DiagramShape>
398+
<DiagramShape Id="shape3-2">
399+
<DiagramShapeContent Text="Shape 3-2" />
400+
</DiagramShape>
401+
<DiagramShape Id="shape3-3">
402+
<DiagramShapeContent Text="Shape 3-3" />
350403
</DiagramShape>
351404
</DiagramShapes>
352405
353406
<DiagramConnections>
354-
<DiagramConnection FromId="shape1" ToId="shape2" />
355-
<DiagramConnection FromId="shape1" ToId="shape3" />
356-
<DiagramConnection FromId="shape4" ToId="shape5" />
357-
<DiagramConnection FromId="shape4" ToId="shape6" />
407+
<DiagramConnection FromId="shape1-1" ToId="shape1-2" />
408+
<DiagramConnection FromId="shape1-1" ToId="shape1-3" />
409+
<DiagramConnection FromId="shape2-1" ToId="shape2-2" />
410+
<DiagramConnection FromId="shape2-1" ToId="shape2-3" />
411+
<DiagramConnection FromId="shape3-1" ToId="shape3-2" />
412+
<DiagramConnection FromId="shape3-1" ToId="shape3-3" />
358413
</DiagramConnections>
359414
</TelerikDiagram>
415+
416+
ComponentSpacingX:
417+
<TelerikNumericTextBox @bind-Value="@XSpacing" Width="80px" Step="30" />
418+
ComponentSpacingY:
419+
<TelerikNumericTextBox @bind-Value="@YSpacing" Width="80px" Step="30" />
420+
OffsetX:
421+
<TelerikNumericTextBox @bind-Value="@XOffset" Width="80px" Step="30" />
422+
OffsetY:
423+
<TelerikNumericTextBox @bind-Value="@YOffset" Width="80px" Step="30" />
424+
Width:
425+
<TelerikNumericTextBox @bind-Value="@LayoutWidth" Width="80px" Step="200" />
426+
427+
@code {
428+
private int XSpacing { get; set; } = 20;
429+
private int YSpacing { get; set; } = 20;
430+
private int XOffset { get; set; } = 50;
431+
private int YOffset { get; set; } = 50;
432+
private int LayoutWidth { get; set; } = 500;
433+
}
360434
````
361435

362436
## See Also

0 commit comments

Comments
 (0)