D3 API Reference

D3 is a collection of modules that are designed to work together; you can use the modules independently, or you can use them together as part of the default build. The source and documentation for each module is available in its repository. Follow the links below to learn more. For changes between major versions, see CHANGES; see also the release notes and the 3.x reference.

D3 uses semantic versioning. The current version is exposed as d3.version.

Arrays (d3-array)

Array manipulation, ordering, searching, summarizing, etc.


Methods for computing basic summary statistics.

Methods for searching arrays for a specific element.


Methods for transforming arrays and for generating new arrays.


Bin discrete samples into continuous, non-overlapping intervals.

Axes (d3-axis)

Human-readable reference marks for scales.

Brushes (d3-brush)

Select a one- or two-dimensional region using the mouse or touch.

Chords (d3-chord)

Collections (d3-collection)

Handy data structures for elements keyed by string.


Methods for converting associative arrays (objects) to arrays.


Like ES6 Map, but with string keys and a few other differences.


Like ES6 Set, but with string keys and a few other differences.


Group data into arbitrary hierarchies.

Colors (d3-color)

Color manipulation and color space conversion.

Color Schemes (d3-scale-chromatic)

Color ramps and palettes for quantitative, ordinal and categorical scales.



Sequential (Single Hue)

Sequential (Multi-Hue)


Contours (d3-contour)

Compute contour polygons using marching squares.

Dispatches (d3-dispatch)

Separate concerns using named callbacks.

Dragging (d3-drag)

Drag and drop SVG, HTML or Canvas using mouse or touch input.

Delimiter-Separated Values (d3-dsv)

Parse and format delimiter-separated values, most commonly CSV and TSV.

Easings (d3-ease)

Easing functions for smooth animation.

Fetches (d3-fetch)

Convenience methods on top of the Fetch API.

Forces (d3-force)

Force-directed graph layout using velocity Verlet integration.

Number Formats (d3-format)

Format numbers for human consumption.

Geographies (d3-geo)

Geographic projections, shapes and math.



Spherical Math

Spherical Shapes



Hierarchies (d3-hierarchy)

Layout algorithms for visualizing hierarchical data.

Interpolators (d3-interpolate)

Interpolate numbers, colors, strings, arrays, objects, whatever!

Paths (d3-path)

Serialize Canvas path commands to SVG.

Polygons (d3-polygon)

Geometric operations for two-dimensional polygons.

Quadtrees (d3-quadtree)

Two-dimensional recursive spatial subdivision.

Random Numbers (d3-random)

Generate random numbers from various distributions.

Scales (d3-scale)

Encodings that map abstract data to visual representation.

Continuous Scales

Map a continuous, quantitative domain to a continuous range.

Sequential Scales

Map a continuous, quantitative domain to a continuous, fixed interpolator.

Diverging Scales

Map a continuous, quantitative domain to a continuous, fixed interpolator.

Quantize Scales

Map a continuous, quantitative domain to a discrete range.

Ordinal Scales

Map a discrete domain to a discrete range.

Selections (d3-selection)

Transform the DOM by selecting elements and joining to data.

Selecting Elements

Modifying Elements

Joining Data

Handling Events

Control Flow

Local Variables


Shapes (d3-shape)

Graphical primitives for visualization.


Circular or annular sectors, as in a pie or donut chart.


Compute the necessary angles to represent a tabular dataset as a pie or donut chart.


A spline or polyline, as in a line chart.


An area, defined by a bounding topline and baseline, as in an area chart.


Interpolate between points to produce a continuous shape.

A smooth cubic Bézier curve from a source to a target.


A categorical shape encoding, as in a scatterplot.


Stack shapes, placing one adjacent to another, as in a stacked bar chart.

Time Formats (d3-time-format)

Parse and format times, inspired by strptime and strftime.

Time Intervals (d3-time)

A calculator for humanity’s peculiar conventions of time.

Timers (d3-timer)

An efficient queue for managing thousands of concurrent animations.

Transitions (d3-transition)

Animated transitions for selections.

Voronoi Diagrams (d3-voronoi)

Compute the Voronoi diagram of a given set of points.

Zooming (d3-zoom)

Pan and zoom SVG, HTML or Canvas using mouse or touch input.