@nidhipathak002,
In the above JSFiddle you were adding new dataPoints just after performing dps.shift()
operation which was making the gridlines denser on each successive call. Hence just by removing the line dps.push({y: yVal, x : xVal});
from your code will work fine as shown in this updated JSFiddle.
____
Shashi Ranjan
Team CanvasJS