@@ -395,7 +395,7 @@ GraphSpectrumPlot._drawPowerSpectralDensityGraph = function (canvasCtx) {
395
395
canvasCtx . restore ( ) ;
396
396
} ;
397
397
398
- GraphSpectrumPlot . _drawFrequencyVsXGraph = function ( canvasCtx ) {
398
+ GraphSpectrumPlot . _drawFrequencyVsXGraph = function ( canvasCtx , drawPSD = false ) {
399
399
const PLOTTED_BLACKBOX_RATE = this . _fftData . blackBoxRate / this . _zoomX ;
400
400
401
401
const ACTUAL_MARGIN_LEFT = this . _getActualMarginLeft ( ) ;
@@ -407,7 +407,7 @@ GraphSpectrumPlot._drawFrequencyVsXGraph = function (canvasCtx) {
407
407
canvasCtx . translate ( LEFT , TOP ) ;
408
408
409
409
if ( this . _cachedDataCanvas == null ) {
410
- this . _cachedDataCanvas = this . _drawHeatMap ( ) ;
410
+ this . _cachedDataCanvas = this . _drawHeatMap ( drawPSD ) ;
411
411
}
412
412
413
413
canvasCtx . drawImage ( this . _cachedDataCanvas , 0 , 0 , WIDTH , HEIGHT ) ;
@@ -467,7 +467,7 @@ GraphSpectrumPlot._drawFrequencyVsXGraph = function (canvasCtx) {
467
467
}
468
468
} ;
469
469
470
- GraphSpectrumPlot . _drawHeatMap = function ( ) {
470
+ GraphSpectrumPlot . _drawHeatMap = function ( drawPSD = false ) {
471
471
const THROTTLE_VALUES_SIZE = 100 ;
472
472
const SCALE_HEATMAP = 1.3 ; // Value decided after some tests to be similar to the scale of frequency graph
473
473
// This value will be maximum color
@@ -485,9 +485,16 @@ GraphSpectrumPlot._drawHeatMap = function () {
485
485
for ( let j = 0 ; j < 100 ; j ++ ) {
486
486
// Loop for frequency
487
487
for ( let i = 0 ; i < this . _fftData . fftLength ; i ++ ) {
488
- const valuePlot = Math . round (
489
- Math . min ( this . _fftData . fftOutput [ j ] [ i ] * fftColorScale , 100 )
490
- ) ;
488
+ if ( drawPSD ) {
489
+ const min = - 40 , max = 10 ; //limit values dBm
490
+ let valuePlot = Math . max ( this . _fftData . fftOutput [ j ] [ i ] , min ) ;
491
+ valuePlot = Math . min ( this . _fftData . fftOutput [ j ] [ i ] , max ) ;
492
+ valuePlot = Math . round ( ( valuePlot - min ) * 100 / ( max - min ) ) ;
493
+ } else {
494
+ const valuePlot = Math . round (
495
+ Math . min ( this . _fftData . fftOutput [ j ] [ i ] * fftColorScale , 100 )
496
+ ) ;
497
+ }
491
498
492
499
// The fillStyle is slow, but I haven't found a way to do this faster...
493
500
canvasCtx . fillStyle = `hsl(360, 100%, ${ valuePlot } %)` ;
0 commit comments