Bring data to life with SVG, Canvas and HTML. 📊📈🎉
Перейти к файлу
Mike Bostock aa47c28816 Update d3-drag. 2016-05-11 16:46:45 -07:00
bin Windows build compatibility. 2016-03-14 12:25:49 -07:00
test Add tests. 2016-01-04 17:05:54 -08:00
.gitignore Checkpoint 4.0 branch. 2016-01-01 21:41:20 -08:00
.npmignore Checkpoint 4.0 branch. 2016-01-01 21:41:20 -08:00
LICENSE Checkpoint 4.0 branch. 2016-01-01 21:41:20 -08:00
README.md Update d3-drag. 2016-05-11 16:46:45 -07:00
d3.sublime-project Checkpoint 4.0 branch. 2016-01-01 21:41:20 -08:00
index.js Oops, forgot to export symbols. 2016-05-11 08:51:29 -07:00
package.json Update d3-drag. 2016-05-11 16:46:45 -07:00

README.md

D3: Data-Driven Documents

This branch contains the prerelease of D3 4.0. This API is unstable and may change at any point prior to the release.

Installing

If you use NPM, npm install d3@next. Otherwise, download the latest release. The released bundle supports AMD, CommonJS, and vanilla environments. Create a custom build using Rollup or your preferred bundler. You can also load directly from d3js.org:

<script src="https://d3js.org/d3.v4.0.0-alpha.38.min.js"></script>

API Reference

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

Arrays

Array manipulation, ordering, searching, summarizing, etc.

Statistics

Methods for computing basic summary statistics.

  • d3.min - compute the minimum value in an array.
  • d3.max - compute the maximum value in an array.
  • d3.extent - compute the minimum and maximum value in an array.
  • d3.sum - compute the sum of an array of numbers.
  • d3.mean - compute the arithmetic mean of an array of numbers.
  • d3.median - compute the median of an array of numbers (the 0.5-quantile).
  • d3.quantile - compute a quantile for a sorted array of numbers.
  • d3.variance - compute the variance of an array of numbers.
  • d3.deviation - compute the standard deviation of an array of numbers.

Histograms

Bin discrete samples into continuous, non-overlapping intervals.

Search

Methods for searching arrays for a specific element.

Transformations

Methods for transforming arrays and for generating new arrays.

  • d3.merge - merge multiple arrays into one array.
  • d3.pairs - create an array of adjacent pairs of elements.
  • d3.permute - reorder an array of elements according to an array of indexes.
  • d3.shuffle - randomize the order of an array.
  • d3.ticks - generate representative values from a numeric interval.
  • d3.tickStep - generate representative values from a numeric interval.
  • d3.range - generate a range of numeric values.
  • d3.transpose - transpose an array of arrays.
  • d3.zip - transpose a variable number of arrays.

Axes

Human-readable reference marks for scales.

Collections

Handy data structures for elements keyed by string.

Objects

Methods for converting associative arrays (objects) to arrays.

  • d3.keys - list the keys of an associative array.
  • d3.values - list the values of an associated array.
  • d3.entries - list the key-value entries of an associative array.

Maps

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

  • d3.map - create a new, empty map.
  • map.has - returns true if the map contains the given key.
  • map.get - get the value for the given key.
  • map.set - set the value for the given key.
  • map.remove - remove the entry for given key.
  • map.clear - remove all entries.
  • map.keys - get the array of keys.
  • map.values - get the array of values.
  • map.entries - get the array of entries (key-values objects).
  • map.each - call a function for each entry.
  • map.empty - returns false if the map has at least one entry.
  • map.size - compute the number of entries.

Sets

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

  • d3.set - create a new, empty set.
  • set.has - returns true if the set contains the given value.
  • set.add - add the given value.
  • set.remove - remove the given value.
  • set.clear - remove all values.
  • set.values - get the array of values.
  • set.each - call a function for each value.
  • set.empty - returns true if the set has at least one value.
  • set.size - compute the number of values.

Nests

