Skip to content

API 索引

🌐 API index

D3 是一个模块集合,这些模块被设计成可以协同工作;你可以单独使用这些模块,或者将它们作为默认构建的一部分一起使用。

🌐 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 - 创建一个全精度加法器。
  • adder.add - 向加法器添加一个值。
  • adder.valueOf - 获取加法器值的双精度表示。
  • fcumsum - 计算数字的全精度累积和。
  • fsum - 计算一个数字可迭代对象的全精度求和。

Bin

将离散样本分箱到连续、不重叠的区间中。

🌐 Bin discrete samples into continuous, non-overlapping intervals.

二分

🌐 Bisect

快速在已排序数组中查找值。

🌐 Quickly find a value in a sorted array.

  • bisector - 使用访问器或比较器进行二分。
  • bisector.right - bisectRight,使用给定的比较器。
  • bisector.left - bisectLeft,使用给定的比较器。
  • bisector.center - 在排序数组中进行值的二分查找。
  • bisect - 在排序数组中进行二分查找以寻找某个值。
  • bisectRight - 在已排序数组中进行值的二分查找。
  • bisectLeft - 在已排序数组中二分查找一个值。
  • bisectCenter - 在已排序数组中二分查找一个值。

模糊

🌐 Blur

在一维或二维中模糊定量值。

🌐 Blur quantitative values in one or two dimensions.

  • d3.blur - 原地模糊一个数字数组。
  • d3.blur2 - 就地模糊二维数字数组。
  • d3.blurImage - 原地模糊一个 RGBA ImageData。

🌐 Group

对离散值进行分组。

🌐 Group discrete values.

  • d3.group - 将可迭代对象分组到嵌套的 Map 中。
  • d3.groups - 将可迭代对象分组到嵌套数组中。
  • d3.rollup - 将可迭代对象归约为嵌套的 Map。
  • d3.rollups - 将可迭代对象缩减为嵌套数组。
  • d3.index - 将可迭代对象索引到嵌套的 Map 中。
  • d3.indexes - 将可迭代对象索引到嵌套数组中。
  • d3.flatGroup - 将可迭代对象分组为一个扁平数组。
  • d3.flatRollup - 将可迭代对象归约为一个扁平数组。
  • d3.groupSort - 根据分组后的值对键进行排序。

实习生

🌐 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 - 计算可迭代对象中有效数字值的数量。
  • d3.min - 计算可迭代对象中的最小值。
  • d3.minIndex - 计算可迭代对象中最小值的索引。
  • d3.max - 计算可迭代对象中的最大值。
  • d3.maxIndex - 计算可迭代对象中最大值的索引。
  • d3.least - 返回可迭代对象中最小的元素。
  • d3.leastIndex - 返回可迭代对象中最小元素的索引。
  • d3.greatest - 返回可迭代对象中的最大元素。
  • d3.greatestIndex - 返回可迭代对象中最大元素的索引。
  • d3.extent - 计算可迭代对象中的最小值和最大值。
  • d3.mode - 计算一个数字可迭代对象的众数(最常见的值)。
  • d3.sum - 计算一组数字可迭代对象的总和。
  • d3.mean - 计算一个数字可迭代对象的算术平均值。
  • d3.median - 计算一个数字可迭代对象的中位数(0.5 分位数)。
  • d3.medianIndex - 计算一个数字可迭代对象的中位数索引(0.5分位数)。
  • d3.cumsum - 计算可迭代对象的累积和。
  • d3.quantile - 计算一组数字的分位数。
  • d3.quantileIndex - 计算一组数字的分位数索引。
  • d3.quantileSorted - 计算已排序数组的分位数。
  • d3.rank - 计算可迭代对象的排名顺序。
  • d3.variance - 计算一个数字可迭代对象的方差。
  • d3.deviation - 计算一组数字的标准差。
  • d3.every - 测试所有值是否满足某个条件。
  • d3.some - 测试是否有任何值满足某个条件。

蜱虫

🌐 Ticks

从连续间隔中生成代表值。

🌐 Generate representative values from a continuous interval.

变换

