1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
<html>
<head>
<title>Donut</title>
<script type="text/javascript" src="protovis-r3.3.js"></script>
</head>
<body>
<script type="text/javascript+protovis">
var data = pv.range(10).map(function(x) {return Math.abs(Math.sin(x))}),
w = 400,
h = 400,
r = w / 2,
t = 30,
a = pv.Scale.linear(0, pv.sum(data)).range(0, 2 * Math.PI);
var vis = new pv.Panel()
.width(w)
.height(h);
vis.add(pv.Wedge)
.data(data)
.innerRadius(r - t)
.outerRadius(r)
.angle(a)
.title(function(d) d)
.anchor("outer").add(pv.Label)
.visible(function(d) d > .05)
.textMargin(t + 5)
.text(function(d) d.toFixed(2));
vis.render();
</script>
</body>
</html>
|