logo

G6

  • Docs
  • API
  • Playground
  • Community
  • Productsantv logo arrow
  • 5.0.49
  • Introduction
  • Data
  • Getting Started
    • Quick Start
    • Installation
    • Integration
      • react
      • vue
      • angular
    • Step-by-step guide
  • Graph
    • Extensions En
    • Graph
    • Options
    • extension
  • Element
    • Element Overview
    • Element State
    • Node
      • Node Overview
      • Common Node Configuration
      • Circle Node
      • Diamond Node
      • Donut Node
      • Ellipse Node
      • Hexagon Node
      • HTML Node
      • Image Node
      • Rect Node
      • Star Node
      • Triangle Node
      • Custom Node
      • Define Nodes with React
    • Edge
      • Edge Overview
      • Edge Common Configuration
      • Cubic Bezier Curve Edge
      • CubicHorizontal Bezier Curve Edge
      • CubicVertical Bezier Curve Edge
      • Line Edge
      • Polyline Edge
      • Quadratic Bezier Curve Edge
      • Custom Edge
    • Combo
      • Combo Overview
      • Combo Common Options
      • Circle Combo
      • Rect Combo
      • Custom Combo
    • Shape
      • Shape and KeyShape
      • Atomic Shapes and Their Properties
      • Design and Implementation of Composite Shape
  • Layout
    • Layout Overview
    • Common Layout Configuration Options
    • AntvDagre Layout
    • Circular Layout
    • ComboCombined Layout
    • CompactBox Layout
    • Concentric Layout
    • 3D Force-Directed Layout
    • D3 Force-Directed Layout
    • Dagre Layout
    • Dendrogram Layout
    • Fishbone Layout
    • ForceAtlas2 Force-directed Layout
    • Force-directed Layout
    • Fruchterman Force-directed Layout
    • Grid Layout
    • Indented Tree
    • MDS High-dimensional Data Dimensionality Reduction Layout
    • Mindmap Tree
    • Radial Layout
    • Random Layout
    • Snake Layout
    • Custom Layout
  • Behavior
    • Behavior Overview
    • ZoomCanvas
    • AutoAdaptLabel
    • BrushSelect
    • ClickSelect
    • CollapseExpand
    • CreateEdge
    • DragCanvas
    • DragElement
    • DragElementForce
    • FixElementSize
    • FocusElement
    • HoverActivate
    • LassoSelect
    • OptimizeViewportTransform
    • ScrollCanvas
    • Custom Behavior
  • Plugin
    • Plugin Overview
    • Background
    • BubbleSets
    • Contextmenu
    • EdgeBundling
    • EdgeFilterLens
    • Fisheye
    • Fullscreen
    • GridLine
    • History
    • Hull
    • Legend
    • Minimap
    • Snapline
    • Timebar
    • Toolbar
    • Tooltip
    • Watermark
    • Custom Plugin
  • Transform
    • Data Transformation Overview
    • MapNodeSize
    • PlaceRadialLabels
    • ProcessParallelEdges
    • Custom Transform
  • Theme
    • Theme Overview
    • Custom Theme
    • Palette
    • Custom Palette
  • Animation
    • Animation Overview
    • Custom Animation
  • Further Reading
    • Event
    • renderer
    • coordinate
    • download-image
    • Using Iconfont
    • Use 3D
    • Bundle Project
  • What's new
    • Feature
    • Upgrade To 5.0
  • FAQ
  • contribute

Indented Tree

Previous
Grid Layout
Next
MDS High-dimensional Data Dimensionality Reduction Layout

Resource

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-Interactive solution
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Indented Tree Layout

Overview

Indented tree layout represents the hierarchy of tree nodes through indentation in the horizontal direction. Each element occupies a row or column, commonly used in file directory structures, organizational charts, and other scenarios. This layout provides a clear structure for displaying hierarchical relationships.

Indented Tree Layout

Use Cases

  • File directory structure visualization
  • Organizational charts
  • Classification system display
  • Tree-like data where hierarchical relationships need to be emphasized

Configuration Items

IndentedLayout supports common layout configuration items and specific configuration items, as shown below.

PropertyDescriptionTypeDefaultRequired
typeLayout type, must be 'indented''indented'-✓
directionLayout direction, see details below'LR' | 'RL' | 'H''LR'
indentColumn spacing, fixed value or functionnumber | (d?: Node) => number20
getWidthGet each node's width, effective when direction='H'(d?: Node) => number-
getHeightGet each node's height(d?: Node) => number-
getSideNode placement on left/right side of root, overrides direction='H'(d?: Node) => 'left' | 'right'-
dropCapWhether the first child of each node starts on the next linebooleantrue
isLayoutInvisibleNodesWhether invisible nodes participate in layout (when preLayout=true)booleanfalse
nodeFilterNodes participating in this layout(node: NodeData) => boolean() => true
preLayoutUse pre-layout, calculate layout before initializing elementsbooleanfalse
enableWorkerWhether to run layout in WebWorkerboolean-
iterationsNumber of iterations for iterative layoutnumber-

Complex Type Explanations

  • direction

    • 'LR': Root node on the left, layout to the right LR
    • 'RL': Root node on the right, layout to the left RL
    • 'H': Root node in the middle, horizontal symmetric layout H
  • indent

    • Fixed value: Consistent indentation for all levels
    • Function: (d?: Node) => number, customize indentation based on node
    • Example:
      (d) => {
      if (d.parent?.id === 'testId') return d.parent.x + 50;
      return 100;
      };
  • getWidth/getHeight

    • Used to customize each node's width/height, often for content adaptation
    • Example:
      (d) => (d.id === 'testId' ? 50 : 100);
  • getSide

    • Specifies which side of the root node a node should be placed, only effective when direction='H'
    • Example:
      (d) => (d.id === 'testId' ? 'left' : 'right');

Example Code

For more examples, see Online Demo

Automatic Child Node Distribution

import { Graph, treeToGraphData } from '@antv/g6';
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/algorithm-category.json')
.then((res) => res.json())
.then((data) => {
const graph = new Graph({
container: 'container',
data: treeToGraphData(data),
autoFit: 'view',
layout: {
type: 'indented',
direction: 'H',
indent: 80,
getHeight: () => 16,
getWidth: () => 32,
},
});
graph.render();
});

Right Side Child Node Distribution

// ... code as above, layout.direction: 'LR'

Left Side Child Node Distribution

// ... code as above, layout.direction: 'RL'

Custom Child Node Distribution

layout: {
type: 'indented',
direction: 'H',
indent: 80,
getHeight: () => 16,
getWidth: () => 32,
getSide: (d) => {
if (d.id === 'Regression' || d.id === 'Classification') return 'left';
return 'right';
},
}

No Line Break for First Child Node

layout: {
type: 'indented',
direction: 'LR',
indent: 80,
getHeight: () => 16,
getWidth: () => 32,
dropCap: false,
}