@@ -100,8 +100,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
100100 } ) ;
101101 } ;
102102
103- let dataLoad = function ( ) {
104- GraphSpectrumCalc . setDataBuffer ( dataBuffer ) ;
103+ const dataLoad = function ( fieldIndex , curve , fieldName ) {
104+ if ( fieldIndex > 0 && curve != null && fieldName != null ) {
105+ GraphSpectrumCalc . setDataBuffer ( fieldIndex , curve , fieldName ) ;
106+ }
105107
106108 switch ( userSettings . spectrumType ) {
107109 case SPECTRUM_TYPE . FREQ_VS_THROTTLE :
@@ -127,15 +129,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
127129 It is only used to record the current curve positions, collect the data and draw the
128130 analyser on screen*/
129131 this . plotSpectrum = function ( fieldIndex , curve , fieldName ) {
130- // Store the data pointers
131- dataBuffer . fieldIndex = fieldIndex ;
132- dataBuffer . curve = curve ;
133- dataBuffer . fieldName = fieldName ;
134-
135132 // Detect change of selected field.... reload and redraw required.
136133 if ( fftData == null || fieldIndex != fftData . fieldIndex || dataReload ) {
137134 dataReload = false ;
138- dataLoad ( ) ;
135+ dataLoad ( fieldIndex , curve , fieldName ) ;
139136 GraphSpectrumPlot . setData ( fftData , userSettings . spectrumType ) ;
140137 }
141138
@@ -206,20 +203,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
206203 userSettings . spectrumType = optionSelected ;
207204 saveOneUserSetting ( "spectrumType" , userSettings . spectrumType ) ;
208205
209- // Restore dataBuffer if it was corrupted
210- if ( ! dataBuffer . curve ) {
211- dataBuffer . curve = GraphSpectrumCalc . _dataBuffer . curve ;
212- dataBuffer . fieldName = GraphSpectrumCalc . _dataBuffer . fieldName ;
213- dataBuffer . fieldIndex = GraphSpectrumCalc . _dataBuffer . fieldIndex ;
214- console . warn ( "The dataBuffer was corrupted (set to default zeroes) in FlightLogAnalyser.spectrumTypeElem.change event" ) ;
215- }
216206 // Recalculate the data, for the same curve than now, and draw it
217207 dataReload = true ;
218- that . plotSpectrum (
219- dataBuffer . fieldIndex ,
220- dataBuffer . curve ,
221- dataBuffer . fieldName ,
222- ) ;
208+ that . plotSpectrum ( - 1 , null , null ) ; // Update fft data only
223209 }
224210
225211 // Hide overdraw and zoomY if needed
0 commit comments