forked from lineupjs/lineupjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrouping.html
43 lines (39 loc) · 1.14 KB
/
grouping.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 lang="en">
<meta charset="UTF-8" />
<title>LineUp Builder Test</title>
<link href="./LineUpJS.css" rel="stylesheet" />
<link href="./demo.css" rel="stylesheet" />
</head>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="./LineUpJS.js"></script>
<script>
window.onload = function () {
const arr = [];
const cats = ['c1', 'c2', 'c3'];
const cats2 = ['a1', 'a2'];
for (let i = 0; i < 100; ++i) {
arr.push({
a: Math.random() * 10,
d: 'Row ' + i,
cat: cats[Math.floor(Math.random() * 3)],
cat2: cats2[Math.floor(Math.random() * 2)],
});
}
const builder = LineUpJS.builder(arr);
builder.deriveColumns();
// and two rankings
const ranking = LineUpJS.buildRanking()
.supportTypes()
.group()
.allColumns() // add all columns
.groupBy('cat', 'cat2')
.groupSortBy('a');
builder.ranking(ranking);
builder.buildTaggle(document.body);
};
</script>
</body>
</html>