Group data into arbitrary hierarchies.

  • d3.nest - create a new nest generator.
  • nest.key - add a level to the nest hierarchy.
  • nest.sortKeys - sort the current nest level by key.
  • nest.sortValues - sort the leaf nest level by value.
  • nest.rollup - specify a rollup function for leaf values.
  • nest.map - generate the nest, returning a map.
  • nest.object - generate the nest, returning an associative array.
  • nest.entries - generate the nest, returning an array of key-values tuples.

Colors

Color manipulation and color space conversion.

Delimiter-Separated Values

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

  • d3.dsvFormat - create a new parser and formatter for the given delimiter.
  • dsv.parse - parse the given string, returning an array of objects.
  • dsv.parseRows - parse the given string, returning an array of rows.
  • dsv.format - format the given array of objects.
  • dsv.formatRows - format the given array of rows.
  • d3.csvParse - parse the given CSV string, returning an array of objects.
  • d3.csvParseRows - parse the given CSV string, returning an array of rows.
  • d3.csvFormat - format the given array of objects as CSV.
  • d3.csvFormatRows - format the given array of rows as CSV.
  • d3.tsvParse - parse the given TSV string, returning an array of objects.
  • d3.tsvParseRows - parse the given TSV string, returning an array of rows.
  • d3.tsvFormat - format the given array of objects as TSV.
  • d3.tsvFormatRows - format the given array of rows as TSV.

Dispatches

Separate concerns using named callbacks.

Dragging

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

  • d3.drag - create a drag behavior.
  • drag - apply the drag behavior to a selection.
  • drag.container - set the coordinate system.
  • drag.filter - ignore some initiating input events.
  • drag.subject - set the thing being dragged.
  • drag.x - set the x-coordinate of the subject.
  • drag.y - set the y-coordinate of the subject.
  • drag.on - listen for drag events.
  • event.on - listen for drag events on the current gesture.

Easings

Easing functions for smooth animation.

Forces

Force-directed graph layout using velocity Verlet integration.

Hierarchies

Layout algorithms for visualizing hierarchical data.

Interpolators

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

Number Formats

Format numbers for human consumption.

Paths

Serialize Canvas path commands to SVG.

Polygons

Geometric operations for two-dimensional polygons.

Quadtrees

Two-dimensional recursive spatial subdivision.

Queues

Evaluate asynchronous tasks with configurable concurrency.

  • d3.queue - manage the concurrent evaluation of asynchronous tasks.
  • queue.defer - register a task for evaluation.
  • queue.abort - abort any active tasks and cancel any pending ones.
  • queue.await - register a callback for when tasks complete.
  • queue.awaitAll - register a callback for when tasks complete.

Random Numbers

Generate random numbers from various distributions.

Requests

A convenient alternative to asynchronous XMLHttpRequest.

Scales

Encodings that map abstract data to visual representation.

Continuous Scales

Map a continuous, quantitative domain to a continuous range.

Sequential Color Scales

Map a continuous, quantitative domain to a continuous, fixed color ramp.

Quantize Scales

Map a continuous, quantitative domain to a discrete range.

Ordinal Scales

Map a discrete domain to a discrete range.

Categorical Color Scales

Map a discrete domain to a discrete, fixed categorical color range.

Selections

Transform the DOM by selecting elements and joining to data.

Selecting Elements

Modifying Elements

Joining Data

Handling Events

  • selection.on - add or remove event listeners.
  • selection.dispatch - dispatch a custom event.
  • d3.event - the current user event, during interaction.
  • d3.customEvent - temporarily define a custom event.
  • d3.mouse - get the mouse position relative to a given container.
  • d3.touch - get a touch position relative to a given container.
  • d3.touches - get the touch positions relative to a given container.

Control Flow

Namespaces

Shapes

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.

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

Parse and format times, inspired by strptime and strftime.

Time Intervals

A calculator for humanitys peculiar conventions of time.

Timers

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 timers 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.

Transitions

Animated transitions for selections.

Voronoi Diagrams

Compute the Voronoi diagram of a given set of points.