lara-light-indigo

OrganizationChart

OrganizationChart visualizes hierarchical organization data.

Advanced
CEO
walter.jpg
Walter White
      
CFO
saul.jpg
Saul Goodman
    
Tax
Legal
COO
mike.jpg
Mike E.
Operations
CTO
jesse.jpg
Jesse Pinkman
      
Development
      
Analysis
Front End
Back End
QA
R&D
Basic
F.C Barcelona
    
F.C Barcelona
    
Chelsea FC
F.C. Barcelona
Real Madrid
    
Bayern Munich
Real Madrid
Import via Module

import { OrganizationChart } from 'primereact/organizationchart';
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/organizationchart/organizationchart.min.js"></script>
 
Getting Started

OrganizationChart requires a model of TreeNode as its value.


export const OrganizationChartDemo = () => {

    const data = [{
        label: 'F.C Barcelona',
        expanded: true,
        children: [
            {
                label: 'F.C Barcelona',
                expanded: true,
                children: [
                    {
                        label: 'Chelsea FC'
                    },
                    {
                        label: 'F.C. Barcelona'
                    }
                ]
            },
            {
                label: 'Real Madrid',
                expanded: true,
                children: [
                    {
                        label: 'Bayern Munich'
                    },
                    {
                        label: 'Real Madrid'
                    }
                ]
            }
        ]
    }];

    return (
        <OrganizationChart value={data}></OrganizationChart>
    )
}
 
Templating

Label of the treenode is displayed inside the node content by default and templating enables further customization.


<OrganizationChart value={data} nodeTemplate={nodeTemplate}></OrganizationChart>
 


const nodeTemplate = (node) => {
    if (node.type === "person") {
        return (
            <div>
                <div className="node-header">{node.label}</div>
                    <div className="node-content">
                        <img alt={node.data.avatar} src={`images/organization/${node.data.avatar}`} style={{ width: '32px' }}/>
                    <div>{node.data.name}</div>
                </div>
            </div>
        );
    }

    if (node.type === "department") {
        return node.label;
    }
}
 
Expand/Collapse State

In order to display a treenode as expanded by default, set "expanded" property as true in your model.

Selection

OrganizationChart supports two selection methods; single or multiple. Selection is enabled by setting selectionMode property to the corresponding mode, defining selection property along with selectionChange callback.


<OrganizationChart value={data} selectionMode="single" selection={selectedNode} onSelectionChange={event => setSelectedNode(event.data)}></OrganizationChart>
 
Properties
NameTypeDefaultDescription
idstringnullUnique identifier of the element.
valuearraynullAn array of nested TreeNodes.
stylestringnullInline style of the component.
classNamestringnullStyle class of the component.
selectionModestringnullDefines the selection mode, valid values "single" and "multiple".
selectionanynullA single treenode instance or an array to refer to the selections.
nodeTemplatefunctionnullTemplate function that gets a node as a parameter and returns a content.
Events
NameParametersDescription
onNodeSelectevent.originalEvent: browser event
event.node: Selected node instance.
Callback to invoke when a node is selected.
onNodeUnselectevent.originalEvent: browser event
event.node: Unselected node instance.
Callback to invoke when a node is unselected.
onSelectionChangeevent.originalEvent: browser event
event.data: New selection.
Callback to invoke when node selection changes.
Styling

Following is the list of structural style classes.

NameElement
p-organizationchartContainer element.
p-organizationchart-tableTable container of a node.
p-organizationchart-linesConnector lines container.
p-organizationchart-nodesContained of node children.
p-organizationchart-line-rightRight side line of a node connector.
p-organizationchart-line-leftLeft side line of a node connector.
p-organizationchart-line-topTop side line of a node connector.
Accessibility

This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.

Dependencies

None.

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma