Skip to content

Commit d26c67e

Browse files
committed
Resolved issue of imported curves frequency scaling
1 parent cc01fee commit d26c67e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/graph_spectrum_plot.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ GraphSpectrumPlot._drawFrequencyGraph = function (canvasCtx) {
261261
x += stepX;
262262
}
263263

264-
const scaleX = 2 * WIDTH / PLOTTED_BLACKBOX_RATE * this._zoomX;
264+
const scaleX = 2 * WIDTH / PLOTTED_BLACKBOX_RATE;
265265
const spectrumCount = this._importedSpectrums.curvesCount();
266266
for (let spectrumNum = 0; spectrumNum < spectrumCount; spectrumNum++) {
267267
const curvesPonts = this._importedSpectrums._curvesData[spectrumNum].points;
@@ -346,7 +346,7 @@ GraphSpectrumPlot._drawPowerSpectralDensityGraph = function (canvasCtx) {
346346

347347
const ticksCount = (maxY - minY) / dbStep;
348348
const pointsCount = this._fftData.fftLength;
349-
const scaleX = 2 * WIDTH / PLOTTED_BLACKBOX_RATE * this._zoomX;
349+
const scaleX = 2 * WIDTH / PLOTTED_BLACKBOX_RATE;
350350
const scaleY = HEIGHT / (maxY - minY);
351351

352352
canvasCtx.translate(LEFT, TOP);
@@ -357,7 +357,10 @@ GraphSpectrumPlot._drawPowerSpectralDensityGraph = function (canvasCtx) {
357357
canvasCtx.strokeStyle = "white";
358358
canvasCtx.moveTo(0, 0);
359359
for (let pointNum = 0; pointNum < pointsCount; pointNum++) {
360-
const freq = PLOTTED_BLACKBOX_RATE / 2 * pointNum / pointsCount;
360+
const freq = this._fftData.blackBoxRate / 2 * pointNum / pointsCount;
361+
if(freq > PLOTTED_BLACKBOX_RATE / 2) {
362+
break;
363+
}
361364
const y = HEIGHT - (this._fftData.fftOutput[pointNum] - minY) * scaleY;
362365
canvasCtx.lineTo(freq * scaleX, y);
363366
}
@@ -372,6 +375,9 @@ GraphSpectrumPlot._drawPowerSpectralDensityGraph = function (canvasCtx) {
372375
canvasCtx.strokeStyle = this.curvesColors[spectrumNum];
373376
canvasCtx.moveTo(0, HEIGHT);
374377
for (const point of curvesPonts) {
378+
if(point.x > PLOTTED_BLACKBOX_RATE / 2) {
379+
break;
380+
}
375381
canvasCtx.lineTo(point.x * scaleX, HEIGHT - (point.y - minY) * scaleY);
376382
}
377383
canvasCtx.stroke();

0 commit comments

Comments
 (0)