@@ -451,7 +451,7 @@ GraphSpectrumPlot._drawFrequencyVsXGraph = function (canvasCtx, drawPSD = false)
451
451
MARGIN_BOTTOM ,
452
452
"Hz"
453
453
) ;
454
-
454
+
455
455
if ( this . _spectrumType === SPECTRUM_TYPE . FREQ_VS_THROTTLE ||
456
456
this . _spectrumType === SPECTRUM_TYPE . PSD_VS_THROTTLE ) {
457
457
this . _drawVerticalGridLines (
@@ -523,6 +523,17 @@ GraphSpectrumPlot._drawHeatMap = function (drawPSD = false) {
523
523
return heatMapCanvas ;
524
524
} ;
525
525
526
+ GraphSpectrumPlot . getValueFromMatrixFFT = function ( frequency , vsArgument ) {
527
+ const NUM_VS_BINS = 100 ; // redefinition of value from graph_spectrum_calc.js module!
528
+ const matrixFFT = this . _fftData ;
529
+ let vsArgumentIndex = Math . round ( NUM_VS_BINS * ( vsArgument - matrixFFT . vsRange . min ) / ( matrixFFT . vsRange . max - matrixFFT . vsRange . min ) ) ;
530
+ if ( vsArgumentIndex === NUM_VS_BINS ) {
531
+ vsArgumentIndex = NUM_VS_BINS - 1 ;
532
+ }
533
+ const freqIndex = Math . round ( 2 * frequency / matrixFFT . blackBoxRate * ( matrixFFT . fftOutput [ 0 ] . length - 1 ) ) ;
534
+ return matrixFFT . fftOutput [ vsArgumentIndex ] [ freqIndex ] ;
535
+ } ;
536
+
526
537
GraphSpectrumPlot . _drawPidErrorVsSetpointGraph = function ( canvasCtx ) {
527
538
const ACTUAL_MARGIN_LEFT = this . _getActualMarginLeft ( ) ;
528
539
@@ -1463,6 +1474,7 @@ GraphSpectrumPlot._drawMousePosition = function (
1463
1474
lineWidth
1464
1475
) {
1465
1476
// X axis
1477
+ let mouseFrequency = 0 ;
1466
1478
if (
1467
1479
this . _spectrumType === SPECTRUM_TYPE . FREQUENCY ||
1468
1480
this . _spectrumType === SPECTRUM_TYPE . FREQ_VS_THROTTLE ||
@@ -1475,7 +1487,7 @@ GraphSpectrumPlot._drawMousePosition = function (
1475
1487
const sampleRate = this . _fftData . blackBoxRate / this . _zoomX ;
1476
1488
const marginLeft = this . _getActualMarginLeft ( ) ;
1477
1489
1478
- const mouseFrequency =
1490
+ mouseFrequency =
1479
1491
( ( mouseX - marginLeft ) / WIDTH ) *
1480
1492
( this . _fftData . blackBoxRate / this . _zoomX / 2 ) ;
1481
1493
if ( mouseFrequency >= 0 && mouseFrequency <= sampleRate ) {
@@ -1513,12 +1525,12 @@ GraphSpectrumPlot._drawMousePosition = function (
1513
1525
if ( unitLabel !== null ) {
1514
1526
const val_min = this . _fftData . vsRange . min ;
1515
1527
const val_max = this . _fftData . vsRange . max ;
1516
- const mouseValue = ( 1 - mouseY / HEIGHT ) * ( val_max - val_min ) + val_min ;
1517
- if ( mouseValue >= val_min && mouseValue <= val_max ) {
1518
- const valueLabel = `${ mouseValue . toFixed ( 0 ) } ${ unitLabel } ` ;
1528
+ const vsArgValue = ( 1 - mouseY / HEIGHT ) * ( val_max - val_min ) + val_min ;
1529
+ if ( vsArgValue >= val_min && vsArgValue <= val_max ) {
1530
+ const valueLabel = `${ vsArgValue . toFixed ( 0 ) } ${ unitLabel } ` ;
1519
1531
this . _drawHorizontalMarkerLine (
1520
1532
canvasCtx ,
1521
- mouseValue ,
1533
+ vsArgValue ,
1522
1534
val_min ,
1523
1535
val_max ,
1524
1536
valueLabel ,
@@ -1528,6 +1540,18 @@ GraphSpectrumPlot._drawMousePosition = function (
1528
1540
stroke ,
1529
1541
lineWidth
1530
1542
) ;
1543
+
1544
+ if ( this . _spectrumType == SPECTRUM_TYPE . PSD_VS_THROTTLE ||
1545
+ this . _spectrumType == SPECTRUM_TYPE . PSD_VS_RPM ) {
1546
+ const label = Math . round ( this . getValueFromMatrixFFT ( mouseFrequency , vsArgValue ) ) . toString ( ) + "dBm/Hz" ;
1547
+ this . _drawAxisLabel (
1548
+ canvasCtx ,
1549
+ label ,
1550
+ mouseX - 25 ,
1551
+ mouseY - 4 ,
1552
+ "left" ,
1553
+ ) ;
1554
+ }
1531
1555
}
1532
1556
}
1533
1557
} else if ( this . _spectrumType === SPECTRUM_TYPE . PIDERROR_VS_SETPOINT ) {
0 commit comments