Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-hierarchy

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-hierarchy

Layout algorithms for visualizing hierarchical data.

  • 3.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4M
increased by6.2%
Maintainers
2
Weekly downloads
 
Created

What is d3-hierarchy?

The d3-hierarchy npm package is designed to help visualize hierarchical data structures. It provides a variety of layouts and utilities to manipulate and display hierarchical data, such as trees and clusters, making it a powerful tool for creating complex visualizations.

What are d3-hierarchy's main functionalities?

Hierarchy Creation

This feature allows the creation of a hierarchy from a nested data structure. The example shows how to convert a simple nested object into a d3 hierarchy node structure.

const d3 = require('d3-hierarchy');
const data = {name: 'root', children: [{name: 'child1'}, {name: 'child2'}]};
const root = d3.hierarchy(data);
console.log(root);

Tree Layout

The tree layout computes the position of each node in a hierarchical tree structure. The example demonstrates setting up a tree layout with specified dimensions and applying it to a hierarchy.

const treeLayout = d3.tree().size([400, 200]);
const treeData = treeLayout(root);
console.log(treeData);

Cluster Layout

Similar to the tree layout, the cluster layout arranges nodes in a way that keeps all leaves at the same depth. The example sets up a cluster layout and applies it to a hierarchy.

const clusterLayout = d3.cluster().size([400, 200]);
const clusterData = clusterLayout(root);
console.log(clusterData);

Partition Layout

The partition layout sizes each node based on its value, useful for creating partition diagrams and sunburst charts. The example shows how to apply a partition layout to a hierarchy.

const partitionLayout = d3.partition().size([400, 200]);
const partitionData = partitionLayout(root);
console.log(partitionData);

Pack Layout

The pack layout is used for circle packing visualizations. Nodes are packed inside a circle, with child nodes inside parent nodes. The example demonstrates setting up and applying a pack layout.

const packLayout = d3.pack().size([200, 200]).padding(3);
const packedData = packLayout(root);
console.log(packedData);

Other packages similar to d3-hierarchy

Keywords

FAQs

Package last updated on 02 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc