@@ -19,12 +19,7 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
1919 analyserZoomY = 1.0 /* 100% */ ,
2020 dataReload = false ,
2121 fftData = null ,
22- prefs = new PrefStorage ( ) ,
23- dataBuffer = {
24- fieldIndex : 0 ,
25- curve : null ,
26- fieldName : null ,
27- } ;
22+ prefs = new PrefStorage ( ) ;
2823
2924 try {
3025 let isFullscreen = false ;
@@ -100,8 +95,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
10095 } ) ;
10196 } ;
10297
103- let dataLoad = function ( ) {
104- GraphSpectrumCalc . setDataBuffer ( dataBuffer ) ;
98+ const dataLoad = function ( fieldIndex , curve , fieldName ) {
99+ if ( fieldIndex > 0 && curve != null && fieldName != null ) {
100+ GraphSpectrumCalc . setDataBuffer ( fieldIndex , curve , fieldName ) ;
101+ }
105102
106103 switch ( userSettings . spectrumType ) {
107104 case SPECTRUM_TYPE . FREQ_VS_THROTTLE :
@@ -127,15 +124,10 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
127124 It is only used to record the current curve positions, collect the data and draw the
128125 analyser on screen*/
129126 this . plotSpectrum = function ( fieldIndex , curve , fieldName ) {
130- // Store the data pointers
131- dataBuffer . fieldIndex = fieldIndex ;
132- dataBuffer . curve = curve ;
133- dataBuffer . fieldName = fieldName ;
134-
135127 // Detect change of selected field.... reload and redraw required.
136128 if ( fftData == null || fieldIndex != fftData . fieldIndex || dataReload ) {
137129 dataReload = false ;
138- dataLoad ( ) ;
130+ dataLoad ( fieldIndex , curve , fieldName ) ;
139131 GraphSpectrumPlot . setData ( fftData , userSettings . spectrumType ) ;
140132 }
141133
@@ -206,20 +198,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
206198 userSettings . spectrumType = optionSelected ;
207199 saveOneUserSetting ( "spectrumType" , userSettings . spectrumType ) ;
208200
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- }
216201 // Recalculate the data, for the same curve than now, and draw it
217202 dataReload = true ;
218- that . plotSpectrum (
219- dataBuffer . fieldIndex ,
220- dataBuffer . curve ,
221- dataBuffer . fieldName ,
222- ) ;
203+ that . plotSpectrum ( - 1 , null , null ) ; // Update fft data only
223204 }
224205
225206 // Hide overdraw and zoomY if needed
0 commit comments