使用D3.js画一个SVG 的 圆 circle
可以使用如下代码创建:
<svg width="50" height="50">
<circle cx="25" cy="25" r="25" fill="purple" />
</svg>
D3.js来创建这些图形可以看做这一过程为两步:
- 创建SVG容器(SVG坐标空间)
- 画圆形
//创建一个SVG容器
var svgContainer = d3.select("body").append("svg")
.attr("width",200)
.attr("height",200); //画圆形
var circle = svgContainer.append("circle")
.attr("cx",30)
.attr("cy",30)
.attr("r",20);