@@ -113,7 +113,7 @@ GraphSpectrumCalc._dataLoadFrequencyVsX = function(vsFieldNames, minValue = Infi
113113
114114 // We divide it into FREQ_VS_THR_CHUNK_TIME_MS FFT chunks, we calculate the average throttle
115115 // for each chunk. We use a moving window to get more chunks available.
116- const fftChunkLength = this . _blackBoxRate * FREQ_VS_THR_CHUNK_TIME_MS / 1000 ;
116+ const fftChunkLength = Math . round ( this . _blackBoxRate * FREQ_VS_THR_CHUNK_TIME_MS / 1000 ) ;
117117 const fftChunkWindow = Math . round ( fftChunkLength / FREQ_VS_THR_WINDOW_DIVISOR ) ;
118118
119119 let maxNoise = 0 ; // Stores the maximum amplitude of the fft over all chunks
@@ -156,9 +156,9 @@ GraphSpectrumCalc._dataLoadFrequencyVsX = function(vsFieldNames, minValue = Infi
156156 }
157157 // Translate the average vs value to a bin index
158158 const avgVsValue = sumVsValues / fftChunkLength ;
159- let vsBinIndex = Math . floor ( NUM_VS_BINS * ( avgVsValue - flightSamples . minValue ) / ( flightSamples . maxValue - flightSamples . minValue ) ) ;
159+ let vsBinIndex = Math . round ( NUM_VS_BINS * ( avgVsValue - flightSamples . minValue ) / ( flightSamples . maxValue - flightSamples . minValue ) ) ;
160160 // ensure that avgVsValue == flightSamples.maxValue does not result in an out of bounds access
161- if ( vsBinIndex == = NUM_VS_BINS ) { vsBinIndex = NUM_VS_BINS - 1 ; }
161+ if ( vsBinIndex > = NUM_VS_BINS ) { vsBinIndex = NUM_VS_BINS - 1 ; }
162162 numberSamples [ vsBinIndex ] ++ ;
163163
164164 // add the output from the fft to the row given by the vs value bin index
@@ -349,7 +349,7 @@ GraphSpectrumCalc._getFlightSamplesFreqVsX = function(vsFieldNames, minValue = I
349349 }
350350
351351 // Calculate min max average of the VS values in the chunk what will used by spectrum data definition
352- const fftChunkLength = this . _blackBoxRate * FREQ_VS_THR_CHUNK_TIME_MS / 1000 ;
352+ const fftChunkLength = Math . round ( this . _blackBoxRate * FREQ_VS_THR_CHUNK_TIME_MS / 1000 ) ;
353353 const fftChunkWindow = Math . round ( fftChunkLength / FREQ_VS_THR_WINDOW_DIVISOR ) ;
354354 for ( let fftChunkIndex = 0 ; fftChunkIndex + fftChunkLength < samplesCount ; fftChunkIndex += fftChunkWindow ) {
355355 for ( const vsValueArray of vsValues ) {
0 commit comments