-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
112 lines (89 loc) · 2.83 KB
/
index.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!--link href="dist/css/dc.css" rel="stylesheet">
<link href="dist/css/bootstrap.css" rel="stylesheet">
<link href="dist/css/bootstrap-theme.css" rel="stylesheet"-->
<link href="dist/style.css" rel="stylesheet">
</head>
<body>
<div class="container theme-showcase" role="main">
<div class="jumbotron">
<h1>dc example</h1>
<p>This is a template showcasing boostrap and dc.js. Use it as a starting point to create something more unique by building on or modifying it.</p>
</div>
<div class="row">
<div class="col-md-12">
<div id="test"></div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<table id="table" class="table">
<thead>
<tr>
<th>Name</th>
<th>Qty</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<!--script src="dist/js/jquery.js"></script>
<script src="dist/js/bootstrap.js"></script>
<script type="text/javascript" src="dist/js/d3.js"></script>
<script type="text/javascript" src="dist/js/crossfilter.js"></script>
<script type="text/javascript" src="dist/js/dc.js"></script-->
<script type="text/javascript" src="dist/all.js"></script>
<script type="text/javascript">
"use strict";
var graphs = [];
d3.csv("data/sample.csv", function(error, data) {
var ndx = crossfilter(data);
graphs.pie = drawPie("#test");
graphs.table = drawTable("#table");
jQuery (function($) {
dc.renderAll();
});
function drawPie (dom) {
var dim = ndx.dimension(function(d) {return d.name;});
var group = dim.group().reduceSum(function(d) {return d.qty;});
var chart = dc.pieChart(dom)
.width(768)
.height(480)
.slicesCap(4)
.innerRadius(100)
.dimension(dim)
.group(group)
.legend(dc.legend());
return chart;
}
function drawTable (dom) {
var dim = ndx.dimension(function(d) {return null;});
var chart= dc.dataTable(dom)
.dimension(dim)
.size(1000)
.group(function (d) { return "";})
.columns([
function (d) {
return d.name || "";
},
function (d) {
return d.qty || "";
}
])
.sortBy(function (d) {
return d.name;
})
.order(d3.ascending);
return chart;
}
});
</script>
</body>
</html>