Skip to content

Commit dd0e816

Browse files
updated graph functionality
* ctrl+click on the graph will lock the crosshair - also locks time and path marker - to unlock, just click again * graph path marker is now clickable to display position infobox * fixed graph not redrawing after change of follow target while graph is minimized
1 parent c4c3f2e commit dd0e816

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

js/app.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ $(window).ready(function() {
407407
$('#map').stop(null,null).animate({'height': h}, function() {
408408
if(map) google.maps.event.trigger(map, 'resize');
409409

410-
if(plot_open && follow_vehicle !== null && vehicles[follow_vehicle].graph_data_updated) updateGraph(follow_vehicle, true);
410+
if(plot_open &&
411+
follow_vehicle !== null &&
412+
(follow_vehicle != graph_vehicle || vehicles[follow_vehicle].graph_data_updated)) updateGraph(follow_vehicle, true);
411413
});
412414
});
413415

@@ -449,12 +451,9 @@ $(window).ready(function() {
449451

450452
// reset nite-overlay and timebox when mouse goes out of the graph box
451453
$("#telemetry_graph").on('mouseout','.holder', function() {
452-
nite.setDate(null);
453-
nite.refresh();
454-
if(polyMarker) polyMarker.setMap(null);
454+
if(plot_crosshair_locked) return;
455455

456-
$("#timebox").removeClass('past').addClass('present');
457-
updateTimebox(new Date());
456+
updateGraph(null, true);
458457
});
459458

460459
// hand cursor for dragging the vehicle list

js/plot_config.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ function updateLegend(pos) {
5555

5656
if(!polyMarker) {
5757
polyMarker = new google.maps.Marker({
58-
clickable: false,
58+
clickable: true,
5959
flat: true,
6060
map: map,
6161
visible: true,
6262
icon: null
6363
});
64+
google.maps.event.addListener(polyMarker, 'click', function() { mapInfoBox_handle_path({latLng: this.getPosition()}); });
6465
}
6566

6667
// this loop finds an existing data point, so we can get coordinates
@@ -98,11 +99,22 @@ function updateLegend(pos) {
9899
}
99100
}
100101

102+
var plot_crosshair_locked = false;
103+
104+
$(plot_holder).bind("click", function (event) {
105+
if(plot_crosshair_locked) {
106+
plot_crosshair_locked = false;
107+
} else if(event.ctrlKey) {
108+
plot_crosshair_locked = true;
109+
}
110+
});
101111
// update legend values on mouse hover
102112
$(plot_holder).bind("plothover", function (event, pos, item) {
103-
plot.lockCrosshair();
104-
plot.setCrosshair(pos);
113+
if(plot_crosshair_locked) return;
114+
105115
if (!updateLegendTimeout) {
116+
plot.lockCrosshair();
117+
plot.setCrosshair(pos);
106118
updateLegend(pos);
107119
updateLegendTimeout = setTimeout(function() { updateLegendTimeout = null; }, 40);
108120
}

js/tracker.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var got_positions = false;
2020
var zoomed_in = false;
2121
var max_positions = 0; // maximum number of positions that ajax request should return (0 means no maximum)
2222
var follow_vehicle = null;
23+
var graph_vehicle = null;
2324
var manual_pan = false;
2425

2526
var car_index = 0;
@@ -398,6 +399,7 @@ function load() {
398399
'<div class="row vehicle'+elm_uuid+'"><div class="header empty">' +
399400
'<img style="width:90px;height:30px" src="img/hab-spinner.gif"/></div></div>'
400401
);
402+
listScroll.refresh();
401403

402404
refresh();
403405

@@ -669,13 +671,11 @@ function stopFollow() {
669671

670672
if(follow_vehicle in vehicles) vehicles[follow_vehicle].follow = false;
671673
follow_vehicle = null;
674+
graph_vehicle = null;
672675

673676
// clear graph
674-
plot = $.plot(plot_holder, {}, plot_options);
675-
676-
// reset nite overlay
677-
nite.setDate(null);
678-
nite.refresh();
677+
if(plot) plot = $.plot(plot_holder, {}, plot_options);
678+
updateGraph(null, true);
679679

680680
// update lookangles box
681681
if(GPS_ts !== null) $("#lookanglesbox span").hide().parent().find(".nofollow").show();
@@ -1143,7 +1143,7 @@ var mapInfoBox_handle_prediction_path = function(event) {
11431143
};
11441144

11451145
var mapInfoBox_handle_path = function(event) {
1146-
var vehicle = this.vehicle;
1146+
var vehicle = this.vehicle || vehicles[follow_vehicle];
11471147
var target = event.latLng;
11481148
var p = vehicle.positions;
11491149

@@ -1820,16 +1820,23 @@ function addPosition(position) {
18201820
function updateGraph(vcallsign, reset_selection) {
18211821
if(!plot || !plot_open) return;
18221822

1823-
if(polyMarker) polyMarker.setPosition(null);
18241823

18251824
if(reset_selection) {
18261825
delete plot_options.xaxis;
18271826

1827+
if(polyMarker) polyMarker.setPosition(null);
1828+
plot_crosshair_locked = false;
1829+
18281830
// reset nite overlay
18291831
nite.setDate(null);
18301832
nite.refresh();
1833+
1834+
$("#timebox").removeClass('past').addClass('present');
1835+
updateTimebox(new Date());
18311836
}
18321837

1838+
if(vcallsign === null) return;
1839+
18331840
var series = vehicles[vcallsign].graph_data;
18341841

18351842
// if we are drawing the plot for the fisrt time
@@ -1849,6 +1856,7 @@ function updateGraph(vcallsign, reset_selection) {
18491856

18501857
// replot graph, with this vehicle data, and this vehicles yaxes config
18511858
plot = $.plot(plot_holder, series, $.extend(false, plot_options, {yaxes:vehicles[vcallsign].graph_yaxes}));
1859+
graph_vehicle = follow_vehicle;
18521860

18531861
vehicles[vcallsign].graph_data_updated = false;
18541862
}

0 commit comments

Comments
 (0)