# 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`. You can also download the [latest release on GitHub](https://github.com/d3/d3-shape/releases/latest). For vanilla HTML in modern browsers, import d3-shape from Skypack:
```html
<script type="module">
import {line} from "https://cdn.skypack.dev/d3-shape@3";
const l = line();
</script>
```
For legacy environments, you can load d3-shape’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported:
```html
<script src="https://cdn.jsdelivr.net/npm/d3-path@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-shape@3"></script>
<script>
const l = 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/mas
没有合适的资源?快使用搜索试试~ 我知道了~
基于 ThreeJs 的中国 3D 地图展示,使用 vue 框架.zip
共2000个文件
js:2002个
json:165个
md:50个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 12 下载量 71 浏览量
2022-06-06
11:08:14
上传
评论 4
收藏 11.35MB ZIP 举报
温馨提示
基于 ThreeJs 的中国 3D 地图展示,使用 vue 框架.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于 ThreeJs 的中国 3D 地图展示,使用 vue 框架.zip (2000个子文件)
tabler-icons.min.css 51KB
open-sans.css 578B
Three-chinaMap-Demo.html 12KB
web-ifc-api.js 1.43MB
three.js 1.12MB
three.module.js 1.11MB
OimoPhysics.js 1.08MB
draco_encoder.js 932KB
draco_encoder.js 907KB
draco_decoder.js 737KB
three.min.js 602KB
d3.js 562KB
draco_decoder.js 535KB
lottie_canvas.js 447KB
ammo.wasm.js 385KB
vue.js 336KB
vue.esm.js 320KB
vue.common.dev.js 314KB
vue.esm.browser.js 310KB
RectAreaLightUniformsLib.js 306KB
RectAreaLightUniformsLib.js 306KB
d3.min.js 269KB
vue.runtime.js 235KB
vue.runtime.esm.js 223KB
vue.runtime.common.dev.js 219KB
mmdparser.module.js 155KB
chevrotain.module.min.js 154KB
chevrotain.min.js 150KB
rhino3dm.js 131KB
rhino3dm.module.js 131KB
opentype.module.min.js 124KB
opentype.min.js 124KB
GLTFLoader.js 101KB
GLTFLoader.js 100KB
FBXLoader.js 97KB
FBXLoader.js 95KB
vue.min.js 92KB
vue.common.prod.js 92KB
vue.esm.browser.min.js 91KB
d3-geo.js 87KB
ColladaLoader.js 82KB
fflate.module.js 81KB
ColladaLoader.js 80KB
ArcballControls.js 79KB
ArcballControls.js 75KB
VRMLLoader.js 73KB
predicates.js 73KB
VRMLLoader.js 71KB
index.js 66KB
vue.runtime.min.js 64KB
SVGLoader.js 64KB
IFCLoader.js 64KB
vue.runtime.common.prod.js 64KB
SVGLoader.js 63KB
GLTFExporter.js 62KB
basis_transcoder.js 61KB
GLTFExporter.js 61KB
flow.module.js 60KB
WebGLRenderer.js 56KB
EXRLoader.js 55KB
EXRLoader.js 54KB
d3-shape.js 53KB
draco_wasm_wrapper.js 52KB
draco_wasm_wrapper.js 52KB
MMDLoader.js 51KB
MMDLoader.js 50KB
Three.Legacy.js 49KB
SMAAPass.js 48KB
SMAAPass.js 48KB
LDrawLoader.js 47KB
LDrawLoader.js 46KB
FXAAShader.js 45KB
FXAAShader.js 45KB
ecsy.module.js 44KB
d3-delaunay.js 44KB
WebGLTextures.js 42KB
TransformControls.js 40KB
TransformControls.js 39KB
MarchingCubes.js 37KB
MarchingCubes.js 37KB
Geometry.js 37KB
Geometry.js 36KB
d3-hierarchy.js 36KB
d3-geo.min.js 35KB
3MFLoader.js 34KB
3MFLoader.js 34KB
LightningStrike.js 32KB
LightningStrike.js 32KB
d3-array.js 32KB
3DMLoader.js 31KB
sbcs-data-generated.js 31KB
3DMLoader.js 31KB
d3-scale.js 30KB
incircle.js 30KB
fflate.min.js 29KB
d3-shape.min.js 29KB
MMDPhysics.js 28KB
MMDPhysics.js 28KB
RGBMLoader.js 28KB
insphere.js 28KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
「已注销」
- 粉丝: 793
- 资源: 3613
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页