@ferdydh/d3-org-chart
TypeScript icon, indicating that this package has built-in type declarations

0.2.7 • Public • Published

Customizable organization chart, based on d3 v7

NPM version

This repo is a fork from d3-org-chart by David B(twitter and LinkedIn). Our ultimate goal is to integrate typescript and react natively into the library, fix reported issues, improve customization, and provide better documentation.

Installing

npm i @ferdydh/d3-org-chart
import { OrgChart } from '@ferdydh/d3-org-chart';

type Props = {
     data: DataType[]
}

type DataType = {
     id: string | number // required property
     parentId: string | number // required property
}

export const OrgChartComponent = ({ data }: Props) => {
  const container = useRef(null);

  useEffect(() => {
    if (fields && container.current) {
      const chart = new OrgChart<DataType>()
        .container(container.current)
        .data(fields)
        .render();
    }
  }, [fields, container.current]);

  return (
    <div>
      <div ref={container} />
    </div>
  );
};

Custom components & algorithms used

Author

Ferdy DH

Package Sidebar

Install

npm i @ferdydh/d3-org-chart

Weekly Downloads

3

Version

0.2.7

License

MIT

Unpacked Size

333 kB

Total Files

18

Last publish

Collaborators

  • ferdydh