Skip to main content
100%

D3.js Tree Example

✓ Published0🌍 Public
Aakshayvenishetty1437
Last edited Jul 21, 2023
Created on Jul 21, 2023
Forked from Hello VizHub

This example shows a static hierarchical tree layout rendered as SVG, with a root node branching into three categories (Animals, Vehicles, Countries) and their leaf children. It demonstrates the core D3.js v5 tree API, using `d3.hierarchy()` to structure the data, `d3.tree()` to compute node positions, and `d3.linkHorizontal()` to draw curved paths between parent and child nodes. The code explicitly sets SVG dimensions with margins, appends circles for nodes and text labels that align based on whether a node has children, and loads D3 via a CDN script tag.

AI-generated description

An example showing the capabilities of VizHub:

  • Loads D3 via UNPKG.
  • Demonstrates use of import from "d3".
  • Demonstrates use of import from local ES6 modules.
MIT Licensed

Similar vizzes