Skip to content

Commit 07a3f06

Browse files
optimization: draw telemetry graph only when necessary
1 parent b018520 commit 07a3f06

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

js/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,23 @@ $(window).ready(function() {
367367
e.removeClass('active');
368368
var h = $('#map').height() + $('#telemetry_graph').height();
369369

370+
plot_open = false;
371+
370372
//analytics
371373
if(typeof _gaq == 'object') _gaq.push(['_trackEvent', 'UI', 'Collapse', 'Telemetry Graph']);
372374
} else {
373375
e.addClass('active');
374376
var h = $('#map').height() - $('#telemetry_graph').height();
375377

378+
plot_open = true;
379+
376380
//analytics
377381
if(typeof _gaq == 'object') _gaq.push(['_trackEvent', 'UI', 'Expand', 'Telemetry Graph']);
378382
}
379383
$('#map').stop(null,null).animate({'height': h}, function() {
380384
if(map) google.maps.event.trigger(map, 'resize');
385+
386+
if(plot_open && follow_vehicle != -1 && vehicles[follow_vehicle].graph_data_updated) updateGraph(follow_vehicle, true);
381387
});
382388
});
383389

js/tracker.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ var ls_receivers = false;
4545
var ls_pred = false;
4646

4747
var plot = null;
48+
var plot_open = false;
4849

4950
// weather
5051
var weatherOverlayId = "nexrad-n0q-900913";
@@ -1245,7 +1246,7 @@ function addPosition(position) {
12451246
}
12461247

12471248
function updateGraph(idx, reset_selection) {
1248-
if(!plot) return;
1249+
if(!plot || !plot_open) return;
12491250

12501251
if(polyMarker) polyMarker.setPosition(null);
12511252

@@ -1259,6 +1260,8 @@ function updateGraph(idx, reset_selection) {
12591260

12601261
// replot graph, with this vehicle data, and this vehicles yaxes config
12611262
plot = $.plot(plot_holder, vehicles[idx].graph_data, $.extend(false, plot_options, {yaxes:vehicles[idx].graph_yaxes}));
1263+
1264+
vehicles[idx].graph_data_updated = false;
12621265
}
12631266

12641267
function graphAddLastPosition(idx) {

0 commit comments

Comments
 (0)