@@ -451,7 +451,7 @@ GraphSpectrumPlot._drawFrequencyVsXGraph = function (canvasCtx, drawPSD = false)
451451 MARGIN_BOTTOM ,
452452 "Hz"
453453 ) ;
454-
454+
455455 if ( this . _spectrumType === SPECTRUM_TYPE . FREQ_VS_THROTTLE ||
456456 this . _spectrumType === SPECTRUM_TYPE . PSD_VS_THROTTLE ) {
457457 this . _drawVerticalGridLines (
@@ -523,6 +523,17 @@ GraphSpectrumPlot._drawHeatMap = function (drawPSD = false) {
523523 return heatMapCanvas ;
524524} ;
525525
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+
526537GraphSpectrumPlot . _drawPidErrorVsSetpointGraph = function ( canvasCtx ) {
527538 const ACTUAL_MARGIN_LEFT = this . _getActualMarginLeft ( ) ;
528539
@@ -1463,6 +1474,7 @@ GraphSpectrumPlot._drawMousePosition = function (
14631474 lineWidth
14641475) {
14651476 // X axis
1477+ let mouseFrequency = 0 ;
14661478 if (
14671479 this . _spectrumType === SPECTRUM_TYPE . FREQUENCY ||
14681480 this . _spectrumType === SPECTRUM_TYPE . FREQ_VS_THROTTLE ||
@@ -1475,7 +1487,7 @@ GraphSpectrumPlot._drawMousePosition = function (
14751487 const sampleRate = this . _fftData . blackBoxRate / this . _zoomX ;
14761488 const marginLeft = this . _getActualMarginLeft ( ) ;
14771489
1478- const mouseFrequency =
1490+ mouseFrequency =
14791491 ( ( mouseX - marginLeft ) / WIDTH ) *
14801492 ( this . _fftData . blackBoxRate / this . _zoomX / 2 ) ;
14811493 if ( mouseFrequency >= 0 && mouseFrequency <= sampleRate ) {
@@ -1513,12 +1525,12 @@ GraphSpectrumPlot._drawMousePosition = function (
15131525 if ( unitLabel !== null ) {
15141526 const val_min = this . _fftData . vsRange . min ;
15151527 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 } ` ;
15191531 this . _drawHorizontalMarkerLine (
15201532 canvasCtx ,
1521- mouseValue ,
1533+ vsArgValue ,
15221534 val_min ,
15231535 val_max ,
15241536 valueLabel ,
@@ -1528,6 +1540,18 @@ GraphSpectrumPlot._drawMousePosition = function (
15281540 stroke ,
15291541 lineWidth
15301542 ) ;
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+ }
15311555 }
15321556 }
15331557 } else if ( this . _spectrumType === SPECTRUM_TYPE . PIDERROR_VS_SETPOINT ) {
0 commit comments