An Organisation Chart displays hierarchical relationships between people, departments, or entities as a tree of connected cards.
Simple Organisation Chart Copy Link
import { Component } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgChartOptions,
ContextMenuModule,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
ModuleRegistry.registerModules([OrganizationSeriesModule, ContextMenuModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
constructor() {
this.options = {
title: {
text: "Company Organisation",
},
data: getData(),
initialState: {
collapsed: [
"Mr. Jeffrey Brown",
"Nicole Jones",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
},
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
node: {
clickToExpand: false,
image: {
key: "avatar",
height: 50,
width: 50,
position: "left",
},
title: {
key: "name",
},
subtitle: {
key: "job",
},
labels: [
{
key: "location",
},
],
},
},
],
};
}
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
department: "Executive",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/19.webp",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
department: "Technology",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/20.webp",
},
{
id: "Mr. Jeffrey Brown",
parentId: "Joseph Howe",
name: "Mr. Jeffrey Brown",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/22.webp",
},
{
id: "Melissa Vazquez",
parentId: "Mr. Jeffrey Brown",
name: "Melissa Vazquez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Thomas",
parentId: "Mr. Jeffrey Brown",
name: "John Thomas",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/5.webp",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
department: "Technology",
location: "Portugal",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/29.webp",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/25.webp",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
department: "Technology",
location: "Ireland",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/7.webp",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
department: "Technology",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Rachel Ibarra",
parentId: "Justin Contreras",
name: "Rachel Ibarra",
job: "Design",
department: "Technology",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Gomez",
parentId: "Justin Contreras",
name: "John Gomez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/17.webp",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
department: "Operations",
location: "Netherlands",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
department: "Operations",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/33.webp",
},
{
id: "Devin Pittman",
parentId: "Lawrence Martinez",
name: "Devin Pittman",
job: "Design",
department: "Operations",
location: "United Kingdom",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Emily Barajas",
parentId: "Lawrence Martinez",
name: "Emily Barajas",
job: "Design",
department: "Operations",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/28.webp",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
department: "Operations",
location: "Spain",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/35.webp",
},
{
id: "Michael Morris",
parentId: "Eric Jensen",
name: "Michael Morris",
job: "Design",
department: "Operations",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Jodi Miller",
parentId: "Eric Jensen",
name: "Jodi Miller",
job: "Design",
department: "Operations",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/30.webp",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
The Org Chart is designed to display a single series and is created using the organization series type.
The data passed in should be an array of nodes, with each node containing a unique identifier field, and a second field that references the identifier of its parent node. The root node should have a null value for its parentId.
{
series: [
{
type: 'organization',
idKey: 'id',
parentIdKey: 'parentId',
node: {
title: { key: 'name' },
subtitle: { key: 'job' },
image: { key: 'avatar' },
labels: [{ key: 'location' }],
},
},
],
}In this configuration:
idKeyandparentIdKeydefine parent-child relationships. These default to'id'and'parentId'respectively.titleandsubtitledisplay the primary and secondary card text with the values from the provided data fields. The keys default to'title'and'subtitle'respectively.imagedisplays an image sourced from the data field specified bykey. The key defaults to'image'.labelsallow adding additional text rows below the subtitle, each mapping a data field viakey.
Text Copy Link
Each node can display a title, subtitle as well as an array of labels.
import { Component } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgChartOptions,
ContextMenuModule,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
ModuleRegistry.registerModules([OrganizationSeriesModule, ContextMenuModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
constructor() {
this.options = {
title: { text: "Company Organisation" },
data: getData(),
initialState: {
collapsed: [
"Mr. Jeffrey Brown",
"Nicole Jones",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
},
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
node: {
image: { key: "avatar", position: "left", height: 50, width: 50 },
title: { key: "name", textAlign: "left", fontSize: 16 },
subtitle: { key: "job", textAlign: "left", fontStyle: "italic" },
labels: [
{ key: "location", textAlign: "left" },
{
key: "status",
textAlign: "right",
itemStyler: ({ datum }) => {
const isRemote = datum.status === "Remote";
return {
fill: isRemote ? "#fff3e0" : "#e8f5e9",
stroke: isRemote ? "#ff9800" : "#4caf50",
color: isRemote ? "#e65100" : "#2e7d32",
cornerRadius: 8,
padding: 4,
fontWeight: "bold",
};
},
},
],
},
},
],
};
}
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
department: "Executive",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/19.webp",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
department: "Technology",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/20.webp",
},
{
id: "Mr. Jeffrey Brown",
parentId: "Joseph Howe",
name: "Mr. Jeffrey Brown",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/22.webp",
},
{
id: "Melissa Vazquez",
parentId: "Mr. Jeffrey Brown",
name: "Melissa Vazquez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Thomas",
parentId: "Mr. Jeffrey Brown",
name: "John Thomas",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/5.webp",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
department: "Technology",
location: "Portugal",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/29.webp",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/25.webp",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
department: "Technology",
location: "Ireland",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/7.webp",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
department: "Technology",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Rachel Ibarra",
parentId: "Justin Contreras",
name: "Rachel Ibarra",
job: "Design",
department: "Technology",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Gomez",
parentId: "Justin Contreras",
name: "John Gomez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/17.webp",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
department: "Operations",
location: "Netherlands",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
department: "Operations",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/33.webp",
},
{
id: "Devin Pittman",
parentId: "Lawrence Martinez",
name: "Devin Pittman",
job: "Design",
department: "Operations",
location: "United Kingdom",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Emily Barajas",
parentId: "Lawrence Martinez",
name: "Emily Barajas",
job: "Design",
department: "Operations",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/28.webp",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
department: "Operations",
location: "Spain",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/35.webp",
},
{
id: "Michael Morris",
parentId: "Eric Jensen",
name: "Michael Morris",
job: "Design",
department: "Operations",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Jodi Miller",
parentId: "Eric Jensen",
name: "Jodi Miller",
job: "Design",
department: "Operations",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/30.webp",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
{
series: [
{
type: 'organization',
node: {
image: { key: 'avatar', position: 'left', height: 50, width: 50 },
title: { key: 'name', textAlign: 'left', fontSize: 16 },
subtitle: { key: 'job', textAlign: 'left', fontStyle: 'italic' },
labels: [
{ key: 'location', textAlign: 'left' },
{
key: 'status',
textAlign: 'right',
itemStyler: ({ datum }) => ({
fill: datum.status === 'Remote' ? '#fff3e0' : '#e8f5e9',
stroke: datum.status === 'Remote' ? '#ff9800' : '#4caf50',
color: datum.status === 'Remote' ? '#e65100' : '#2e7d32',
cornerRadius: 8,
padding: 4,
fontWeight: 'bold',
}),
},
],
},
},
],
}In this configuration:
titleandsubtitledisplay the primary and secondary text with their ownkey,textAlign, and font styles.labelsis an array with each entry mapping a data field to a label stacked vertically below the subtitle.- An
itemStyleris used to add a pill-style background to the 'status' label, with the fill and stroke colour determined by the label value.
See the API Reference for the available styling options for each text element.
Image Copy Link
Each node can display an optional image by referencing a data field containing an image URL.
import { Component } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgChartOptions,
AgOrganizationSeriesOptions,
AgOrganizationSeriesOptionsNodeImagePosition,
AgStandaloneChartOptions,
ContextMenuModule,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
import clone from "clone";
ModuleRegistry.registerModules([OrganizationSeriesModule, ContextMenuModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<div class="example-controls">
<div class="controls-row">
Position:
<button (click)="changePosition('top')">Top</button>
<button (click)="changePosition('right')">Right</button>
<button (click)="changePosition('bottom')">Bottom</button>
<button (click)="changePosition('left')">Left</button>
<span class="gap-left">
Corner Radius:
<input type="range" id="cornerRadiusInput" min="0" max="25" value="25" step="1" (input)="changeCornerRadius($event)" (change)="changeCornerRadius($event)">
<span id="cornerRadiusValue" style="display: inline-block; min-width: 3ch; text-align: right">25</span>
</span>
</div>
</div>
<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
constructor() {
this.options = {
title: { text: "Company Organisation" },
data: getData(),
initialState: {
collapsed: [
"Mr. Jeffrey Brown",
"Nicole Jones",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
},
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
node: {
image: {
key: "avatar",
height: 50,
width: 50,
position: "left",
cornerRadius: 25,
},
title: { key: "name" },
subtitle: { key: "job" },
labels: [{ key: "location" }],
},
},
],
};
}
changePosition = (position: AgOrganizationSeriesOptionsNodeImagePosition) => {
const options = clone(this.options);
(options.series![0] as AgOrganizationSeriesOptions).node!.image!.position =
position;
this.options = options;
};
changeCornerRadius = (event: any) => {
const options = clone(this.options);
const value = Number(event.target.value);
document.getElementById("cornerRadiusValue")!.innerHTML = String(value);
(
options.series![0] as AgOrganizationSeriesOptions
).node!.image!.cornerRadius = value;
this.options = options;
};
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
department: "Executive",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/19.webp",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
department: "Technology",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/20.webp",
},
{
id: "Mr. Jeffrey Brown",
parentId: "Joseph Howe",
name: "Mr. Jeffrey Brown",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/22.webp",
},
{
id: "Melissa Vazquez",
parentId: "Mr. Jeffrey Brown",
name: "Melissa Vazquez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Thomas",
parentId: "Mr. Jeffrey Brown",
name: "John Thomas",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/5.webp",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
department: "Technology",
location: "Portugal",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/29.webp",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/25.webp",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
department: "Technology",
location: "Ireland",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/7.webp",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
department: "Technology",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Rachel Ibarra",
parentId: "Justin Contreras",
name: "Rachel Ibarra",
job: "Design",
department: "Technology",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Gomez",
parentId: "Justin Contreras",
name: "John Gomez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/17.webp",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
department: "Operations",
location: "Netherlands",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
department: "Operations",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/33.webp",
},
{
id: "Devin Pittman",
parentId: "Lawrence Martinez",
name: "Devin Pittman",
job: "Design",
department: "Operations",
location: "United Kingdom",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Emily Barajas",
parentId: "Lawrence Martinez",
name: "Emily Barajas",
job: "Design",
department: "Operations",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/28.webp",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
department: "Operations",
location: "Spain",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/35.webp",
},
{
id: "Michael Morris",
parentId: "Eric Jensen",
name: "Michael Morris",
job: "Design",
department: "Operations",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Jodi Miller",
parentId: "Eric Jensen",
name: "Jodi Miller",
job: "Design",
department: "Operations",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/30.webp",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
{
series: [
{
type: 'organization',
node: {
image: {
key: 'avatar',
cornerRadius: 25,
width: 50,
height: 50,
position: 'left',
},
},
},
],
}In this configuration:
keymaps to a data field containing an image URL.positionplaces the image within the card ('top','bottom','left', or'right').- The image position dictates the layout of the text within the card.
widthandheightcontrol the image dimensions.cornerRadiusrounds the image corners, allowing rounded rectangles or circles.
Direction Copy Link
import { Component } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgOrganizationSeriesOptions,
AgStandaloneChartOptions,
ContextMenuModule,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
import clone from "clone";
ModuleRegistry.registerModules([OrganizationSeriesModule, ContextMenuModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<div class="example-controls">
<div class="controls-row">
<button (click)="changeDirection('horizontal')">Horizontal</button>
<button (click)="changeDirection('vertical')">Vertical</button>
<button (click)="toggleReverse()">Toggle Reverse</button>
</div>
</div>
<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
constructor() {
this.options = {
title: {
text: "Company Organisation",
},
data: getData(),
initialState: {
collapsed: [
"Mr. Jeffrey Brown",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
},
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
direction: "horizontal",
node: {
clickToExpand: false,
image: {
key: "avatar",
height: 50,
width: 50,
position: "left",
},
title: {
key: "name",
},
subtitle: {
key: "job",
},
labels: [
{
key: "location",
},
],
},
},
],
};
}
changeDirection = (direction: "horizontal" | "vertical") => {
const options = clone(this.options);
(options.series![0] as AgOrganizationSeriesOptions).direction = direction;
this.options = options;
};
toggleReverse = () => {
const options = clone(this.options);
(options.series![0] as AgOrganizationSeriesOptions).reverse = !(
options.series![0] as AgOrganizationSeriesOptions
).reverse;
this.options = options;
};
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
department: "Executive",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/19.webp",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
department: "Technology",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/20.webp",
},
{
id: "Mr. Jeffrey Brown",
parentId: "Joseph Howe",
name: "Mr. Jeffrey Brown",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/22.webp",
},
{
id: "Melissa Vazquez",
parentId: "Mr. Jeffrey Brown",
name: "Melissa Vazquez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Thomas",
parentId: "Mr. Jeffrey Brown",
name: "John Thomas",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/5.webp",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
department: "Technology",
location: "Portugal",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/29.webp",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/25.webp",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
department: "Technology",
location: "Ireland",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/7.webp",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
department: "Technology",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Rachel Ibarra",
parentId: "Justin Contreras",
name: "Rachel Ibarra",
job: "Design",
department: "Technology",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Gomez",
parentId: "Justin Contreras",
name: "John Gomez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/17.webp",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
department: "Operations",
location: "Netherlands",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
department: "Operations",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/33.webp",
},
{
id: "Devin Pittman",
parentId: "Lawrence Martinez",
name: "Devin Pittman",
job: "Design",
department: "Operations",
location: "United Kingdom",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Emily Barajas",
parentId: "Lawrence Martinez",
name: "Emily Barajas",
job: "Design",
department: "Operations",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/28.webp",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
department: "Operations",
location: "Spain",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/35.webp",
},
{
id: "Michael Morris",
parentId: "Eric Jensen",
name: "Michael Morris",
job: "Design",
department: "Operations",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Jodi Miller",
parentId: "Eric Jensen",
name: "Jodi Miller",
job: "Design",
department: "Operations",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/30.webp",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
{
series: {
type: 'organization',
direction: 'horizontal',
reverse: false,
},
} Expander Copy Link
The expander is displayed on nodes with children and is used to collapse and expand subtrees.
import { Component } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgOrganizationSeriesOptions,
AgStandaloneChartOptions,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
import clone from "clone";
ModuleRegistry.registerModules([OrganizationSeriesModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<div class="example-controls">
<div class="controls-row">
<input type="checkbox" id="showAllChildren" checked="" (change)="setShowAllChildren($event.target.checked)">
<label for="showAllChildren">showAllChildren</label>
<input type="checkbox" id="showDirectChildren" checked="" class="gap-left" (change)="setShowDirectChildren($event.target.checked)">
<label for="showDirectChildren">showDirectChildren</label>
</div>
</div>
<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
constructor() {
this.options = {
title: { text: "Company Organisation" },
data: getData(),
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
node: {
title: { key: "name" },
subtitle: { key: "job" },
},
expander: {
text: {
showAllChildren: true,
showDirectChildren: true,
},
},
},
],
};
}
setShowAllChildren = (showAllChildren: boolean) => {
const options = clone(this.options);
(
options.series![0] as AgOrganizationSeriesOptions
).expander!.text!.showAllChildren = showAllChildren;
this.options = options;
};
setShowDirectChildren = (showDirectChildren: boolean) => {
const options = clone(this.options);
(
options.series![0] as AgOrganizationSeriesOptions
).expander!.text!.showDirectChildren = showDirectChildren;
this.options = options;
};
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
{
series: [
{
type: 'organization',
expander: {
text: {
showAllChildren: true,
showDirectChildren: true,
},
},
},
],
}In this example:
showAllChildrenincludes the total count of all descendants in the expander text.showDirectChildrenincludes the count of direct children in the expander text.- A
formattercan be used instead, for full control over the expander text. The params includeallChildren,directChildren,depthandisCollapsedalongside the datum.
See the API Reference for more details.
Customisation Copy Link
Node Styling Copy Link
import { Component } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgChartOptions,
ContextMenuModule,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
ModuleRegistry.registerModules([OrganizationSeriesModule, ContextMenuModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
constructor() {
this.options = {
title: { text: "Company Organisation" },
data: getData(),
initialState: {
collapsed: [
"Mr. Jeffrey Brown",
"Nicole Jones",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
},
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
node: {
width: 180,
// height: 120,
cornerRadius: 12,
image: {
key: "avatar",
position: "left",
height: 50,
width: 50,
cornerRadius: 25,
},
itemStyler: ({ datum }) => {
if (datum.department === "Executive")
return {
fill: "#76B2DC",
fillOpacity: 0.2,
stroke: "#1B65BF",
strokeWidth: 2,
};
if (datum.department === "Technology")
return {
fill: "#7AE281",
fillOpacity: 0.2,
stroke: "#327C35",
strokeWidth: 2,
};
if (datum.department === "Operations")
return {
fill: "#EBB967",
fillOpacity: 0.2,
stroke: "#A94F1D",
strokeWidth: 2,
};
},
title: { key: "name" },
subtitle: { key: "job" },
labels: [{ key: "location" }],
},
},
],
};
}
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
department: "Executive",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/19.webp",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
department: "Technology",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/20.webp",
},
{
id: "Mr. Jeffrey Brown",
parentId: "Joseph Howe",
name: "Mr. Jeffrey Brown",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/22.webp",
},
{
id: "Melissa Vazquez",
parentId: "Mr. Jeffrey Brown",
name: "Melissa Vazquez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Thomas",
parentId: "Mr. Jeffrey Brown",
name: "John Thomas",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/5.webp",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
department: "Technology",
location: "Portugal",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/29.webp",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/25.webp",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
department: "Technology",
location: "Ireland",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/7.webp",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
department: "Technology",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Rachel Ibarra",
parentId: "Justin Contreras",
name: "Rachel Ibarra",
job: "Design",
department: "Technology",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Gomez",
parentId: "Justin Contreras",
name: "John Gomez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/17.webp",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
department: "Operations",
location: "Netherlands",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
department: "Operations",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/33.webp",
},
{
id: "Devin Pittman",
parentId: "Lawrence Martinez",
name: "Devin Pittman",
job: "Design",
department: "Operations",
location: "United Kingdom",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Emily Barajas",
parentId: "Lawrence Martinez",
name: "Emily Barajas",
job: "Design",
department: "Operations",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/28.webp",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
department: "Operations",
location: "Spain",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/35.webp",
},
{
id: "Michael Morris",
parentId: "Eric Jensen",
name: "Michael Morris",
job: "Design",
department: "Operations",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Jodi Miller",
parentId: "Eric Jensen",
name: "Jodi Miller",
job: "Design",
department: "Operations",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/30.webp",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
{
series: [
{
type: 'organization',
node: {
width: 180,
cornerRadius: 12,
itemStyler: ({ datum }) => {
if (datum.department === 'Executive')
return { fill: '#76B2DC', fillOpacity: 0.2, stroke: '#1B65BF', strokeWidth: 2 };
if (datum.department === 'Technology')
return { fill: '#7AE281', fillOpacity: 0.2, stroke: '#327C35', strokeWidth: 2 };
if (datum.department === 'Operations')
return { fill: '#EBB967', fillOpacity: 0.2, stroke: '#A94F1D', strokeWidth: 2 };
},
},
},
],
}In this configuration:
- The
widthoption is used to set the card dimensions. This causes text wrapping when the content exceeds the available space. cornerRadiusrounds the card corners.- Each department is assigned a specific colour by using the
itemStylercallback based on thedepartmentfield in the data.
See the API Reference for the full list of available styling options.
Connectors Copy Link
Connectors are the lines drawn between parent and child nodes and are configured via the link property.
import { Component } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgOrganizationSeriesOptions,
AgStandaloneChartOptions,
ContextMenuModule,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
import clone from "clone";
ModuleRegistry.registerModules([OrganizationSeriesModule, ContextMenuModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<div class="example-controls">
<div class="controls-row">
Corner Radius:
<input type="range" id="cornerRadiusInput" min="0" max="25" value="8" step="1" (input)="changeCornerRadius($event)" (change)="changeCornerRadius($event)">
<span id="cornerRadiusValue" style="display: inline-block; min-width: 3ch; text-align: right">8</span>
</div>
</div>
<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
constructor() {
this.options = {
title: { text: "Company Organisation" },
data: getData(),
initialState: {
collapsed: [
"Mr. Jeffrey Brown",
"Nicole Jones",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
},
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
link: {
stroke: "#ff8833",
strokeWidth: 2,
lineDash: [8, 2],
interpolation: { type: "step", cornerRadius: 8 },
itemStyler: ({ fromDatum }) => {
if (fromDatum.department === "Technology") {
return { stroke: "#00994d" };
} else if (fromDatum.job === "CEO") {
return { stroke: "#006f9b", strokeWidth: 4, lineDash: [] };
}
},
},
node: {
image: {
key: "avatar",
position: "left",
height: 50,
width: 50,
cornerRadius: 25,
},
title: { key: "name" },
subtitle: { key: "job" },
labels: [{ key: "location" }],
},
},
],
};
}
changeCornerRadius = (event: any) => {
const options = clone(this.options);
const value = Number(event.target.value);
document.getElementById("cornerRadiusValue")!.innerHTML = String(value);
(options.series![0] as AgOrganizationSeriesOptions).link!.interpolation = {
type: "step",
cornerRadius: value,
};
this.options = options;
};
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
department: "Executive",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/19.webp",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
department: "Technology",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/20.webp",
},
{
id: "Mr. Jeffrey Brown",
parentId: "Joseph Howe",
name: "Mr. Jeffrey Brown",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/22.webp",
},
{
id: "Melissa Vazquez",
parentId: "Mr. Jeffrey Brown",
name: "Melissa Vazquez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Thomas",
parentId: "Mr. Jeffrey Brown",
name: "John Thomas",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/5.webp",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
department: "Technology",
location: "Portugal",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/29.webp",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/25.webp",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
department: "Technology",
location: "Ireland",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/7.webp",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
department: "Technology",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Rachel Ibarra",
parentId: "Justin Contreras",
name: "Rachel Ibarra",
job: "Design",
department: "Technology",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Gomez",
parentId: "Justin Contreras",
name: "John Gomez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/17.webp",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
department: "Operations",
location: "Netherlands",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
department: "Operations",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/33.webp",
},
{
id: "Devin Pittman",
parentId: "Lawrence Martinez",
name: "Devin Pittman",
job: "Design",
department: "Operations",
location: "United Kingdom",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Emily Barajas",
parentId: "Lawrence Martinez",
name: "Emily Barajas",
job: "Design",
department: "Operations",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/28.webp",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
department: "Operations",
location: "Spain",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/35.webp",
},
{
id: "Michael Morris",
parentId: "Eric Jensen",
name: "Michael Morris",
job: "Design",
department: "Operations",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Jodi Miller",
parentId: "Eric Jensen",
name: "Jodi Miller",
job: "Design",
department: "Operations",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/30.webp",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
{
series: [
{
type: 'organization',
link: {
stroke: '#ff8833',
strokeWidth: 2,
lineDash: [8, 2],
interpolation: { type: 'step', cornerRadius: 8 },
itemStyler: ({ fromDatum }) => {
if (fromDatum.department === 'Technology') {
return { stroke: '#00994d' };
} else if (fromDatum.job === 'CEO') {
return { stroke: '#006f9b', strokeWidth: 4, lineDash: [] };
}
},
},
},
],
}In this configuration:
interpolation.cornerRadiusrounds the corners of each step.lineDashsets a dashed line pattern.link.itemStylerstyles connectors per-relationship, receivingfromDatum(parent) andtoDatum(child).
Expander Copy Link
The expander's appearance can be customised via the expander property. See Expander above for text-content options like child counts and formatter.
import { Component } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgChartOptions,
ContextMenuModule,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
ModuleRegistry.registerModules([OrganizationSeriesModule, ContextMenuModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
constructor() {
this.options = {
title: { text: "Company Organisation" },
data: getData(),
initialState: {
collapsed: [
"Mr. Jeffrey Brown",
"Nicole Jones",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
},
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
expander: {
cornerRadius: 25,
strokeWidth: 2,
padding: 15,
itemStyler: ({ datum }) => {
if (datum.department === "Technology")
return { fill: "#e8f5e9", stroke: "#2e7d32" };
if (datum.department === "Operations")
return { fill: "#fff3e0", stroke: "#e65100" };
},
},
node: {
image: {
key: "avatar",
position: "left",
height: 50,
width: 50,
cornerRadius: 25,
},
itemStyler: ({ datum }) => {
if (datum.department === "Executive")
return {
fill: "#76B2DC",
fillOpacity: 0.2,
stroke: "#1B65BF",
strokeWidth: 2,
};
if (datum.department === "Technology")
return {
fill: "#7AE281",
fillOpacity: 0.2,
stroke: "#327C35",
strokeWidth: 2,
};
if (datum.department === "Operations")
return {
fill: "#EBB967",
fillOpacity: 0.2,
stroke: "#A94F1D",
strokeWidth: 2,
};
},
title: { key: "name" },
subtitle: { key: "job" },
labels: [{ key: "location" }],
},
},
],
};
}
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
department: "Executive",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/19.webp",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
department: "Technology",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/20.webp",
},
{
id: "Mr. Jeffrey Brown",
parentId: "Joseph Howe",
name: "Mr. Jeffrey Brown",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/22.webp",
},
{
id: "Melissa Vazquez",
parentId: "Mr. Jeffrey Brown",
name: "Melissa Vazquez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Thomas",
parentId: "Mr. Jeffrey Brown",
name: "John Thomas",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/5.webp",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
department: "Technology",
location: "Portugal",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/29.webp",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/25.webp",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
department: "Technology",
location: "Ireland",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/7.webp",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
department: "Technology",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Rachel Ibarra",
parentId: "Justin Contreras",
name: "Rachel Ibarra",
job: "Design",
department: "Technology",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Gomez",
parentId: "Justin Contreras",
name: "John Gomez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/17.webp",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
department: "Operations",
location: "Netherlands",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
department: "Operations",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/33.webp",
},
{
id: "Devin Pittman",
parentId: "Lawrence Martinez",
name: "Devin Pittman",
job: "Design",
department: "Operations",
location: "United Kingdom",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Emily Barajas",
parentId: "Lawrence Martinez",
name: "Emily Barajas",
job: "Design",
department: "Operations",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/28.webp",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
department: "Operations",
location: "Spain",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/35.webp",
},
{
id: "Michael Morris",
parentId: "Eric Jensen",
name: "Michael Morris",
job: "Design",
department: "Operations",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Jodi Miller",
parentId: "Eric Jensen",
name: "Jodi Miller",
job: "Design",
department: "Operations",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/30.webp",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
{
series: [
{
type: 'organization',
expander: {
cornerRadius: 25,
strokeWidth: 2,
padding: 15,
itemStyler: ({ datum }) => {
if (datum.department === 'Technology') return { fill: '#e8f5e9', stroke: '#2e7d32' };
if (datum.department === 'Operations') return { fill: '#fff3e0', stroke: '#e65100' };
},
},
},
],
}In this configuration:
cornerRadius,strokeWidth, andpaddingcontrol the button shape and border.expander.itemStylerprovides per-node styling based on the department.
Node Spacing Copy Link
Three spacing properties control the gaps between nodes. These values apply at the leaf level, with higher levels in the hierarchy deriving their spacing from these.
import { Component } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgOrganizationSeriesOptions,
AgStandaloneChartOptions,
ContextMenuModule,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
import clone from "clone";
ModuleRegistry.registerModules([OrganizationSeriesModule, ContextMenuModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<div class="example-controls">
<div class="controls-row">
Sibling:
<input type="range" id="innerSpacingInput" min="1" max="60" value="20" step="1" (input)="changeInnerSpacing($event)" (change)="changeInnerSpacing($event)">
<span id="innerSpacingValue" style="display: inline-block; min-width: 3ch; text-align: right">20</span>
<span class="gap-left">
Cousin:
<input type="range" id="outerSpacingInput" min="1" max="80" value="40" step="1" (input)="changeOuterSpacing($event)" (change)="changeOuterSpacing($event)">
<span id="outerSpacingValue" style="display: inline-block; min-width: 3ch; text-align: right">40</span>
</span>
<span class="gap-left">
Depth:
<input type="range" id="verticalSpacingInput" min="20" max="100" value="52" step="2" (input)="changeDepthSpacing($event)" (change)="changeDepthSpacing($event)">
<span id="depthSpacing" style="display: inline-block; min-width: 3ch; text-align: right">52</span>
</span>
</div>
</div>
<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
constructor() {
this.options = {
title: { text: "Company Organisation" },
data: getData(),
initialState: {
collapsed: [
"Mr. Jeffrey Brown",
"Nicole Jones",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
},
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
innerSpacing: 20,
outerSpacing: 40,
depthSpacing: 52,
node: {
image: {
key: "avatar",
position: "left",
height: 50,
width: 50,
cornerRadius: 25,
},
title: { key: "name" },
subtitle: { key: "job" },
labels: [{ key: "location" }],
},
},
],
};
}
changeInnerSpacing = (event: any) => {
const options = clone(this.options);
const value = Number(event.target.value);
document.getElementById("innerSpacingValue")!.innerHTML = String(value);
(options.series![0] as AgOrganizationSeriesOptions).innerSpacing = value;
this.options = options;
};
changeOuterSpacing = (event: any) => {
const options = clone(this.options);
const value = Number(event.target.value);
document.getElementById("outerSpacingValue")!.innerHTML = String(value);
(options.series![0] as AgOrganizationSeriesOptions).outerSpacing = value;
this.options = options;
};
changeDepthSpacing = (event: any) => {
const options = clone(this.options);
const value = Number(event.target.value);
document.getElementById("depthSpacing")!.innerHTML = String(value);
(options.series![0] as AgOrganizationSeriesOptions).depthSpacing = value;
this.options = options;
};
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
department: "Executive",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/19.webp",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
department: "Technology",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/20.webp",
},
{
id: "Mr. Jeffrey Brown",
parentId: "Joseph Howe",
name: "Mr. Jeffrey Brown",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/22.webp",
},
{
id: "Melissa Vazquez",
parentId: "Mr. Jeffrey Brown",
name: "Melissa Vazquez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Thomas",
parentId: "Mr. Jeffrey Brown",
name: "John Thomas",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/5.webp",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
department: "Technology",
location: "Portugal",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/29.webp",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/25.webp",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
department: "Technology",
location: "Ireland",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/7.webp",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
department: "Technology",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Rachel Ibarra",
parentId: "Justin Contreras",
name: "Rachel Ibarra",
job: "Design",
department: "Technology",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Gomez",
parentId: "Justin Contreras",
name: "John Gomez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/17.webp",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
department: "Operations",
location: "Netherlands",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
department: "Operations",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/33.webp",
},
{
id: "Devin Pittman",
parentId: "Lawrence Martinez",
name: "Devin Pittman",
job: "Design",
department: "Operations",
location: "United Kingdom",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Emily Barajas",
parentId: "Lawrence Martinez",
name: "Emily Barajas",
job: "Design",
department: "Operations",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/28.webp",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
department: "Operations",
location: "Spain",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/35.webp",
},
{
id: "Michael Morris",
parentId: "Eric Jensen",
name: "Michael Morris",
job: "Design",
department: "Operations",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Jodi Miller",
parentId: "Eric Jensen",
name: "Jodi Miller",
job: "Design",
department: "Operations",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/30.webp",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
{
series: [
{
type: 'organization',
innerSpacing: 20,
outerSpacing: 40,
depthSpacing: 52,
},
],
}In this configuration:
innerSpacingis the gap between sibling nodes, such as the gap between 'Lawrence Martinez' and 'Eric Jensen'.outerSpacingis the gap between cousin nodes, such as the gap between 'Justin Contreras' and 'Lawrence Martinez'.depthSpacingis the gap between parent and child nodes, such as the gap between 'Gary Garcia' and 'Lawrence Martinez'.
Interactivity Copy Link
Collapse and Expand Copy Link
Nodes with children can be collapsed and expanded by clicking the expander. They can also be controlled programmatically.
import { Component, ViewChild } from "@angular/core";
import { AgCharts } from "ag-charts-angular";
import {
AgOrganizationSeriesOptions,
AgStandaloneChartOptions,
ContextMenuModule,
ModuleRegistry,
OrganizationSeriesModule,
} from "ag-charts-enterprise";
import { getData } from "./data";
import clone from "clone";
ModuleRegistry.registerModules([OrganizationSeriesModule, ContextMenuModule]);
@Component({
selector: "my-app",
standalone: true,
imports: [AgCharts],
template: `<div class="example-controls">
<div class="controls-row">
<button (click)="expandAll()">Expand All</button>
<button (click)="collapseAll()">Collapse All</button>
<button (click)="toggleCTO()">Toggle CTO</button>
<input type="checkbox" id="clickToExpand" checked="" class="gap-left" (change)="setClickToExpand($event.target.checked)">
<label for="clickToExpand">Click node to expand</label>
</div>
</div>
<ag-charts
[options]="options"
></ag-charts>
`,
})
export class AppComponent {
public options;
@ViewChild(AgCharts)
public agCharts!: AgCharts;
constructor() {
this.options = {
title: { text: "Company Organisation" },
data: getData(),
initialState: {
collapsed: [
"Mr. Jeffrey Brown",
"Nicole Jones",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
},
series: [
{
type: "organization",
idKey: "id",
parentIdKey: "parentId",
node: {
image: {
key: "avatar",
position: "left",
height: 50,
width: 50,
cornerRadius: 25,
},
title: { key: "name" },
subtitle: { key: "job" },
labels: [{ key: "location" }],
clickToExpand: true,
},
},
],
listeners: {
collapsedChange: ({ collapsed, expanded }) => {
console.log(
"collapsed:",
collapsed.map((item) => item.itemId),
"expanded:",
expanded.map((item) => item.itemId),
);
},
},
};
}
setClickToExpand = (clickToExpand: boolean) => {
const options = clone(this.options);
(options.series![0] as AgOrganizationSeriesOptions).node!.clickToExpand =
clickToExpand;
this.options = options;
};
expandAll = () => {
const { version } = this.agCharts.chart!.getState();
this.agCharts.chart!.setState({ version, collapsed: [] });
};
collapseAll = () => {
const { version } = this.agCharts.chart!.getState();
this.agCharts.chart!.setState({
version,
collapsed: [
"Joseph Howe",
"Gary Garcia",
"Mr. Jeffrey Brown",
"Nicole Jones",
"Justin Contreras",
"Lawrence Martinez",
"Eric Jensen",
],
});
};
toggleCTO = () => {
const { version, collapsed: prev } = this.agCharts.chart!.getState();
const collapsed = prev?.filter((id) => id !== "Joseph Howe");
if (!prev?.includes("Joseph Howe")) {
collapsed?.push("Joseph Howe");
}
this.agCharts.chart!.setState({ version, collapsed });
};
}
export function getData() {
return [
{
id: "Ashley Rivers",
parentId: null,
name: "Ashley Rivers",
job: "CEO",
department: "Executive",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/19.webp",
},
{
id: "Joseph Howe",
parentId: "Ashley Rivers",
name: "Joseph Howe",
job: "CTO",
department: "Technology",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/20.webp",
},
{
id: "Mr. Jeffrey Brown",
parentId: "Joseph Howe",
name: "Mr. Jeffrey Brown",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/22.webp",
},
{
id: "Melissa Vazquez",
parentId: "Mr. Jeffrey Brown",
name: "Melissa Vazquez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Thomas",
parentId: "Mr. Jeffrey Brown",
name: "John Thomas",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/5.webp",
},
{
id: "Nicole Jones",
parentId: "Joseph Howe",
name: "Nicole Jones",
job: "Exec. Vice President",
department: "Technology",
location: "Portugal",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/29.webp",
},
{
id: "James Long",
parentId: "Nicole Jones",
name: "James Long",
job: "Design",
department: "Technology",
location: "Netherlands",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/25.webp",
},
{
id: "Susan Hernandez",
parentId: "Nicole Jones",
name: "Susan Hernandez",
job: "Design",
department: "Technology",
location: "Ireland",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/7.webp",
},
{
id: "Justin Contreras",
parentId: "Joseph Howe",
name: "Justin Contreras",
job: "Design",
department: "Technology",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Rachel Ibarra",
parentId: "Justin Contreras",
name: "Rachel Ibarra",
job: "Design",
department: "Technology",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/2.webp",
},
{
id: "John Gomez",
parentId: "Justin Contreras",
name: "John Gomez",
job: "Design",
department: "Technology",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/17.webp",
},
{
id: "Gary Garcia",
parentId: "Ashley Rivers",
name: "Gary Garcia",
job: "Head of Department",
department: "Operations",
location: "Netherlands",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Lawrence Martinez",
parentId: "Gary Garcia",
name: "Lawrence Martinez",
job: "Design",
department: "Operations",
location: "United States",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/33.webp",
},
{
id: "Devin Pittman",
parentId: "Lawrence Martinez",
name: "Devin Pittman",
job: "Design",
department: "Operations",
location: "United Kingdom",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/18.webp",
},
{
id: "Emily Barajas",
parentId: "Lawrence Martinez",
name: "Emily Barajas",
job: "Design",
department: "Operations",
location: "Italy",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/28.webp",
},
{
id: "Eric Jensen",
parentId: "Gary Garcia",
name: "Eric Jensen",
job: "Design",
department: "Operations",
location: "Spain",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/35.webp",
},
{
id: "Michael Morris",
parentId: "Eric Jensen",
name: "Michael Morris",
job: "Design",
department: "Operations",
location: "France",
status: "In Office",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/10.webp",
},
{
id: "Jodi Miller",
parentId: "Eric Jensen",
name: "Jodi Miller",
job: "Design",
department: "Operations",
location: "Italy",
status: "Remote",
avatar: "https://www.ag-grid.com/charts/example-assets/docs-images/hr/30.webp",
},
];
}
// Angular entry point file
import '@angular/compiler';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent);
{
initialState: {
collapsed: ['Lawrence Martinez', 'Eric Jensen'],
},
series: [
{
type: 'organization',
node: {
clickToExpand: true,
},
},
],
listeners: {
collapsedChange: ({ collapsed, expanded }) => {
console.log(
'collapsed:',
collapsed.map((item) => item.itemId),
'expanded:',
expanded.map((item) => item.itemId)
);
},
},
}In this example:
- The subtrees under 'Lawrence Martinez' and 'Eric Jensen' will start in a collapsed state. This uses the
initialState.collapsedproperty to specify which subtrees start collapsed. - Use
node.clickToExpandto toggle collapsing/expanding by clicking anywhere on the card instead of the expander only.- Defaults to
falsewhen node has a click listener or has Data Selection enabled, otherwise defaults totrue.
- Defaults to
- The
collapsedarray contains the identifiers of all currently collapsed nodes.- See the State API page for more details.
- Changes in the collapsed items can be listened to with the
collapsedChangeevent, logged to the console here showing theitemIdof each newly collapsed and expanded node.- See the Events API page for more details.
Zoom Copy Link
Organisation Charts have zoom and pan enabled by default. Scroll to zoom in and out, and click and drag the background to pan across the hierarchy.
See the Zoom page for the full range of zoom options.
Accessibility Copy Link
Organisation Charts support full keyboard navigation and screen readers.
The following keys are available:
- ←→↑↓ moves focus between nodes.
- Alt+↓ and Alt+↑ expand and collapse the focused node.
- ↵ Enter or ␣ Space trigger any click listeners, and also toggle the focused node when
clickToExpandis enabled.
See Accessibility for more details.