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.

  • 新的 Adder - 创建一个全精度加法器。

    ¥new Adder - create a full precision adder.

  • adder.add - 向加法器添加一个值。

    ¥adder.add - add a value to an adder.

  • adder.valueOf - 获取加法器值的双精度表示。

    ¥adder.valueOf - get the double-precision representation of an adder’s value.

  • fcumsum - 计算数字的全精度累积和。

    ¥fcumsum - compute a full precision cumulative summation of numbers.

  • fsum - 计算数字可迭代对象的全精度和。

    ¥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 - 使用访问器或比较器进行二分。

    ¥bisector - bisect using an accessor or comparator.

  • bisector.right - 使用给定的比较器进行右二分。

    ¥bisector.right - bisectRight, with the given comparator.

  • bisector.left - 使用给定的比较器进行左二分。

    ¥bisector.left - bisectLeft, with the given comparator.

  • bisector.center - 在已排序数组中二分查找值。

    ¥bisector.center - binary search for a value in a sorted array.

  • bisect - 在已排序数组中二分查找值。

    ¥bisect - binary search for a value in a sorted array.

  • bisectRight - 在已排序数组中二分查找值。

    ¥bisectRight - binary search for a value in a sorted array.

  • bisectLeft - 在已排序数组中二分查找值。

    ¥bisectLeft - binary search for a value in a sorted array.

  • bisectCenter - 在已排序数组中二分查找值。

    ¥bisectCenter - binary search for a value in a sorted array.

模糊

¥Blur

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

¥Blur quantitative values in one or two dimensions.

  • d3.blur - 对数字数组进行原地模糊处理。

    ¥d3.blur - blur an array of numbers in place.

  • d3.blur2 - 对二维数字数组进行原地模糊处理。

    ¥d3.blur2 - blur a two-dimensional array of numbers in place.

  • d3.blurImage - 对 RGBA 图片数据进行原地模糊处理。

    ¥d3.blurImage - blur an RGBA ImageData in place.

群组

¥Group

对离散值进行分组。

¥Group discrete values.

  • d3.group - 将可迭代对象分组为一个嵌套 Map。

    ¥d3.group - group an iterable into a nested Map.

  • d3.groups - 将可迭代对象分组为一个嵌套数组。

    ¥d3.groups - group an iterable into a nested array.

  • d3.rollup - 将可迭代对象简化为嵌套 Map。

    ¥d3.rollup - reduce an iterable into a nested Map.

  • d3.rollups - 将可迭代对象简化为嵌套数组。

    ¥d3.rollups - reduce an iterable into a nested array.

  • d3.index - 将可迭代对象索引到嵌套 Map 中。

    ¥d3.index - index an iterable into a nested Map.

  • d3.indexes - 将可迭代对象索引到嵌套数组中。

    ¥d3.indexes - index an iterable into a nested array.

  • d3.flatGroup - 将可迭代对象分组为一个平面数组。

    ¥d3.flatGroup - group an iterable into a flat array.

  • d3.flatRollup - 将可迭代对象简化为平面数组。

    ¥d3.flatRollup - reduce an iterable into a flat array.

  • d3.groupSort - 根据分组值对键进行排序。

    ¥d3.groupSort - sort keys according to grouped 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 - 计算可迭代对象中的有效数字值。

    ¥d3.count - count valid number values in an iterable.

  • d3.min - 计算可迭代对象的最小值。

    ¥d3.min - compute the minimum value in an iterable.

  • d3.minIndex - 计算可迭代对象中最小值的索引。

    ¥d3.minIndex - compute the index of the minimum value in an iterable.

  • d3.max - 计算可迭代对象的最大值。

    ¥d3.max - compute the maximum value in an iterable.

  • d3.maxIndex - 计算可迭代对象中最大值的索引。

    ¥d3.maxIndex - compute the index of the maximum value in an iterable.

  • d3.least - 返回可迭代对象的最小元素。

    ¥d3.least - returns the least element of an iterable.

  • d3.leastIndex - 返回可迭代对象中最小元素的索引。

    ¥d3.leastIndex - returns the index of the least element of an iterable.

  • d3.greatest - 返回可迭代对象中的最大元素。

    ¥d3.greatest - returns the greatest element of an iterable.

  • d3.greatestIndex - 返回可迭代对象中最大元素的索引。

    ¥d3.greatestIndex - returns the index of the greatest element of an iterable.

  • d3.extent - 计算可迭代对象的最小值和最大值。

    ¥d3.extent - compute the minimum and maximum value in an iterable.

  • d3.mode - 计算数值可迭代对象的众数(最常见的值)。

    ¥d3.mode - compute the mode (the most common value) of an iterable of numbers.

  • d3.sum - 计算可迭代对象的和。

    ¥d3.sum - compute the sum of an iterable of numbers.

  • d3.mean - 计算可迭代对象的算术平均值。

    ¥d3.mean - compute the arithmetic mean of an iterable of numbers.

  • d3.median - 计算数值可迭代对象的中位数(0.5 分位数)。

    ¥d3.median - compute the median of an iterable of numbers (the 0.5-quantile).

  • d3.medianIndex - 计算数值可迭代对象的中位数索引(0.5 分位数)。

    ¥d3.medianIndex - compute the median index of an iterable of numbers (the 0.5-quantile).

  • d3.cumsum - 计算可迭代对象的累积和。

    ¥d3.cumsum - compute the cumulative sum of an iterable.

  • d3.quantile - 计算数字可迭代对象的分位数。

    ¥d3.quantile - compute a quantile for an iterable of numbers.

  • d3.quantileIndex - 计算数字可迭代对象的分位数索引。

    ¥d3.quantileIndex - compute a quantile index for an iterable of numbers.

  • d3.quantileSorted - 计算已排序数字数组的分位数。

    ¥d3.quantileSorted - compute a quantile for a sorted array of numbers.

  • d3.rank - 计算可迭代对象的排序。

    ¥d3.rank - compute the rank order of an iterable.

  • d3.variance - 计算可迭代对象的方差。

    ¥d3.variance - compute the variance of an iterable of numbers.

  • d3.deviation - 计算可迭代对象的标准差。

    ¥d3.deviation - compute the standard deviation of an iterable of numbers.

  • d3.every - 测试所有值是否满足条件。

    ¥d3.every - test if all values satisfy a condition.

  • d3.some - 测试任何值是否满足条件。

    ¥d3.some - test if any value satisfies a condition.

