# d3-shape
Visualizations typically consist of discrete graphical marks, such as [symbols](#symbols), [arcs](#arcs), [lines](#lines) and [areas](#areas). While the rectangles of a bar chart may be easy enough to generate directly using [SVG](http://www.w3.org/TR/SVG/paths.html#PathData) or [Canvas](http://www.w3.org/TR/2dcontext/#canvaspathmethods), other shapes are complex, such as rounded annular sectors and centripetal Catmull–Rom splines. This module provides a variety of shape generators for your convenience.
As with other aspects of D3, these shapes are driven by data: each shape generator exposes accessors that control how the input data are mapped to a visual representation. For example, you might define a line generator for a time series by [scaling](https://github.com/d3/d3-scale) fields of your data to fit the chart:
```js
const line = d3.line()
.x(d => x(d.date))
.y(d => y(d.value));
```
This line generator can then be used to compute the `d` attribute of an SVG path element:
```js
path.datum(data).attr("d", line);
```
Or you can use it to render to a Canvas 2D context:
```js
line.context(context)(data);
```
For more, read [Introducing d3-shape](https://medium.com/@mbostock/introducing-d3-shape-73f8367e6d12).
## Installing
If you use NPM, `npm install d3-shape`. Otherwise, download the [latest release](https://github.com/d3/d3-shape/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-shape.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
```html
<script src="https://d3js.org/d3-path.v2.min.js"></script>
<script src="https://d3js.org/d3-shape.v2.min.js"></script>
<script>
const line = d3.line();
</script>
```
## API Reference
* [Arcs](#arcs)
* [Pies](#pies)
* [Lines](#lines)
* [Areas](#areas)
* [Curves](#curves)
* [Custom Curves](#custom-curves)
* [Links](#links)
* [Symbols](#symbols)
* [Custom Symbol Types](#custom-symbol-types)
* [Stacks](#stacks)
Note: all the methods that accept arrays also accept iterables and convert them to arrays internally.
### Arcs
[<img alt="Pie Chart" src="https://raw.githubusercontent.com/d3/d3-shape/master/img/pie.png" width="295" height="295">](http://bl.ocks.org/mbostock/8878e7fd82034f1d63cf)[<img alt="Donut Chart" src="https://raw.githubusercontent.com/d3/d3-shape/master/img/donut.png" width="295" height="295">](http://bl.ocks.org/mbostock/2394b23da1994fc202e1)
The arc generator produces a [circular](https://en.wikipedia.org/wiki/Circular_sector) or [annular](https://en.wikipedia.org/wiki/Annulus_\(mathematics\)) sector, as in a pie or donut chart. If the difference between the [start](#arc_startAngle) and [end](#arc_endAngle) angles (the *angular span*) is greater than [τ](https://en.wikipedia.org/wiki/Turn_\(geometry\)#Tau_proposal), the arc generator will produce a complete circle or annulus. If it is less than τ, arcs may have [rounded corners](#arc_cornerRadius) and [angular padding](#arc_padAngle). Arcs are always centered at ⟨0,0⟩; use a transform (see: [SVG](http://www.w3.org/TR/SVG/coords.html#TransformAttribute), [Canvas](http://www.w3.org/TR/2dcontext/#transformations)) to move the arc to a different position.
See also the [pie generator](#pies), which computes the necessary angles to represent an array of data as a pie or donut chart; these angles can then be passed to an arc generator.
<a name="arc" href="#arc">#</a> d3.<b>arc</b>() · [Source](https://github.com/d3/d3-shape/blob/master/src/arc.js)
Constructs a new arc generator with the default settings.
<a name="_arc" href="#_arc">#</a> <i>arc</i>(<i>arguments…</i>) · [Source](https://github.com/d3/d3-shape/blob/master/src/arc.js)
Generates an arc for the given *arguments*. The *arguments* are arbitrary; they are simply propagated to the arc generator’s accessor functions along with the `this` object. For example, with the default settings, an object with radii and angles is expected:
```js
const arc = d3.arc();
arc({
innerRadius: 0,
outerRadius: 100,
startAngle: 0,
endAngle: Math.PI / 2
}); // "M0,-100A100,100,0,0,1,100,0L0,0Z"
```
If the radii and angles are instead defined as constants, you can generate an arc without any arguments:
```js
const arc = d3.arc()
.innerRadius(0)
.outerRadius(100)
.startAngle(0)
.endAngle(Math.PI / 2);
arc(); // "M0,-100A100,100,0,0,1,100,0L0,0Z"
```
If the arc generator has a [context](#arc_context), then the arc is rendered to this context as a sequence of [path method](http://www.w3.org/TR/2dcontext/#canvaspathmethods) calls and this function returns void. Otherwise, a [path data](http://www.w3.org/TR/SVG/paths.html#PathData) string is returned.
<a name="arc_centroid" href="#arc_centroid">#</a> <i>arc</i>.<b>centroid</b>(<i>arguments…</i>) · [Source](https://github.com/d3/d3-shape/blob/master/src/arc.js)
Computes the midpoint [*x*, *y*] of the center line of the arc that would be [generated](#_arc) by the given *arguments*. The *arguments* are arbitrary; they are simply propagated to the arc generator’s accessor functions along with the `this` object. To be consistent with the generated arc, the accessors must be deterministic, *i.e.*, return the same value given the same arguments. The midpoint is defined as ([startAngle](#arc_startAngle) + [endAngle](#arc_endAngle)) / 2 and ([innerRadius](#arc_innerRadius) + [outerRadius](#arc_outerRadius)) / 2. For example:
[<img alt="Circular Sector Centroids" src="https://raw.githubusercontent.com/d3/d3-shape/master/img/centroid-circular-sector.png" width="250" height="250">](http://bl.ocks.org/mbostock/9b5a2fd1ce1a146f27e4)[<img alt="Annular Sector Centroids" src="https://raw.githubusercontent.com/d3/d3-shape/master/img/centroid-annular-sector.png" width="250" height="250">](http://bl.ocks.org/mbostock/c274877f647361f3df7d)
Note that this is **not the geometric center** of the arc, which may be outside the arc; this method is merely a convenience for positioning labels.
<a name="arc_innerRadius" href="#arc_innerRadius">#</a> <i>arc</i>.<b>innerRadius</b>([<i>radius</i>]) · [Source](https://github.com/d3/d3-shape/blob/master/src/arc.js)
If *radius* is specified, sets the inner radius to the specified function or number and returns this arc generator. If *radius* is not specified, returns the current inner radius accessor, which defaults to:
```js
function innerRadius(d) {
return d.innerRadius;
}
```
Specifying the inner radius as a function is useful for constructing a stacked polar bar chart, often in conjunction with a [sqrt scale](https://github.com/d3/d3-scale#sqrt). More commonly, a constant inner radius is used for a donut or pie chart. If the outer radius is smaller than the inner radius, the inner and outer radii are swapped. A negative value is treated as zero.
<a name="arc_outerRadius" href="#arc_outerRadius">#</a> <i>arc</i>.<b>outerRadius</b>([<i>radius</i>]) · [Source](https://github.com/d3/d3-shape/blob/master/src/arc.js)
If *radius* is specified, sets the outer radius to the specified function or number and returns this arc generator. If *radius* is not specified, returns the current outer radius accessor, which defaults to:
```js
function outerRadius(d) {
return d.outerRadius;
}
```
Specifying the outer radius as a function is useful for constructing a coxcomb or polar bar chart, often in conjunction with a [sqrt scale](https://github.com/d3/d3-scale#sqrt). More commonly, a constant outer radius is used for a pie or donut chart. If the outer radius is smaller than the inner radius, the inner and outer radii are swapped. A negative value is treated as zero.
<a name="arc_cornerRadius" href="#arc_cornerRadius">#</a> <i>arc</i>.<b>cornerRadius</b>([<i>radius</i>]) · [Source](https://github.com/d3/d3-shape/blob/master/src/arc.js)
If *radius* is specified, sets the corner radius
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Ai企联系统去授权最新 版uniapp开发+新增PC端 整体感觉页面还算不错,功能也还行,没有公众号也可以完美搭建 源码全开源,可随意二开。 项目uniapp开发的,支持3.5 4.0 Mj 此套系统5端适配,Web+H5+微信小程序+抖音小程序+双端APP,支持流量主! 好像有能力的快手小程序那些也可以上线。 自己有能力的可以二开,UI后台也可以自己改。
资源推荐
资源详情
资源评论
收起资源包目录
Ai企联系统去授权最新版uniapp开发+新增PC端 (2000个子文件)
uni.css 10KB
uniicons.css 9KB
prism-treeview.css 8KB
uni-icons.css 8KB
prism-treeview.min.css 7KB
prism-previewers.css 5KB
prism-previewers.min.css 4KB
index.css 3KB
admin-icons.css 3KB
iconfont.css 2KB
editor-icon.css 2KB
prism-toolbar.css 2KB
prism-line-highlight.css 2KB
github-dark.min.css 1KB
prism-toolbar.min.css 1KB
prism-line-highlight.min.css 1KB
prism-inline-color.css 1KB
prism-command-line.css 949B
prism-match-braces.css 815B
prism-line-numbers.css 782B
prism-match-braces.min.css 758B
prism-command-line.min.css 751B
image-uploading.css 633B
prism-line-numbers.min.css 609B
prism-inline-color.min.css 527B
prism-show-invisibles.css 456B
prism-show-invisibles.min.css 386B
prism-diff-highlight.css 379B
prism-unescaped-markup.css 359B
unlock-content.css 345B
prism-diff-highlight.min.css 336B
prism-unescaped-markup.min.css 250B
prism-wpd.css 235B
prism-wpd.min.css 205B
divider.css 74B
prism-autolinker.css 29B
prism-autolinker.min.css 23B
template.html 103KB
template.h5.html 883B
echarts.min.js 730KB
echarts.min.js 730KB
remarkable.js 381KB
index.js 300KB
u-charts.js 297KB
highlight-uni.min.js 203KB
index.js 168KB
index.js 168KB
index.js 151KB
index.js 151KB
u-charts.min.js 141KB
index.min.js 124KB
chat.js 123KB
index.browser.js 122KB
index.browser.js 122KB
remarkable.min.js 120KB
js-yaml.js 112KB
markdown-it.min.js 93KB
command.js 61KB
statResult.js 57KB
prism.js 57KB
index.js 50KB
loader.js 46KB
js-yaml.min.js 39KB
semver.js 38KB
prism-core.js 38KB
d3-delaunay.js 36KB
argument_parser.js 34KB
prism-sqf.js 33KB
prism-sqf.min.js 33KB
dumper.js 31KB
icons.js 27KB
d3-selection.js 26KB
components.js 26KB
d3-transition.js 25KB
calendar.js 25KB
formatter.js 22KB
prism-previewers.js 20KB
d3-brush.js 19KB
main.js 19KB
index.obj.js 19KB
index.js 18KB
brush.js 18KB
app_configs.js 16KB
prism-factor.js 16KB
d3-delaunay.min.js 16KB
payResult.js 16KB
utils.js 15KB
action_container.js 15KB
activeDevices.js 14KB
MsgManager.js 14KB
index.js 14KB
prism-vim.js 14KB
prism-vim.min.js 14KB
uni-data-picker.js 13KB
prism-csharp.js 13KB
index.esm.js 13KB
config-ucharts.js 13KB
d3-selection.min.js 13KB
errorResult.js 12KB
pageResult.js 12KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
如鹿觅水
- 粉丝: 243
- 资源: 388
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 白色大气风格的农业培育企业网站模板下载.zip
- 白色大气风格的男人男士网站模板下载.zip
- 白色大气风格的女性风衣企业网站模板.zip
- 白色大气风格的欧美穿衣风格网站模板下载.zip
- 白色大气风格的欧美品牌服装网站模板下载.zip
- 白色大气风格的苹果ipad应用官网模板下载.zip
- 白色大气风格的欧美商务合作HTML模板.zip
- 白色大气风格的贫困儿童救助网站模板下载.zip
- 白色大气风格的葡萄酒酒庄模板下载.zip
- 白色大气风格的企业站通用整站网站源码下载.zip
- 白色大气风格的汽车4s店模板下载.zip
- 白色大气风格的全屏背景科技公司模板下载.zip
- 白色大气风格的前端设计案例展示模板.zip
- 白色大气风格的汽车爱好者模板下载.zip
- 白色大气风格的人体艺术摄影网站模板下载.zip
- 白色大气风格的软件开发公司企业整站模板下载.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功