@@ -47,6 +47,7 @@ export const GraphSpectrumPlot = window.GraphSpectrumPlot || {
4747 fontSizeFrameLabel : "6" ,
4848 fontSizeFrameLabelFullscreen : "9" ,
4949 } ,
50+ _importedSpectrumsData : [ ] ,
5051} ;
5152
5253GraphSpectrumPlot . initialize = function ( canvas , sysConfig ) {
@@ -57,7 +58,6 @@ GraphSpectrumPlot.initialize = function (canvas, sysConfig) {
5758 this . _logRateWarning = undefined ;
5859 this . _zoomX = 1 ;
5960 this . _zoomY = 1 ;
60- this . _importedSpectrumData = null ;
6161} ;
6262
6363GraphSpectrumPlot . setZoom = function ( zoomX , zoomY ) {
@@ -90,12 +90,24 @@ GraphSpectrumPlot.setData = function (fftData, spectrumType) {
9090 this . _invalidateDataCache ( ) ;
9191} ;
9292
93- GraphSpectrumPlot . setImportedSpectrumData = function ( curvesData ) {
94- this . _importedSpectrumData = curvesData ;
93+ GraphSpectrumPlot . getImportedSpectrumCount = function ( ) {
94+ return this . _importedSpectrumsData . length ;
95+ } ;
96+
97+ GraphSpectrumPlot . addImportedSpectrumData = function ( curvesData ) {
98+ this . _importedSpectrumsData . push ( curvesData ) ;
99+ this . _invalidateCache ( ) ;
100+ this . _invalidateDataCache ( ) ;
101+ GraphSpectrumPlot . draw ( ) ;
102+ } ;
103+
104+ GraphSpectrumPlot . clearImportedSpectrums = function ( curvesData ) {
105+ this . _importedSpectrumsData . length = 0 ;
95106 this . _invalidateCache ( ) ;
96107 this . _invalidateDataCache ( ) ;
97108 GraphSpectrumPlot . draw ( ) ;
98109} ;
110+
99111GraphSpectrumPlot . setOverdraw = function ( overdrawType ) {
100112 this . _overdrawType = overdrawType ;
101113 this . _invalidateCache ( ) ;
@@ -204,19 +216,27 @@ GraphSpectrumPlot._drawFrequencyGraph = function (canvasCtx) {
204216 }
205217
206218
207- //Draw imported spectrum
208- if ( this . _importedSpectrumData ) {
209- const curvesPonts = this . _importedSpectrumData ;
219+ //Draw imported spectrums
220+ const curvesColors = [
221+ "Blue" ,
222+ "Purple" ,
223+ "DeepPink" ,
224+ "DarkCyan" ,
225+ "Chocolate" ,
226+ ] ;
227+
228+ for ( let spectrumNum = 0 ; spectrumNum < this . _importedSpectrumsData . length ; spectrumNum ++ ) {
229+ const curvesPonts = this . _importedSpectrumsData [ spectrumNum ] ;
210230 const pointsCount = curvesPonts . length ;
211231 const scaleX = 2 * WIDTH / PLOTTED_BLACKBOX_RATE * this . _zoomX ;
212232
213233 canvasCtx . beginPath ( ) ;
214- canvasCtx . strokeStyle = "blue" ;
234+ canvasCtx . strokeStyle = curvesColors [ spectrumNum ] ;
215235 canvasCtx . moveTo ( 0 , HEIGHT ) ;
216- const filterPointsCount = 20 ;
217- for ( let i = 0 ; i < pointsCount ; i ++ ) {
236+ const filterPointsCount = 50 ;
237+ for ( let pointNum = 0 ; pointNum < pointsCount ; pointNum ++ ) {
218238 // Apply moving average filter at spectrum points to get visible line
219- let filterStartPoint = i - filterPointsCount / 2 ;
239+ let filterStartPoint = pointNum - filterPointsCount / 2 ;
220240 if ( filterStartPoint < 0 ) {
221241 filterStartPoint = 0 ;
222242 }
@@ -229,15 +249,16 @@ GraphSpectrumPlot._drawFrequencyGraph = function (canvasCtx) {
229249 }
230250 }
231251 let middleValue = 0 ;
232- for ( let j = filterStartPoint ; j < filterStopPoint ; j ++ ) {
233- middleValue += curvesPonts [ j ] . value ;
252+ for ( let i = filterStartPoint ; i < filterStopPoint ; i ++ ) {
253+ middleValue += curvesPonts [ i ] . value ;
234254 }
235255 middleValue /= filterPointsCount ;
236256
237- canvasCtx . lineTo ( curvesPonts [ i ] . freq * scaleX , HEIGHT - middleValue * fftScale ) ;
257+ canvasCtx . lineTo ( curvesPonts [ pointNum ] . freq * scaleX , HEIGHT - middleValue * fftScale ) ;
238258 }
239259 canvasCtx . stroke ( ) ;
240260 }
261+
241262 this . _drawAxisLabel (
242263 canvasCtx ,
243264 this . _fftData . fieldName ,
0 commit comments