Skip to content

Commit d70b83b

Browse files
authored
Merge pull request #77 from DHTMLX/autoplace-shapes-padding-4693
[update] autoplacement docs for v6.1.3
2 parents 835ff47 + ae49015 commit d70b83b

8 files changed

Lines changed: 143 additions & 51 deletions

File tree

docs/api/diagram/autoplace_method.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: You can learn about the autoPlace method in the documentation of th
77
# autoPlace()
88

99
:::info
10-
The **autoPlace()** method works only in the default mode of the diagram and only for shapes
10+
The `autoPlace()` method works only in the default mode of the diagram and only for shapes
1111
:::
1212

1313
### Description
@@ -16,16 +16,18 @@ The **autoPlace()** method works only in the default mode of the diagram and onl
1616

1717
### Usage
1818

19-
~~~jsx
19+
~~~ts
2020
autoPlace(config?: object): void;
2121
~~~
2222

2323
### Parameters
2424

2525
- `config` - (optional) an object with configuration settings of the autoplacement. If not specified, the default settings will be applied. Here you can specify the following parameters:
26-
- `mode` - (optional) the mode of connecting shapes, "direct" (by default) or "edges"
27-
- `graphPadding` - (optional) sets the distance between unconnected diagrams, 200 by default
28-
- `placeMode` - (optional) sets the mode of placement of shapes, "orthogonal" (by default) or "radial"
26+
- `mode` - (optional) the mode of connecting shapes, *"direct"* (by default) or *"edges"*
27+
- `graphPadding` - (optional) sets the distance between unconnected diagrams, *200* by default
28+
- `placeMode` - (optional) sets the mode of placement of shapes, *"orthogonal"* (by default) or *"radial"*
29+
- `itemPadding` - (optional) minimal padding between items (the minimal value is *1*), *20* by default
30+
- `levelPadding` - (optional) minimal padding between hierarchy levels (the minimal value is *1*), *20* by default
2931

3032
### Example
3133

@@ -51,6 +53,10 @@ Connector lines with no arrows are aligned "from center to center"; they are str
5153

5254
Connector lines are aligned "from side to side".
5355

56+
:::note
57+
If `fromSide` and `toSide` are set on a link, the autoplacement algorithm will preserve those values but will not use them during placement calculation. The key properties that define links are `from` and `to`, while `fromSide` and `toSide` are calculated automatically by the algorithm.
58+
:::
59+
5460
:::info
5561
To add arrows to the lines, specify **forwardArrow: "filled"** or **backArrow: "filled"** in the configuration of a [line object](../../../lines/configuration_properties/).
5662
:::
@@ -94,9 +100,12 @@ Shapes are arranged on imaginary circles relative to the central shape, i.e. a s
94100

95101
**Change log**:
96102

103+
- The `itemPadding` and `levelPadding` parameters are added in v6.1.3
97104
- The **placeMode** parameter is added in v5.0
98105
- The **autoplacement** property is added in v3.0
99106

