@@ -413,9 +413,6 @@ function updateVehicleInfo(index, position) {
413413 $ ( '.portrait .vehicle' + index ) . html ( a + p + b ) ;
414414 $ ( '.landscape .vehicle' + index ) . html ( a + l + b ) ;
415415
416- // update graph is current vehicles is followed
417- if ( vehicles [ index ] . follow ) updateGraph ( index ) ;
418-
419416 return true ;
420417}
421418
@@ -713,6 +710,7 @@ function addPosition(position) {
713710 alt_list : [ 0 ] ,
714711 time_last_alt : 0 ,
715712 alt_max : 100 ,
713+ graph_data_updated : false ,
716714 graph_data : [ ] ,
717715 graph_yaxes : [ ]
718716 } ;
@@ -798,11 +796,22 @@ function updateGraph(idx) {
798796function graphAddLastPosition ( idx ) {
799797 if ( ! plot ) return ;
800798
799+ vehicles [ idx ] . graph_data_updated = true ;
801800 var data = vehicles [ idx ] . graph_data ;
802801 var new_data = vehicles [ idx ] . curr_position ;
803802 var ts = ( new Date ( new_data . gps_time ) ) . getTime ( ) ; // flot needs miliseconds for time
804803 var series_idx = 1 ;
805804
805+ //insert gap when there are 2mins, or more, without telemetry
806+ if ( vehicles [ idx ] . graph_data . length ) {
807+ var ts_last_idx = vehicles [ idx ] . graph_data [ 0 ] . data . length - 1 ;
808+ var ts_last = vehicles [ idx ] . graph_data [ 0 ] . data [ ts_last_idx ] [ 0 ] ;
809+
810+ if ( ts_last + 120000 < ts ) {
811+ $ . each ( vehicles [ idx ] . graph_data , function ( k , v ) { v . data . push ( [ ts_last + 1 , null ] ) ; } )
812+ }
813+ }
814+
806815 // altitude is always the first series
807816 if ( data [ 0 ] === undefined ) {
808817 data [ 0 ] = {
@@ -1066,6 +1075,9 @@ function update(response) {
10661075 lastPPointer . push ( vehicles [ i ] . curr_position ) ;
10671076 }
10681077
1078+ // update graph is current vehicles is followed
1079+ if ( follow_vehicle != - 1 && vehicles [ follow_vehicle ] . graph_data_updated ) updateGraph ( follow_vehicle ) ;
1080+
10691081 // store in localStorage
10701082 offline . set ( 'positions' , lastPositions ) ;
10711083
0 commit comments