核心函数

选择器

  • d3.select - 在当前document中选择一个元素
  • d3.selectAll - 在当前document中选择多个元素
  • selection.attr - 获取或设置属性值
  • selection.classed - 添加或移除CSS类
  • selection.style - 获取或设置样式属性
  • selection.property - 获取或设置行内属性
  • selection.text - 获取或设置文本内容
  • selection.html - 获取或设置innerHTML内容
  • selection.append - 创建并添加新元素
  • selection.insert - 在已存在元素前创建并添加一个新元素
  • selection.remove - 从document中移除元素
  • selection.data - 在计算相关连接时,获取或设置一组元素的数据
  • selection.enter - 为缺失的元素返回占位符
  • selection.exit - 返回不再需要的元素
  • selection.datum - 获取或设置单个元素的数据,不必计算连接
  • selection.filter - 根据数据过滤选择器
  • selection.sort - 根据数据将document中元素排序
  • selection.order - 重排document中元素以匹配选择
  • selection.on - 为交互添加或移除事件监听
  • selection.transition - 在选中的元素上开启过渡
  • selection.interrupt - 如果有过渡,立即中断当前过渡
  • selection.each - 为每个选中的元素调用一个函数
  • selection.call - 为当前的选择调用一个函数
  • selection.empty - 如果选择为空,返回true
  • selection.node - 返回选择中的第一个节点
  • selection.size - 返回选中的元素数量
  • selection.select - 选择每个选中元素的后代元素
  • selection.selectAll - 选择每个选中元素的多个后代元素
  • d3.selection - 增强选择器的原型或测试实例类型
  • d3.event - 访问用于交互的当前用户事件
  • d3.mouse - 获取指定容器与鼠标的相对位置
  • d3.touch - 获取指定容器与单点触摸的相对位置
  • d3.touches - 获取指定容器与多点触摸的相对位置

过渡

  • d3.transition - 开启一个动画过渡
  • transition.delay - 指定每个元素的延迟时间(以毫秒为单位)
  • transition.duration - 指定每个元素的持续时间(以毫秒为单位)
  • transition.ease - 指定过渡的缓动函数
  • transition.attr - 平滑地过渡到一个新的属性值
  • transition.attrTween - 在两个属性值之间平滑地过渡
  • transition.style - 平滑地过渡到一个新的样式值
  • transition.styleTween - 在两个样式属性值之间平滑地过渡
  • transition.text - 在过渡开始时设置文本内容
  • transition.tween - specify a custom tween operator to run as part of the transition.
  • transition.select - start a transition on a descendant element for each selected element.
  • transition.selectAll - start a transition on multiple descendants for each selected element.
  • transition.filter - filter a transition based on data.
  • transition.transition - when this transition ends, start another one on the same elements.
  • transition.remove - remove selected elements at the end of a transition.
  • transition.empty - returns true if the transition is empty.
  • transition.node - returns the first node in the transition.
  • transition.size - returns the number of elements in the selection.
  • transition.each - add a listener for transition end events.
  • transition.call - call a function passing in the current transition.
  • d3.ease - customize transition timing.
  • ease - a parametric easing function.
  • d3.timer - start a custom animation timer.
  • d3.timer.flush - immediately execute any zero-delay timers.
  • d3.interpolate - interpolate two values.
  • interpolate - a parametric interpolation function.
  • d3.interpolateNumber - interpolate two numbers.
  • d3.interpolateRound - interpolate two integers.
  • d3.interpolateString - interpolate two strings.
  • d3.interpolateRgb - interpolate two RGB colors.
  • d3.interpolateHsl - interpolate two HSL colors.
  • d3.interpolateLab - interpolate two Lab* colors.
  • d3.interpolateHcl - interpolate two HCL colors.
  • d3.interpolateArray - interpolate two arrays of values.
  • d3.interpolateObject - interpolate two arbitrary objects.
  • d3.interpolateTransform - interpolate two 2D matrix transforms.
  • d3.interpolateZoom - zoom and pan between two points smoothly.
  • d3.interpolators - register a custom interpolator.

