From ad8fe704590d4a617b066dcc22717c76c7a98cf2 Mon Sep 17 00:00:00 2001 From: Vladimir Demidov Date: Fri, 30 May 2025 15:40:51 +0300 Subject: [PATCH 1/2] =?UTF-8?q?Revert=20"Bug=20fix:=20The=20spectrum=20gra?= =?UTF-8?q?ph=20is=20sometimes=20not=20displayed=20after=20change=20s?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 692e02a7b8aed7847d7bea8657197017593be936. --- src/graph_spectrum.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/graph_spectrum.js b/src/graph_spectrum.js index bfa93be1..c89251a5 100644 --- a/src/graph_spectrum.js +++ b/src/graph_spectrum.js @@ -17,16 +17,15 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) { let that = this, analyserZoomX = 1.0 /* 100% */, analyserZoomY = 1.0 /* 100% */, + dataBuffer = { + fieldIndex: 0, + curve: 0, + fieldName: null, + }, dataReload = false, fftData = null, prefs = new PrefStorage(); - this.dataBuffer = { - fieldIndex: 0, - curve: 0, - fieldName: null, - }; - try { let isFullscreen = false; @@ -101,8 +100,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) { }); }; - const dataLoad = function () { - GraphSpectrumCalc.setDataBuffer(that.dataBuffer); + let dataLoad = function () { + GraphSpectrumCalc.setDataBuffer(dataBuffer); + switch (userSettings.spectrumType) { case SPECTRUM_TYPE.FREQ_VS_THROTTLE: fftData = GraphSpectrumCalc.dataLoadFrequencyVsThrottle(); @@ -128,16 +128,19 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) { analyser on screen*/ this.plotSpectrum = function (fieldIndex, curve, fieldName) { // Store the data pointers + dataBuffer = { + fieldIndex: fieldIndex, + curve: curve, + fieldName: fieldName, + }; - that.dataBuffer.fieldIndex = fieldIndex; - that.dataBuffer.curve = curve; - that.dataBuffer.fieldName = fieldName; // Detect change of selected field.... reload and redraw required. if (fftData == null || fieldIndex != fftData.fieldIndex || dataReload) { dataReload = false; dataLoad(); GraphSpectrumPlot.setData(fftData, userSettings.spectrumType); } + that.draw(); // draw the analyser on the canvas.... }; @@ -208,9 +211,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) { // Recalculate the data, for the same curve than now, and draw it dataReload = true; that.plotSpectrum( - that.dataBuffer.fieldIndex, - that.dataBuffer.curve, - that.dataBuffer.fieldName, + dataBuffer.fieldIndex, + dataBuffer.curve, + dataBuffer.fieldName ); } From aa8ea0ad8d0f94794b6b9076038c6a381ec2e9db Mon Sep 17 00:00:00 2001 From: Vladimir Demidov Date: Fri, 30 May 2025 15:57:39 +0300 Subject: [PATCH 2/2] Code style improvement --- src/graph_spectrum.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graph_spectrum.js b/src/graph_spectrum.js index c89251a5..fc5db706 100644 --- a/src/graph_spectrum.js +++ b/src/graph_spectrum.js @@ -213,7 +213,7 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) { that.plotSpectrum( dataBuffer.fieldIndex, dataBuffer.curve, - dataBuffer.fieldName + dataBuffer.fieldName, ); }