Skip to content

API index

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.

d3-array

Array manipulation, ordering, searching, summarizing, etc.

Add

Add floating point values with full precision.

  • new Adder - create a full precision adder.
  • adder.add - add a value to an adder.
  • adder.valueOf - get the double-precision representation of an adder’s value.
  • fcumsum - compute a full precision cumulative summation of numbers.
  • fsum - compute a full precision summation of an iterable of numbers.

Bin

Bin discrete samples into continuous, non-overlapping intervals.

Bisect

Quickly find a value in a sorted array.

  • bisector - bisect using an accessor or comparator.
  • bisector.right - bisectRight, with the given comparator.
  • bisector.left - bisectLeft, with the given comparator.
  • bisector.center - binary search for a value in a sorted array.
  • bisect - binary search for a value in a sorted array.
  • bisectRight - binary search for a value in a sorted array.
  • bisectLeft - binary search for a value in a sorted array.
  • bisectCenter - binary search for a value in a sorted array.

Blur

Blur quantitative values in one or two dimensions.

  • d3.blur - blur an array of numbers in place.
  • d3.blur2 - blur a two-dimensional array of numbers in place.
  • d3.blurImage - blur an RGBA ImageData in place.

Group

Group discrete values.

Intern

Create maps and sets with non-primitive values such as dates.

Sets

Logical operations on sets.

Sort

Sort and reorder arrays of values.

Summarize

Compute summary statistics.

  • d3.count - count valid number values in an iterable.
  • d3.min - compute the minimum value in an iterable.
  • d3.minIndex - compute the index of the minimum value in an iterable.
  • d3.max - compute the maximum value in an iterable.
  • d3.maxIndex - compute the index of the maximum value in an iterable.
  • d3.least - returns the least element of an iterable.
  • d3.leastIndex - returns the index of the least element of an iterable.
  • d3.greatest - returns the greatest element of an iterable.
  • d3.greatestIndex - returns the index of the greatest element of an iterable.
  • d3.extent - compute the minimum and maximum value in an iterable.
  • d3.mode - compute the mode (the most common value) of an iterable of numbers.
  • d3.sum - compute the sum of an iterable of numbers.
  • d3.mean - compute the arithmetic mean of an iterable of numbers.
  • d3.median - compute the median of an iterable of numbers (the 0.5-quantile).
  • d3.medianIndex - compute the median index of an iterable of numbers (the 0.5-quantile).
  • d3.cumsum - compute the cumulative sum of an iterable.
  • d3.quantile - compute a quantile for an iterable of numbers.
  • d3.quantileIndex - compute a quantile index for an iterable of numbers.
  • d3.quantileSorted - compute a quantile for a sorted array of numbers.
  • d3.rank - compute the rank order of an iterable.
  • d3.variance - compute the variance of an iterable of numbers.
  • d3.deviation - compute the standard deviation of an iterable of numbers.
  • d3.every - test if all values satisfy a condition.
  • d3.some - test if any value satisfies a condition.

Ticks

Generate representative values from a continuous interval.

  • d3.ticks - generate representative values from a numeric interval.
  • d3.tickIncrement - generate representative values from a numeric interval.
  • d3.tickStep - generate representative values from a numeric interval.
  • d3.nice - extend an interval to align with ticks.
  • d3.range - generate a range of numeric values.

Transform

Derive new arrays.

d3-axis

Human-readable reference marks for scales.

d3-brush

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

d3-chord

d3-color

Color manipulation and color space conversion.

d3-contour

Compute contour polygons using marching squares.

d3-delaunay

Compute the Voronoi diagram of a set of two-dimensional points.

d3-dispatch

Separate concerns using named callbacks.

d3-drag

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

d3-dsv

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

d3-ease

Easing functions for smooth animation.

d3-fetch

Convenience methods on top of the Fetch API.

  • d3.blob - get a file as a blob.
  • d3.buffer - get a file as an array buffer.
  • d3.csv - get a comma-separated values (CSV) file.
  • d3.dsv - get a delimiter-separated values (CSV) file.
  • d3.html - get an HTML file.
  • d3.image - get an image.
  • d3.json - get a JSON file.
  • d3.svg - get an SVG file.
  • d3.text - get a plain text file.
  • d3.tsv - get a tab-separated values (TSV) file.
  • d3.xml - get an XML file.

d3-force

Force-directed graph layout using velocity Verlet integration.

d3-format

Format numbers for human consumption.

d3-geo

Geographic projections, shapes and math.

Paths

  • d3.geoPath - create a new geographic path generator.
  • path - project and render the specified feature.
  • path.area - compute the projected planar area of a given feature.
  • path.bounds - compute the projected planar bounding box of a given feature.
  • path.centroid - compute the projected planar centroid of a given feature.
  • path.digits - set the output precision.
  • path.measure - compute the projected planar length of a given feature.
  • path.projection - set the geographic projection.
  • path.context - set the render context.
  • path.pointRadius - set the radius to display point features.

Projections

Raw projections

Azimuthal projections

Conic projections

Cylindrical projections

Streams

Spherical shapes

Spherical math

  • d3.geoArea - compute the spherical area of a given feature.
  • d3.geoBounds - compute the latitude-longitude bounding box for a given feature.
  • d3.geoCentroid - compute the spherical centroid of a given feature.
  • d3.geoDistance - compute the great-arc distance between two points.
  • d3.geoLength - compute the length of a line string or the perimeter of a polygon.
  • d3.geoInterpolate - interpolate between two points along a great arc.
  • d3.geoContains - test whether a point is inside a given feature.
  • d3.geoRotation - create a rotation function for the specified angles.

d3-hierarchy

Layout algorithms for visualizing hierarchical data.

d3-interpolate

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

Value interpolation

Color interpolation

Transform interpolation

Zoom interpolation

d3-path

Serialize Canvas path commands to SVG.

d3-polygon

Geometric operations for two-dimensional polygons.

d3-quadtree

Two-dimensional recursive spatial subdivision.

d3-random

Generate random numbers from various distributions.

d3-scale

Encodings that map abstract data to visual representation.

Linear scales

Map a continuous, quantitative domain to a continuous range.

Pow scales

Log scales

Symlog scales

Time scales

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.

Quantile scales

Threshold scales

Ordinal scales

Map a discrete domain to a discrete range.

Band scales

Point scales

d3-scale-chromatic

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

Categorical

Cyclical

Diverging

Sequential

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

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.

d3-time

A calculator for humanity’s peculiar conventions of time.

d3-time-format

Parse and format times, inspired by strptime and strftime.

d3-timer

An efficient queue for managing thousands of concurrent animations.

  • d3.now - get the current high-resolution time.
  • d3.timer - schedule a new timer.
  • timer.restart - reset the timer’s start time and callback.
  • timer.stop - stop the timer.
  • d3.timerFlush - immediately execute any eligible timers.
  • d3.timeout - schedule a timer that stops on its first callback.
  • d3.interval - schedule a timer that is called with a configurable period.

d3-transition

Animated transitions for selections.

d3-zoom

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