🎨
UI Component3M+/wkISC

d3

D3.js (Data-Driven Documents) is the most powerful and flexible JavaScript library for creating custom data visualizations in the browser using SVG, Canvas, and

Installation

npm
npm install d3
yarn
yarn add d3
pnpm
pnpm add d3

Import

ESM
import * as d3 from 'd3';

Quick Example

usage
import * as d3 from 'd3';

const data = [30, 86, 168, 281, 303, 365];

d3.select('.chart')
  .selectAll('div')
  .data(data)
  .join('div')
  .style('width', (d) => `${d}px`)
  .style('background', '#3b82f6')
  .style('margin', '2px')
  .style('padding', '4px')
  .style('color', 'white')
  .text((d) => d);

About d3

D3.js (Data-Driven Documents) is the most powerful and flexible JavaScript library for creating custom data visualizations in the browser using SVG, Canvas, and HTML. D3 provides a low-level approach where you directly manipulate the DOM based on data, giving complete control over every visual element. The library's core concept is the data join — binding an array of data to DOM elements and defining enter, update, and exit behaviors. D3 includes modules for scales (linear, logarithmic, ordinal, time), axes, shapes (lines, arcs, areas, curves), geographic projections, hierarchical layouts (tree, treemap, sunburst, force-directed graph), transitions and animations, brush and zoom interactions, and data parsing (CSV, TSV, JSON). D3's selection API (d3.select, d3.selectAll) provides jQuery-like DOM manipulation with data binding. The library is not a charting library — it is a toolkit for building custom visualizations of any kind. While libraries like Chart.js and Recharts offer simpler APIs for standard charts, D3 enables unique, custom visualizations that no template-based charting library can produce. D3 v7 uses ES modules for tree shaking, and Observable (created by D3's author Mike Bostock) provides an interactive notebook environment for D3 development.

Quick Facts

Packaged3
CategoryUI Component
Weekly Downloads3M+
LicenseISC
Installnpm install d3

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.