{"id":15760544,"url":"https://github.com/xswei/d3js_doc","last_synced_at":"2025-04-08T01:35:42.754Z","repository":{"id":37359337,"uuid":"70567445","full_name":"xswei/d3js_doc","owner":"xswei","description":"D3js中文文档  D3中文 :bar_chart: :chart_with_upwards_trend: :tada:","archived":false,"fork":false,"pushed_at":"2020-10-10T10:45:36.000Z","size":8654,"stargazers_count":1961,"open_issues_count":53,"forks_count":346,"subscribers_count":49,"default_branch":"master","last_synced_at":"2025-04-01T00:34:00.088Z","etag":null,"topics":["d3","d3js","d3v4","d3v5"],"latest_commit_sha":null,"homepage":"https://d3js.org.cn/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xswei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-11T07:28:07.000Z","updated_at":"2025-03-31T08:50:17.000Z","dependencies_parsed_at":"2022-07-12T05:30:33.542Z","dependency_job_id":null,"html_url":"https://github.com/xswei/d3js_doc","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xswei%2Fd3js_doc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xswei%2Fd3js_doc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xswei%2Fd3js_doc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xswei%2Fd3js_doc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xswei","download_url":"https://codeload.github.com/xswei/d3js_doc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247761051,"owners_count":20991531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["d3","d3js","d3v4","d3v5"],"created_at":"2024-10-04T10:58:41.106Z","updated_at":"2025-04-08T01:35:42.734Z","avatar_url":"https://github.com/xswei.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub stars](https://img.shields.io/github/stars/xswei/d3js_doc.svg?style=flat-square)](https://github.com/xswei/d3js_doc/stargazers)\n[![GitHub issues](https://img.shields.io/github/issues/xswei/d3js_doc.svg?style=flat-square)](https://github.com/xswei/d3js_doc/issues)\n[![GitHub forks](https://img.shields.io/github/forks/xswei/d3js_doc.svg?style=flat-square)](https://github.com/xswei/d3js_doc/network)\n[![GitHub last commit](https://img.shields.io/github/last-commit/xswei/d3js_doc.svg?style=flat-square)](https://github.com/xswei/d3js_doc)\n\n# D3: Data-Driven Documents\n\n\u003ca href=\"https://d3js.org\"\u003e\u003cimg src=\"https://d3js.org/logo.svg\" align=\"left\" hspace=\"10\" vspace=\"10\"\u003e\u003c/a\u003e\n\n**D3** (或者叫 **D3.js** )是一个基于 `web` 标准的 **JavaScript** 可视化库。 `D3` 可以借助 `SVG`, `Canvas` 以及 `HTML` 将你的数据生动的展现出来。 `D3` 结合了强大的可视化交互技术以及数据驱动 `DOM` 的技术，让你可以借助于现代浏览器的强大功能自由的对数据进行可视化。 \n\n\u003cbr\u003e\n\n## 资源\n\n* [最新发行版](https://github.com/d3/d3/releases)\n\n#### 文档\n\n* [API 文档 ( 中文版 )](https://github.com/xswei/d3js_doc/tree/master/API_Reference/API.md?_blank)\n* [API 文档 ( 英文版 )](https://github.com/d3/d3/blob/master/API.md?_blank)\n* [d3-queue(v5.x.x中被移除)](https://github.com/xswei/d3js_doc/blob/master/API_Reference/V4.md)\n* [d3-request(v5.x.x中被移除)](https://github.com/xswei/d3js_doc/blob/master/API_Reference/V4.md)\n* [v3 与 v4](https://github.com/xswei/d3js_doc/tree/master/API_Reference/CHANGES.md)\n\n#### 示例\n\n* [官方画廊](https://github.com/d3/d3/wiki/Gallery?_blank)\n* [搜索示例](http://blockbuilder.org/search#)\n* [Mike Bostock 的示例](https://bl.ocks.org/mbostock?_blank)\n\n#### 社区\n\n* [d3.js on Stack Overflow](https://stackoverflow.com/questions/tagged/d3.js?_blank)\n* [d3.js Google Group](http://groups.google.com/group/d3-js?_blank)\n* [插件](https://github.com/d3/d3/wiki/Plugins?_blank)\n* [图说数据](http://www.graphvis.cn/)\n* [GraphVis](https://gitee.com/baopengdu/GraphVis)\n\n#### 教程\n\n* [教程](https://github.com/d3/d3/wiki/Tutorials?_blank)\n* [基于 d3js 的图论](https://mrpandey.github.io/d3graphTheory/index.html)\n* [理解数据绑定](https://bost.ocks.org/mike/join/?_blank)\n* [数据绑定示例](https://bl.ocks.org/mbostock/3808218?_blank)\n* [D3 in Depth](https://www.d3indepth.com/)\n\n## 安装\n\n如果使用 `npm`，则可以通过 `npm install d3` 来安装。 此外还可以下载 [最新版](https://unpkg.com/d3/build/)， 最新版支持 `AMD`、`CommonJS` 以及基础标签引入形式。 你也可以直接从 [d3js.org](https://d3js.org)， [CDNJS](https://cdnjs.com/libraries/d3), 或者 [unpkg](https://unpkg.com/d3/) 加载. 比如：\n\n```js\n\u003cscript src=\"https://d3js.org/d3.v6.js\"\u003e\u003c/script\u003e\n```\n\n压缩版：\n\n```js\n\u003cscript src=\"https://d3js.org/d3.v5.min.js\"\u003e\u003c/script\u003e\n```\n\n你也可以单独使用 `d3` 中的某个模块， 比如单独使用 [d3-selection](https://github.com/d3/d3-selection)：\n\n```js\n\u003cscript src=\"https://d3js.org/d3-selection.v1.js\"\u003e\u003c/script\u003e\n\n```\n\nD3基于 [ES2015 modules](http://www.2ality.com/2014/09/es6-modules-final.html) 开发。  可以使用 `Rollup`， `webpack` 或者其他你偏爱的打包工具进行构建。 在一个符合 ES2015 的应用中导入 `d3` 或者 `d3` 的某些模块：\n\n```js\nimport { scaleLinear } from \"d3-scale\";\n```\n\n或者导入 `d3` 的全部功能并且设置命名空间 (这里是 `d3`)：\n\n```js\nimport * as d3 from \"d3\";\n```\n\n在 `Nodejs` 环境中：\n\n```js\nvar d3 = require(\"d3\");\n```\n\n你也可以导入多个模块然后将这些模块集合到 `d3` 对象中， 此时使用 [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)：\n\n```js\nvar d3 = Object.assign({}, require(\"d3-format\"), require(\"d3-geo\"), require(\"d3-geo-projection\"));\n```\n\n## 支持环境\n\n`D3 5.0` 支持最新浏览器，比如 `Chrome`，`Edge`，`Firefox` 以及 `Safari`。`D3 v4` 以及之前的版本支持 `IE 9` 以上的版本。`D3` 的一部分功能能在旧版的浏览器中运行，因为 `D3` 的核心功能对浏览器的要求比较低。例如 `d3-selection` 使用 `Level 1` 级 [Selectors API](http://www.w3.org/TR/selectors-api/)，但是可以通过预先加载 [Sizzle](http://sizzlejs.com/) 来实现兼容。现代浏览器对 [SVG](http://www.w3.org/TR/SVG/) 和 [CSS3 Transition](http://www.w3.org/TR/css3-transitions/) 的支持比较好。所以 `D3` 不支持更低级别的浏览器，如果你的浏览器不支持这些标准，那么对不起了，大兄弟。\n\n`D3` 也可以运行在 [Node](http://nodejs.org/) 和 [Web workers](http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html) 中. 在 `Node` 环境中使用 `DOM` 的时候，必须要提供自己的 `DOM` 实现。推荐使用 [JSDOM](https://github.com/tmpvar/jsdom)，为了避免定义全局 `document`，建议将 `DOM` 传递给 `d3.select` 或者将 `NodeList` 传递给 `d3.selectAll`，如下：\n\n```js\nvar d3 = require(\"d3\"),\n    jsdom = require(\"jsdom\");\n\nvar document = jsdom.jsdom(),\n    svg = d3.select(document.body).append(\"svg\");\n```\n在支持 [ES 模块化](http://exploringjs.com/es6/ch_modules.html) 的环境中，你可以将 `d3` 作为一个命名空间来导入 `D3` 的全部功能：\n\n```js\nimport * as d3 from \"d3\";\n```\n如果你不想导入全部模块，则分配命名空间的时候要和 `d3` 进行区分：\n\n```js\nimport * as d3 from \"d3\";\nimport * as d3GeoProjection from \"d3-geo-projection\";\n```\n出于这个原因，应该优先考虑 `D3` 模块中的原有变量名，可以按需导入：\n\n```js\nimport {select, selectAll} from \"d3-selection\";\nimport {geoPath} from \"d3-geo\";\nimport {geoPatterson} from \"d3-geo-projection\";\n```\n如果你使用打包工具，则确保已经配置好正确的入口，可以参考 [resolve.mainFields](https://webpack.js.org/configuration/resolve/#resolve-mainfields)\n\n## Changes in D3 6.0 \n\n[2020.08.26发布](https://github.com/d3/d3/releases/tag/v6.0.0)\n\n*这个文档只包含主要更新。 次要更新以及修订请参阅 [发布记录](https://github.com/d3/d3/releases).*\n\nD3 现在 **采用原生集合** (Map 和 Set) 并且 **接受迭代**。[d3.group 和 d3.rollup](https://observablehq.com/@d3/d3-group) 是强大的用来替代 d3.nest 的聚合函数，并且能与 [d3-hierarchy](https://observablehq.com/d/9a453665f405eebf) 以及 d3-selection 很好的结合。在 d3-array 中也新增了很多辅助工具，比如 [d3.greatest](https://observablehq.com/@d3/d3-least)，[d3.quickselect](https://observablehq.com/@d3/d3-quickselect)，以及 [d3.fsum](https://observablehq.com/@d3/d3-fsum).\n\nD3 现在 **直接将事件传递给监听器**，替代了全局 d3.event 并将 D3 与普通 JavaScript 和大多数其他框架内联。\n\n**d3-delaunay** (基于 Vladimir Agafonkin 的 [Delaunator](https://github.com/mapbox/delaunator)) 替代了 d3-voronoi, 获得了极大的性能提升，鲁棒性以及 [搜索](https://observablehq.com/@d3/delaunay-find)。新的 [d3-geo-voronoi](https://github.com/Fil/d3-geo-voronoi) 可以用于球面地理数据计算! **d3-random** 进行了 [极大的扩展](https://github.com/d3/d3-random/blob/master/README.md) 并且包含了快速 [线性同余生成器](https://observablehq.com/@d3/d3-randomlcg) 用于随机性。 **d3-chord** 包含了新的布局以用于 [有向](https://observablehq.com/@d3/directed-chord-diagram) 和转置弦图。 **d3-scale** 新增了[径向缩放](https://observablehq.com/@d3/radial-stacked-bar-chart-ii) 类型。\n\n… 以及其他各种小的改进。 [超过 450 个例子](https://observablehq.com/@d3/gallery) 已经升级到 D3 6.0!\n\n### d3-array\n\n* 接受迭代.\n* 新增 [d3.group](https://github.com/d3/d3-array/blob/master/README.md#group).\n* 新增 [d3.groups](https://github.com/d3/d3-array/blob/master/README.md#groups).\n* 新增 [d3.index](https://github.com/d3/d3-array/blob/master/README.md#index).\n* 新增 [d3.indexes](https://github.com/d3/d3-array/blob/master/README.md#indexes).\n* 新增 [d3.rollup](https://github.com/d3/d3-array/blob/master/README.md#rollup).\n* 新增 [d3.rollups](https://github.com/d3/d3-array/blob/master/README.md#rollups).\n* 新增 [d3.maxIndex](https://github.com/d3/d3-array/blob/master/README.md#maxIndex).\n* 新增 [d3.minIndex](https://github.com/d3/d3-array/blob/master/README.md#minIndex).\n* 新增 [d3.greatest](https://github.com/d3/d3-array/blob/master/README.md#greatest).\n* 新增 [d3.greatestIndex](https://github.com/d3/d3-array/blob/master/README.md#greatestIndex).\n* 新增 [d3.least](https://github.com/d3/d3-array/blob/master/README.md#least).\n* 新增 [d3.leastIndex](https://github.com/d3/d3-array/blob/master/README.md#leastIndex).\n* 新增 [d3.bin](https://github.com/d3/d3-array/blob/master/README.md#bin).\n* 新增 [d3.count](https://github.com/d3/d3-array/blob/master/README.md#count).\n* 新增 [d3.cumsum](https://github.com/d3/d3-array/blob/master/README.md#cumsum).\n* 新增 [d3.fsum](https://github.com/d3/d3-array/blob/master/README.md#fsum).\n* 新增 [d3.Adder](https://github.com/d3/d3-array/blob/master/README.md#Adder).\n* 新增 [d3.quantileSorted](https://github.com/d3/d3-array/blob/master/README.md#quantileSorted).\n* 新增 [d3.quickselect](https://github.com/d3/d3-array/blob/master/README.md#quickselect).\n* 新增 [*bisector*.center](https://github.com/d3/d3-array/blob/master/README.md#bisector_center).\n* [d3.cross](https://github.com/d3/d3-array/blob/master/README.md#cross) 允许两个以上的迭代.\n* [d3.quantile](https://github.com/d3/d3-array/blob/master/README.md#quantile) 接受未排序的输入.\n* 修复了 *array*.sort 在 Safari 上的缺陷.\n* 修复了直方图分箱阈值忽略 `NaN` 输入的缺陷.\n* 修复了 [d3.ticks](https://github.com/d3/d3-array/blob/master/README.md#ticks) 不返回域外的刻度的缺陷.\n* 提高 [d3.median](https://github.com/d3/d3-array/blob/master/README.md#median) 的性能.\n\n参考 https://observablehq.com/@d3/d3-array-2-0 获取更多详情.\n\n### d3-brush\n\n* 新增 [*event*.mode](https://github.com/d3/d3-brush/blob/master/README.md#brush-events).\n* [*brush*.on](https://github.com/d3/d3-brush/blob/master/README.md#brush_on) 直接传递 *event* 给监听器.\n* 改进多点触控交互.\n\n### d3-chord\n\n* 新增 [d3.chordDirected](https://github.com/d3/d3-chord/blob/master/README.md#chordDirected).\n* 新增 [d3.chordTranspose](https://github.com/d3/d3-chord/blob/master/README.md#chordTranspose).\n* 新增 [d3.ribbonArrow](https://github.com/d3/d3-chord/blob/master/README.md#ribbonArrow).\n* 新增 [*ribbon*.padAngle](https://github.com/d3/d3-chord/blob/master/README.md#ribbon_padAngle).\n* 新增 [*ribbon*.sourceRadius](https://github.com/d3/d3-chord/blob/master/README.md#ribbon_sourceRadius).\n* 新增 [*ribbon*.targetRadius](https://github.com/d3/d3-chord/blob/master/README.md#ribbon_targetRadius).\n\n### d3-delaunay\n\n* 新增 [d3.Delaunay](https://github.com/d3/d3-delaunay/blob/master/README.md).\n\n### d3-drag\n\n* [*drag*.on](https://github.com/d3/d3-drag/blob/master/README.md#drag_on) 直接传递 *event* 给监听器.\n\n### d3-force\n\n* [*simulation*.tick](https://github.com/d3/d3-force/blob/master/README.md#simulation_tick) 新增 *iterations* 参数.\n* 新增 [*forceCenter*.strength](https://github.com/d3/d3-force/blob/master/README.md#center_strength).\n* 新增 [*forceSimulation*.randomSource](https://github.com/d3/d3-force/blob/master/README.md#simulation_randomSource).\n* 所有内置的力模型现在都是完全确定的 (包括“抖动的”重合节点).\n* 通过半径的偏移来改进默认的 phyllotaxis 布局.\n* 改进边引用未知节点时的错误消息.\n* [*force*.initialize](https://github.com/d3/d3-force/blob/master/README.md#force_initialize) 被改为传递一个随机的源.\n* 修复初始化位置固定的节点的缺陷.\n\n### d3-format\n\n* 将默认的负号改为负号 (−) 而不是连字减号 (-).\n* 修正大于或等于 1e21 的数字的十进制格式 `d`.\n\n### d3-geo\n\n* 修复一些退化多边形的裁剪.\n\n### d3-hierarchy\n\n* 接受迭代.\n* 新增 [*node*[Symbol.iterator]](https://github.com/d3/d3-hierarchy/blob/master/README.md#node_iterator); 层次结构现在是可迭代的.\n* 新增 [*node*.find](https://github.com/d3/d3-hierarchy/blob/master/README.md#node_find).\n* [*node*.each](https://github.com/d3/d3-hierarchy/blob/master/README.md#node_each) 修改为传递遍历的索引.\n* [*node*.eachAfter](https://github.com/d3/d3-hierarchy/blob/master/README.md#node_eachAfter) 修改为传递遍历的索引.\n* [*node*.eachBefore](https://github.com/d3/d3-hierarchy/blob/master/README.md#node_eachBefore) 修改为传递遍历的索引.\n* 修复 [d3.packSiblings](https://github.com/d3/d3-hierarchy/blob/master/README.md#packSiblings).\n* 修复 [d3.treemapBinary](https://github.com/d3/d3-hierarchy/blob/master/README.md#treemapBinary) 被零除的缺陷.\n* 修复 [d3.treemapResquarify](https://github.com/d3/d3-hierarchy/blob/master/README.md#treemapResquarify) 被零除的缺陷.\n\n### d3-interpolate\n\n* 新增 [*interpolateZoom*.rho](https://github.com/d3/d3-interpolate/blob/master/README.md#interpolateZoom_rho). (#25)\n* 允许 [d3.piecewise](https://github.com/d3/d3-interpolate/blob/master/README.md#piecewise) 默认使用 d3.interpolate. #90\n* [d3.interpolateTransformCss](https://github.com/d3/d3-interpolate/blob/master/README.md#interpolateTransformCss) 被修改为使用 DOMMatrix 并需要绝对单位. #83\n\n### d3-quadtree\n\n* 修正了坐标偏离到巨大值时的无限循环.\n\n### d3-random\n\n* 新增 [d3.randomLcg](https://github.com/d3/d3-random/blob/master/README.md#randomLcg).\n* 新增 [d3.randomGamma](https://github.com/d3/d3-random/blob/master/README.md#randomGamma).\n* 新增 [d3.randomBeta](https://github.com/d3/d3-random/blob/master/README.md#randomBeta).\n* 新增 [d3.randomWeibull](https://github.com/d3/d3-random/blob/master/README.md#randomWeibull).\n* 新增 [d3.randomCauchy](https://github.com/d3/d3-random/blob/master/README.md#randomCauchy).\n* 新增 [d3.randomLogistic](https://github.com/d3/d3-random/blob/master/README.md#randomLogistic).\n* 新增 [d3.randomPoisson](https://github.com/d3/d3-random/blob/master/README.md#randomPoisson).\n* 新增 [d3.randomInt](https://github.com/d3/d3-random/blob/master/README.md#randomInt).\n* 新增 [d3.randomBinomial](https://github.com/d3/d3-random/blob/master/README.md#randomBinomial).\n* 新增 [d3.randomGeometric](https://github.com/d3/d3-random/blob/master/README.md#randomGeometric).\n* 新增 [d3.randomPareto](https://github.com/d3/d3-random/blob/master/README.md#randomPareto).\n* 新增 [d3.randomBernoulli](https://github.com/d3/d3-random/blob/master/README.md#randomBernoulli).\n* 允许 [d3.randomBates](https://github.com/d3/d3-random/blob/master/README.md#randomBates) 取小数 *n*.\n* 允许 [d3.randomIrwinHall](https://github.com/d3/d3-random/blob/master/README.md#randomIrwinHall) 取小数 *n*.\n* 默认的源中不再包含 Math.random.\n\n感谢 @Lange, @p-v-d-Veeken, @svanschooten, @Parcly-Taxel 和 @jrus 的贡献s!\n\n### d3-scale\n\n* 接受迭代.\n* 新增 [*diverging*.rangeRound](https://github.com/d3/d3-scale/blob/master/README.md#diverging_rangeRound).\n* 新增 [*sequential*.range](https://github.com/d3/d3-scale/blob/master/README.md#sequential_range) (为了与 d3-axis 兼容).\n* 新增 [*sequential*.rangeRound](https://github.com/d3/d3-scale/blob/master/README.md#sequential_rangeRound).\n* 新增 [*sequentialQuantile*.quantiles](https://github.com/d3/d3-scale/blob/master/README.md#sequentialQuantile_quantiles).\n* 新增 [d3.scaleRadial](https://github.com/d3/d3-scale/blob/master/README.md#radial-scales).\n* [*diverging*.range](https://github.com/d3/d3-scale/blob/master/README.md#diverging_range) 现在可以用来设置插值.\n* [*sequential*.range](https://github.com/d3/d3-scale/blob/master/README.md#sequential_range) 现在可以用来设置插值.\n* [d3.scaleDiverging](https://github.com/d3/d3-scale/blob/master/README.md#diverging-scales) 现在可以接受一个范围数组代替一个插值器.\n* [d3.scaleSequential](https://github.com/d3/d3-scale/blob/master/README.md#sequential-scales) 现在可以接受一个范围数组代替一个插值器.\n* 修复了 [*continuous*.nice](https://github.com/d3/d3-scale/blob/master/README.md#continuous_nice).\n* 修复了 [*log*.ticks](https://github.com/d3/d3-scale/blob/master/README.md#log_ticks).\n* 修复了 [*log*.ticks](https://github.com/d3/d3-scale/blob/master/README.md#log_ticks). #44\n* 修复了 [*scale*.clamp](https://github.com/d3/d3-scale/blob/master/README.md#continuous_clamp) 在 [sequential quantile scales](https://github.com/d3/d3-scale/blob/master/README.md#scaleSequentialQuantile) 的问题. 多谢, @Fil!\n* 修复了 [*scale*.clamp](https://github.com/d3/d3-scale/blob/master/README.md#continuous_clamp) 用于域值大于范围值的连续缩放.\n* 修复了 [diverging scales](https://github.com/d3/d3-scale/blob/master/README.md#diverging-scales) 在降序时的问题.\n* 从 [*time*.ticks](https://github.com/d3/d3-scale/blob/master/README.md#time_ticks) 和 [*time*.nice](https://github.com/d3/d3-scale/blob/master/README.md#time_nice) 中移除 *step* 参数.\n\n### d3-selection\n\n* 新增 [*selection*.selectChild](https://github.com/d3/d3-selection/blob/master/README.md#selection_selectChild).\n* 新增 [*selection*.selectChildren](https://github.com/d3/d3-selection/blob/master/README.md#selection_selectChildren).\n* 新增 [d3.pointer](https://github.com/d3/d3-selection/blob/master/README.md#pointer).\n* 新增 [d3.pointers](https://github.com/d3/d3-selection/blob/master/README.md#pointers).\n* 新增 *selection*[Symbol.iterator]; selections are now iterable!\n* [*selection*.data](https://github.com/d3/d3-selection/blob/master/README.md#selection_data) 接受迭代.\n* [d3.selectAll](https://github.com/d3/d3-selection/blob/master/README.md#selectAll) 接受迭代.\n* [*selection*.on](https://github.com/d3/d3-selection/blob/master/README.md#selection_on) 被修改为直接传递 *event* 给监听器.\n* 从 *selection*.on 监听器中移除索引和组!\n* 移除 d3.event!\n* 移除 d3.mouse.\n* 移除 d3.touch.\n* 移除 d3.touches.\n* 移除 d3.customEvent.\n* 移除 d3.clientPoint.\n* 移除 d3.sourceEvent.\n* 修复了 *selection*.merge(*transition*) 报错问题.\n\n所有的修改请参考 https://observablehq.com/@d3/d3-selection-2-0.\n\n### d3-shape\n\n* 接受迭代.\n* 新增 [d3.line](https://github.com/d3/d3-shape/blob/master/README.md#line)(*x*, *y*) 速写.\n* 新增 [d3.area](https://github.com/d3/d3-shape/blob/master/README.md#area)(*x*, *y0*, *y1*) 速写.\n* 新增 [d3.symbol](https://github.com/d3/d3-shape/blob/master/README.md#symbol)(*type*, *size*) 速写.\n\n### d3-time-format\n\n* 新增 ISO 8601 “week year” (`%G` and `%g`).\n\n### d3-timer\n\n* 修复了 [*interval*.restart](https://github.com/d3/d3-timer/blob/master/README.md#timer_restart) 作为间隔重新启动的问题.\n\n### d3-transition\n\n* 新增 [*transition*.easeVarying](https://github.com/d3/d3-transition/blob/master/README.md#transition_easeVarying).\n* 新增 *transition*[Symbol.iterator]; transitions are now iterable.\n* 修复了 [*selection*.transition](https://github.com/d3/d3-transition/blob/master/README.md#selection_transition) 未找到时的错误.\n* 修复了 [*transition*.end](https://github.com/d3/d3-transition/blob/master/README.md#transition_end) 选择集为空时候的解析问题.\n\n### d3-zoom\n\n* 新增 [*zoom*.tapDistance](https://github.com/d3/d3-zoom/blob/master/README.md#zoom_tapDistance).\n* [*zoom*.on](https://github.com/d3/d3-zoom/blob/master/README.md#zoom_on) 直接传递 *event* 给监听器.\n* 修改默认的 [*zoom*.filter](https://github.com/d3/d3-zoom/blob/master/README.md#zoom_filter) 如果按下控制键，过滤器观察 *wheel* 事件.\n* 修改默认的 [*zoom*.wheelDelta](ttps://github.com/d3/d3-zoom/blob/master/README.md#zoom_wheelDelta) 如果按下控制键，缩放更快.\n* 不要设置触控动作:无.\n* 升级到 [d3-selection 2](https://observablehq.com/@d3/d3-selection-2-0).\n\n### Breaking Changes\n\nD3 6.0 包含了一些非向后兼容的改变.\n\n* 移除了 [d3.event](https://observablehq.com/d/f91cccf0cad5e9cb#events).\n* 修改 [*selection*.on](https://observablehq.com/d/f91cccf0cad5e9cb#events) 直接将 *event* 传递给监听器.\n* 修改 [*transition*.on](https://observablehq.com/d/f91cccf0cad5e9cb#events) 直接将 *event* 传递给监听器.\n* 修改 [*brush*.on](https://observablehq.com/d/f91cccf0cad5e9cb#event_brush) 直接将 *event* 传递给监听器.\n* 修改 [*drag*.on](https://observablehq.com/d/f91cccf0cad5e9cb#event_drag) 直接将 *event* 传递给监听器.\n* 修改 [*zoom*.on](https://observablehq.com/d/f91cccf0cad5e9cb#event_zoom) 直接将 *event* 传递给监听器.\n* 移除了 d3.mouse; 使用 [d3.pointer](https://observablehq.com/d/f91cccf0cad5e9cb#pointer).\n* 移除了 d3.touch; 使用 [d3.pointer](https://observablehq.com/d/f91cccf0cad5e9cb#pointer).\n* 移除了 d3.touches; 使用 [d3.pointers](https://observablehq.com/d/f91cccf0cad5e9cb#pointer).\n* 移除了 d3.clientPoint; 使用 [d3.pointer](https://observablehq.com/d/f91cccf0cad5e9cb#pointer).\n* 移除了 d3.voronoi; 使用 [d3.Delaunay](https://observablehq.com/d/f91cccf0cad5e9cb#delaunay).\n* 移除了 d3.nest; 使用 [d3.group](https://observablehq.com/d/f91cccf0cad5e9cb#group) and [d3.rollup](https://observablehq.com/d/f91cccf0cad5e9cb#group).\n* 移除了 d3.map; 使用 [Map](https://observablehq.com/d/f91cccf0cad5e9cb#collection).\n* 移除了 d3.set; 使用 [Set](https://observablehq.com/d/f91cccf0cad5e9cb#collection).\n* 移除了 d3.keys; 使用 [Object.keys](https://observablehq.com/d/f91cccf0cad5e9cb#collection).\n* 移除了 d3.values; 使用 [Object.values](https://observablehq.com/d/f91cccf0cad5e9cb#collection).\n* 移除了 d3.entries; 使用 [Object.entries](https://observablehq.com/d/f91cccf0cad5e9cb#collection).\n* 重命名 d3.histogram 为 [d3.bin](https://observablehq.com/d/f91cccf0cad5e9cb#bin).\n* 重命名 d3.scan 为 [d3.leastIndex](https://observablehq.com/d/f91cccf0cad5e9cb#leastIndex).\n* 修改 [d3.interpolateTransformCss](https://observablehq.com/d/f91cccf0cad5e9cb#interpolateTransformCss), 需要绝对单位.\n* 修改 [d3.format](https://observablehq.com/d/f91cccf0cad5e9cb#minus) 负数, 默认设置为减号而不是连字符减号.\n\nD3 现在需要运行在支持 [ES2015](http://www.ecma-international.org/ecma-262/6.0/) 的浏览器上. 对于不支持的浏览器，你需要自己做转义.\n\n最后, 对 [Bower](https://bower.io) 的支持被取消了; D3 现在只在 npm 和 GitHub 上发布.\n\n参考我们的 [升级指南](https://observablehq.com/d/f91cccf0cad5e9cb) 获取升级帮助.\n\n#### 5.x.x 大版本改动\n\n`D3 5.0` 引入了很少的非向后兼容的改变。\n\n`D3 5.0` 现在采用的是 [Promises](https://developer.mozilla.org/docs/Web/JavaScript/Guide/Using_promises) 来替代异步回调加载数据。 `Promises` 简化了异步代码结构，尤其是现代浏览器支持 [async 和 await](https://javascript.info/async-await) 操作。(在 [Observable](https://beta.observablehq.com) 中参考 [promises 介绍](https://beta.observablehq.com/@mbostock/introduction-to-promises))。例如在 `V4` 中使用如下方式加载 `CSV` 文件：\n\n```js\nd3.csv(\"file.csv\", function(error, data) {\n  if (error) throw error;\n  console.log(data);\n});\n```\n\n在 `V5` 中基于 `Promises` 实现：\n\n```js\nd3.csv(\"file.csv\").then(function(data) {\n  console.log(data);\n});\n```\n\n要注意的是不需要重新抛出错误，因为 `Promise` 会自动 `reject`，并且需要的话可以使用 *promise*.catch。使用 `await` 的话代码会更简单：\n\n```js\nconst data = await d3.csv(\"file.csv\");\nconsole.log(data);\n```\n\n由于采用了 `promises`，`D3 5.0` 使用 [Fetch API](https://fetch.spec.whatwg.org/) 来代替 [XMLHttpRequest](https://developer.mozilla.org/docs/Web/API/XMLHttpRequest)：[d3-request](https://github.com/d3/d3-request) 模块由 [d3-fetch](https://github.com/d3/d3-fetch) 替代。`Fetch` 支持许多强大的特性，比如 [响应流](https://beta.observablehq.com/@mbostock/streaming-shapefiles)。`D3 5.0` 也不再使用 [d3-queue](https://github.com/d3/d3-queue)，取而代之推荐 [Promise.all](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) 来处理批量异步任务，或者使用辅助库比如 [p-queue](https://github.com/sindresorhus/p-queue) 来 [控制并发](https://beta.observablehq.com/@mbostock/hello-p-queue)。\n\n`D3 5.0` 不再提供 `d3.schemeCategory20*` 颜色方案。因为这些颜色有缺陷，可能会错误的暗示数据中的关系：色调相近的可能被认为是一个分组，而亮度可能被错认为是排序。作为替换，`D3 5.0` 使用 [d3-scale-chromatic](https://github.com/d3/d3-scale-chromatic)，它实现了 `ColorBrewer` 的方案设计，包括 [categorical](https://github.com/d3/d3-scale-chromatic/blob/master/README.md#categorical)， [diverging](https://github.com/d3/d3-scale-chromatic/blob/master/README.md#diverging)，[sequential single-hue](https://github.com/d3/d3-scale-chromatic/blob/master/README.md#sequential-single-hue) 和 [sequential multi-hue](https://github.com/d3/d3-scale-chromatic/blob/master/README.md#sequential-multi-hue) 方案。这些颜色方案在连续式和分散式都是可用的。\n\n`D3 5.0` 提供了通过 [d3-contour](https://github.com/d3/d3-contour) 实现的 [marching squares(生成二维轮廓的算法)](https://beta.observablehq.com/@mbostock/d3-contour-plot) 和 [density estimation(密度估计)](https://beta.observablehq.com/@mbostock/d3-density-contours). 并且添加了两个新的 [d3-selection](https://github.com/d3/d3-selection)  方法：[*selection*.clone](https://github.com/d3/d3-selection/blob/master/README.md#selection_clone) 用来克隆已选择的节点，[d3.create](https://github.com/d3/d3-selection/blob/master/README.md#create) 用来创建分离的元素。 [Geographic projections](https://github.com/d3/d3-geo) 也支持  [*projection*.angle](https://github.com/d3/d3-geo/blob/master/README.md#projection_angle)，一种由 **Philippe Rivière** 提出的梦幻般的新的多面体投影。\n\n最后，`D3 5.0` 的 [package.json](https://github.com/d3/d3/blob/master/package.json) 不再引用依赖的精确版本，解决了重复安装 `D3` 模块的问题。\n\n## 本地开发\n\n由于浏览器的安全策略，不能直接读取本地文件。在本地开发的时候，必须要运行一个服务器环境而不是使用 `file://`, 推荐使用 `Nodejs` 的[http-server](https://www.npmjs.com/package/http-server)，安装方法:\n\n```js\nnpm install -g http-server\n```\n\n运行:\n\n```js\nhttp-server \u0026 \n\n```\n\n然后会在当前目录启动一个 http://localhost:8080 的服务。\n\n### 营养跟不上了快给我来瓶冰阔乐\n\n\u003cimg src=\"https://github.com/xswei/d3js_doc/blob/master/img/weichat-donate.png\" width=\"200\" align=center /\u003e\n\n### 翻译说明\n\n每个子仓库中包含三个 `.md` 文件：\n\n- *README.md* 文件是翻译后的中文版\n- *README_EN.md* 文件是翻译时参照的英文版\n- *README_ORIGIN.md* 文件是源仓库文档\n\n更新时，首先将 *README_ORIGIN.md* 与官网文档进行同步，然后将 *README_EN.md* 和 *README_ORIGIN.md* 进行比对， 将 `diff` 更新至 *README.md*，同时将 *README_EN.md* 与 *README_ORIGIN.md* 进行同步。\n\n### 版权说明\n\n\u003ca rel=\"license\" href=\"https://creativecommons.org/licenses/by-nc/4.0/deed.zh\"\u003e\u003cimg alt=\"Creative Commons License\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png\" /\u003e\u003c/a\u003e\n\n### star 趋势\n\n[![Stargazers over time](https://starchart.cc/xswei/d3js_doc.svg)](https://starchart.cc/xswei/d3js_doc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxswei%2Fd3js_doc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxswei%2Fd3js_doc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxswei%2Fd3js_doc/lists"}