@@ -813,17 +813,20 @@ function graphAddLastPosition(idx) {
813813 var ts = ( new Date ( new_data . gps_time ) ) . getTime ( ) ; // flot needs miliseconds for time
814814 var series_idx = 1 ;
815815
816- //insert gap when there are 2mins, or more, without telemetry
817816 if ( vehicles [ idx ] . graph_data . length ) {
818817 var ts_last_idx = data [ 0 ] . data . length - 1 ;
819818 var ts_last = data [ 0 ] . data [ ts_last_idx ] [ 0 ] ;
820819
820+ //insert gap when there are 2mins, or more, without telemetry
821821 if ( ts_last + 120000 < ts ) {
822822 $ . each ( data , function ( k , v ) { v . data . push ( [ ts_last + 1 , null ] ) ; v . nulls += 1 ; } )
823823 }
824+
825+ // update the selection upper limit to the latest timestamp, only if the upper limit is equal to the last timestamp
826+ if ( plot_options . xaxis && follow_vehicle == idx && ts_last == plot_options . xaxis . max ) plot_options . xaxis . max = ts ;
824827 }
825828
826- // altitude is always the first series
829+ // altitude is always first in the series
827830 if ( data [ 0 ] === undefined ) {
828831 data [ 0 ] = {
829832 label : "altitude = 0" ,
@@ -857,18 +860,10 @@ function graphAddLastPosition(idx) {
857860
858861 if ( isInt ( v ) ) $ . extend ( true , data [ i ] , { noInterpolate : true , lines : { steps : true } } ) ;
859862 }
863+
860864 data [ i ] . data . push ( [ ts , parseFloat ( v ) ] ) ;
861865 if ( parseFloat ( v ) < 0 ) delete vehicles [ idx ] . graph_yaxes [ i ] . min ;
862866 } ) ;
863-
864- // if a selection is made, that reaches the end, new data will be appended as it comes
865- if ( plot_options . xaxis && follow_vehicle == idx ) {
866- var prev_idx = data [ 0 ] . data . length - 2 ;
867- var prev_ts = data [ 0 ] . data [ prev_idx ] [ 0 ] ;
868-
869- // update the selection upper limit to the latest timestamp
870- if ( prev_ts == plot_options . xaxis . max ) plot_options . xaxis . max = ts ;
871- }
872867}
873868
874869function refresh ( ) {
0 commit comments