@mikhailfarberov/react-org-chart

1.0.3 • Public • Published

react-org-chart - an easy React component to create an organizational chart

npm npm peer dependency version npm peer dependency version npm peer dependency version

react-org-chart provides a simple and stylish organizational chart React component. It supports different chart node attributes (see #configuration) and multi-root tree (see #demo).

Table of Contents

  1. Installation
  2. Demo
  3. Configuration
  4. Credits
  5. License

Installation

Install via Npm: npm install @mikhailfarberov/react-org-chart

Demo

See demo or https://github.com/mikhailfarberov/react-org-chart/blob/master/demo/

var tree = [
  {
    id: 11,
    avatar: 'sample.png',
    title: 'Paul',
    subtitle: '',
    descr: '',
    date: 'since 10.03.2020',
    label: 'Chief of Board',
    link: {url: 'https://github.com', text: 'sample link'}, 
    children: [
      {
        id: 12,
        avatar: 'sample.png',
        title: 'Sara',
        subtitle: '',
        descr: '',
        date: 'since 10.03.2020',
        label: 'CTO',
        link: {url: 'https://github.com', text: 'sample link'}, 
      },
      {
        id: 13,
        avatar: 'sample.png',
        title: 'Kevin',
        subtitle: '',
        descr: '',
        date: 'since 10.03.2020',
        label: 'CTO',
        link: {url: 'https://github.com', text: 'sample link'}, 
      },
      {
        id: 14,
        avatar: 'sample.png',
        title: 'James',
        subtitle: '',
        descr: '',
        date: 'since 10.03.2020',
        label: 'CTO',
        link: {url: 'https://github.com', text: 'sample link'}, 
      }
    ]
  }
];

<OrgChart tree={tree} />

Configuration

The OrgChart component accepts three properties:

  • tree - an array of nodes Node format:
{
    id: 11,                     // Unique
    avatar: 'sample.png',       // Optional
    title: 'Paul',
    subtitle: '',               // Optional
    descr: '',                  // Optional
    date: '10.03.2020',         // Optional. Date in text format
    label: 'Chief of Board',    // Optional
    link: {url: 'https://github.com', text: 'sample link', 'image' => 'sample.png'}, // Optional
    children: [], // Optional
    hasChild: 0 // Optional. Allows to show number of child nodes with empty children array that can be loaded asyncroniously when the node is expanded
}
  • collapse - Render the tree collapsed. Default false.
  • onExpandItem - Event fired when a node is expanded. Can be used to load child nodes asynchronously.

Credits

Special thanks to:

  1. Avatar Icon by Dmitriy Bondarchuk

License

react-org-chart is released under the MIT license.

/@mikhailfarberov/react-org-chart/

    Package Sidebar

    Install

    npm i @mikhailfarberov/react-org-chart

    Weekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    26.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • mikhailfarberov