🌐 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.color - 解析给定的 CSS 颜色说明符。
  • color.opacity - 颜色的不透明度。
  • color.rgb - 计算此颜色的 RGB 等效值。
  • color.copy - 返回此颜色的副本。
  • color.brighter - 创建此颜色的更亮副本。
  • color.darker - 创建此颜色的更暗版本。
  • color.displayable - 如果颜色可以在标准硬件上显示,则返回 true。
  • color.formatHex - 返回此颜色的十六进制 RRGGBB 字符串表示。
  • color.formatHex8 - 返回此颜色的十六进制 RRGGBBAA 字符串表示。
  • color.formatHsl - 返回此颜色的 RGB 字符串表示。
  • color.formatRgb - 返回该颜色的 HSL 字符串表示。
  • color.toString - 返回该颜色的 RGB 字符串表示。
  • d3.rgb - 创建一个新的 RGB 颜色。
  • rgb.clamp - 返回此颜色限制在 RGB 颜色空间内的副本。
  • d3.hsl - 创建一个新的 HSL 颜色。
  • hsl.clamp - 返回此颜色在 HSL 色彩空间内限制后的副本。
  • d3.lab - 创建一个新的实验室颜色。
  • d3.gray - 创建一个新的实验室灰色。
  • d3.hcl - 创建一个新的 HCL 颜色。
  • d3.lch - 创建一个新的 HCL 颜色。
  • d3.cubehelix - 创建一个新的 Cubehelix 颜色。

d3-contour

使用行进方格计算轮廓多边形。

🌐 Compute contour polygons using marching squares.

d3-delaunay

计算一组二维点的 Voronoi 图。

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

d3-dispatch

使用命名回调函数分离关注点。

🌐 Separate concerns using named callbacks.

d3-drag

使用鼠标或触摸输入拖放 SVG、HTML 或 Canvas。

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

d3-dsv

解析和格式化以分隔符分隔的值,最常见的是 CSV 和 TSV。

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

d3-ease

用于实现平滑动画的缓动函数。

🌐 Easing functions for smooth animation.

d3-fetch

基于 Fetch API 的便捷方法。

🌐 Convenience methods on top of the Fetch API.

  • d3.blob - 以 blob 形式获取文件。
  • d3.buffer - 将文件获取为数组缓冲区。
  • d3.csv - 获取一个逗号分隔值 (CSV) 文件。
  • d3.dsv - 获取一个分隔符分隔的值(CSV)文件。
  • d3.html - 获取一个 HTML 文件。
  • d3.image - 获取一张图片。
  • d3.json - 获取一个 JSON 文件。
  • d3.svg - 获取一个 SVG 文件。
  • d3.text - 获取一个纯文本文件。
  • d3.tsv - 获取一个制表符分隔值(TSV)文件。
  • d3.xml - 获取一个 XML 文件。

d3-force

使用速度 Verlet 积分的力导向图布局。

🌐 Force-directed graph layout using velocity Verlet integration.

d3-format

格式化数字以供人类理解。

🌐 Format numbers for human consumption.

d3-geo

地理投影、形状和数学。

🌐 Geographic projections, shapes and math.

路径

🌐 Paths

预测

🌐 Projections

原始预测

🌐 Raw projections

方位投影

🌐 Azimuthal projections

锥面投影

🌐 Conic projections

圆柱投影

🌐 Cylindrical projections

🌐 Streams

球形

🌐 Spherical shapes

球面数学

🌐 Spherical math

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

将 Canvas 路径命令序列化为 SVG。

🌐 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 量表

🌐 Pow scales

对数刻度

🌐 Log scales

Symlog 量表

🌐 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.namespace - 为带前缀的 XML 名称加上限定符,例如“xlink:href”。
  • d3.namespaces - 内置的 XML 命名空间。

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.

🌐 Links

从源到目标的平滑三次贝塞尔曲线。

🌐 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

解析和格式化时间,灵感来自 strptime 和 strftime。

🌐 Parse and format times, inspired by strptime and strftime.

d3-timer

一个用于管理数千个并发动画的高效队列。

🌐 An efficient queue for managing thousands of concurrent animations.

  • d3.now - 获取当前高分辨率时间。
  • d3.timer - 安排一个新的计时器。
  • timer.restart - 重置计时器的开始时间和回调。
  • timer.stop - 停止计时器。
  • d3.timerFlush - 立即执行任何符合条件的定时器。
  • d3.timeout - 安排一个在第一次回调时停止的定时器。
  • d3.interval - 安排一个定时器,以可配置的周期被调用。

d3-transition

选择 的动画过渡。

🌐 Animated transitions for selections.

d3-zoom

使用鼠标或触摸输入平移和缩放 SVG、HTML 或 Canvas。

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