Skip to content

Commit fcfa587

Browse files
fix pred.alt. not showing on clipped graphs
1 parent 5bf3d63 commit fcfa587

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

js/tracker.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,20 +1921,22 @@ function updateGraph(vcallsign, reset_selection) {
19211921
updateTimebox(new Date());
19221922
}
19231923

1924-
if(vcallsign === null) return;
1924+
if(vcallsign === null || !vehicles.hasOwnProperty(vcallsign)) return;
19251925

19261926
var series = vehicles[vcallsign].graph_data;
19271927

19281928
// if we are drawing the plot for the fisrt time
19291929
// and the dataset is too large, we set an initial selection of the last 7 days
19301930
if(!plot_options.hasOwnProperty('xaxis')) {
19311931
if(series.length && series[0].data.length > 4001) {
1932-
var end = series[0].data.length - 1;
1932+
var last = series[0].data.length - 1;
1933+
var end_a = series[0].data[last][0];
1934+
var end_b = (series[1].data.length) ? series[1].data[series[1].data.length - 1][0] : 0;
19331935

19341936
plot_options.xaxis = {
19351937
superzoom: 1,
1936-
min: series[0].data[end-4000][0],
1937-
max: series[0].data[end][0],
1938+
min: series[0].data[last-4000][0],
1939+
max: Math.max(end_a, end_b),
19381940
};
19391941

19401942
}
@@ -2643,7 +2645,9 @@ function update(response) {
26432645
end: function(ctx) {
26442646

26452647
// update graph is current vehicles is followed
2646-
if(follow_vehicle !== null && vehicles[follow_vehicle].graph_data_updated) updateGraph(follow_vehicle, false);
2648+
if(follow_vehicle !== null &&
2649+
vehicles.hasOwnProperty(follow_vehicle) &&
2650+
vehicles[follow_vehicle].graph_data_updated) updateGraph(follow_vehicle, false);
26472651

26482652
// store in localStorage
26492653
offline.set('positions', ctx.lastPositions);

0 commit comments

Comments
 (0)