-
Notifications
You must be signed in to change notification settings - Fork 1
/
remote_plot.html
165 lines (144 loc) · 5.92 KB
/
remote_plot.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 19 September 2007), see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii">
<title>EEG Plot</title>
<!--[if IE]><script language="javascript" type="text/javascript" src="media/js/excanvas.pack.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src=
"media/js/jquery.js">
</script>
<script language="javascript" type="text/javascript" src="media/js/jquery.sparkline.js">
</script>
<script language="javascript" type="text/javascript" src="media/js/flot/jquery.flot.js">
</script>
<script language="javascript" type="text/javascript" src="media/js/ui.core.js">
</script>
<script language="javascript" type="text/javascript" src="media/js/ui.dialog.js">
</script>
<script language="javascript" type="text/javascript" src="media/js/ui.resizable.js">
</script>
<script language="javascript" type="text/javascript" src="media/js/ui.draggable.js">
</script>
<!--<link rel="stylesheet" href=-->
<!--"http://dev.jquery.com/view/tags/ui/latest/themes/flora/flora.all.css"-->
<!--type="text/css" media="screen" title="Flora (Default)">-->
<link rel="stylesheet" type="text/css" href="media/css/style.css" media="screen" />
<!--[if IE]><link rel="stylesheet" type="text/css" href="media/css/ie.css" /><![endif]-->
</head>
<body>
<div id="wrapper">
<div class="generic nineforty" style="background-color: #555; color:white;">
<h1 class="header_title" style="text-align:center;color:white;">Toledo EEG</h1>
<ul id="eeg_header" style="background-color:white;color:black;"></ul>
</div>
<div class="generic nineforty">
<!-- <h2>Plot</h2>-->
<div id="plot" style="height:400px;"></div>
<div id="miniature" style=
"float:right;margin-right:20px;margin-top:-120px">
<div id="overview" style="width:166px;height:100px"></div>
<p id="overviewLegend" style="margin-right:40px;margin-left:10px"/>
</div>
<div class="generic nineforty">
<div class="sparkline"/>
</div>
</div>
<div id="ft">Toledo EEG. Powered by Django</div>
<script id="source" language="javascript" type="text/javascript">
$(function () {
var num_of_samples = 200;
function getData(r, x1, x2) {
var d = new Array();
for(var i = 0; i < r.length; i++) {
d[i] = new Object();
d[i].label = r[i].label;
d[i].data = new Array();
}
for(var i = 0; i < r.length; i++) {
for (var j = x1; j < x2; j++)
d[i].data[j] = r[i].data[j];
}
return d;
};
$("#eeg_header").hide();
$(".header_title").click(function() {
$("#eeg_header").slideToggle("slow");
});
<!-- $(".header_title").mouseover(function() {-->
<!-- $("#eeg_header").slideToggle("slow");-->
<!-- });-->
<!-- $(".header_title").mouseout(function() {-->
<!-- $("#eeg_header").slideToggle("slow");-->
<!-- });-->
$.getJSON("http://localhost:8000/remote_plot/"+num_of_samples,
function(response){
var options = {
legend: {show: true},
points: {show: true},
lines: {show: true},
yaxis: {ticks: 10},
selection: {mode: "x"}
};
var data = response.samples;
$.plot($("#plot"), data, options);
$.each(response.header, function(i, item) {
$("#eeg_header").append("<li><b>" + i + "<\/b>: " + item + "<\/li>");
});
var overview = $.plot($("#overview"), data, {
lines: { show: true, lineWidth: 1 },
shadowSize: 0,
legend: {show: false},
xaxis: { ticks: 4 },
yaxis: { ticks: 3, min: -2, max: 2 },
grid: { color: "#999" },
selection: { mode: "x" }
});
// now connect the two
$("#plot").bind("plotselected", function (event, ranges) {
// make sure the indecies are integers
ranges.xaxis.from = parseInt(ranges.xaxis.from);
ranges.xaxis.to = parseInt(ranges.xaxis.to);
plot = $.plot($("#plot"), getData(data, ranges.xaxis.from, ranges.xaxis.to),
$.extend(true, {}, options, {
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to-1 }
}));
// don't fire event on the overview to prevent eternal loop
overview.setSelection(ranges, true);
});
$("#overview").bind("plotselected", function (event, ranges) {
plot.setSelection(ranges);
});
$.each(data, function(index, sample) {
$(".legendLabel:contains('" + this.label[0] + "')").click(function() {
var a = new Array();
for(i = 0; i < sample.data.length; i++)
a[i] = sample.data[i][1];
var clean_name = sample.label[0].split(" ").join("").split("+").join("");
$(".sparkline").append(
"<div class='dialog" + clean_name + "'>" +
"<h3>" + sample.label + "<\/h3>" +
"<div class='sparkline_plot" + clean_name + "'> Loading...<\/div>" +
"<\/div><br/>"
);
$(".sparkline_plot" + clean_name).sparkline(a);
$(".dialog" + clean_name).dialog({
modal: true,
overlay: {
opacity: 0.75,
background: "white"
},
resizable: false,
width: ($("." + clean_name).width()),
height: $("." + clean_name).height()
});
});
});
});
});
</script>
</body>
</html>