I really found this question and answer helpful on how to get animations at different speeds.
Change the animation speed of a D3 path
What pointed to this block:
http://bl.ocks.org/explunit/6082362
I am following this and would like to add a circle that moves along the top of the line. I added a marker
var marker = g.append("circle")
.attr("r", 7)
.attr("id", "marker")
but for the life of me I cannot get him to follow the line at the same speed.
I added this bit to the end of this block.
var p = path.node().getPointAtLength(lengthAt[i-1] );
markerTransition = markerTransition.transition()
.duration(lineData[i].speed)
.ease('linear')
.attr("transform", "translate(" + p.x + "," + p.y + ")");
and now I have a moving circle, but it does not synchronize with the line and for some reason is in different coordinates.
How can I make my circle follow the line correctly (at different speeds)?
UPDATE:
!
jsfiddle: http://jsfiddle.net/mbrownshoes/k86fbade/6/
, , , .