Actually in your code, I see you are using new Date() which changes when the function is executing. so your scale for axis and scale for drawing elements gets changed. Can you try replaceing below line

updateDomains(new Date() - duration);


var currentDate = new Date();
updateDomains(currentDate - duration);

Also in tick function send currentDate to displayDomains function. when you want to change the scale you change variable currentDate.

Hope it helps.


Related Query

More Query from same tag