TreeSpider is a powerful library designed to elegantly display organizational structures. Built with D3.js and TypeScript, it supports various chart types for personalized visualization, making it easy to represent data in a way that fits your organization. Install and set up with minimal effort to enhance your data presentation.
TreeSpider is a powerful library designed to display organizational structures in a visually appealing manner. Built with D3.js and TypeScript, it offers flexible customization options to suit the specific needs of any organization.
To get started with TreeSpider, the data structure required is simple and linear. Each employee is represented with an ID and a parent ID indicating the reporting structure. The data format is as follows:
{
id: string;
parentId: string;
name: string;
role: string;
location: string;
image: string;
}
Add your organization's employee data in this format:
const tree_data = [
{id: "1", name: "Abayomi Amusa", role: "Manager", location: "Lagos, Nigeria"},
{id: "2", parentId: "1", name: "Trey Anderson", role: "Product Manager", location: "California, United States"},
...
];
Create a TreeSpider instance and pass in the data:
const instance1 = new TreeSpider({
targetContainer: '#container-1',
tree_data: tree_data
});
TreeSpider offers various options for customization, including:
Example of setting custom options:
const chart = new TreeSpider({
targetContainer: '#chart-container',
tree_data: tree_data,
chart_head_type: 'landscape',
tree_type: 'hSpiderWalk',
pallet: {
darker: .8,
gray: 10
}
});
TreeSpider allows programmatic interaction through methods, making it easy to initialize, manage and respond to events within the library:
const chart = new TreeSpider({
autoInitialize: false
});
document.querySelector('#random-button').onclick = () => chart.initialize();
Subscribe to various events using either the addEventListener method or the on method:
chart.on('library.init', (e) => {
console.log("The library has been initialized", e);
});
TreeSpider provides an intuitive and flexible solution for visualizing an organization’s structure, making it an essential tool for anyone looking to enhance their organizational chart presentation.
No comments yet.
Sign in to be the first to comment.