4
<title>Pie Chart</title>
5
<script type="text/javascript" src="../../d3.v2.js"></script>
6
<style type="text/css">
15
<script type="text/javascript">
19
r = Math.min(w, h) / 2,
20
data = d3.range(10).map(Math.random).sort(d3.descending),
21
color = d3.scale.category20(),
22
arc = d3.svg.arc().outerRadius(r),
23
donut = d3.layout.pie();
25
var vis = d3.select("body").append("svg")
30
var arcs = vis.selectAll("g.arc")
34
.attr("transform", "translate(" + r + "," + r + ")");
36
var paths = arcs.append("path")
37
.attr("fill", function(d, i) { return color(i); });
42
.attrTween("d", tweenPie);
46
.delay(function(d, i) { return 2000 + i * 50; })
48
.attrTween("d", tweenDonut);
50
function tweenPie(b) {
52
var i = d3.interpolate({startAngle: 0, endAngle: 0}, b);
58
function tweenDonut(b) {
59
b.innerRadius = r * .6;
60
var i = d3.interpolate({innerRadius: 0}, b);