I have developed a web application using D3.js in which there are 100 circles. I want the circles to move slightly (by 2px randomly) and smoothly all the time.
Here is what I have tried using jQuery:
setInterval(function() {
$('.circle_Negative').each(function() {
var newq = makeNewPosition();
$(this).animate({ cx: +$(this).attr("cx")+newq[0], cy: +$(this).attr("cy")+newq[1] },200);
});
}, 200);
function makeNewPosition() {
var nh = Math.floor(Math.random()*2);
var nw = Math.floor(Math.random()*2);
return [nh,nw];
}
But this is not at all smooth. I think there could be better ways by which it can be done using D3 itself but I could not figure out much.