-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpie-v1.html
43 lines (36 loc) · 968 Bytes
/
pie-v1.html
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
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Pie Chart v1</title>
</head>
<body>
<script src="d3.v3.min.js"></script>
<script>
(function() {
'use strict';
var data = [10, 20, 30, 40];
var width = 960,
height = 500,
radius = Math.min(width, height) / 2;
var color = d3.scale.category10();
var arc = d3.svg.arc()
.outerRadius(radius - 10);
var pie = d3.layout.pie()
.value(function(d) { return d; });
var svg = d3.select('body')
.append('svg')
.attr('width', width)
.attr('height', height)
.append('g')
.attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')');
var path = svg.selectAll('path')
.data(pie(data))
.enter()
.append('path')
.attr('d', arc)
.attr('fill', function(d, i) { return color(i); });
})();
</script>
</body>
</html>