d3-org-chart vs react-d3-tree
D3.js Visualization Libraries
d3-org-chartreact-d3-treeSimilar Packages:

D3.js Visualization Libraries

D3.js visualization libraries are designed to help developers create complex and interactive data visualizations in web applications. These libraries leverage the power of D3.js, a JavaScript library for producing dynamic, interactive data visualizations in web browsers. They simplify the process of creating hierarchical visualizations, such as organizational charts or tree diagrams, by providing pre-built components and functionalities that abstract away much of the complexity involved in D3.js. This allows developers to focus on the data and its representation rather than the underlying implementation details.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
d3-org-chart01,159305 kB1352 years agoMIT
react-d3-tree01,191121 kB148a year agoMIT

Feature Comparison: d3-org-chart vs react-d3-tree

Integration with Frameworks

  • d3-org-chart:

    d3-org-chart is a standalone library that can be integrated into any web application, but it does not provide specific support for React or other frameworks. It is designed to be simple and easy to use, making it suitable for projects that do not require a full framework integration.

  • react-d3-tree:

    react-d3-tree is specifically built for React applications, allowing for seamless integration with React's component lifecycle. This makes it easier to manage state and props, providing a more idiomatic React experience.

Customization

  • d3-org-chart:

    d3-org-chart offers limited customization options out of the box, focusing on providing a clean and straightforward organizational chart. However, it allows for some degree of styling and configuration through CSS and basic options.

  • react-d3-tree:

    react-d3-tree provides extensive customization options, allowing developers to modify the appearance and behavior of the tree structure through props. This includes custom node rendering, event handling, and styling, making it highly adaptable to specific design requirements.

Complexity and Learning Curve

  • d3-org-chart:

    d3-org-chart has a lower learning curve compared to other D3.js libraries, as it abstracts much of the complexity involved in creating organizational charts. Developers can quickly get started with basic configurations and options.

  • react-d3-tree:

    react-d3-tree may have a steeper learning curve for those unfamiliar with React, as it requires understanding React's component model and lifecycle. However, once familiar, developers can leverage React's capabilities to create more complex and interactive visualizations.

Performance

  • d3-org-chart:

    d3-org-chart is optimized for rendering hierarchical data efficiently, but performance can vary based on the complexity of the chart and the amount of data being visualized. It is generally suitable for moderate-sized datasets.

  • react-d3-tree:

    react-d3-tree is designed to handle larger datasets more efficiently by leveraging React's virtual DOM. It minimizes unnecessary re-renders and optimizes performance through React's reconciliation process.

Community and Support

  • d3-org-chart:

    d3-org-chart has a smaller community compared to more established libraries, which may result in limited resources and support. However, it is straightforward enough that many developers can implement it without extensive documentation.

  • react-d3-tree:

    react-d3-tree benefits from the larger React community, providing access to a wealth of resources, tutorials, and third-party libraries that can enhance its functionality and ease of use.

How to Choose: d3-org-chart vs react-d3-tree

  • d3-org-chart:

    Choose d3-org-chart if you need a specialized library for creating organizational charts with a focus on simplicity and ease of use. It provides a straightforward API and is optimized for rendering hierarchical data in a visually appealing manner.

  • react-d3-tree:

    Choose react-d3-tree if you are looking for a React-specific solution that integrates seamlessly with React's component-based architecture. It offers more flexibility in terms of customization and is ideal for applications that already utilize React for their UI.

README for d3-org-chart

SWUbanner

Highly customizable d3 based organization chart

NPM version

Medium article about this project

Highly customizable org chart built with d3 v7.

Features

Simple Data
Custom Content
Nested Data
Online Data
CSV Data
Styled Tree
Expand Node Collapse Node
Add Node Remove Node Fit Screen Change Layout
Center Node Highlight Node Fullscreen Zoom in and out
Export Expand & Collapse All Multi Node Connections Paging
Horizontal View Active node centering Interactive Node Searching org chart
Scrollable content

How to use

Just copy this code and paste at - https://realtimehtml.com/

<script src="https://d3js.org/d3.v7.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-org-chart@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-flextree@2.1.2/build/d3-flextree.js"></script>
<div class="chart-container"></div>

<script>
 var chart;
 d3
  .csv(
   "https://raw.githubusercontent.com/bumbeishvili/sample-data/main/org.csv"
  )
  .then((data) => {
   chart = new d3.OrgChart().container(".chart-container").data(data).render();
  });
</script>

Installing

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

 new OrgChart()
     .container(<DomElementOrCssSelector>)
     .data(<Data>) // https://github.com/bumbeishvili/sample-data/blob/main/data-oracle.csv
     .render();

In general, we encourage to look into the source code to understand how it works. The chart code is basically a single class. At the top of the class, we have a state object called attrs which stores the state of the org chart and each single property is overridable by the user.

For example, one of the property name inside attrs object is duration, which controls animation duration for chart, when expanding or collapsing nodes.

If we want to get the value, we can either do

chart.getChartState().duration

or directly

chart.duration()

chart in the above case is an instance of OrgChart class. We can get it using new OrgChart()

If we want to set property, we can pass argument to the same function and it will automatically set the value

chart.duration(3000)  // This will become very slow moving chart

You can see list of all properties , their description of what each property does in the actual source code.

https://github.com/bumbeishvili/org-chart/blob/5be7e0962e46013b3a95dd19f41f829c3c853d1f/src/d3-org-chart.js#L41

Be aware that they are chainable, so if we wanted to set multiple properties, we would do this

const chart = new OrgChart()
                    .data(ourData)
                    .container(ourDomElementOrCssSelector)
                    .duration(ourDuration)
                    .render()


// We can keep chaining values in runtime
chart.data(updatedData).render()

Have you impressively customized an organizational chart and want to be featured on this page? Just email me at me@davidb.dev and include screenshot of your org chart and it will be featured on this page (dimensions of image should be 500 X 500).

Jump To Examples

Default
Sky
Circles
Oval
Clean (Design by Anton)
Futuristic - Full Functionality
Prev version design

Featured customizations:

Check out several libraries and frameworks integrations

Custom components & algorithms I used

Quick Docs

Check the sample data here - https://github.com/bumbeishvili/sample-data/blob/main/data-oracle.csv

For the full functionality of exposed methods check Futuristic Example and button bound functions

For the high level overview of margins and content setting check the image bellow

Notes & appreciations

I created this org-chart when I was hired by TeamApps.

Although this Org chart was specifically created for teamapps java web application framework , it's very flexible and can be used in any environment, where d3 and DOM is accessible.

Big thanks to Matthias and Yann, who assembled requirements for org-chart and had valuable pieces of advice afterwads.

Also, thanks all people who made generous donations, it gives me motivation to further improve this org chart component.

Thanks contractzen for the significant contribution, which made implementation of some of the most important features (optimal layout, exporting ) possible.

Author

David B (twitter)
David B (linkedin)

I am available for freelance data visualization work. Please contact me in case you'd like me to help you with my experience and expertise

You can also book data viz related consultation session with me