-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpie.html
40 lines (31 loc) · 888 Bytes
/
pie.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>dc.js - Pie Chart Example</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/dc.css"/>
</head>
<body>
<div id="test"></div>
<script type="text/javascript" src="js/d3.js"></script>
<script type="text/javascript" src="js/crossfilter.js"></script>
<script type="text/javascript" src="js/dc.min.js"></script>
<script type="text/javascript">
var chart = dc.pieChart("#test");
d3.csv("sample.csv", function(error, data) {
var ndx = crossfilter(data),
dimension = ndx.dimension(function(d) {return d.name;})
group = dimension.group().reduceSum(function(d) {return d.qty;});
chart
.width(768)
.height(480)
.slicesCap(4)
.innerRadius(100)
.dimension(dimension)
.group(group)
.legend(dc.legend());
chart.render();
});
</script>
</body>
</html>