100107
**Related articles**: [Arranging shapes automatically](../../../guides/manipulating_items/#arranging-shapes-automatically)
101108

102-
**Related sample**: [Diagram. Default mode. Autoplacement](https://snippet.dhtmlx.com/f3uekgjw)
109+
**Related sample**:
110+
- [Diagram. Default mode. Radial autoplacement with padding options](https://snippet.dhtmlx.com/huut0l1s)
111+
- [Diagram. Default mode. Autoplacement](https://snippet.dhtmlx.com/f3uekgjw)

docs/api/diagram/autoplacement_property.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,42 @@ description: You can learn about the autoplacement property in the documentation
1111
@short: Optional. An object with configuration settings for auto-placement of shapes
1212

1313
:::info
14-
The `autoplacement` property works only in the default mode of the diagram and only for shapes
14+
The `autoplacement` property works only in the default mode of the diagram and only for shapes. It does not work if you use groups or swimlanes.
15+
16+
Autoplacement will be applied only after the [`autoPlace()`](/api/diagram/autoplace_method/) method is applied.
1517
:::
1618

1719
### Usage
1820

19-
~~~jsx
21+
~~~ts
2022
autoplacement?: {
21-
mode?: "direct" | "edges",
22-
graphPadding?: number,
23-
placeMode?: "orthogonal" | "radial"
23+
mode?: "direct" | "edges", // "direct" by default
24+
graphPadding?: number, // 200 by default
25+
placeMode?: "orthogonal" | "radial", // "orthogonal" by default
26+
itemPadding?: number, // 20 by default
27+
levelPadding?: number // 20 by default
2428
};
2529
~~~
2630

2731
### Parameters
2832

2933
The `autoplacement` object has the following parameters:
3034

31-
- `mode` - (optional) the mode of connecting shapes, "direct" (by default) or "edges"
32-
- `graphPadding` - (optional) sets the distance between two or more unconnected diagrams, *"200"* by default
33-
- `placeMode` - (optional) sets the mode of placement of shapes, "orthogonal" (by default) or "radial"
35+
- `mode` - (optional) the mode of connecting shapes, *"direct"* (by default) or *"edges"*
36+
- `graphPadding` - (optional) sets the distance between two or more unconnected diagrams, *200* by default
37+
- `placeMode` - (optional) sets the mode of placement of shapes, *"orthogonal"* (by default) or *"radial"*
38+
- `itemPadding` - (optional) minimal padding between items (the minimal value is *1*), *20* by default
39+
- `levelPadding` - (optional) minimal padding between hierarchy levels (the minimal value is *1*), *20* by default
3440

3541
### Default config
3642

3743
~~~jsx
3844
autoplacement: {
3945
mode: "direct",
4046
graphPadding: 200,
41-
placeMode: "orthogonal"
47+
placeMode: "orthogonal",
48+
itemPadding: 20,
49+
levelPadding: 20
4250
}
4351
~~~
4452

@@ -47,7 +55,10 @@ autoplacement: {
4755
~~~jsx
4856
const diagram = new dhx.Diagram("diagram_container", {
4957
autoplacement: {
50-
mode: "edges",
58+
placeMode: "radial",
59+
mode: "direct",
60+
itemPadding: 10,
61+
levelPadding: 10,
5162
graphPadding: 100
5263
}
5364
});
@@ -109,11 +120,17 @@ Shapes are arranged on imaginary circles relative to the central shape, i.e. the
109120

110121
![](../../assets/edges_radial.png)
111122

112-
**Change log**: The `placeMode` parameter is added in v5.0
123+
**Change log**:
124+
125+
- The `itemPadding` and `levelPadding` parameters are added in v6.1.3
126+
- The `placeMode` parameter is added in v5.0
113127

114128
**Related articles**:
115129

116130
- [Configuring autoplacement for shapes](../../../guides/diagram/configuration/#configuring-autoplacement-for-shapes)
117131
- [Arranging shapes automatically](../../../guides/manipulating_items/#arranging-shapes-automatically)
118132

119-
**Related sample**: [Diagram. Default mode. Autoplacement](https://snippet.dhtmlx.com/f3uekgjw)
133+
**Related sample**:
134+
135+
- [Diagram. Default mode. Radial autoplacement with padding options](https://snippet.dhtmlx.com/huut0l1s)
136+
- [Diagram. Default mode. Arranging a generated radial dataset with autoplacement](https://snippet.dhtmlx.com/rwsime82)

docs/api/diagram_editor/editor/config/autoplacement_property.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,40 @@ description: You can learn about the autoplacement property of editor in the doc
1111
@short: Optional. An object with configuration settings for auto-placement of shapes
1212

1313
:::info
14-
The `autoplacement` property works only in the default mode of the editor (`type:"default"`) and only for shapes
14+
The `autoplacement` property works only in the default mode of the editor and only for shapes. It does not work if you use groups or swimlanes.
1515
:::
1616

1717
### Usage
1818

19-
~~~jsx
19+
~~~ts
2020
autoplacement?: {
21-
mode?: "direct" | "edges",
22-
graphPadding?: number,
23-
placeMode?: "orthogonal" | "radial"
21+
mode?: "direct" | "edges", // "direct" by default
22+
graphPadding?: number, // 200 by default
23+
placeMode?: "orthogonal" | "radial", // "orthogonal" by default
24+
itemPadding?: number, // 20 by default
25+
levelPadding?: number // 20 by default
2426
};
2527
~~~
2628

2729
### Parameters
2830

2931
The `autoplacement` object has the following parameters:
3032

31-
- `mode` - (optional) the mode of connecting shapes, "direct" (by default) or "edges"
32-
- `graphPadding` - (optional) sets the distance between unconnected diagrams, *"200"* by default
33-
- `placeMode` - (optional) sets the mode of placement of shapes, "orthogonal" (by default) or "radial"
33+
- `mode` - (optional) the mode of connecting shapes, *"direct"* (by default) or *"edges"*
34+
- `graphPadding` - (optional) sets the distance between unconnected diagrams, *200* by default
35+
- `placeMode` - (optional) sets the mode of placement of shapes, *"orthogonal"* (by default) or *"radial"*
36+
- `itemPadding` - (optional) minimal padding between items (the minimal value is *1*), *20* by default
37+
- `levelPadding` - (optional) minimal padding between hierarchy levels (the minimal value is *1*), *20* by default
3438

3539
### Default config
3640

3741
~~~jsx
3842
autoplacement: {
3943
mode: "direct",
4044
graphPadding: 200,
41-
placeMode: "orthogonal"
45+
placeMode: "orthogonal",
46+
itemPadding: 20,
47+
levelPadding: 20
4248
}
4349
~~~
4450

@@ -47,11 +53,15 @@ autoplacement: {
4753
~~~jsx
4854
const editor = new dhx.DiagramEditor("editor_container", {
4955
autoplacement: {
50-
graphPadding: 100,
51-
mode: "edges",
52-
placeMode: "radial"
56+
placeMode: "radial",
57+
mode: "direct",
58+
itemPadding: 10,
59+
levelPadding: 10,
60+
graphPadding: 100
5361
}
5462
});
63+
64+
editor.parse(data);
5565
~~~
5666

5767
## Modes of connecting shapes
@@ -108,7 +118,8 @@ Shapes are arranged on imaginary circles relative to the central shape, i.e. the
108118

109119
**Change log**:
110120

111-
- The **placeMode** parameter is added in v5.0
112-
- The **autoplacement** property is added in v3.0
121+
- The `itemPadding` and `levelPadding` parameters are added in v6.1.3
122+
- The `placeMode` parameter is added in v5.0
123+
- The `autoplacement` property is added in v3.0
113124

114-
**Related sample**: [Diagram. Default mode. Autoplacement](https://snippet.dhtmlx.com/f3uekgjw)
125+
**Related sample**: [Diagram editor. Default mode. Radial auto layout algorithm](https://snippet.dhtmlx.com/f0cespbk)
44.8 KB
Loading
149 KB
Loading

docs/guides/diagram/configuration.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,29 +121,40 @@ You can specify the position of a diagram on a page and set margins for shapes i
121121

122122
## Configuring autoplacement for shapes
123123

124-
The DHTMLX Diagram library lets you configure settings for arranging connected shapes of Diagram in the hierarchical structure automatically. You can specify the [](../../api/diagram/autoplacement_property.md) property in the configuration object of Diagram and configure the mode of connecting shapes and distance between unconnected diagrams:
124+
The DHTMLX Diagram library lets you configure settings for arranging connected shapes of Diagram in the hierarchical structure automatically. You can specify the [`autoplacement`](/api/diagram/autoplacement_property/) property in the configuration object of Diagram and configure the mode of connecting shapes and distance between unconnected diagrams:
125125

126126
~~~jsx
127127
const diagram = new dhx.Diagram("diagram_container", {
128128
autoplacement: {
129129
mode: "edges",
130130
graphPadding: 100,
131-
placeMode: "radial"
131+
placeMode: "radial",
132+
itemPadding: 10,
133+
levelPadding: 10
132134
}
133135
});
136+
137+
diagram.data.parse(data);
138+
134139
diagram.autoPlace();
135140
~~~
136141

137-
The property can contain three options:
142+
The property can contain the following options:
138143

139-
- **mode** - (*string*) optional, the mode of connecting shapes, "direct" (by default) or "edges"
140-
- **graphPadding** - (*number*) optional, sets the distance between unconnected diagrams, "200" by default
141-
- **placeMode** - (*string*) sets the mode of placement of shapes, "orthogonal" (by default) or "radial"
144+
- `mode` - (*string*) optional, the mode of connecting shapes, *"direct"* (by default) or *"edges"*
145+
- `graphPadding` - (*number*) optional, sets the distance between unconnected diagrams, *200* by default
146+
- `placeMode` - (*string*) optional, sets the mode of placement of shapes, *"orthogonal"* (by default) or *"radial"*
147+
- `itemPadding` - (*number*) optional, minimal padding between items (the minimal value is *1*), *20* by default
148+
- `levelPadding` - (*number*) optional, minimal padding between hierarchy levels (the minimal value is *1*), *20* by default
142149

143150
:::note
144-
The autoplacement will be applied only after the [](../../api/diagram/autoplace_method.md) method is applied. The autoplacement does not work if you use groups or swimlanes.
151+
Autoplacement will be applied only after the [`autoPlace()`](/api/diagram/autoplace_method/) method is applied. It works only in the default mode of the diagram and only for shapes. Autoplacement does not work if you use groups or swimlanes.
145152
:::
146153

154+
![Radial autoplacement with padding options](../../assets/radial_autoplacement.png)
155+
156+
**Related sample**: [Diagram. Default mode. Radial autoplacement with padding options](https://snippet.dhtmlx.com/huut0l1s)
157+
147158
## Adjusting the Diagram scale
148159

149160
If necessary, you can scale a diagram to fit your application. It can be done with the help of the [](../../api/diagram/scale_property.md) option.

docs/guides/manipulating_items.md

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ description: You can learn about manipulating items in the documentation of the
55
---
66
# Manipulating items
77

8-
You can easily manipulate Diagram items via the [Diagram Editor](../../guides/diagram_editor/initialization/). But in this article we'll explore the examples on how to manipulate the items of DHTMLX Diagram via the component's API. The article contains different sections that cover such questions as:
8+
You can easily manipulate Diagram items via the [Diagram Editor](../../guides/diagram_editor/initialization/). But in this article we'll explore the examples on how to manipulate the items of DHTMLX Diagram via the component's API.
9+
10+
## Overview
11+
12+
The article contains different sections that cover such questions as:
913

1014
- [how to automatically arrange shapes in the hierarchical order](#arranging-shapes-automatically);
1115
- how to perform a range of operations over items, in particular:
@@ -30,12 +34,18 @@ The library provides you with the ability to implement auto-placement for shapes
3034
- to place connected shapes in the symmetric order at once;
3135
- to arrange data loaded in the JSON format or loaded from the server in the hierarchical structure.
3236

33-
To perform the auto-placement, you need to make use of the [](../api/diagram/autoplace_method.md) method. The method can take one parameter:
37+
To perform the auto-placement, you need to make use of the [`autoPlace()`](/api/diagram/autoplace_method/) method. The method can take one parameter:
38+
39+
- `config` - (*object*) optional, an object with configuration settings of the auto-placement. The object can contain the following properties:
40+
- `mode` - (*string*) optional, the mode of connecting shapes, *"direct"* (by default) or *"edges"*
41+
- `graphPadding` - (*number*) optional, sets the distance between unconnected diagrams, *200* by default
42+
- `placeMode` - (*string*) optional, sets the mode of placement of shapes, *"orthogonal"* (by default) or *"radial"*
43+
- `itemPadding` - (*number*) optional, minimal padding between items (the minimal value is *1*), *20* by default
44+
- `levelPadding` - (*number*) optional, minimal padding between hierarchy levels (the minimal value is *1*), *20* by default
3445

35-
- **config** - (*object*) optional, an object with configuration settings of the auto-placement. The object contains two optional properties:
36-
- **mode** - (*string*) the mode of connecting shapes, "direct" (by default) or "edges"
37-
- **graphPadding** - (*number*) sets the distance between unconnected diagrams, *"200"* by default
38-
- **placeMode** - (*string*) sets the mode of placement of shapes, "orthogonal" (by default) or "radial"
46+
:::note
47+
The `autoPlace()` method works only in the default mode of the diagram and only for shapes. The autoplacement does not work if you use groups or swimlanes.
48+
:::
3949

4050
~~~jsx
4151
const diagram = new dhx.Diagram("diagram_container");
@@ -44,7 +54,9 @@ diagram.data.parse(data);
4454
diagram.autoPlace({
4555
mode: "edges",
4656
graphPadding: 100,
47-
placeMode: "radial"
57+
placeMode: "radial",
58+
itemPadding: 10,
59+
levelPadding: 10
4860
});
4961
~~~
5062

@@ -59,11 +71,29 @@ diagram.data.parse(data);
5971
diagram.autoPlace();
6072
~~~
6173

62-
There is also the ability to configure settings for the auto-placement by using the [](../api/diagram/autoplacement_property.md) configuration option of Diagram and applying the **autoPlace()** method.
74+
There is also the ability to configure settings for the auto-placement by using the [`autoplacement`](/api/diagram/autoplacement_property/) configuration option of Diagram and applying the `autoPlace()` method. The example below demonstrates how to generate and arrange a radial dataset using autoplacement.
6375

64-
:::note
65-
The **autoPlace()** method works only in the default mode of the diagram and only for shapes.
66-
:::
76+
~~~jsx
77+
const diagram = new dhx.Diagram("diagram_container", {
78+
scale: 0.3,
79+
autoplacement: {
80+
placeMode: "radial",
81+
mode: "direct"
82+
}
83+
});
84+
85+
diagram.data.parse(getNodes(120, 5));
86+
87+
diagram.autoPlace({
88+
itemPadding: 10,
89+
levelPadding: 10,
90+
graphPadding: 100,
91+
});
92+
~~~
93+
94+
![Autoplacement with a generated radial dataset](../assets/radial_datasets_generator.png)
95+
96+
**Related sample:** [Diagram. Default mode. Arranging a generated radial dataset with autoplacement](https://snippet.dhtmlx.com/rwsime82)
6797

6898
## Adding an item
6999

docs/whats_new.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ description: You can learn a new information about DHTMLX JavaScript Diagram lib
88

99
If you are updating Diagram from an older version, check [Migration to Newer Version](migration.md) for details.
1010

11+
## Version 6.1.3
12+
13+
Released on May 21, 2026
14+
15+
### Updates
16+
17+
- Diagram / Diagram Editor. Improvements in the autoplacement logic. Added the ability to control spacing between shapes and levels via new `itemPadding` and `levelPadding` properties in the [`autoPlace()`](/api/diagram/autoplace_method/) Diagram method and the [`autoplacement`](/api/diagram/autoplacement_property/) configuration object
18+
19+
### Fixes
20+
21+
- Diagram. Fixed the issue where applying autoplacement resulted in incorrect distances between shapes
22+
- Diagram. Fixed the issue where calling [`autoPlace()`](/api/diagram/autoplace_method/) ignored [`fromSide` and `toSide`](/lines/configuration_properties/) link values, ensuring the diagram structure remains consistent
23+
- Diagram. The `Radial` autoplacement algorithm was refactored to fix the issue with critically large distances between shapes, providing a more compact layout
24+
1125
## Version 6.1.2
1226

1327
Released on April 2, 2026

0 commit comments

Comments
 (0)