{
animate();
const timer = d3.timer(interpolator);
function interpolator(elapsed) {
const t = Math.min(1, easing(elapsed / transitionDuration));
data.forEach(point => {
point.x = point.sx - interpolate(t);
});
draw();
if (t === 1) {
timer.stop();
addNewDatapoint();
animate();
timer.restart(interpolator);
}
}
}