@@ -15,7 +15,8 @@ interface CanvasProps {
1515 selectedBits : BitSelection ;
1616 isDisplay : boolean ;
1717 canvasCount ?: number ;
18- currentValue ?:number ;
18+ timeBase ?: number ;
19+ currentSamplingRate :number ;
1920 Zoom : number ;
2021 currentSnapshot : number ;
2122 snapShotRef : React . MutableRefObject < boolean [ ] > ;
@@ -28,7 +29,8 @@ const Canvas = forwardRef(
2829 selectedBits,
2930 isDisplay,
3031 canvasCount = 6 , // default value in case not provided
31- currentValue= 4 ,
32+ timeBase = 4 ,
33+ currentSamplingRate,
3234 Zoom,
3335 currentSnapshot,
3436 snapShotRef,
@@ -41,10 +43,10 @@ const Canvas = forwardRef(
4143 const [ numChannels , setNumChannels ] = useState < number > ( canvasCount ) ;
4244 const numXRef = useRef < number > ( 2000 ) ; // To track the calculated value
4345 const [ canvases , setCanvases ] = useState < HTMLCanvasElement [ ] > ( [ ] ) ;
44- const [ samplingRate , setSamplingRate ] = useState < number > ( 500 ) ;
4546 const [ wglPlots , setWglPlots ] = useState < WebglPlot [ ] > ( [ ] ) ;
4647 const [ lines , setLines ] = useState < WebglLine [ ] > ( [ ] ) ;
4748 const linesRef = useRef < WebglLine [ ] > ( [ ] ) ;
49+ const [ samplingRate , setSamplingRate ] = useState < number > ( 500 ) ;
4850 const sweepPositions = useRef < number [ ] > ( new Array ( 6 ) . fill ( 0 ) ) ; // Array for sweep positions
4951 const currentSweepPos = useRef < number [ ] > ( new Array ( 6 ) . fill ( 0 ) ) ; // Array for sweep positions
5052 const array3DRef = useRef < number [ ] [ ] [ ] > (
@@ -68,12 +70,12 @@ const Canvas = forwardRef(
6870 return 500 ; // Default fallback
6971 }
7072 } , [ ] ) ;
73+
7174
75+ useEffect ( ( ) => {
76+ numXRef . current = ( currentSamplingRate * timeBase ) ;
7277
73- useEffect ( ( ) => {
74- numXRef . current = ( getpoints ( selectedBits ) * currentValue ) ;
75-
76- } , [ currentValue ] ) ;
78+ } , [ timeBase ] ) ;
7779
7880 const prevCanvasCountRef = useRef < number > ( canvasCount ) ;
7981
@@ -116,11 +118,11 @@ const Canvas = forwardRef(
116118
117119
118120 useEffect ( ( ) => {
119- // Reset when currentValue changes
121+ // Reset when timeBase changes
120122 currentSweepPos . current = new Array ( numChannels ) . fill ( 0 ) ;
121123 sweepPositions . current = new Array ( numChannels ) . fill ( 0 ) ;
122- } , [ currentValue ] ) ;
123-
124+ } , [ timeBase ] ) ;
125+
124126
125127 useImperativeHandle (
126128 ref ,
@@ -131,7 +133,7 @@ const Canvas = forwardRef(
131133 currentSweepPos . current = new Array ( numChannels ) . fill ( 0 ) ;
132134 sweepPositions . current = new Array ( numChannels ) . fill ( 0 ) ;
133135 }
134-
136+
135137 if ( pauseRef . current ) {
136138 processIncomingData ( data ) ;
137139 updatePlots ( data , Zoom ) ;
@@ -149,7 +151,7 @@ const Canvas = forwardRef(
149151 previousCounter = data [ 0 ] ; // Update the previous counter with the current counter
150152 } ,
151153 } ) ,
152- [ Zoom , numChannels , currentValue ]
154+ [ Zoom , numChannels , timeBase ]
153155 ) ;
154156
155157 const createCanvases = ( ) => {
@@ -186,7 +188,7 @@ const Canvas = forwardRef(
186188 const opacityLightMajor = "0.4" ; // Opacity for every 5th line in light theme
187189 const opacityLightMinor = "0.1" ; // Opacity for other lines in light theme
188190 const distanceminor = samplingRate * 0.04 ;
189- const numGridLines = getpoints ( selectedBits ) * 4 / distanceminor ;
191+ const numGridLines = getpoints ( selectedBits ) * 4 / distanceminor ;
190192 for ( let j = 1 ; j < numGridLines ; j ++ ) {
191193 const gridLineX = document . createElement ( "div" ) ;
192194 gridLineX . className = "absolute bg-[rgb(128,128,128)]" ;
@@ -317,12 +319,12 @@ const Canvas = forwardRef(
317319 sweepPositions . current [ i ] = ( currentSweepPos . current [ i ] + 1 ) % line . numPoints ;
318320 } ) ;
319321 } ,
320- [ lines , wglPlots , numChannels , theme , currentValue ]
322+ [ lines , wglPlots , numChannels , theme , timeBase ]
321323 ) ;
322324
323325 useEffect ( ( ) => {
324326 createCanvases ( ) ;
325- } , [ numChannels , theme , currentValue ] ) ;
327+ } , [ numChannels , theme , timeBase ] ) ;
326328
327329
328330 const animate = useCallback ( ( ) => {
0 commit comments