Skip to content

Commit 8f619f7

Browse files
authored
Revert "Bug fix: The spectrum graph is sometimes not displayed after change spectrums type" (#838)
* Revert "Bug fix: The spectrum graph is sometimes not displayed after change s…" This reverts commit 692e02a. * Code style improvement
1 parent 692e02a commit 8f619f7

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/graph_spectrum.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
1717
let that = this,
1818
analyserZoomX = 1.0 /* 100% */,
1919
analyserZoomY = 1.0 /* 100% */,
20+
dataBuffer = {
21+
fieldIndex: 0,
22+
curve: 0,
23+
fieldName: null,
24+
},
2025
dataReload = false,
2126
fftData = null,
2227
prefs = new PrefStorage();
2328

24-
this.dataBuffer = {
25-
fieldIndex: 0,
26-
curve: 0,
27-
fieldName: null,
28-
};
29-
3029
try {
3130
let isFullscreen = false;
3231

@@ -101,8 +100,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
101100
});
102101
};
103102

104-
const dataLoad = function () {
105-
GraphSpectrumCalc.setDataBuffer(that.dataBuffer);
103+
let dataLoad = function () {
104+
GraphSpectrumCalc.setDataBuffer(dataBuffer);
105+
106106
switch (userSettings.spectrumType) {
107107
case SPECTRUM_TYPE.FREQ_VS_THROTTLE:
108108
fftData = GraphSpectrumCalc.dataLoadFrequencyVsThrottle();
@@ -128,16 +128,19 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
128128
analyser on screen*/
129129
this.plotSpectrum = function (fieldIndex, curve, fieldName) {
130130
// Store the data pointers
131+
dataBuffer = {
132+
fieldIndex: fieldIndex,
133+
curve: curve,
134+
fieldName: fieldName,
135+
};
131136

132-
that.dataBuffer.fieldIndex = fieldIndex;
133-
that.dataBuffer.curve = curve;
134-
that.dataBuffer.fieldName = fieldName;
135137
// Detect change of selected field.... reload and redraw required.
136138
if (fftData == null || fieldIndex != fftData.fieldIndex || dataReload) {
137139
dataReload = false;
138140
dataLoad();
139141
GraphSpectrumPlot.setData(fftData, userSettings.spectrumType);
140142
}
143+
141144
that.draw(); // draw the analyser on the canvas....
142145
};
143146

@@ -208,9 +211,9 @@ export function FlightLogAnalyser(flightLog, canvas, analyserCanvas) {
208211
// Recalculate the data, for the same curve than now, and draw it
209212
dataReload = true;
210213
that.plotSpectrum(
211-
that.dataBuffer.fieldIndex,
212-
that.dataBuffer.curve,
213-
that.dataBuffer.fieldName,
214+
dataBuffer.fieldIndex,
215+
dataBuffer.curve,
216+
dataBuffer.fieldName,
214217
);
215218
}
216219

0 commit comments

Comments
 (0)