Circular Layout
Previous
AntvDagre Layout
Next
ComboCombined Layout
Loading...
Circular layout arranges nodes evenly or at intervals on a circle, and also supports spiral layouts by configuring different startRadius and endRadius. See more circular layout examples or source code.
Circular layout:
Spiral layout:
Other settings use the default configuration (layout width and height default to the entire canvas container)
const graph = new Graph({// other configurationslayout: {type: 'circular',},});
| Property | Description | Type | Default | Required | 
|---|---|---|---|---|
| type | Layout type | circular | - | ✓ | 
| angleRatio | How many 2*PI between the first and last node | number | 1 | |
| center | Center of the layout | [number, number]|[number, number, number] | [ layout width/ 2,layout height/ 2] | |
| clockwise | Whether to arrange clockwise | boolean | true | |
| divisions | Number of segments on the ring (segments will be evenly distributed, effective when endRadius - startRadius != 0) | number | 1 | |
| nodeSize | Node size (diameter), used for collision detection | Size | ((nodeData: Node) => Size) | 10 | |
| nodeSpacing | Minimum spacing between rings, used to adjust radius | number | ((nodeData: Node) => number) | 10 | |
| ordering | Node ordering on the ring, see details | topology|topology-directed|degree | - | |
| radius | Circle radius, if set, spiral layout configs startRadiusandendRadiusare ignored, see details | number | - | |
| startAngle | Start angle of the layout | number | 0 | |
| endAngle | End angle of the layout | number | 2 * Math.PI | |
| startRadius | Start radius for spiral layout, usage | number | - | |
| endRadius | End radius for spiral layout | number | - | |
| width | Layout width | number | canvas width | |
| height | Layout height | number | canvas height | 
Node ordering on the ring
topology: topological ordertopology-directed: topological order (directed graph)degree: order by degreeIf not set (null), the order in the array is used directly
If radius, startRadius, and endRadius are not set, the default is Math.min(layout width, layout height) / 2, i.e., fills the entire layout area
const graph = new Graph({// other configurationslayout: {type: 'circular',},});
import { Graph } from '@antv/g6';fetch('https://assets.antv.antgroup.com/g6/circular.json').then((res) => res.json()).then((data) => {const graph = new Graph({container: 'container',autoFit: 'view',data,node: {style: {labelText: (d) => d.id,labelFill: '#fff',labelPlacement: 'center',},},layout: {type: 'circular',},behaviors: ['drag-canvas', 'drag-element'],});graph.render();});
const graph = new Graph({// other configurationslayout: {type: 'circular',startRadius: 10,endRadius: 300,},});
import { Graph } from '@antv/g6';fetch('https://assets.antv.antgroup.com/g6/circular.json').then((res) => res.json()).then((data) => {const graph = new Graph({container: 'container',autoFit: 'center',data,node: {style: {labelText: (d) => d.id,labelFill: '#fff',labelPlacement: 'center',},},layout: {type: 'circular',startRadius: 10,endRadius: 300,},behaviors: ['drag-canvas', 'drag-element'],});graph.render();});