刻度

¥Ticks

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

¥Generate representative values from a continuous interval.

  • d3.ticks - 根据数值间隔生成代表值。

    ¥d3.ticks - generate representative values from a numeric interval.

  • d3.tickIncrement - 根据数值间隔生成代表值。

    ¥d3.tickIncrement - generate representative values from a numeric interval.

  • d3.tickStep - 根据数值间隔生成代表值。

    ¥d3.tickStep - generate representative values from a numeric interval.

  • d3.nice - 扩展间隔以与刻度对齐。

    ¥d3.nice - extend an interval to align with ticks.

  • d3.range - 生成一系列数值。

    ¥d3.range - generate a range of numeric values.

变换

¥Transform

导出新数组。

¥Derive new arrays.

  • d3.cross - 计算两个可迭代对象的笛卡尔积。

    ¥d3.cross - compute the Cartesian product of two iterables.

  • d3.merge - 将多个可迭代对象合并为一个数组。

    ¥d3.merge - merge multiple iterables into one array.

  • d3.pairs - 创建一个相邻元素对的数组。

    ¥d3.pairs - create an array of adjacent pairs of elements.

  • d3.transpose - 转置一个数组的数组。

    ¥d3.transpose - transpose an array of arrays.

  • d3.zip - 转置可变数量的数组。

    ¥d3.zip - transpose a variable number of arrays.

  • d3.filter - 过滤值。

    ¥d3.filter - filter values.

  • d3.map - 地图值。

    ¥d3.map - map values.

  • d3.reduce - 减少值。

    ¥d3.reduce - reduce values.

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 颜色说明符。

    ¥d3.color - parse the given CSS color specifier.

  • color.opacity - 颜色的不透明度。

    ¥color.opacity - the color’s opacity.

  • color.rgb - 计算此颜色的 RGB 等效值。

    ¥color.rgb - compute the RGB equivalent of this color.

  • color.copy - 返回此颜色的副本。

    ¥color.copy - return a copy of this color.

  • color.brighter - 创建此颜色的更亮副本。

    ¥color.brighter - create a brighter copy of this color.

  • color.darker - 创建此颜色的更暗副本。

    ¥color.darker - create a darker copy of this color.

  • color.displayable - 如果颜色在标准硬件上可显示,则返回 true。

    ¥color.displayable - returns true if the color is displayable on standard hardware.

  • color.formatHex - 返回此颜色的十六进制 RRGGBB 字符串表示形式。

    ¥color.formatHex - returns the hexadecimal RRGGBB string representation of this color.

  • color.formatHex8 - 返回此颜色的十六进制 RRGGBBAA 字符串表示形式。

    ¥color.formatHex8 - returns the hexadecimal RRGGBBAA string representation of this color.

  • color.formatHsl - 返回此颜色的 RGB 字符串表示形式。

    ¥color.formatHsl - returns the RGB string representation of this color.

  • color.formatRgb - 返回此颜色的 HSL 字符串表示形式。

    ¥color.formatRgb - returns the HSL string representation of this color.

  • color.toString - 返回此颜色的 RGB 字符串表示形式。

    ¥color.toString - returns the RGB string representation of this color.

  • d3.rgb - 创建一个新的 RGB 颜色。

    ¥d3.rgb - create a new RGB color.

  • rgb.clamp - 返回此颜色在 RGB 颜色空间中的副本。

    ¥rgb.clamp - returns copy of this color clamped to the RGB color space.

  • d3.hsl - 创建一个新的 HSL 颜色。

    ¥d3.hsl - create a new HSL color.

  • hsl.clamp - 返回此颜色在 HSL 颜色空间中的副本。

    ¥hsl.clamp - returns copy of this color clamped to the HSL color space.

  • d3.lab - 创建一个新的 Lab 颜色。

    ¥d3.lab - create a new Lab color.

  • d3.gray - 创建一个新的 Lab 灰色。

    ¥d3.gray - create a new Lab gray.

  • d3.hcl - 创建一个新的 HCL 颜色。

    ¥d3.hcl - create a new HCL color.

  • d3.lch - 创建一个新的 HCL 颜色。

    ¥d3.lch - create a new HCL color.

  • d3.cubehelix - 创建一个新的 Cubehelix 颜色。

    ¥d3.cubehelix - create a new Cubehelix color.

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.blob - get a file as a blob.

  • d3.buffer - 获取数组缓冲区文件。

    ¥d3.buffer - get a file as an array buffer.

  • d3.csv - 获取逗号分隔值 (CSV) 文件。

    ¥d3.csv - get a comma-separated values (CSV) file.

  • d3.dsv - 获取分隔符分隔值 (CSV) 文件。

    ¥d3.dsv - get a delimiter-separated values (CSV) file.

  • d3.html - 获取 HTML 文件。

    ¥d3.html - get an HTML file.

  • d3.image - 获取图片。

    ¥d3.image - get an image.

  • d3.json - 获取 JSON 文件。

    ¥d3.json - get a JSON file.

  • d3.svg - 获取 SVG 文件。

    ¥d3.svg - get an SVG file.

  • d3.text - 获取纯文本文件。

    ¥d3.text - get a plain text file.

  • d3.tsv - 获取制表符分隔值 (TSV) 文件。

    ¥d3.tsv - get a tab-separated values (TSV) file.

  • d3.xml - 获取 XML 文件。

    ¥d3.xml - get an XML file.

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 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-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.now - get the current high-resolution time.

  • d3.timer - 安排一个新的计时器。

    ¥d3.timer - schedule a new timer.

  • timer.restart - 重置计时器的启动时间和回调。

    ¥timer.restart - reset the timer’s start time and callback.

  • timer.stop - 停止计时器。

    ¥timer.stop - stop the timer.

  • d3.timerFlush - 立即执行任何符合条件的计时器。

    ¥d3.timerFlush - immediately execute any eligible timers.

  • d3.timeout - 安排一个在第一次回调时停止的计时器。

    ¥d3.timeout - schedule a timer that stops on its first callback.

  • d3.interval - 安排一个以可配置周期调用的计时器。

    ¥d3.interval - schedule a timer that is called with a configurable period.

d3-transition

selections 的动画过渡。

¥Animated transitions for selections.

d3-zoom

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

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