score:2

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);

with

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.

Ganesh


Related Query

More Query from same tag