D3 API Reference

D3 4.0 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 3.x and 4.0, see CHANGES; see also 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.

Statistics

Methods for computing basic summary statistics.

Methods for searching arrays for a specific element.

Transformations

Methods for transforming arrays and for generating new arrays.

Histograms

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.

Objects

Methods for converting associative arrays (objects) to arrays.

Maps

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

Sets

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

Nests

Group data into arbitrary hierarchies.

Colors (d3-color)

Color manipulation and color space conversion.

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.

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.

Paths

Projections

Spherical Math

Spherical Shapes

Streams

Transforms

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.

Queues (d3-queue)

Evaluate asynchronous tasks with configurable concurrency.

Random Numbers (d3-random)

Generate random numbers from various distributions.

Requests (d3-request)

A convenient alternative to asynchronous XMLHttpRequest.

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.

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

Namespaces

Shapes (d3-shape)

Graphical primitives for visualization.

Arcs

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

Pies

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

Lines

A spline or polyline, as in a line chart.

Areas

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

Curves

Interpolate between points to produce a continuous shape.

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

Symbols

A categorical shape encoding, as in a scatterplot.

Stacks

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.