Skip to content

Commit 908c5bd

Browse files
demvladhaslinghuis
andcommitted
Bug fix: The spectrum graph is sometimes not displayed after change spectrums type (#837)
* Resolved random bug of lose dataBuffer data by change spectrum type * Code style improvement Co-authored-by: Mark Haslinghuis <[email protected]> --------- Co-authored-by: Mark Haslinghuis <[email protected]>
1 parent 0e8278d commit 908c5bd

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/graph_spectrum.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
1919
let that = this,
2020
analyserZoomX = 1.0 /* 100% */,
2121
analyserZoomY = 1.0 /* 100% */,
22-
dataBuffer = {
23-
fieldIndex: 0,
24-
curve: 0,
25-
fieldName: null,
26-
},
2722
dataReload = false,
2823
fftData = null,
2924
prefs = new PrefStorage();
3025

26+
this.dataBuffer = {
27+
fieldIndex: 0,
28+
curve: 0,
29+
fieldName: null,
30+
};
31+
3132
try {
3233
let isFullscreen = false;
3334

@@ -122,9 +123,8 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
122123
});
123124
};
124125

125-
let dataLoad = function () {
126-
GraphSpectrumCalc.setDataBuffer(dataBuffer);
127-
126+
const dataLoad = function () {
127+
GraphSpectrumCalc.setDataBuffer(that.dataBuffer);
128128
switch (userSettings.spectrumType) {
129129
case SPECTRUM_TYPE.FREQ_VS_THROTTLE:
130130
fftData = GraphSpectrumCalc.dataLoadFrequencyVsThrottle();
@@ -162,19 +162,16 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
162162
analyser on screen*/
163163
this.plotSpectrum = function (fieldIndex, curve, fieldName) {
164164
// Store the data pointers
165-
dataBuffer = {
166-
fieldIndex: fieldIndex,
167-
curve: curve,
168-
fieldName: fieldName,
169-
};
170165

166+
that.dataBuffer.fieldIndex = fieldIndex;
167+
that.dataBuffer.curve = curve;
168+
that.dataBuffer.fieldName = fieldName;
171169
// Detect change of selected field.... reload and redraw required.
172170
if (fftData == null || fieldIndex != fftData.fieldIndex || dataReload) {
173171
dataReload = false;
174172
dataLoad();
175173
GraphSpectrumPlot.setData(fftData, userSettings.spectrumType);
176174
}
177-
178175
that.draw(); // draw the analyser on the canvas....
179176
};
180177

@@ -282,9 +279,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
282279
// Recalculate the data, for the same curve than now, and draw it
283280
dataReload = true;
284281
that.plotSpectrum(
285-
dataBuffer.fieldIndex,
286-
dataBuffer.curve,
287-
dataBuffer.fieldName,
282+
that.dataBuffer.fieldIndex,
283+
that.dataBuffer.curve,
284+
that.dataBuffer.fieldName,
288285
);
289286
}
290287

0 commit comments

Comments
 (0)