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

NameTypeDescription
addNodeaddNode(node: any) => Promise<void>Add node to organizational chart
fitfit() => Promise<void>Fit chart to screen
getOrgChartgetOrgChart() => Promise<any>Get the chart instance
refreshrefresh() => Promise<void>Refresh the chart