Skip to content
mbostock edited this page May 29, 2011 · 151 revisions

Everything in D3 is scoped under the d3 namespace. D3 is broken up into several modules so that you can pick and choose which features you need and minimize the weight. The default build of d3.js includes the core, scale and svg modules, at about 12KB uglified and gzipped. However, you can edit the Makefile to produce a custom build that suites your needs. D3 does not introduce anything else in the global namespace. However, for nonstandard browsers we do register polyfills for Date.now and Object.create.

D3 uses semantic versioning. You can find the current version of D3 as d3.version.

d3 (core)

Selections

  • d3.select - select an element from the current document.
  • d3.selectAll - select multiple elements from the current document.
  • attr - get or set attribute values.
  • classed - add or remove CSS classes.
  • style - get or set style properties.
  • property - get or set raw properties.
  • text - get or set text content.
  • html - get or set inner HTML content.
  • append - create and append new elements.
  • insert - create and insert new elements before existing elements.
  • remove - remove elements from the document.
  • data - bind data to elements, and compute a relational join.
  • enter - returns placeholders for missing elements.
  • exit - returns elements that are no longer needed.
  • filter - filter a selection based on data.
  • map - modify the data associated with the selected elements.
  • sort - sort elements in the document based on data.
  • on - add or remove event listeners for interaction.
  • transition - start a transition on the selected elements.
  • each - call a function for each selected element.
  • call - call a function passing in the current selection.
  • empty - returns true if the selection is empty.
  • node - access the first node in a selection.
  • select - subselect a descendant element for each selected element.
  • selectAll - subselect multiple descendants for each selected element.
  • d3.ns - access or extend known XML namespaces.
  • d3.functor - create a function that returns a constant.

Transitions

Events

  • d3.dispatch - create a custom event dispatcher.
  • d3.event - access the current user event for interaction.

Working with Arrays

  • d3.ascending - compare two values for sorting.
  • d3.descending - compare two values for sorting.
  • d3.min - find the minimum value in an array.
  • d3.max - find the maximum value in an array.
  • 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.
  • d3.split - split an array into multiple arrays.
  • d3.merge - merge multiple arrays into one array.
  • d3.range - generate a range of numeric values.
  • d3.nest - group array elements hierarchically.

Loading External Resources

  • d3.xhr - load a resource using XMLHttpRequest.
  • d3.text - load a text file.
  • d3.json - load a JSON blob.
  • d3.html - load an HTML document fragment.
  • d3.xml - load an XML document fragment.

Also see the csv module.

Number Formatting

  • d3.format

Colors

  • d3.rgb
  • d3.hsl

d3.behavior

d3.chart

d3.csv

d3.geo

d3.geom

d3.layout

d3.scale

d3.svg

d3.time

Clone this wiki locally