Skip to main content

OrgChart

The TkOrgChart component allows users to visualize organizational data using d3-org-chart.

import { TkOrgChart } from '@takeoff-ui/react'

Basic​

A simple org chart.

View Code
const data = {
name: 'Emre Arslan',
title: 'CEO',
children: [
{
name: 'Emre Arslan',
title: 'CTO',
children: [
{
name: 'Engineering manager',
title: 'VP of Engineering',
},
{
name: 'Engineering manager',
title: 'VP of Engineering',
},
{
name: 'Engineering manager',
title: 'VP of Engineering',
},
{
name: 'Engineering manager',
title: 'VP of Engineering',
},
],
},
],
};
const options = {
nodeId: (d: any) => d.id,
parentNodeId: (d: any) => d.parentId,
};
<TkOrgChart
ref={chartRef}
data={data}
options={options}
collapsible = {true}
onTkNodeClick={handleNodeClick}
/>

API​

Props​

NameTypeDefaultDescription
stringnullAccessibility label for the chart
booleantrueEnable or disable expand/collapse buttons functionality When disabled, all nodes will be automatically expanded
any[]nullChart data should be an array of node objects with at least id, parentId (optional for root), and name properties.
anynullChart options for d3-org-chart customization

Events​

NameDescription
tk-node-clickNode click event

Methods​

NameDescription
addNodeAdd node to organizational chart
fitFit chart to screen
getOrgChartGet the chart instance
refreshRefresh the chart