数组

  • 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.extent - find 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.
  • d3.bisect - search for a value in a sorted array.
  • d3.bisectRight - search for a value in a sorted array.
  • d3.bisectLeft - search for a value in a sorted array.
  • d3.bisector - bisect using an accessor or comparator.
  • d3.shuffle - randomize the order of an array.
  • d3.permute - reorder an array of elements according to an array of indexes.
  • d3.zip - transpose a variable number of arrays.
  • d3.transpose - transpose an array of arrays.
  • d3.pairs - returns an array of adjacent pairs of elements.
  • 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.merge - merge multiple arrays into one array.
  • d3.range - generate a range of numeric values.
  • d3.nest - group array elements hierarchically.
  • 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 - evaluate the nest operator, returning an associative array.
  • nest.entries - evaluate the nest operator, returning an array of key-values tuples.
  • d3.map - a shim for ES6 maps, since objects are not hashes!
  • map.has - returns true if the map contains the specified key.
  • map.get - returns the value for the specified key.
  • map.set - sets the value for the specified key.
  • map.remove - removes the entry for specified key.
  • map.keys - returns the map’s array of keys.
  • map.values - returns the map’s array of values.
  • map.entries - returns the map’s array of entries (key-values objects).
  • map.forEach - calls the specified function for each entry in the map.
  • map.empty - returns false if the map has at least one entry.
  • map.size - returns the number of entries in the map.
  • d3.set - a shim for ES6 sets, since objects are not hashes!
  • set.has - returns true if the set contains the specified value.
  • set.add - adds the specified value.
  • set.remove - removes the specified value.
  • set.values - returns the set’s array of values.
  • set.forEach - calls the specified function for each value in the set.
  • set.empty - returns true if the set has at least one value.
  • set.size - returns the number of values in the set.

数学

  • d3.random.normal - generate a random number with a normal distribution.
  • d3.random.logNormal - generate a random number with a log-normal distribution.
  • d3.random.bates - generate a random number with a Bates distribution.
  • d3.random.irwinHall - generate a random number with an Irwin–Hall distribution.
  • d3.transform - compute the standard form of a 2D matrix transform.

加载外部资源

  • d3.xhr - request a resource using XMLHttpRequest.
  • xhr.header - set a request header.
  • xhr.mimeType - set the Accept request header and override the response MIME type.
  • xhr.response - set a response mapping function.
  • xhr.get - issue a GET request.
  • xhr.post - issue a POST request.
  • xhr.send - issue a request with the specified method and data.
  • xhr.abort - abort an outstanding request.
  • xhr.on - add an event listener for "progress", "load" or "error" events.
  • d3.text - request a text file.
  • d3.json - request a JSON blob.
  • d3.html - request an HTML document fragment.
  • d3.xml - request an XML document fragment.
  • d3.csv - request a comma-separated values (CSV) file.
  • d3.tsv - request a tab-separated values (TSV) file.

字符串格式化

  • 3.format - format a number as a string.
  • d3.formatPrefix - returns the SI prefix for the specified value and precision.
  • d3.requote - quote a string for use in a regular expression.
  • d3.round - rounds a value to some digits after the decimal point.

CSV格式化(d3.csv)

  • d3.csv - request a comma-separated values (CSV) file.
  • d3.csv.parse - parse a CSV string into objects using the header row.
  • d3.csv.parseRows - parse a CSV string into tuples, ignoring the header row.
  • d3.csv.format - format an array of objects into a CSV string.
  • d3.csv.formatRows - format an array of tuples into a CSV string.
  • d3.tsv - request a tab-separated values (TSV) file.
  • d3.tsv.parse - parse a TSV string into objects using the header row.
  • d3.tsv.parseRows - parse a TSV string into tuples, ignoring the header row.
  • d3.tsv.format - format an array of objects into a TSV string.
  • d3.tsv.formatRows - format an array of tuples into a TSV string.
  • d3.dsv - create a parser/formatter for the specified delimiter and mime type.

本地化

  • d3.locale - create a new locale using the specified strings.
  • locale.numberFormat - create a new number formatter.
  • locale.timeFormat - create a new time formatter / parser.

颜色

  • d3.rgb - specify a color in RGB space.
  • rgb.brighter - increase RGB channels by some exponential factor (gamma).
  • rgb.darker - decrease RGB channels by some exponential factor (gamma).
  • rgb.hsl - convert from RGB to HSL.
  • rgb.toString - convert an RGB color to a string.
  • d3.hsl - specify a color in HSL space.
  • hsl.brighter - increase lightness by some exponential factor (gamma).
  • hsl.darker - decrease lightness by some exponential factor (gamma).
  • hsl.rgb - convert from HSL to RGB.
  • hsl.toString - convert an HSL color to a string.
  • d3.lab - specify a color in Lab* space.
  • lab.brighter - increase lightness by some exponential factor (gamma).
  • lab.darker - decrease lightness by some exponential factor (gamma).
  • lab.rgb - convert from Lab* to RGB.
  • lab.toString - convert a Lab* color to a string.
  • d3.hcl - specify a color in HCL space.
  • hcl.brighter - increase lightness by some exponential factor (gamma).
  • hcl.darker - decrease lightness by some exponential factor (gamma).
  • hcl.rgb - convert from HCL to RGB.
  • hcl.toString - convert an HCL color to a string.

命名空间

  • d3.ns.prefix - 访问或扩展已知的XML命名空间
  • d3.ns.qualify - 限定一个前缀名称,例如"xlink:href"

内部

  • d3.functor - 创建一个返回常量的函数
  • d3.rebind - 重新绑定get/set方法到一个子类上
  • d3.dispatch - 创建一个特定的事件分发器
  • dispatch.on - 注册或注销事件监听器
  • dispatch.type - 为指定的监听器分发事件