Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
137 lines (131 loc) · 5.49 KB
/
Copy pathindex.html
File metadata and controls
137 lines (131 loc) · 5.49 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>d3Stream demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.slim.min.js" integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.5/umd/popper.min.js" integrity="sha256-jpW4gXAhFvqGDD5B7366rIPD7PDbAmqq4CO0ZnHbdM4=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha256-DiWJXXyq81WlPRnDfGmgYZj2aOVCKyEdJ1l+2TmDuAs=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha256-m/h/cUDAhf6/iBRixTbuc8+Rg2cIETQtPcH9D3p2Kg0=" crossorigin="anonymous" />
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="d3Stream.js" type="text/javascript"></script>
<link rel="stylesheet" href="d3Stream.css">
<script type="text/javascript">
$(function () {
var s1 = new d3Stream([5, 2, 3, 4, 4, 7, 4, 3, 5, 6], d3);
s1.display('#simple .card-body')
.map(function (d, i) { return { x: i, y: d, z: 0 }; })
.domainPad('x', [0.5, 1])
.barChart()
.lineChart()
.update();
var $shake = $('<button>?</button>').on('click', function (event) {
s1.update(d3.shuffle(s1.data));
});
var $plus = $('<button>+</button>').on('click', function (event) {
s1.update(s1.data.concat(Math.floor(Math.random() * 10)));
});
var $minus = $('<button>-</button>').on('click', function (event) {
s1.update(s1.data.slice(0, s1.data.length - 1));
});
$('#simple .card-body').append($minus).append($shake).append($plus);
var s2 = new d3Stream([
{ id: "123N", "1.1 Count": 1, "1.1 Total": 10, "1.1 Max": 10, "1.2 Count": 2, "1.2 Total": 10, "1.2 Max": 10, "1.3 Count": 4, "1.3 Total": 50, "1.3 Max": 50 },
{ id: "124O", "1.1 Count": 3, "1.1 Total": 10, "1.1 Max": 10, "1.2 Count": 3, "1.2 Total": 10, "1.2 Max": 10, "1.3 Count": 6, "1.3 Total": 40, "1.3 Max": 50 },
{ id: "125P", "1.1 Count": 2, "1.1 Total": 5, "1.1 Max": 10, "1.2 Count": 2, "1.2 Total": 0, "1.2 Max": 10, "1.3 Count": 100, "1.3 Total": 0, "1.3 Max": 50 },
{ id: "126Q", "1.1 Count": 0, "1.1 Total": 0, "1.1 Max": 10, "1.2 Count": 0, "1.2 Total": 0, "1.2 Max": 10, "1.3 Count": 0, "1.3 Total": 0, "1.3 Max": 50 },
], d3);
var rounds = ['1.1', '1.2', '1.3'];
var roundLabels = { 0: { label: '1.1' }, 1: { label: '1.2' }, 2: { label: '1.3' }};
s2.display('#lines .card-body')
.cross(rounds)
.mapAsStreams(function (row) {
return row.map(function (pair, i) {
return {
x: i,
y: pair[0][pair[1] + ' Total'],
z: pair[0][pair[1] + ' Count'],
group: pair[0].id,
payload: pair,
};
})
.cumulate('y')
})
.domainIQR('z')
.domainBands('x', roundLabels)
.lineChart()
.update();
var groupLabels = { 0: { label: 'None' }, 1: { label: '< 90%' }, 2: { label: '100%' }};
s2.display('#bars .card-body', { groups: groupLabels, chartText: true })
.repeat(rounds)
.map(function (pair, i) {
var countKey = pair[1] + ' Count';
var totalKey = pair[1] + ' Total';
var maxKey = pair[1] + ' Max';
return new d3Stream(pair[0]).group([
function (d) { return d[countKey] == 0; },
function (d) { return d[totalKey] < 0.9 * d[maxKey]; },
function (d) { return true; },
]).map(function (group, j) {
return {
x: i,
y: group.length,
z: 0,
group: j,
payload: group,
};
})
.unstream();
})
.domainBands('x', roundLabels)
.stackedBarChart()
.table2d()
.update();
var s3 = new d3Stream([
[
{ "group": "3", "x": "1", "y": 2 },
{ "group": "3", "x": "2", "y": 0 }
],
[
{ "group": "4", "x": "1", "y": 1 },
{ "group": "4", "x": "2", "y": 5 }
]
], d3);
s3.display('#whatnot .card-body')
.domainBands(['x'], ["1", "2"])
.stackedBarChart()
.table2d()
.update();
});
</script>
</head>
<body>
<div class="container-fluid">
<div class="card" id="simple">
<div class="card-header bg-info text-white">
Simple
</div>
<div class="card-body"></div>
</div>
<div class="card" id="lines">
<div class="card-header bg-info text-white">
Lines
</div>
<div class="card-body"></div>
</div>
<div class="card" id="bars">
<div class="card-header bg-info text-white">
Bars
</div>
<div class="card-body"></div>
</div>
<div class="card" id="whatnot">
<div class="card-header bg-info text-white">
Test
</div>
<div class="card-body"></div>
</div>
</div>
</body>
</html>