@@ -713,11 +713,17 @@ function addPosition(position) {
713713 alt_list : [ 0 ] ,
714714 time_last_alt : 0 ,
715715 alt_max : 100 ,
716- graph_data : [ ]
716+ graph_data : [ ] ,
717+ graph_yaxes : [ ]
717718 } ;
719+
720+ // deep copy yaxes config for graph
721+ $ . each ( $ . extend ( false , plot_options . yaxes , { } ) , function ( k , v ) { vehicle_info . graph_yaxes . push ( v ) } ) ;
722+
718723 vehicles . push ( vehicle_info ) ;
719724 }
720725
726+
721727 var vehicle_index = $ . inArray ( position . vehicle , vehicle_names ) ;
722728 var vehicle = vehicles [ vehicle_index ] ;
723729
@@ -785,7 +791,8 @@ function addPosition(position) {
785791function updateGraph ( idx ) {
786792 if ( ! plot ) return ;
787793
788- plot = $ . plot ( plot_holder , vehicles [ idx ] . graph_data , plot_options ) ;
794+ // replot graph, with this vehicle data, and this vehicles yaxes config
795+ plot = $ . plot ( plot_holder , vehicles [ idx ] . graph_data , $ . extend ( false , plot_options , { yaxes :vehicles [ idx ] . graph_yaxes } ) ) ;
789796}
790797
791798function graphAddLastPosition ( idx ) {
@@ -809,7 +816,7 @@ function graphAddLastPosition(idx) {
809816
810817 // push latest altitude
811818 data [ 0 ] . data . push ( [ ts , parseInt ( new_data . gps_alt ) ] ) ;
812- if ( parseInt ( new_data . gps_alt ) < 0 ) delete plot_options . yaxes [ series_idx - 1 ] . min ;
819+ if ( parseInt ( new_data . gps_alt ) < 0 ) delete vehicles [ idx ] . graph_yaxes [ series_idx - 1 ] . min ;
813820
814821 // the rest of the series is from the data field
815822 var json = $ . parseJSON ( new_data . data ) ;
@@ -830,7 +837,7 @@ function graphAddLastPosition(idx) {
830837 if ( isInt ( v ) ) $ . extend ( true , data [ i ] , { noInterpolate : true , lines : { steps : true } } ) ;
831838 }
832839 data [ i ] . data . push ( [ ts , parseFloat ( v ) ] ) ;
833- if ( parseFloat ( v ) < 0 ) delete plot_options . yaxes [ i + 1 ] . min ;
840+ if ( parseFloat ( v ) < 0 ) delete vehicles [ idx ] . graph_yaxes [ i ] . min ;
834841 } ) ;
835842}
836843
0 commit comments