Skip to content

Commit 2306408

Browse files
tweaks to telemtry graph
* sparse data is now visiable (data being more than 3 minutes apart) * hovering over the graph, will also update the day/night overlay with the specific datetime, if it's turned on (useful for long flights) * hovering over the graph places a marker on the polyline, the marker will now be placed on the correct position
1 parent 0752818 commit 2306408

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

cache.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# version 165
2+
# version 176
33

44
# gogole maps files
55
http://maps.google.com/maps/api/js?v=3.10&sensor=false&key=AIzaSyCOqkcNey4CCyG4X0X5qxHAhCgD8g5DwXg

js/plot_config.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ function updateLegend() {
9090
} else {
9191
y = p1[1] + (p2[1] - p1[1]) * (pos.x - p1[0]) / (p2[0] - p1[0]);
9292
}
93-
y = y.toFixed(2);
9493

95-
if((p1 && p1[1] == null) || (p2 && p2[1] == null)) y = null;
94+
y = ((p1 && p1[1] == null) || (p2 && p2[1] == null)) ? null : y.toFixed(2);
9695
}
9796
legend.eq(i).text(series.label.replace(/=.*/, "= " + y));
9897
}
@@ -117,9 +116,23 @@ function updateLegend() {
117116

118117
if(follow_vehicle != -1 && vehicles[follow_vehicle].positions.length) {
119118
// adjust index for null data points
120-
j = j - vehicles[follow_vehicle].graph_data[0].nulls;
119+
var null_count = 0;
120+
var data_ref = vehicles[follow_vehicle].graph_data[0];
121+
122+
if(j > data_ref.data.length / 2) {
123+
for(var i = data_ref.data.length - 1; i > j; i--) null_count += (data_ref.data[i][1] == null) ? 1 : 0;
124+
null_count = data_ref.nulls - null_count * 2;
125+
} else {
126+
for(var i = 0; i < j; i++) null_count += (data_ref.data[i][1] == null) ? 1 : 0;
127+
null_count *= 2;
128+
}
129+
121130
// update position
122-
polyMarker.setPosition(vehicles[follow_vehicle].positions[j]);
131+
polyMarker.setPosition(vehicles[follow_vehicle].positions[j - null_count]);
132+
133+
// adjust nite overlay
134+
nite.setDate(new Date(data_ref.data[j][0]));
135+
nite.refresh();
123136
}
124137
}
125138

js/tracker.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ function addPosition(position) {
776776

777777
vehicle_info.image_src = host_url + markers_url + "hab_nyan.gif";
778778

779-
// whats nyan only purpose? Make people happy, of course. And how?
779+
// whats nyan only purpose? Make people happy, of course. And how?
780780
var rainbow = ["#ff0000", "#fc9a00", "#f6ff00", "#38ff01", "#009aff","#0000ff"];
781781
vehicle_info.polyline = [];
782782

@@ -869,7 +869,13 @@ function updateGraph(idx, reset_selection) {
869869

870870
if(polyMarker) polyMarker.setPosition(null);
871871

872-
if(reset_selection) delete plot_options.xaxis;
872+
if(reset_selection) {
873+
delete plot_options.xaxis;
874+
875+
// reset nite overlay
876+
nite.setDate(null);
877+
nite.refresh();
878+
}
873879

874880
// replot graph, with this vehicle data, and this vehicles yaxes config
875881
plot = $.plot(plot_holder, vehicles[idx].graph_data, $.extend(false, plot_options, {yaxes:vehicles[idx].graph_yaxes}));
@@ -889,9 +895,15 @@ function graphAddLastPosition(idx) {
889895
var ts_last_idx = data[0].data.length - 1;
890896
var ts_last = data[0].data[ts_last_idx][0];
891897

892-
//insert gap when there are 2mins, or more, without telemetry
893-
if(ts_last + 120000 < ts) {
894-
$.each(data, function(k,v) { v.data.push([ts_last+1, null]); v.nulls += 1; })
898+
//insert gap when there are 3mins, or more, without telemetry
899+
var gap_size = 180000; // 3 mins in milis
900+
901+
if(ts_last + gap_size < ts) {
902+
$.each(data, function(k,v) {
903+
v.data.push([ts_last+gap_size, v.data[v.data.length - 1][1]]);
904+
v.data.push([ts_last+gap_size+1, null]);
905+
v.nulls += 2;
906+
})
895907
}
896908

897909
// update the selection upper limit to the latest timestamp, only if the upper limit is equal to the last timestamp
@@ -929,6 +941,7 @@ function graphAddLastPosition(idx) {
929941
label: k + " = 0",
930942
key: k,
931943
yaxis: i + 1,
944+
nulls: 0,
932945
data: []
933946
};
934947

0 commit comments

Comments
 (0)