-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.html
141 lines (129 loc) · 4.15 KB
/
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
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dygraph/1.1.1/dygraph-combined.js"></script>
<script type="text/javascript" src="http://jquery-csv.googlecode.com/git/src/jquery.csv.js"></script>
</head>
<body>
<form>
Choose dataset:
<select name="Dataset" class="dataset">
<option value="color1.rtf" selected="selected">North from Safety Zone (Scan 1)</option>
<option value="color2.rtf">North from Safety Zone (Scan 2)</option>
<option value="color3.rtf">East from Safety Zone (Scan 1)</option>
<option value="color4.rtf">East form Safety Zone (Scan 2)</option>
</select>
<br/>
White/Black/White Detector:<br/>
White Threshold:<input id="white" type="number" min="0" max="128" value="90"/>
Black Threshold:<input id="black" type="number" min="0" max="128" value="20"/>
Min Distance Between Peaks:<input id="minwidth" type="number" min="0" max="500" value="5"/>
Max Distance Between Peaks:<input id="maxwidth" type="number" min="0" max="500" value="40"/>
</form>
<div id="div_g" style="width:600px; height:300px;"></div>
<p>You can click-drag to zoom in on the color data. Double-click to unzoom.</p>
<script type="text/javascript">
$(document).ready(function () {
var colors=[];
var data=[];
var annotations=[];
var g;
var whitethresh=90;
var blackthresh=20;
var minwidth=5;
var maxwidth=40;
$("#white").change(function() {
whitethresh=$(this).val();
analyze();
redraw();
});
$("#black").change(function() {
blackthresh=$(this).val();
analyze();
redraw();
});
$("#minwidth").change(function() {
minwidth=$(this).val();
analyze();
redraw();
});
$("#maxwidth").change(function() {
maxwidth=$(this).val();
analyze();
redraw();
});
function update(name) {
$.ajax({
url: "https://raw.githubusercontent.com/swb1701/fll/master/colordata/"+name,
async: false,
success: function(csvd) {
colors = $.csv2Array(csvd);
},
dataType: "text",
complete: function() {
}
});
}
function analyze() {
annotations=[];
var lastwhite=-1;
var lastblack=-1;
var hit=0;
for(var i=0;i<colors.length;i++) {
if (colors[i]>whitethresh) {
if (lastwhite>-1 && lastblack>-1) {
var dif=i-lastblack;
var dif2=lastblack-lastwhite;
if (dif>minwidth && dif<maxwidth && dif2>minwidth && dif2>maxwidth) {
hit=hit+1;
annotations.push({series:"Color",x:i,shortText:hit,tickHeight:-30});
lastwhite=-1;
lastblack=-1;
}
}
lastwhite=i;
} else if (colors[i]<blackthresh) {
lastblack=i;
}
}
}
function redraw() {
data=[];
for (var i=0;i<colors.length;i++) {
data.push([i,colors[i]]);
}
//var highlight_start = 2200;
//var highlight_end = 2550;
g=new Dygraph(
document.getElementById("div_g"),
data,
{
labels: ['X', 'Color'],
animatedZooms: true,
/*
underlayCallback: function(canvas, area, g) {
var bottom_left = g.toDomCoords(highlight_start, -20);
var top_right = g.toDomCoords(highlight_end, +20);
var left = bottom_left[0];
var right = top_right[0];
canvas.fillStyle = "rgba(255, 255, 102, 1.0)";
canvas.fillRect(left, area.y, right - left, area.h);
}
*/
}
);
g.setAnnotations(annotations);
}
$(".dataset").change(function() {
update($(this).val());
analyze();
redraw();
});
update("color1.rtf");
analyze();
redraw();
}
);
</script>
</body>
</html>