Skip to content

Commit 257f5cc

Browse files
committed
The vertical slider shifts the PSD charts dBm range
1 parent e6d4fe4 commit 257f5cc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/graph_spectrum_plot.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,15 +504,24 @@ GraphSpectrumPlot._drawHeatMap = function (drawPSD = false) {
504504

505505
const fftColorScale = 100 / (this._zoomY * SCALE_HEATMAP);
506506

507+
//Compute the dbm range shift from zoomY as[-30, -20, -10, 0, +10, +20]
508+
let dBmRangeShift = Math.floor(1 / this._zoomY) - 1; // -1 ... 9
509+
if (dBmRangeShift > 0) {
510+
dBmRangeShift = -10 * Math.round(dBmRangeShift / 3); //-10, -20, -30
511+
} else if (dBmRangeShift < 0) {
512+
dBmRangeShift = -10 * Math.round(dBmRangeShift * 2); //+20
513+
}
514+
const dBmValueMin = MIN_DBM_VALUE + dBmRangeShift,
515+
dBmValueMax = MAX_DBM_VALUE + dBmRangeShift;
507516
// Loop for throttle
508517
for (let j = 0; j < THROTTLE_VALUES_SIZE; j++) {
509518
// Loop for frequency
510519
for (let i = 0; i < this._fftData.fftLength; i++) {
511520
let valuePlot;
512521
if (drawPSD) {
513-
valuePlot = Math.max(this._fftData.fftOutput[j][i], MIN_DBM_VALUE);
514-
valuePlot = Math.min(valuePlot, MAX_DBM_VALUE);
515-
valuePlot = Math.round((valuePlot - MIN_DBM_VALUE) * 100 / (MAX_DBM_VALUE - MIN_DBM_VALUE));
522+
valuePlot = Math.max(this._fftData.fftOutput[j][i], dBmValueMin);
523+
valuePlot = Math.min(valuePlot, dBmValueMax);
524+
valuePlot = Math.round((valuePlot - dBmValueMin) * 100 / (dBmValueMax - dBmValueMin));
516525
} else {
517526
valuePlot = Math.round(
518527
Math.min(this._fftData.fftOutput[j][i] * fftColorScale, 100)

0 commit comments

Comments
 (0)