API

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.

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

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

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

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

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.geoRotation - create a rotation function for the specified angles.
  • rotation - rotate the given point around the sphere.
  • rotation.invert - unrotate the given point around the sphere.

Spherical Shapes

Projections

Raw Projections

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.

  • 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 (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.

Symbols

A categorical shape encoding, as in a scatterplot.

Stacks

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值