-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathvis_line.html
241 lines (194 loc) · 5.51 KB
/
vis_line.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://getbootstrap.com/examples/justified-nav/justified-nav.css" rel="stylesheet">
<link rel="stylesheet" href="static/css/stylegraph.css">
<style>
svg {
font: 10px sans-serif;
}
path.line {
fill: none;
stroke: #126ac2;
stroke-width: 1.5px;
}
path.area {
fill: #fff;
}
.axis {
shape-rendering: crispEdges;
}
.x.axis line {
stroke: #000;
}
.x.axis path {
fill: none;
stroke: #000;
}
.y.axis line,
.y.axis path {
fill: none;
stroke: #000;
}
.card {
/* Add shadows to create the "card" effect */
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
/*height: 75vh;*/
width: 100%;
background-color: white;
}
/* On mouse-over, add a deeper shadow */
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
/* Add some padding inside the card container */
.container {
padding: 40px 16px;
width:1500px;
}
</style>
<body style="background-color:#75cbe7; color: #515656; ">
<div class="container">
<div class="card" id="here">
<h3 style="padding: 30px 15px;"><center>Footfall in <b><i>{{room_name}}</i></b> on {{date}}</center></h4>
<h4 style="padding: 30px 15px;"><center>{{file_name}}</center></h3>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var resultsJSON = {% raw response %};
console.log(resultsJSON)
data = resultsJSON
var margin = {top: 40, right: 40, bottom: 40, left: 40},
width = 1100 - margin.left - margin.right,
height = 300 - margin.top - margin.bottom;
min_time = d3.max(data.frames, function(d) { return d.time; })
max_time = d3.min(data.frames, function(d) { return d.time; })
var x = d3.scale.linear()
.domain([max_time, min_time])
.range([0, width]);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
//.tickSize(-height);
var yAxis = d3.svg.axis()
.scale(y)
//.ticks(4)
.orient("left")
.ticks(10,"");
var svg = d3.select("#here").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var area = d3.svg.area()
.interpolate("monotone")
.x(function(d) { return x(d.time); })
.y0(height)
.y1(function(d) { return y(d.count); });
var line = d3.svg.line()
.interpolate("monotone")
.x(function(d) { return x(d.time); })
.y(function(d) { return y(d.count); });
svg.append("clipPath")
.attr("id", "clip")
.append("rect")
.attr("width", width)
.attr("height", height);
// Compute the minimum and maximum time, and the maximum count.
y.domain([0, d3.max(data.frames, function(d) { return d.count; })]);
svg.datum(data.frames);
svg.append("path")
.attr("class", "area")
.attr("clip-path", "url(#clip)")
.attr("d", area);
/*svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" + width + ",0)")
.call(yAxis);*/
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.attr("x", 6)
.selectAll("text")
.style("text-anchor", "end")
.attr("dx", ".71em");
//.attr("dy", "-.01em")
//.attr("transform", "rotate(-90)" );
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 5)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Count");
svg.append("path")
.attr("class", "line")
.attr("clip-path", "url(#clip)")
.attr("d", line);
// svg.append("text")
// .attr("x", width - 6)
// .attr("y", height - 6)
// .style("text-anchor", "end")
// .text(data[0].symbol);
// On click, update the x-axis.
</script>
<style type="text/css">
#custom-seekbar
{
cursor: pointer;
height: 10px;
margin-bottom: 10px;
margin-left: 40px;
margin-right: 40px;
outline: thin solid #69C4E4;
overflow: hidden;
position: relative;
/*width: 100%;*/
}
#custom-seekbar span
{
background-color: #69C4E4;
position: absolute;
top: 0;
left: 0;
height: 10px;
width: 0px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div id="custom-seekbar">
<span></span>
</div>
<video id="video" width="400" controls muted style="align-self: center">
<source src= {{file_path}} type="video/mp4">
</video>
<script type="text/javascript">
var vid = document.getElementById("video");
var margin = {top: 40, right: 40, bottom: 40, left: 40},
width = 1100 - margin.left - margin.right,
height = 300 - margin.top - margin.bottom;
document.getElementById("custom-seekbar").style.width = width;
vid.ontimeupdate = function(){
var percentage = ( vid.currentTime / vid.duration ) * 100;
$("#custom-seekbar span").css("width", percentage+"%");
};
$("#custom-seekbar").on("click", function(e){
var offset = $(this).offset();
var left = (e.pageX - offset.left);
var totalWidth = $("#custom-seekbar").width();
var percentage = ( left / totalWidth );
var vidTime = vid.duration * percentage;
vid.currentTime = vidTime;
});//click()
</script>
</div>