@@ -302,15 +302,31 @@ export class PlotSweepComponent
302302 const targetLength = this . plotWidth / this . numSteps ;
303303 let processedXData : number [ ] = [ ] ;
304304 let processedYData : number [ ] = [ ] ;
305+ let processedSweepValues = [ ...sweepValues ] ;
305306
306- // Interpolate numPoints between each consecutive value in plotDataX
307- if ( this . plotDataX && this . plotDataX . length > 1 && this . numPoints ?. value ) {
308- const numPoints = this . numPoints . value ;
307+ if ( this . stepToSweepDelay . value > 0 && this . totalTimePerStep > 0 ) {
308+ processedSweepValues = [ 0 , ...sweepValues ] ;
309+ }
310+
311+ if ( this . plotDataX && this . plotDataX . length > 1 ) {
312+ const hasDelay = this . stepToSweepDelay . value > 0 ;
313+
309314 for ( let i = 0 ; i < this . plotDataX . length - 1 ; i ++ ) {
310- const x0 = this . plotDataX [ i ] ;
311- const x1 = this . plotDataX [ i + 1 ] ;
312- for ( let j = 0 ; j < numPoints ; j ++ ) {
313- processedXData . push ( x0 + ( x1 - x0 ) * ( j / numPoints ) ) ;
315+ const stepStart = this . plotDataX [ i ] ;
316+ const stepEnd = this . plotDataX [ i + 1 ] ;
317+
318+ if ( hasDelay ) {
319+ processedXData . push ( stepStart ) ;
320+ processedXData . push ( stepStart + this . stepToSweepDelay . value ) ;
321+ for ( let j = 1 ; j < this . numPoints . value ; j ++ ) {
322+ const sweepProgress = j / ( this . numPoints . value - 1 ) ;
323+ const sweepDuration = stepEnd - ( stepStart + this . stepToSweepDelay . value ) ;
324+ processedXData . push ( stepStart + this . stepToSweepDelay . value + sweepProgress * sweepDuration ) ;
325+ }
326+ } else {
327+ for ( let j = 0 ; j < this . numPoints . value ; j ++ ) {
328+ processedXData . push ( stepStart + ( stepEnd - stepStart ) * ( j / this . numPoints . value ) ) ;
329+ }
314330 }
315331 }
316332 processedXData . push ( this . plotDataX [ this . plotDataX . length - 1 ] ) ;
@@ -320,17 +336,17 @@ export class PlotSweepComponent
320336
321337 if ( this . numPoints ?. value > targetLength ) {
322338 processedYData = PlotUtils . minMaxInterpolation (
323- sweepValues ,
339+ processedSweepValues ,
324340 targetLength
325341 ) . y ;
326342 } else {
327- processedYData = sweepValues ;
343+ processedYData = processedSweepValues ;
328344 }
329- console . log ( processedYData ) ;
345+ console . log ( processedYData , processedSweepValues , sweepValues ) ;
330346 this . plotData1 . x = processedXData ;
331- this . plotData1 . y = Array . from ( { length : this . numSteps } , ( ) => sweepValues )
347+ this . plotData1 . y = Array . from ( { length : this . numSteps } , ( ) => processedSweepValues )
332348 . flat ( )
333- . concat ( sweepValues [ sweepValues . length - 1 ] ) ;
349+ . concat ( processedSweepValues [ processedSweepValues . length - 1 ] ) ;
334350
335351 this . plotLayout . xaxis . dtick = this . tickDifference ;
336352 this . plotLayout . xaxis . range = [ 0 , this . tickDifference * 10 ] ;
0 commit comments